[gradsusr] Utilizing data from text file to make calculation in GrADS

Ricardo Hallak hallak at model.iag.usp.br
Thu Feb 21 14:41:03 EST 2013


Hi, Phil.

I think you should use subwrd, instead substr.
Example:
rec=read(input)
pointlon=subwwrd(rec,1)
pointlat=suvwrd(rec,2)
pointtime=subwrd(rec,3)

Also, avoid unnecessary blank spaces in commands.

Additionally, I didn't understand why you are using quotes at the end of some
commands, like in: 'set lat 'pointlat''
For example,
'set lat 'pointlat
should be enough.

Hope this helps,
Ricardo

On Fri, 22 Feb 2013 05:03:18 +1100, Phil Klotzbach wrote
> Hi everyone,
> 
> I am currently running GrADS 2.0.1 on my Windows 7 laptop.  What I 
> have is a simple text file with three columns, a longitude, a 
> latitude, and a time (since 1979 at 0Z).  When I attempt to run the 
> code in GrADS, I get the following error message:
> 
> Set error: Missing or invalid arguments for LON option
> Non-numeric args to numeric operations
> Error occurred on line 18
> In file /cygdrive/c/OPENGR~1/Contents/Resources/Scripts/readfile.gs
> 
> The strange thing is, I can check and see that latitude has been set 
> correctly by GrADS.  It just has problems with longitude and time. I 
> used the three say commands to verify that it has read in the 
> variables correctly (which it has).
> 
> The following is my code as currently written:
> 
> input = 'c:\test.txt'
> 'open c:\500mbtemp.ctl'
> looptime = 1
> while (looptime < 3)
> rec = read(input)
> pointlon = substr(rec, 2, 7)
> pointlat = substr(rec, 10, 7)
> pointtime = substr(rec, 17, 2)
> say pointlon
> say pointlat
> say pointtime
> 'set lat 'pointlat''
> 'set lon 'pointlon''
> 'set t 'pointtime''
> 'd temp'
> answer=result
> res=write("c:\500mbtemp.txt",answer)
> time=time+1
> endwhile
> 
> Here are the contents of c:\test.txt
> 
> 150.00 -16.75 5
> 149.25 -22.50 7
> 
> Lastly c:\500mbtemp.ctl is an ERA-Interim 500 mb temperature file. I 
> have verified manually that the file opened correctly and is working 
> properly.   I know the GrADS treats all variables read from text 
> files as strings, and I'm guessing that this is what is causing the 
> problem here.  Any insights into how this problem can be solved are 
> much appreciated!  Thanks!
> 
> Phil
> 
> -- 
> ----------------------------------------------------
> Phil Klotzbach, Ph.D.
> Research Scientist
> Department of Atmospheric Science
> Colorado State University
> Email: philk at atmos.colostate.edu
> ----------------------------------------------------
> 
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr


Ricardo Hallak

Departamento de Ciências Atmosféricas (ACA)
Instituto de Astronomia, Geofísica e Ciências Atmosféricas (IAG)
Universidade de São Paulo (USP)
Rua do Matão, 1226 - Cidade Universitária - São Paulo SP 05508-900
Phone.: +55 (11) 3091-2850; 3091-4703
Fax: +55 (11) 3091-4714




More information about the gradsusr mailing list