[gradsusr] Writing point model output data to a file
James T. Potemra
jimp at hawaii.edu
Mon Dec 17 02:22:23 EST 2018
Zilore,
I don't think you need to subset the output by line; each of "set lon",
"set lat", and "d t2" should only result in a single line of output.
Therefore you don't need the extra lines with "... = sublin(result,2)"
in your script. This is trying to read the second line of output and
you only have one. This is why you are not getting any output in the file.
The "unknown command" is, I think, a result of not capturing the output
of the write statement. The following should work.
---------------
'open wrfout_d01_2018-12-02_00.ctl'
************************
'set lon 30.13'
xlon=subwrd(result,4)
'set lat -1.97'
xlat=subwrd(result,4)
rc = write('wrfout_t2.txt', 'Temp at Lon. 'xlon 'Lat. 'xlat)
count = 1
while (count <=3)
'set t 'count
'd t2'
temp=subwrd(result,4)
*Save data to file
rc = write('wrfout_t2.txt', temp, append)
count = count + 1
endwhile
rc = close('wrfout_t2.txt')
---------------
Jim
On 12/16/18 8:44 PM, Zilore Mumba wrote:
> I want to write data at all time steps to a file, i.e at a fixed
> longitude and latitude for t=1 to t=9 for a 48 hour forecast run of
> the WRF output, I want all 9 temperatures in a file at that location.
> I wrote the following script
>
> 'open wrfout_d01_2018-12-02_00.ctl'
> ************************
> 'set lon 30.13'
> lons=sublin(result,2)
> xlon=subwrd(lons,4)
> 'set lat -1.97'
> lats=sublin(result,2)
> xlat=subwrd(lats,4)
>
> write('wrfout_t2.txt', 'Temp at Lon. 'xlon 'Lat. 'xlat)
>
> count = 1
> while (count <=3)
> 'set t 'count
> 'd t2'
> tmp=sublin(result,2)
> temp=subwrd(tmp,4)
>
> *Save data to file
> write('wrfout_t2.txt', temp, append)
> count = count + 1
> endwhile
>
> The above script writes "Temp at Lon. 'Lat. " in the file "wrfout_t2"
> as per the first write statement. Then there is no other entry in the
> file, but an error on the terminal "unknown command 0". This error is
> repeated 4 times
> How do I go about achieving what an trying to do?
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
More information about the gradsusr
mailing list