[gradsusr] Nested While Loop Problem

jimbo32886 at gmail.com jimbo32886 at gmail.com
Fri Apr 16 01:38:24 EDT 2010


Jim,
   Thank you very much.  I clearly missed the obvious.
-Jim

On Thu, Apr 15, 2010 at 10:23 PM, James T. Potemra <jimp at hawaii.edu> wrote:

> Hey Jim:
>
> I think you need to reset i = 1 inside the p loop.  As it is, p = 0,
> then i goes from 1 to 25, p increments to 1 but i will be 25.  In oder
> words, put the line "i = 1" after the line "while(p<=1332)".
>
> Jim
>
> jimbo32886 at gmail.com wrote:
> > 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'
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > gradsusr mailing list
> > gradsusr at gradsusr.org
> > http://gradsusr.org/mailman/listinfo/gradsusr
> >
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20100416/f5da539b/attachment-0003.html 


More information about the gradsusr mailing list