[ncl-talk] how to read a fortran binary file using fbinrecread, need setfileoption("bin", "ReadByteOrder", "BigEndian")
xiaoming Hu
yuanfangcan at hotmail.com
Tue Mar 3 13:38:48 MST 2015
Dave
After I add
setfileoption("bin","ReadByteOrder","BigEndian")
everything seems fine.
Thanks a lot!
Xiaoming
From: yuanfangcan at hotmail.com
To: dave.allured at noaa.gov
Date: Tue, 3 Mar 2015 19:43:47 +0000
CC: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] how to read a fortran binary file using fbinrecread
Dave
I tested what you suggested in NCL:
I got
NCAR Command Language Version 6.1.2
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
fatal:NclMalloc Failed:[errno=12]
fatal:fbinrecread: an error occurred reading the requested record. Something is wrong with the FORTRAN binary file.
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 11 in file conwomap_2.ncl
two diagnosis:
od -Ad -i -v -N48 test.dat
0000000 -2066740992 0 0 0
0000016 0 0 0 0
0000032 0 0 0 0
0000048
od -Ad -tx1 -v -N48 test.dat
0000000 00 09 d0 84 00 00 00 00 00 00 00 00 00 00 00 00
0000016 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000032 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000048
Thanks a lot!
Xiaoming
Date: Tue, 3 Mar 2015 12:23:21 -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,
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
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
_______________________________________________
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/697265ac/attachment.html
More information about the ncl-talk
mailing list