<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Dear Andrea,<br>
<br>
Could you try:<br>
<br>
<font face="Arial" size="2"> WRITE (7,REC=1) U<br>
WRITE (7,REC=2) V<br>
</font><br>
for unformatted output (number of elements are specified in your "open"
statement)? This works for our codes... If you had an NDZ, then put
the write statements in a vertical loop, and assign data to 2D "U" and
"V" for each level (or modify the RECL and array dimensions).<br>
<br>
I hope this helps,<br>
Chuck<br>
<br>
Andrea Storto wrote:
<blockquote cite="mid002101c50258$ab87f9c0$b585de54@main" type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta content="MSHTML 6.00.2800.1141" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">Hi everybody,</font></div>
<div><font face="Arial" size="2">I'm trying to create binary files
for GrADS with Fortran:</font></div>
<div> </div>
<div><font face="Arial" size="2">...</font></div>
<div><font face="Arial" size="2"> PARAMETER (NDY=16,NDX=116)</font></div>
<div><font face="Arial" size="2">...</font></div>
<div><font face="Arial" size="2"> REAL U(NDY,NDX)<br>
REAL V(NDY,NDX)<br>
...</font></div>
<div><font face="Arial" size="2">C Reading from files:</font></div>
<div> </div>
<div><font face="Arial" size="2"> do 2 i=1,NDY<br>
read(3,*) (U(i,k),k=1,NDX)<br>
read(4,*) (V(i,k),k=1,NDX)<br>
2 continue</font></div>
<div><font face="Arial" size="2">...</font></div>
<div><font face="Arial" size="2">C Writing on standard output to
test:</font></div>
<div> </div>
<div><font face="Arial" size="2"> WRITE (*,*) 'U variables:'<br>
WRITE (*,*) ((U(K,L),L=1,NDX),K=1,NDY)<br>
WRITE (*,*) ' '<br>
WRITE (*,*) 'V variables:'<br>
WRITE (*,*) ((V(K,L),L=1,NDX),K=1,NDY)</font></div>
<div> </div>
<div><font face="Arial" size="2">C Writing binary files:</font></div>
<div> </div>
<div><font face="Arial" size="2"> OPEN
(7,FILE='uv_uhiX1.dat' ,FORM='UNFORMATTED',<br>
&ACCESS='DIRECT',RECL=NDY*NDX)</font></div>
<div><font face="Arial" size="2">C For Linux pgf77 just change the
last row in:</font></div>
<div><font face="Arial" size="2">C
&ACCESS='DIRECT',RECL=NDY*NDX*4)</font></div>
<div><font face="Arial" size="2"><br>
WRITE (7,REC=1) ((U(K,L),L=1,NDX),K=1,NDY)<br>
WRITE (7,REC=2) ((V(K,L),L=1,NDX),K=1,NDY)<br>
CLOSE(7)</font></div>
<div><font face="Arial" size="2">...</font></div>
<div><font face="Arial" size="2"> </font></div>
<div><font face="Arial" size="2">and ctl file songs like:</font></div>
<div> </div>
<div><font face="Arial" size="2"> dset
^uv_uhiX1.dat <br>
title Prova<br>
undef 1e+20<br>
xdef 16 linear 1.206897 2.413793 <br>
ydef 116 linear 1.031250 2.062500 <br>
zdef 1 levels 0<br>
tdef 1 linear 0Z2jan1987 1dy<br>
vars 2<br>
u 1 33,100 Eastward wind [m/s]<br>
v 1 34,100 Northward wind [m/s]<br>
endvars</font></div>
<div> </div>
<div><font face="Arial" size="2">I compiled with Visual Fortran: OK</font></div>
<div><font face="Arial" size="2">Built .exe: OK</font></div>
<div><font face="Arial" size="2">Verified Standard output and file
existence: OK</font></div>
<div><font face="Arial" size="2">Tested the same command :</font></div>
<div><font face="Arial" size="2"> OPEN
(7,FILE='uv_uhiX1.dat' ,FORM='UNFORMATTED',<br>
&ACCESS='DIRECT',RECL=NDY*NDX)</font></div>
<div>
<font face="Arial" size="2"> WRITE (7,REC=1)
((U(K,L),L=1,NDX),K=1,NDY)<br>
WRITE (7,REC=2) ((V(K,L),L=1,NDX),K=1,NDY)<br>
CLOSE(7)</font></div>
<div><font face="Arial" size="2">: OK for smaller matrices and manual
initialization</font></div>
<div><font face="Arial" size="2">for U and V(!!!)</font></div>
<div><font face="Arial" size="2">Tested ctl structure: OK</font></div>
<div><font face="Arial" size="2">But when I type "open uv_uhiX1.ctl"
I get:</font></div>
<div> </div>
<div><font face="Arial" size="2">Scanning description file:
uv_uhiX1.ctl</font></div>
<div><font face="Arial" size="2">Open Error: Unexpected EOF reading
variables</font></div>
<div><font face="Arial" size="2">Was expecting 2 records. Found 0.</font></div>
<div><font face="Arial" size="2"> The data file was not opened.</font></div>
<div> </div>
<div><font face="Arial" size="2">I don't know why I get this
messsage, since I used the same</font></div>
<div><font face="Arial" size="2">fortran code (but initializing
variables not from file but in Fortran itself!!!).</font></div>
<div><font face="Arial" size="2">Moreover, I can see in standard
output correct values for my variables </font></div>
<div><font face="Arial" size="2">(even if some of them have
exponential notation, others fixed notation)</font></div>
<div><font face="Arial" size="2">Have you ever had my problem?</font></div>
<div><font face="Arial" size="2">Thank you in advance</font></div>
<div> </div>
<div><font face="Arial" size="2">Andrea Storto</font></div>
<div><font face="Arial" size="2"> </font></div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
********************************************************************
Charles Seman <a class="moz-txt-link-abbreviated" href="mailto:Charles.Seman@noaa.gov">Charles.Seman@noaa.gov</a>
Geophysical Fluid Dynamics Laboratory / NOAA
Princeton University voice: (609) 452-6547
P.O. Box 308 fax: (609) 987-5063
Princeton, NJ 08542-0308 <a class="moz-txt-link-freetext" href="http://www.gfdl.noaa.gov/~cjs/">http://www.gfdl.noaa.gov/~cjs/</a>
********************************************************************
"The contents of this message are mine personally and do not reflect
any position of the Government or NOAA."
</pre>
</body>
</html>