[gradsusr] problem related to while loop in grads....

Eric Altshuler ela at cola.iges.org
Thu Nov 8 15:27:57 EST 2012


Kishore,

Try using 'z' instead of 'lev' in your script. If your input dataset has 15 vertical levels, loop over z as follows:

z=1
while (z<=15)
'set z 'z
...
...
z=z+1
endwhile

This is a situation where you want to loop over grid coordinates (z) rather than world coordinates (lev).

Best regards,

Eric L. Altshuler
Assistant Research Scientist
Center for Ocean-Land-Atmosphere Studies
4041 Powder Mill Road, Suite 302
Calverton, MD 20705-3106
USA

E-mail: ela at cola.iges.org
Phone: (301) 902-1257
Fax: (301) 595-9793

----- Original Message -----
From: "Kishore Babu" <kishoreragi at gmail.com>
To: "GrADS Users Forum" <gradsusr at gradsusr.org>
Sent: Thursday, November 8, 2012 5:45:15 AM
Subject: [gradsusr] problem related to while loop in grads....


Dear all, 


I want to calculate the area average of a variable over the globe. I have written the grads scripts as follows. It is giving output file, but for single grid at single level. 



'reinit' 
'sdfopen sample.nc ' 
'set t 1 12' 
lev=1 
while(lev<15) 
'set lev 'lev 
lt1=-90 
while(lt1<90) 
lt2=lt1+10 
ln1=0 
while(ln1<360) 
ln2=ln1+30 
'define temp=aave(t,lon='ln1',lon='ln2',lat='lt1',lat='lt2')' 
'set sdfwrite sample1.nc ' 
'sdfwrite temp' 
ln1=ln1+30 
endwhile 
lt1=lt1+10 
endwhile 
lev=lev+1 
endwhile 


It is giving output file, but for single grid at single level. 



Output file description is as follows... 



Type = Gridded 
Xsize = 1 Ysize = 1 Zsize = 1 Tsize = 12 Esize = 1 
Number of Variables = 1 
temp 0 t,y,x temp 


It looks like there is problem in looping... Could you please help me fix this problem... 


Your help will save a lot of time... 


Thank you in advance.. 


Sincerely, 


Kishore 


_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr



More information about the gradsusr mailing list