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

Phil Klotzbach philk at atmos.colostate.edu
Thu Feb 21 13:03:18 EST 2013


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
----------------------------------------------------




More information about the gradsusr mailing list