[gradsusr] Nested While Loop Problem

jimbo32886 at gmail.com jimbo32886 at gmail.com
Thu Apr 15 22:06:32 EDT 2010


Hello Everyone,
   I am running into a very trivial problem that I just can not figure out.
I am attempting to write some anomalous data out in Grads format, however my
nested loop is not functioning properly.  The second while-loop works just
fine, but the "time" step while-loop is not functioning at all.  Essentially
after I run the script it goes through the first time and the first 24
levels and then stops.  I do not understand why the first loop is not
functioning correctly.  Any help would be greatly appreciated.  I have a
feeling I am making a stupid mistake, but I just can't find it.  I'm running
grads v1.9 on Linux.  The script works just fine with the exception of the
first while-loop.
Thanks,
Jim

*This is my script*

'open template.ctl'
'open salt.ctl'
'set lat 60 90'
'set lon 0 360'
'open arctic1900_2009.ctl'
'set fwrite saltanom.dat'
'set gxout fwrite'
i = 1
p = 0
while(p<=1332) *<---------this loop is not functioning properly
while(i<=24)
'set z 'i''
'set t 1 12'
'tempseasonal = ave(salt.2,t+0,t+0)'
'set t 1 1332'
'modify tempseasonal seasonal'
'set t 'p''
'anom=oacres(salt.1,salt.3-gr2stn(tempseasonal,salt.3),5,4,3,2,1)'
'd anom'
'undefine anom'
i = i + 1
endwhile
p=p+1
endwhile
'disable fwrite'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20100415/ac124179/attachment-0003.html 


More information about the gradsusr mailing list