<div dir="ltr">Laura,<div><br></div><div>1.  Please notice that your array size 43200 * 21600 * 4-byte floats exceeds the conventional 2 Gbyte limit for normal fortran unformatted sequential record size.  This may be the cause of &quot;0 or less than zero fortran control word&quot;.  Some compilers have schemes for larger record size, but they are not standardized and can be troublesome.</div><div><br></div><div>2.  There are several solutions.  I recommend keeping the ordinary fortran unformatted sequential format because it seems you are most familiar with it.  But loop over Y, and write your array in pieces sequentially, one Y subscript at a time.  This will write 21600 records with reasonable record size.</div><div><br></div><div>3.  Check your output file before attempting to read with NCL.  The size of this new file should be exactly 21600 * (43200 + 1 + 1) * 4 bytes in size, including two standard fortran control words for each record.</div><div><br></div>4.  In NCL, pre-dimension your input array.  Then read this new binary sequential file one record at a time, looping over Y, the same as it was written.  Be sure to use the fbinrecread function for reading binary sequential format, multiple records.  Untested:<br><br>nx = 43200<br>ny = 21600<div>oro_usgs = new ( (/ nx, ny /), float)<br>do y = 0, ny-1<br>   oro_usgs(:,y) = fbinrecread (fili, y, nx, &quot;float&quot;)<div>end do</div><div><br></div><div>5.  If you are still having trouble, try writing and reading only a single record (one Y subscript).  This will make a small test file and simplify debugging.</div><div><br></div><div>6.  Unless you are constrained in some way by other issues in your fortran program, please avoid reading and writing this file as big endian.  Modern Macs are little endian machines, and they do well with their native formats.  Reverse endian may be adding confusion needlessly.</div><div><br></div><div>7.  Consider using &quot;od&quot; or another binary viewing program to inspect the contents of your file.  See this write-up for more details on investigating binary formats:</div><div><br></div><div>   <a href="http://www.ncl.ucar.edu/Applications/r-binary.shtml">http://www.ncl.ucar.edu/Applications/r-binary.shtml</a><br></div><div><br></div><div>--Dave</div></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 23, 2015 at 5:55 PM, Laura Fowler <span dir="ltr">&lt;<a href="mailto:laura@ucar.edu" target="_blank">laura@ucar.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Dennis:<br>
Unfortunately, reading the fortran binary file still does not work. I<br>
rewrote the binary files as flat binary files, or<br>
open(unit=21,file=&#39;output.oro_usgs.bin&#39;,form=&#39;unformatted&#39;)<br>
<br>
so in my ncl script,  I have:<br>
oro_usgs = fbinrecread(file1,0,-1,&quot;float&quot;)<br>
<br>
since I do not specify the length of the array oro_usgs. Since I had<br>
to use the option -fconvert=big-endian to read some data, I also tried<br>
to use the option:<br>
<br>
setfileoption(&quot;bin&quot;,&quot;ReadByteOrder&quot;,&quot;BigEndian&quot;)<br>
<br>
but that did not help either. I am really puzzled as what to do next<br>
since I can read that new file with a simple fortran unformatted read.<br>
What else do you suggest?<br>
<br>
Thanks,<br>
Laura<br><br>
<br>
On Fri, Nov 20, 2015 at 5:53 PM, Dennis Shea &lt;<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>&gt; wrote:<br>
&gt; fortran binary writes can create &#39;flat&#39; binary files (access=&#39;direct&#39;)<br>
&gt; or access=&#39;sequential&#39;. The latter is the default.<br>
&gt;<br>
&gt; To read &#39;flat&#39; files use: fbinread<br>
&gt;<br>
&gt; To read &#39;sequential&#39; (which you explicitly specified) use: fbinrecread<br>
&gt;<br>
&gt; ===<br>
&gt; Note: fortran precedes *each* sequential record by a  record separator.<br>
&gt;<br>
&gt; Good luck<br>
&gt;<br>
&gt;<br>
&gt; On Fri, Nov 20, 2015 at 5:25 PM, Laura Fowler &lt;<a href="mailto:laura@ucar.edu">laura@ucar.edu</a>&gt; wrote:<br>
&gt;&gt; Hi:<br>
&gt;&gt;<br>
&gt;&gt; I created a binary file using a fortran sourcecode on my iMac. Using<br>
&gt;&gt; gfortran, I used the option -fconvert=big-endian tom compie the<br>
&gt;&gt; sourcecode. I used the open statement:<br>
&gt;&gt;<br>
&gt;&gt; open(unit=21,file=&#39;oro_usgs.bin&#39;,form=&#39;unformatted&#39;,access=&#39;sequential&#39;)<br>
&gt;&gt;<br>
&gt;&gt; to write the data out. I want to open and read the file in an ncl<br>
&gt;&gt; script to later plot the data. My script looks like that:<br>
&gt;&gt;<br>
&gt;&gt; setfileoption(&quot;bin&quot;,&quot;ReadByteOrder&quot;,&quot;BigEndian&quot;)<br>
&gt;&gt; file1    = &quot;oro_usgs.bin&quot;<br>
&gt;&gt; recl     = 43200*21600<br>
&gt;&gt; oro_usgs = fbinread(file1,recl,&quot;float&quot;)<br>
&gt;&gt; print(max(oro_usgs))<br>
&gt;&gt; printVarSummary(oro_usgs)<br>
&gt;&gt;<br>
&gt;&gt; I get the error:<br>
&gt;&gt;  See <a href="http://www.ncl.ucar.edu/" rel="noreferrer" target="_blank">http://www.ncl.ucar.edu/</a> for more details.<br>
&gt;&gt;  fatal:fbinread: 0 or less than zero fortran control word, FILE NOT<br>
&gt;&gt; SEQUENTIAL ACCESS!<br>
&gt;&gt;  fatal:[&quot;Execute.c&quot;:8128]:Execute: Error occurred at or near line 17<br>
&gt;&gt; in file plot.ncl<br>
&gt;&gt;<br>
&gt;&gt; without the setfileoption, I get the error:<br>
&gt;&gt;<br>
&gt;&gt; See <a href="http://www.ncl.ucar.edu/" rel="noreferrer" target="_blank">http://www.ncl.ucar.edu/</a> for more details.<br>
&gt;&gt; fatal:fbinread: requested variable size exceeds record size<br>
&gt;&gt; fatal:[&quot;Execute.c&quot;:8128]:Execute: Error occurred at or near line 17 in<br>
&gt;&gt; file plot.ncl<br>
&gt;&gt;<br>
&gt;&gt; I do not know what to do next and help would be greatly appreciated. Thanks,<br>
&gt;&gt;<br>
&gt;&gt; Laura<br></blockquote></div></div></div>