[gradsusr] Writing to multiple output files
James T. Potemra
jimp at hawaii.edu
Mon Jun 14 17:53:05 EDT 2010
Hi Justin:
Not sure if I understand this, but you can just make the output file name
change with time, e.g., put the statement " outfile='output.rtf' "
inside the
loop, and change it to something like the following (assume the index i is
for each time step):
i = 1
while ( i<=imax)
'set t 'i
outfile = 'output'%i'.rtf'
i = i + 1
....
endwhile
This will create a file called "output1.rft' for the first time (i=1),
"output2.rtf"
for the second time (t=2) and so on.
Jim
Justin Traiteur wrote:
> I am wondering if anyone knows how to write a GrADS script to write to
> multiple output files. Currently the code only writes to one file for
> one time only. I have a time series that needs to be broken into
> different output files. I have 240 different times to write to and
> would rather not do this by hand. Below is a copy of my current script.
>
>
>
> Thanks,
>
> Justin
>
>
>
>
>
>
>
>
>
> #GrADS script to output "sounding" values to a text file
>
> #SMcMillan, 6/11/2010
>
> #Assumes variables tmpprs, ugrdprs, vgrdprs available
>
> #
>
> outfile='output.rtf'
>
> 'set x 1';'set y 1';'set z 1';'set t 1'
>
> zlev=1;ts=1
>
> lo=3;la=3
>
> while(zlev<=31)
>
> 'd hgtprs(t='ts',lon='lo',lat='la',z='zlev')';val1=subwrd(result,
> 4);hgt=math_format('%9.0f',val1)
>
> 'd ugrdprs(t='ts',lon='lo',lat='la',z='zlev')';val2=subwrd(result,
> 4);u=math_format('%9.1f',val2)
>
> 'd vgrdprs(t='ts',lon='lo',lat='la',z='zlev')';val3=subwrd(result,
> 4);v=math_format('%9.1f',val3)
>
> 'd pressfc(t='ts',lon='lo',lat='la')';val4=subwrd(result,
> 4);prs=math_format('%9.0f',val4)
>
> 'd lev(z='zlev')';plev=subwrd(result,4);val5=subwrd(result,
> 4);plev=math_format('%9.0f',val5)
>
> 'd tmpprs(t='ts',lon='lo',lat='la',z='zlev')';val6=subwrd(result,
> 4);tmp=math_format('%9.1f', val6)
>
> "set z " zlev
>
> 'd tmpprs*pow((1000/lev),0.286)';val7=subwrd(result,
> 4);theta=math_format('%9.1f',val7)
>
> 'd rhprs/100*621.97*(6.11*pow(10,(7.5*(tmpprs-273.15))/(237.7+
> (tmpprs-273.15)))/(lev-(6.11*pow(10,(7.5*(tmpprs-273.15))/(237.7+
> (tmpprs-273.15))))))/1000';val8=subwrd(result,
> 4);mr=math_format('%9.6f',val8)
>
>
> vals=hgt%u%v%theta%mr%prs;say vals
>
> dummy=write(outfile,vals)
>
> zlev=zlev+1
>
> dummy=close(outfile)
>
> endwhile
>
> say 'Files written to 'outfile
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
More information about the gradsusr
mailing list