<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1458" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial size=2>Hi Matt,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>First, to remove "Unknown command: 0" error
(which is harmless), use rs=write(filename,variable [,append]). Write has a
return value! I have a script below that write text outputs in columns. If you
are using Window XP, You need to use Wordpad to see the columns and line breaks.
Otherwise use unix2dos to convert the file to DOS format.</FONT></DIV>
<DIV><FONT face=Arial size=2> </FONT></DIV>
<DIV><FONT face=Arial size=2>Cheers,</FONT></DIV>
<DIV><FONT face=Arial size=2>Eric Tiong</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>* extract GFS vertical wind profile
for way points<BR>*<BR>* tau=1(+00), 2(+03) 3(+06),...<BR>* lat/lon
in nearest degree<BR>* fileName is output file name<BR>function
upper(site)<BR> if (site= '')<BR> say 'correct use
is: mg [tau lat lon fileName]'<BR> return<BR>
endif<BR> rcd = subwrd(site,1)<BR> lat = subwrd(site,2) <BR>
lon = subwrd(site,3)<BR> fl = subwrd(site,4)<BR> xi=lon -
94<BR> yj=lat + 11<BR> i=math_nint(xi)<BR>
j=math_nint(yj)<BR> lcn = 'Site: ' % math_format('%5.1f',lat) % ' ' %
math_format('%6.1f',lon)<BR> 'set lat 'lat<BR> 'set lon
'lon<BR> 'set t 'rcd<BR> 'q time'<BR> tds =
subwrd(result,3)<BR> hdr = 'Level
wind'<BR> rs=write(fl,lcn)<BR> rs=write(fl,tds,append)<BR>
rs=write(fl,hdr,append)<BR> fmt4 = '%3.0f'; fmt5 = '%02.0f'<BR>* 925hPa
<BR> 'set lev 925'<BR> lvl = "925mb"<BR> 'd u'<BR> v1 =
subwrd(result,4)<BR> 'd v'<BR> v2 = subwrd(result,4)<BR> sp =
math_sqrt(v1*v1+v2*v2) * 1.95<BR> dw = math_atan2(-v1,-v2) *
180.0/3.1416 +360.0<BR> if
(dw>360.0)<BR> dw=dw-360.0<BR>
endif<BR> rr=lvl % ' ' % math_format(fmt4,dw) % '/' %
math_format(fmt5,sp)<BR> rs=write(fl, rr, append)<BR>* 850hPa
<BR> 'set lev 850'<BR> lvl = "850mb"<BR> 'd u'<BR> v1 =
subwrd(result,4)<BR> 'd v'<BR> v2 = subwrd(result,4)<BR> sp =
math_sqrt(v1*v1+v2*v2) * 1.95<BR> dw = math_atan2(-v1,-v2) *
180.0/3.1416 +360.0<BR> if
(dw>360.0)<BR> dw=dw-360.0<BR>
endif<BR> rr=lvl % ' ' % math_format(fmt4,dw) % '/' %
math_format(fmt5,sp)<BR> rs=write(fl, rr, append)<BR>* 700hPa
<BR> 'set lev 700'<BR> lvl = "700mb"<BR> 'd u'<BR> v1 =
subwrd(result,4)<BR> 'd v'<BR> v2 = subwrd(result,4)<BR> sp =
math_sqrt(v1*v1+v2*v2) * 1.95<BR> dw = math_atan2(-v1,-v2) *
180.0/3.1416 +360.0<BR> if
(dw>360.0)<BR> dw=dw-360.0<BR>
endif<BR> rr=lvl % ' ' % math_format(fmt4,dw) % '/' %
math_format(fmt5,sp)<BR> rs=write(fl, rr, append)<BR>* 500hPa
<BR> 'set lev 500'<BR> lvl = "500mb"<BR> 'd u'<BR> v1 =
subwrd(result,4)<BR> 'd v'<BR> v2 = subwrd(result,4)<BR> sp =
math_sqrt(v1*v1+v2*v2) * 1.95<BR> dw = math_atan2(-v1,-v2) *
180.0/3.1416 +360.0<BR> if
(dw>360.0)<BR> dw=dw-360.0<BR>
endif<BR> rr=lvl % ' ' % math_format(fmt4,dw) % '/' %
math_format(fmt5,sp)<BR> rs=write(fl, rr, append)<BR>* 400hPa
<BR> 'set lev 400'<BR> lvl = "400mb"<BR> 'd u'<BR> v1 =
subwrd(result,4)<BR> 'd v'<BR> v2 = subwrd(result,4)<BR> sp =
math_sqrt(v1*v1+v2*v2) * 1.95<BR> dw = math_atan2(-v1,-v2) *
180.0/3.1416 +360.0<BR> if
(dw>360.0)<BR> dw=dw-360.0<BR>
endif<BR> rr=lvl % ' ' % math_format(fmt4,dw) % '/' %
math_format(fmt5,sp)<BR> rs=write(fl, rr, append)<BR>* 300hPa
<BR> 'set lev 300'<BR> lvl = "300mb"<BR> 'd u'<BR> v1 =
subwrd(result,4)<BR> 'd v'<BR> v2 = subwrd(result,4)<BR> sp =
math_sqrt(v1*v1+v2*v2) * 1.95<BR> dw = math_atan2(-v1,-v2) *
180.0/3.1416 +360.0<BR> if
(dw>360.0)<BR> dw=dw-360.0<BR>
endif<BR> rr=lvl % ' ' % math_format(fmt4,dw) % '/' %
math_format(fmt5,sp)<BR> rs=write(fl, rr, append)<BR>
rs=close(fl)<BR>return</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>----- Original Message ----- </FONT>
<DIV><FONT face=Arial size=2>From: "M P Borkow" <</FONT><A
href="mailto:mpborkow@NCSU.EDU"><FONT face=Arial
size=2>mpborkow@NCSU.EDU</FONT></A><FONT face=Arial size=2>></FONT></DIV>
<DIV><FONT face=Arial size=2>To: <</FONT><A
href="mailto:GRADSUSR@LIST.CINECA.IT"><FONT face=Arial
size=2>GRADSUSR@LIST.CINECA.IT</FONT></A><FONT face=Arial
size=2>></FONT></DIV>
<DIV><FONT face=Arial size=2>Sent: Friday, September 02, 2005 5:38
AM</FONT></DIV>
<DIV><FONT face=Arial size=2>Subject: Re: help needed with ascii
output</FONT></DIV></DIV>
<DIV><FONT face=Arial><BR><FONT size=2></FONT></FONT></DIV><FONT face=Arial
size=2>> Thanks for the response,<BR>> <BR>> Your script as written
didn't work for me. I had this same problem<BR>> yesterday when I tried
to use the write command, I just get "Unknown<BR>> command: 0". Even if
I don't get that working, I still am unsure of how<BR>> to rewrite it to
include a 'd lat' and 'd lon' command.<BR>> <BR>> -Matt<BR>> <BR>>
<BR>> > Hi Matt<BR>> > I work extensively
with grads writing text and have found that the<BR>> > following method,
while not elegant is for me most effective, have a<BR>> > look at my old
positing below and apply to your problem. essentially<BR>> > what I posted
is an idiots' version of Jennifer's' script but is<BR>> > probably easier
to understand.<BR>> > You will need to assign
values to each variable then create the line<BR>> > before writing the
file.<BR>> > Have a look at the script then give
me some specifics and I'll give<BR>> > you a hand.<BR>>
> Cheers<BR>>
> JP<BR>> ><BR>>
><BR>> ><BR>> > Hi<BR>> > fwrite will
produce a binary file, you need to write a script,<BR>> > somthing like
the following for ascii, using the write command:<BR>> ><BR>> >
function main(args)<BR>> > i = 1<BR>> > while i <= 249<BR>>
> 'set t ' i<BR>> > 'd htsgwsfc'<BR>> >
Val=subwrd(result,4)<BR>> > write (Valuedir.txt,Val, append)<BR>> >
i = i + 1<BR>> > endwhile<BR>> ><BR>> ><BR>> > Good
Luck<BR>> > Jean Pierre<BR>> ><BR>>
</FONT></BODY></HTML>