[ncl-talk] how to read a fortran binary file using fbinrecread

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Tue Mar 3 12:23:21 MST 2015


Xiaoming,

Okay, it looks like your actual fortran program is writing more records
than what you originally showed.  But you are having a problem with the
very first record #0.

Try this in NCL:

   htest = fbinrecread ("./test.dat", 0, -1, "float")
   print ("Size of htest = " + diimsizes (htest))

The output of the print statement will show you the actual number of values
in the first fortran record.  With your numbers, this value should be 401 x
401 = 160801.  If it matches, then jde and ide in your original NCL command
may have values other than 401.

If the htest size is different, then record #0 in the file is not what you
expected.  To debug this further, I would need to look at the binary start
of the file with these two system commands:

   od -Ad -i -v -N48 test.dat
   od -Ad -tx1 -v -N48 test.dat

Also, please keep all replies on the NCL user list.

--Dave

On Tue, Mar 3, 2015 at 11:44 AM, xiaoming Hu <yuanfangcan at hotmail.com>
wrote:

> Dave
>
> Here is the relevant info:
>     ids=1;ide=401
>     jds=1;jde=401
> -rw-r--r-- 1 xhu caps 617M Mar  3 11:11 test.dat
>
> real,dimension(:,:),allocatable   :: u,v,h
>
> NCAR Command Language Version 5.2.1
>
> /usr/local/intel/fc/9.1.040/bin/ifort
>
> Linux cirrus.caps.ou.edu 2.6.18-348.12.1.el5 #1 SMP Mon Jul 1 17:54:12
> EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
>
> I do have close(10) in the fortran code
>
> Thanks a lot!
> Xiaoming
> ------------------------------
> Date: Tue, 3 Mar 2015 11:21:46 -0700
> Subject: Re: [ncl-talk] how to read a fortran binary file using fbinrecread
> From: dave.allured at noaa.gov
> To: yuanfangcan at hotmail.com
> CC: ncl-talk at ucar.edu
>
> Xiaoming,
>
> Please tell us the following debug information.
>
> * The exact values of ids, ide, jds jde.
> * The exact size of the file, in bytes, from "ls -l".
> * The fortran data type of the array "h" in the fortran program (real,
> double, or what?)
>
> * NCL version number.
> * Fortran compiler name and version number.
> * The output from system command "uname -a".
>
> Also, just a guess, try adding close (10) at the end of your fortran
> program, and see if that helps.
>
> --Dave
>
> On Tue, Mar 3, 2015 at 11:09 AM, xiaoming Hu <yuanfangcan at hotmail.com>
> wrote:
>
> Hello
>
> In fortran I have:
>     ids=1;
>   open(10,file='./test.dat',form='unformatted',access='sequential')
>   write(10)((h(i,j),i=ids,ide),j=jds,jde)
>
>
> In ncl I tried to use
>    h    = fbinrecread ("./test.dat",0, (/jde,ide/),"float")
> to read
>
> But I got
> warning:fbinrecread: size specified is greater than record size, filling
> with missing values
> fatal:fbinrecread: an error occurred reading the requested record.
> Something is wrong with the FORTRAN binary file.
> fatal:Execute: Error occurred at or near line 11 in file conwomap_2.ncl
>
> Can anybody help?
>
> Thanks a lot!
>
> Xiaoming
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150303/dcc8a844/attachment.html 


More information about the ncl-talk mailing list