<html><body>
<DIV>Thanks again for all your help. I made an intersting yet simple discovery along the way to solving this problem... </DIV>
<DIV> </DIV>
<DIV>** Variables written out using fwrite MUST be read back into Grads in the exact same order. **</DIV>
<DIV> </DIV>
<DIV>For example:</DIV>
<DIV> </DIV>
<DIV>set fwrite grads.fwrite<BR>set gxout fwrite<BR>d var1<BR>d var2<BR>disable fwrite</DIV>
<DIV> </DIV>
<DIV>The ctl file to read the data back into grads must list the variables in the exact same order they are written out (e.g.):</DIV>
<DIV>.....</DIV>
<DIV>vars 2<BR>var1 0 107,1,1 ** var1 [deg]<BR>var2 0 100,1,1 ** var2 [m]<BR>ENDVARS</DIV>
<DIV> </DIV>
<DIV>If the order ir reversed (i.e var2, var1) you'll be reading degrees for meters or visa versa.</DIV>
<DIV> </DIV>
<DIV>Thanks again, <BR>Mark</DIV>
<DIV> </DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">-------------- Original message -------------- <BR><BR>> The "options yrev" should not be used. Even though your original file has x <BR>> and y reversed, fwrite writes the data from grads arrays so everything is in <BR>> the order grads expects. I don't think that would give you the results you <BR>> report, though. The grid should just be skewed around since you are reading <BR>> rows and columns in the wrong order. The little endian may be a problem. <BR>> If you are writing and reading the files on the same machine, you don't need <BR>> to specify the endian type. Again, fwrite uses the expected format for the <BR>> machine you are on. Since you only have two variables with one time and <BR>> level, there isn't much more that could be wrong. <BR>> <BR>> > -----Original Message----- <BR>> > From: Mark Sponsler [mailto:msponsler@COMCAST.NET] <BR>
> > Sent: Monday, October 17, 2005 2:42 PM <BR>> > To: GRADSUSR@LIST.CINECA.IT <BR>> > Subject: fwrite (again) <BR>> > <BR>> > <BR>> > Sorry to be so bothersome but I have another simple question <BR>> > that I could <BR>> > not answer after reviewing the documentation. <BR>> > <BR>> > When using the fwrite defaults, it streams the data to a <BR>> > binary file for <BR>> > eventualy re-ingestion into GRADS. Is some level of fortran <BR>> > manipulation <BR>> > of the fwrite output required before it can be re-read by Grads? <BR>> > <BR>> > I ask because I was able to manually generate a control file <BR>> > and get Grads <BR>> > to read the file producing some results, but the data is way off <BR>> > (Significant Wave Heights are all too high and and Direction <BR>> > is set to 180 <BR>> > degrees for all grib points). <BR>> > <BR>> > Here
's my modified control file: <BR>> > <BR>> > dset grads.fwrite <BR>> > undef 9.999E+20 <BR>> > options little_endian <BR>> > options yrev <BR>> > ydef 157 linear -78.000000 1 <BR>> > xdef 288 linear 0.000000 1.250000 <BR>> > tdef 1 linear 18Z12nov2004 03hr <BR>> > zdef 1 linear 1 1 <BR>> > vars 2 <BR>> > DIRPWsfc 0 107,1,1 ** surface Primary wave direction [deg] <BR>> > HTSGWsfc 0 100,1,1 ** surface Sig height of wind waves and swell [m] <BR>> > ENDVARS <BR>> > <BR>> > Here's the control file for original dataset that fwrite used as it's <BR>> > source: <BR>> > <BR>> > dset nww3.all.grb <BR>> > index nww3.all.grb.idx <BR>> > undef 9.999E+20 <BR>> > title nww3.all.grb <BR>> > * produced by grib2ctl v0.9.12.5p33e <BR>> > dtype grib 233 <BR>> > options yrev <BR>> > ydef 157 linear -78.000000 1 <BR>> > xdef 288 linear 0.00000
0 1.250000 <BR>> > tdef 61 linear 18Z12nov2004 03hr <BR>> > zdef 1 linear 1 1 <BR>> > vars 11 <BR>> > DIRPWsfc 0 107,1,1 ** surface Primary wave direction [deg] <BR>> > DIRSWsfc 0 109,1,1 ** surface Secondary wave direction [deg] <BR>> > HTSGWsfc 0 100,1,1 ** surface Sig height of wind waves and swell [m] <BR>> > PERPWsfc 0 108,1,1 ** surface Primary wave mean period [s] <BR>> > PERSWsfc 0 110,1,1 ** surface Secondary wave mean period [s] <BR>> > UGRDsfc 0 33,1,1 ** surface u wind [m/s] <BR>> > VGRDsfc 0 34,1,1 ** surface v wind [m/s] <BR>> > WDIRsfc 0 31,1,1 ** surface Wind direction [deg] <BR>> > WINDsfc 0 32,1,1 ** surface Wind speed [m/s] <BR>> > WVDIRsfc 0 101,1,1 ** surface Direction of wind waves [deg] <BR>> > WVPERsfc 0 103,1,1 ** surface Mean period of wind waves [s] <BR>> > ENDVARS <BR>> > </BLOCKQUOTE></body></html>