script problem

Michael Sigmond sigmond at ATMOSP.PHYSICS.UTORONTO.CA
Fri Jun 3 09:29:20 EDT 2005


Dear all,

Browsing the archives I found a problem (see mail of Steve) similar to mine
. Apparently nobody has been able to answer this question, so I'll give it
an other try.

The basic question is: can you define a variable which varies in time, and
then assign a value to the variable at each individual time? When I try to
do it, Grads just redefines the variable to contain one time unit.

e.g.
set lon=0
set lat=0
set lev=1000
set t = 1 19
define test=0
#test is now defined test(t=1,2,3,....,19)=0
set t 1
test=1
#test is now redefined as test(t=1) = 1 and test(t=2,19) does not exist

Best regards,

Michael

On Wed, 9 May 2001 18:17:31 -0400, Ghan, Steven J <Steve.Ghan at PNL.GOV> wrote:

>I have a variable defined in two dimensions, i.e., z,t. From this variable I
>want to calculate a new variable that is defined in only one dimension,
>i.e., t. The logic is a bit complicated, so I am using while/endwhile for
>all z,t. I can see how to calculate the new variable for each time, but I
>can't figure out how to get the new variable to be defined for all t.
>
>To be specific, I have written the script
>
>n=0
>while(n<ntime)
>n=n+1
>'set t 'n
>k=nlev
>while(k>2)
>k=k-1
>'set z 'k
>'d clw'
>rec=sublin(result,1)
>val=subwrd(rec,4)
>if(val>1.e-5)
>   'ztop=zkm'
>   'd ztop'
>   rec=sublin(result,1)
>   val=subwrd(rec,4)
>   say val
>   break
>endif
>endwhile
>endwhile
>
>Here clw and zkm are dimensioned t=1,ntime, z=1,nlev
>I want to plot ztop(t). The script above just resets ztop to a new value
>each time.
>
>I hope this is easy for someone more versed in Grads than I am.
>
>-Steve Ghan



More information about the gradsusr mailing list