<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div>The syntax of units field in a variable declaration depends on the data type: for grib is is a comma-delimited list of index numbers, for netcdf it is a comma-delimited list of coordinate axes, and for binary it is ignored.</div>
<div>—Jennifer<br>
<div> </div>
<div>
<div>
<div>
<div>On Jul 5, 2016, at 2:31 PM, Charles Seman - NOAA Federal <<a href="mailto:charles.seman@noaa.gov">charles.seman@noaa.gov</a>> wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">Lydia,<br>
<br>
Another thing: I don't understand the characters like "12,105,2 **" in <br>
the vars records in your ctl file:<br>
<br>
TMAX 0 12,105,2 ** maximum temperature at 2m above surface [C]<br>
<br>
TMIN 0 11,105,2 ** minimum temperature at 2m above surface [C]<br>
<br>
PRCP 0 61,1,0 ** total precipitation backward accumulated [kg/m^2 or mm]<br>
<br>
SRAD 0 204,1,0 ** total surface downward shortwave radiation flux [mJ/m^2]<br>
<br>
How are these characters used by GrADS? I would expect something like <br>
"0,y,x"<br>
<br>
Chuck<br>
<br>
On 07/05/2016 02:21 PM, Charles Seman - NOAA Federal wrote:<br>
<blockquote type="cite">Lydia,<br>
<br>
I would try to verify some of the values in your arrays... To start,<br>
define a tmax_all(464,224), and read one record into it:<br>
read(17,REC=irec) tmax_all. Then, print out a common row and a column<br>
from it and from tmax to verify you get the same values. Do this for<br>
just one time level, and stop. This is slow and tedious work. Unless<br>
you have access to TotalView or some other visual debugger, then you can<br>
step through your code line by line and should be able to find it.<br>
<br>
Hope this helps,<br>
Chuck<br>
<br>
On 07/05/2016 01:41 PM, Lydia Rill wrote:<br>
<blockquote type="cite">Thanks Chuck! I double checked the record length and it is indeed 4.<br>
<br>
Thank you Jim! Sorry my code was a little messy, I have tried many<br>
different methods.<br>
Good point about the lower left hand corner, that was one of the issues<br>
here.<br>
<br>
When I use 32 x steps, 32 y steps, and 10 time steps I use a record<br>
length of 4096 for the output file and I get a file size of 160K, which<br>
roughly matches 32*32*10*4*4 = 16385<br>
<br>
I am now getting realistic numbers for my output! However, when I<br>
display the data in GrADS for one time I get only parts of the 4x4<br>
degree box, by latitude, for each variable, instead of getting the data<br>
for each variable for the whole box. For example in the middle of the<br>
box I get tmax for 43.5-44N, tmin for 43-43.5N, prcp around 43N, and<br>
srad around 42.5N. Any ideas on why this is happening?<br>
<br>
Here is the updated code:<br>
<br>
integer irec,i,j,t,days<br>
<br>
character(len=100) infile,outfile<br>
<br>
real tmin(464,224),tmax(464,224),prcp(464,224),srad(464,224)<br>
<br>
infile='/Volumes/WebData/NLDAS2/DailyNLDAS/daily.bin'<br>
<br>
outfile='/Volumes/WebData/NLDAS2/Fortran/testdaily.bin'<br>
<br>
open(17,file=infile,form="unformatted",access="direct",recl=32*32*4,status="old")<br>
<br>
<br>
open(18,file=outfile,form="unformatted",access="direct",recl=32*32*4,status="unknown")<br>
<br>
<br>
<br>
days=10<br>
<br>
irec=1<br>
<br>
do t=1,days<br>
<br>
read(17,REC=irec) ((tmax(i,j),i=129,160),j=129,160)<br>
<br>
read(17,REC=irec+1) ((tmin(i,j),i=129,160),j=129,160)<br>
<br>
read(17,REC=irec+2) ((prcp(i,j),i=129,160),j=129,160)<br>
<br>
read(17,REC=irec+3) ((srad(i,j),i=129,160),j=129,160)<br>
<br>
write(18,REC=irec) ((tmax(i,j),i=129,160),j=129,160)<br>
<br>
write(18,REC=irec+1) ((tmin(i,j),i=129,160),j=129,160)<br>
<br>
write(18,REC=irec+2) ((prcp(i,j),i=129,160),j=129,160)<br>
<br>
write(18,REC=irec+3) ((srad(i,j),i=129,160),j=129,160)<br>
<br>
irec=irec+4<br>
<br>
enddo<br>
<br>
<br>
Here is the updated control file:<br>
<br>
dset ^testdaily.bin<br>
<br>
undef 9.999E+20<br>
<br>
title Daily NLDAS2 Data for 04Z through 03Z<br>
<br>
xdef 32 linear -108.9375 0.125<br>
<br>
ydef 32 linear 41.0625 0.125<br>
<br>
tdef 10 linear 00Z02Jan1979 1dy<br>
<br>
zdef 1 linear 1 1<br>
<br>
vars 4<br>
<br>
TMAX 0 12,105,2 ** maximum temperature at 2m above surface [C]<br>
<br>
TMIN 0 11,105,2 ** minimum temperature at 2m above surface [C]<br>
<br>
PRCP 0 61,1,0 ** total precipitation backward accumulated [kg/m^2 or mm]<br>
<br>
SRAD 0 204,1,0 ** total surface downward shortwave radiation flux<br>
[mJ/m^2]<br>
<br>
ENDVARS<br>
<br>
<br>
Thank you both so much for your help,<br>
<br>
Lydia<br>
<br>
On Tue, Jul 5, 2016 at 12:44 PM, James T. Potemra <<a href="mailto:jimp@hawaii.edu">jimp@hawaii.edu</a><br>
<<a href="mailto:jimp@hawaii.edu">mailto:jimp@hawaii.edu</a>>> wrote:<br>
<br>
Hi Lydia,<br>
<br>
You have a couple problems. First, you are reading in tmax, tmin,<br>
prcp then srad, but then you write out tmin, tmin prcp and srad<br>
(tmin twice). Second, your program is reading and writing to the<br>
same variables, and then only the first 8x8 (lower left "corner" of<br>
the data sets). Perhaps these are all missing ?<br>
<br>
Finally, the record length is defined to be 464 by 224, then you<br>
only define (via read) and write the first 8 by 8, which should work<br>
ok, but recognize that the rest of the 464x224 array has not been<br>
defined. So, if you want to use your control file with "xdef 8" and<br>
"ydef 8" you'll need to change your "open" statement for the output<br>
file to be 8*8*4 and not 464*224*4. Alternately you could change<br>
the xdef/ydef lines.<br>
<br>
Note as a quick check, your output file should be 8*8*10*4*4<br>
(x*y*t*4) bytes large for that control file.<br>
<br>
Jim<br>
<br>
On 7/5/16 3:57 AM, Lydia Rill wrote:<br>
<blockquote type="cite"> Hi all,<br>
<br>
I am a new grads user and I have never worked with binary files<br>
before. I have a large binary file I created in grads (code shown<br>
below). I want to split up the binary file by latitude and<br>
longitude degree into smaller binary files. While this is possible<br>
in GrADS, it is too slow for my needs, so I am trying to do it in<br>
Fortran 90.<br>
<br>
However, I am having problems reading the GrADS binary file in<br>
Fortran. It gives me the missing value for each of my variables at<br>
every time step and every location.<br>
<br>
The binary file contains NLDAS 2 forcing data, with 464 x steps,<br>
224 y steps, and 13688 daily time steps for 4 variables (only 1 Z<br>
level). It is a large file at 22GB, and I can successfully display<br>
the variables in GrADS from this binary file. This binary file was<br>
created from data in Grib files.<br>
<br>
I have tried many various ways of reading in the binary data,<br>
using x and y loops, or time loops, or looping through the 4<br>
variables, but nothing has been successful.<br>
<br>
I am working on a Mac (El Capitan).<br>
<br>
Here is the GrADS script I used to create the binary file:<br>
<br>
functionmain(args)<br>
<br>
counthr=subwrd(args,1)<br>
<br>
'reinit'<br>
<br>
'open /Volumes/WebData/NLDAS2/ProcessingFiles/24hours.ctl'<br>
<br>
'set undef 9.999e20'<br>
<br>
'set gxout fwrite'<br>
<br>
'set fwrite -ap /Volumes/WebData/NLDAS2/DailyNLDAS/daily.bin'<br>
<br>
<br>
'set t 1'<br>
<br>
t1=1+4<br>
<br>
t1p=1+5<br>
<br>
while(t1<=counthr+5-23)<br>
<br>
t2=t1+23<br>
<br>
t2p=t1p+23<br>
<br>
'd (max(TMP2m,t='t1',t='t2')-273.15)'<br>
<br>
'd (min(TMP2m,t='t1',t='t2')-273.15)'<br>
<br>
'd sum(APCPsfc,t='t1p',t='t2p')'<br>
<br>
'd (ave(DSWRFsfc,t='t1',t='t2')*24*3600/1000000)'<br>
<br>
t1=t1+24<br>
<br>
t1p=t1p+24<br>
<br>
endwhile<br>
<br>
'quit'<br>
<br>
<br>
Here is the Fortran script to read the binary file<br>
<br>
ProgramReadbin<br>
<br>
implicitnone<br>
<br>
integer irec,i,j,t,days<br>
<br>
real tmin(464,224),tmax(464,224),prcp(464,224),srad(464,224)<br>
<br>
OPEN(17,file='/Volumes/WebData/NLDAS2/DailyNLDAS/daily.bin',&<br>
<br>
&STATUS='Old',FORM='UNFORMATTED',ACCESS='DIRECT',RECL=464*224*4)<br>
<br>
<br>
OPEN(18,file='/Volumes/WebData/NLDAS2/DailyNLDAS/testdaily.bin',&<br>
<br>
&STATUS='UNKNOWN',FORM='UNFORMATTED',ACCESS='DIRECT',RECL=464*224*4)<br>
<br>
days=10<br>
<br>
irec=1<br>
<br>
do t=1,days<br>
<br>
read(17,REC=irec) ((tmax(i,j),i=1,8),j=1,8)<br>
<br>
read(17,REC=irec+1) ((tmin(i,j),i=1,8),j=1,8)<br>
<br>
read(17,REC=irec+2) ((prcp(i,j),i=1,8),j=1,8)<br>
<br>
read(17,REC=irec+3) ((srad(i,j),i=1,8),j=1,8)<br>
<br>
write(18,REC=irec) ((tmin(i,j),i=1,8),j=1,8)<br>
<br>
write(18,REC=irec+1) ((tmin(i,j),i=1,8),j=1,8)<br>
<br>
write(18,REC=irec+2) ((prcp(i,j),i=1,8),j=1,8)<br>
<br>
write(18,REC=irec+3) ((srad(i,j),i=1,8),j=1,8)<br>
<br>
irec=irec+4<br>
<br>
enddo<br>
<br>
end program<br>
<br>
<br>
The corresponding control file is:<br>
<br>
set ^testdaily.bin<br>
<br>
undef 9.999E+20<br>
<br>
title Daily NLDAS2 Data for00Z through 23Z<br>
<br>
xdef 8linear -124.93750.125<br>
<br>
ydef 8linear 25.06250.125<br>
<br>
tdef 10linear 00Z02Jan1979 1dy<br>
<br>
zdef 1linear 11<br>
<br>
vars 4<br>
<br>
TMAX 012,105,2**maximum temperature at 2m above surface [C]<br>
<br>
TMIN 011,105,2**minimum temperature at 2m above surface [C]<br>
<br>
PRCP 061,1,0**total precipitation backward accumulated [kg/m^2ormm]<br>
<br>
SRAD 0204,1,0**total surface downward shortwave radiation flux<br>
[mJ/m^2]<br>
<br>
ENDVARS<br>
<br>
<br>
<br>
Thanks,<br>
<br>
Lydia<br>
<br>
--<br>
Lydia D. Rill<br>
M.S., Michigan State University 2016<br>
B.S., Valparaiso University 2014<br>
(224) 406-5130<br>
<a href="mailto:Lydia.D.Rill@gmail.com">Lydia.D.Rill@gmail.com</a> <<a href="mailto:Lydia.D.Rill@gmail.com">mailto:Lydia.D.Rill@gmail.com</a>><br>
<br>
<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a> <<a href="mailto:gradsusr@gradsusr.org">mailto:gradsusr@gradsusr.org</a>><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
</blockquote>
<br>
<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a> <<a href="mailto:gradsusr@gradsusr.org">mailto:gradsusr@gradsusr.org</a>><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br>
<br>
<br>
<br>
--<br>
Lydia D. Rill<br>
M.S., Michigan State University 2016<br>
B.S., Valparaiso University 2014<br>
(224) 406-5130<br>
<a href="mailto:Lydia.D.Rill@gmail.com">Lydia.D.Rill@gmail.com</a> <<a href="mailto:Lydia.D.Rill@gmail.com">mailto:Lydia.D.Rill@gmail.com</a>><br>
<br>
<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
http://gradsusr.org/mailman/listinfo/gradsusr<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
-- <br>
<br>
Please note that <a href="mailto:Charles.Seman@noaa.gov">Charles.Seman@noaa.gov</a> should be considered my NOAA<br>
email address, not <a href="mailto:cjs@gfdl.noaa.gov">cjs@gfdl.noaa.gov</a>.<br>
<br>
********************************************************************<br>
Charles Seman <a href="mailto:Charles.Seman@noaa.gov">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/">http://www.gfdl.noaa.gov/~cjs/</a><br>
********************************************************************<br>
<br>
"The contents of this message are mine personally and do not reflect any<br>
official or unofficial position of the United States Federal Government,<br>
the United States Department of Commerce, or NOAA."<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
http://gradsusr.org/mailman/listinfo/gradsusr<br>
</blockquote>
</div>
<br>
<div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="font-size: 12px; orphans: 2; widows: 2;">--</div>
<div style="font-size: 12px; orphans: 2; widows: 2;">Jennifer Miletta Adams<br>
Center for Ocean-Land-Atmosphere Studies (COLA)<br>
George Mason University<br>
<br>
<br>
</div>
</div>
</div>
</div>
<br>
</div>
</div>
</div>
</body>
</html>