<br><br>
<div class="gmail_quote">On Wed, Nov 4, 2009 at 5:15 PM, Charles Seman <span dir="ltr"><<a href="mailto:Charles.Seman@noaa.gov">Charles.Seman@noaa.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hossein,<br><br>Please find attached a "<a href="http://printascii.gs/" target="_blank">printascii.gs</a>" script from Prince K. Xavier<br>
<<a href="mailto:xavier@CAOS.IISC.ERNET.IN" target="_blank">xavier@CAOS.IISC.ERNET.IN</a>><br><br>Hope it helps,<br>Chuck<br><br>hossein lotfi wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi All grads user<br>I have a file contain vorticity variable,I want save It's data to<br>a txt file<br>
I have <a href="http://fprintf.gs/" target="_blank">fprintf.gs</a> <<a href="http://fprintf.gs/" target="_blank">http://fprintf.gs</a>> script file to do this,but it<br>can't save vorticity, latitude,longitude to one txt file.<br>
Any suggestion will be appreciated,<br>thanks<br></blockquote><br>--<br><br>Please note that <a href="mailto:Charles.Seman@noaa.gov" target="_blank">Charles.Seman@noaa.gov</a> should be considered my NOAA<br>email address, not <a href="mailto:cjs@gfdl.noaa.gov" target="_blank">cjs@gfdl.noaa.gov</a>.<br>
<br>********************************************************************<br>Charles Seman <a href="mailto:Charles.Seman@noaa.gov" target="_blank">Charles.Seman@noaa.gov</a><br>U.S. Department of Commerce / NOAA / OAR<br>
Geophysical Fluid Dynamics Laboratory voice: (609) 452-6547<br>201 Forrestal Road fax: (609) 987-5063<br>Princeton, NJ 08540-6649 <a href="http://www.gfdl.noaa.gov/~cjs/" target="_blank">http://www.gfdl.noaa.gov/~cjs/</a><br>
********************************************************************<br><br>"The contents of this message are mine personally and do not necessarily<br>reflect any position of the Government or NOAA."<br><br><br>
* To generate ascii data from grads to use in applications like IGOR PRO<br>*<br>* Prince XAVIER (17 Nov 2004, LMD, Paris)<br>*<br>function printascii(args)<br><br>if(args='')<br>say ''<br>say 'No arguments found.'<br>
say ''<br>say 'Syntax is '<br>say '----------------------------------'<br>say 'printascii filename variable [z t]'<br>say '----------------------------------'<br>say ''<br>say 'z(or Z) and t(or T) may be switched on in case of 3 or 4 dimension data.'<br>
say 'If not switched on, no information on level and time will be printed.'<br>say ''<br>say 'Examples:'<br>say 'ga-> printascii rain.ascii rain'<br>say 'ga-> printascii rain.ascii rain z'<br>
say 'ga-> printascii rain.ascii rain t'<br>say 'ga-> printascii rain.ascii rain z t'<br>say ''<br>say ''<br>return<br>endif<br><br>_fname = subwrd(args,1)<br>_var = subwrd(args,2)<br>
arg3 = subwrd(args,3)<br>arg4 = subwrd(args,4)<br><br>say ''<br><br>zflag = 0<br>tflag = 0<br>if(arg3=z|arg3=Z)<br>say 'Level information requested.'<br>zflag = 1<br>endif<br>if(arg3=t|arg3=T)<br>say 'Time information requested.'<br>
tflag = 1<br>endif<br><br>if(arg4=z|arg4=Z)<br>say 'Level information requested.'<br>zflag = 1<br>endif<br>if(arg4=t|arg4=T)<br>say 'Time information requested.'<br>tflag = 1<br>endif<br><br><br>gxstat()<br>
*say _xs' '_xe' '_ys' '_ye' '_zs' '_ze' '_ts' '_te<br>'set x ' _xs' '_xe<br>'set y ' _ys' '_ye<br>gxstat()<br>if((_xe-_xs)=0)<br>_lonint = 1<br>
else<br>_lonint = (_lone-_lons)/(_xe-_xs)<br>endif<br>if((_ye-_ys)=0)<br>_latint = 1<br>else<br>_latint = (_late-_lats)/(_ye-_ys)<br>endif<br>*say _lonint' '_latint<br><br>_tint = 1<br>_zint = 1<br>_yint = 1<br>_xint = 1<br>
<br>_tt = 1<br>while(_tt<=_te)<br>'set t '_tt<br><br> _zz = 1<br> while(_zz<=_ze)<br> 'set z '_zz<br><br> _yy = 1<br> while(_yy<=_ye)<br> 'set y '_yy<br><br> _xx = 1<br> while(_xx<=_xe)<br>
'set x ' _xx<br> 'd '_var<br> val = subwrd(result,4)<br>* say val<br> 'query dims'<br> dum = sublin(result,2)<br> alon = subwrd(dum,6)<br> dum = sublin(result,3)<br> alat = subwrd(dum,6)<br>
dum = sublin(result,4)<br> alev = subwrd(dum,6)<br> dum = sublin(result,5)<br> atim = subwrd(dum,6)<br><br><br><br> if (zflag = 1 & tflag = 1)<br> rc = write(_fname, atim' 'alev' 'alon' 'alat' 'val)<br>
* say atim' 'alev' 'alon' 'alat' 'val<br> endif<br> if (zflag = 0 & tflag = 1)<br> rc = write(_fname, atim' 'alon' 'alat' 'val)<br>* say atim' 'alon' 'alat' 'val<br>
endif<br> if (zflag = 1 & tflag = 0)<br> rc = write(_fname, alev' 'alon' 'alat' 'val)<br>* say alev' 'alon' 'alat' 'val<br> endif<br> if (zflag = 0 & tflag = 0)<br>
rc = write(_fname, alon' 'alat' 'val)<br>* say alon' 'alat' 'val<br> endif<br><br> _xx = _xx + _xint<br> endwhile<br><br> _yy = _yy + _yint<br> endwhile<br><br> _zz = _zz + _zint<br>
endwhile<br><br>_tt = _tt + _tint<br>endwhile<br><br>say 'ASCII output written to '_fname'.'<br>say ' '<br>rc = close(_fname)<br><br><br><br>return<br><br><br>function gxstat()<br>'q dims'<br>
dinf = result<br>lx = sublin(dinf,2)<br>ly = sublin(dinf,3)<br>lz = sublin(dinf,4)<br>lt = sublin(dinf,5)<br>if ( subwrd(lx,7) = 'to')<br> _lons = subwrd(lx,6)<br> _lone = subwrd(lx,8)<br> _xs = subwrd(lx,11)<br> _xe = subwrd(lx,13)<br>
_xs = math_int(_xs)<br> _xe = math_int(_xe)<br>else<br> _lons = subwrd(lx,6)<br> _lone = subwrd(lx,6)<br> _xs = subwrd(lx,9)<br> _xe = subwrd(lx,9)<br> _xs = math_int(_xs)<br> _xe = math_int(_xe)<br>endif<br>if ( subwrd(ly,7) = 'to')<br>
_lats = subwrd(ly,6)<br> _late = subwrd(ly,8)<br> _ys = subwrd(ly,11)<br> _ye = subwrd(ly,13)<br> _ys = math_int(_ys)<br> _ye = math_int(_ye)<br>else<br> _lats = subwrd(ly,6)<br> _late = subwrd(ly,6)<br> _ys = subwrd(ly,9)<br>
_ye = subwrd(ly,9)<br> _ys = math_int(_ys)<br> _ye = math_int(_ye)<br>endif<br>if ( subwrd(lz,7) = 'to')<br> _levs = subwrd(lz,6)<br> _leve = subwrd(lz,8)<br> _zs = subwrd(lz,11)<br> _ze = subwrd(lz,13)<br>else<br>
_levs = subwrd(lz,6)<br> _leve = subwrd(lz,6)<br> _zs = subwrd(lz,9)<br> _ze = subwrd(lz,9)<br>endif<br>if ( subwrd(lt,7) = 'to')<br> _tims = subwrd(lt,6)<br> _time = subwrd(lt,8)<br> _ts = subwrd(lt,11)<br> _te = subwrd(lt,13)<br>
else<br> _tims = subwrd(lt,6)<br> _time = subwrd(lt,6)<br> _ts = subwrd(lt,9)<br> _te = subwrd(lt,9)<br>endif<br>return<br><br></blockquote></div>
<div><br>Hi </div>
<div>thank you for your help </div>
<div>but can we change the command of <a href="http://printascii.gs">printascii.gs</a> file to write the latitude, longitude and other variable such below?</div>
<div> lon lon lon lon lon lon </div>
<div> lat ps ps ps ps ps ps </div>
<div> lat ps ps ps . . . . . . . </div>
<div> lat . . . . . . . . . . . .</div>
<div> lat </div>
<div> thanks alot <img style="MARGIN: 0px 0.2ex; VERTICAL-ALIGN: middle" src="cid:03D@goomoji.gmail" goomoji="03D"></div>
<div> </div>
<div> </div>
<div> </div>