[gradsusr] Writing point model output data to a file

Zilore Mumba zmumba at gmail.com
Mon Dec 17 13:42:15 EST 2018


Jim,
Thanks very much for pointing out to me the issue of wrongly subsetting the
output line. Somehow I had it in my mind that Grads takes the first line as
a control character, so that the the second line is referred to as the
first. I was  obviously wrong.
With your modification of my script, the error disappears, which is a very
big advance, but then it writes the header (correctly) and three blank
lines after.
Thanks for your assistance, though I still have the printing of blanks to
sort out.
Zilore

On Mon, Dec 17, 2018 at 9:22 AM James T. Potemra <jimp at hawaii.edu> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20181217/d753e6d4/attachment.html>


More information about the gradsusr mailing list