[gradsusr] Rewinding an output file in GrADS

Zilore Mumba zmumba at gmail.com
Sun Jan 27 16:02:07 EST 2019


Dear all,
I have the following script, which prints to file pressure  values at a
point, from the GrADS tutorial data set model.dat. Each time I run the
script, I was expecting GrADS to open a new output file, since my first
write statement does not append. However what I get is that each time, I
run the script, the output is appended to earlier output.
My questin 1 is how do I rewind my output file? From GrADS documentation
open(filename) acts as a rewind command. But trying to open the file before
I start writing to it does not work.
My second question (if allowed) is, for temperature I want to write
temp=temp-273,15. When the temperature is a missing value, I get
-999000273.15.
How do I filter out missing values? Alternatively I can write temperature
as is and do the subtraction outside the script.
Help will be appreciated.
'open model.ctl'
************************
header='Pressure'
field='ps'

str2='********'

'set lon 30.03'
'set lat -1.95'

i=1
count = 1
while (count <= 5)
   if(count=1)
      rc=write('model_ps.txt', header)
      rc=write('model_ps.txt', str2,append)
   endif

   plot=subwrd(field,i)
   'set t 'count
   'd ' plot
   press=subwrd(result,4)

* Save data to file
  rc=write('model_ps.txt', press, append)
  count = count + 1
endwhile

rc = close('model_ps.txt')
'close 1'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20190127/a3797d01/attachment.html>


More information about the gradsusr mailing list