string to numeric value??

Dave Allured dave.allured at NOAA.GOV
Wed Jan 26 17:15:25 EST 2005


Haibin,

I tried your sample script.  The only problem I had was with the
comments.  My version of Grads does not seem to allow in-line comments
such as "%The start year".  This caused Yrst.1 to be non-numeric,
therefore it was this variable and not "year" which I think was causing
the error message you got.

When I removed the comments, your script worked fine and gave valid
numeric results.  HTH.

--Dave

Haibin Li wrote:
> Dear All,
> I am in a process to plot time series for multiple model outputs.
> Since the models don't have the same initial time, I want to write a
> script to determine how to " set t t1 t2".
> Here is part of my script:
> ----------------------------------------------
> 'q time'
> res=subwrd(result,3)
> say 'time is 'res
> year=substr(res,9,4)
> say 'Year is 'year
> Yrst.1=1984    %The start year.
> Yred.1=1999   %The end year.
> %The following two lines are for the purpose to determine t1 and t2
> based on monthly data.
> t1=(Yrst.1-year)*12+1
> t2=(Yred.1-year+1)*12
> say 't1 is  't1
> say 't2 is 't2
> --------------------------------------------------
> But there is a problem since the variable "year" from subwrd is a string not
> number, so I got error information about using string as number in GrADS.
> Can someone tell me how to do this trick if there is a way?
> Thanks
>
> Yours,
> Haibin



More information about the gradsusr mailing list