[gradsusr] Extract data into a text file by columns

Leopoldo Alvarez lap.bolsa at gmail.com
Thu May 14 06:12:37 EDT 2015


Hi GrADS users,

I'm trying to implement this solution ->
http://iges.org/grads/gadoc/ascii.html


When I run I get this error->

Error in format:  2rd argument invalid.
   Error occurred on line 29

- - - - - - - - -
- - - - - - - - -

'set x 1 119'
outfile='my_ascii_file.txt'
'!/bin/rm -f 'outfile
'set gxout print'
fmt='%8.3f'
numcols=119
'set prnopts 'fmt' 'numcols' 1'
'd lon'
lon_data = result
'd lat'
lat_data = result
'd t'
v1_data = result
'd t'
v2_data = result
'd t'
v3_data = result
i=1
while (1)
   lons  = sublin(lon_data,i)
   lats  = sublin(lat_data,i)
   line1 = sublin(v1_data,i)
   line2 = sublin(v2_data,i)
   line3 = sublin(v3_data,i)
   if (lons='' | lats='' | line1='' | line2='' | line3=''); break; endif
   if (i>1)
     j=1
     while (j<=numcols)
       str = subwrd(lons,j); lon = math_format(fmt,str)
       str = subwrd(lats,j); lat = math_format(fmt,str)
       str = subwrd(line1,j); v1 = math_format(fmt,str)
       str = subwrd(line2,j); v2 = math_format(fmt,str)
       str = subwrd(line3,j); v3 = math_format(fmt,str)
       record = lon' 'lat' 'v1' 'v2' 'v3
       rc = write(outfile,record,append)
       j=j+1
     endwhile
   endif
   i=i+1
endwhile

- - - - - - - - - -
- - - - - - - - - -

Leopoldo
Tenerife - Canary Islands

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20150514/e9220a1f/attachment.html 


More information about the gradsusr mailing list