[gradsusr] Writing to multiple output files

Justin Traiteur jtraite2 at atmos.illinois.edu
Mon Jun 14 15:46:39 EDT 2010


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



More information about the gradsusr mailing list