Re: fbinread can't read binary file created by Fortran correctly

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Wed Jun 13 2012 - 10:23:58 MDT

Xitian,

Check your gfortran version. You may have a very old gfortran compiler.

Mine is:

gfortran -v
Using built-in specs.
Target: x86_64-apple-darwin10
Configured with: ../gcc-4.5-20090910/configure --enable-languages=fortran,c++ --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10
Thread model: posix
gcc version 4.5.0 20090910 (experimental) (GCC)

I checked on a machine with gfortran 4.1.2, which has the similar problem.

Wei

huangwei@ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924

On Jun 13, 2012, at 9:48 AM, Xitian Cai wrote:

> Hi All,
>
> I'm writing a NCL script to read regular binary files created by FORTRAN. For example, when I compiled the FORTRAN code using ifort compiler and write the binary file, the NCL script is working fine to read it, however when I use gfortran, fbinread got the first value as 0 and neglect the last value. The attached are the example FORTRAN code, NCL script and the binary file created by the FORTRAN code using FORTRAN compiler.
>
> (1) Compile code: gfortran write_binary_test.f
> (2) Run a.out, which creates the binary file Test_WrittenByF.bin
> (3) Run "ncl ReadWrite_Binary_NCL.ncl" which will print the data.
>
> The result should be: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
> But I got:
> (0,0) 0
> (0,1) 1
> (0,2) 2
> (0,3) 3
> (0,4) 4
> (1,0) 5
> (1,1) 6
> (1,2) 7
> (1,3) 8
> (1,4) 9
> (2,0) 10
> (2,1) 11
> (2,2) 12
> (2,3) 13
> (2,4) 14
>
> Does anyone know the problem?
>
> Thanks,
>
> Xitian
> <ReadWrite_Binary_NCL.ncl><write_binary_test.f><Test_WrittenByF.bin>_______________________________________________
> 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
Received on Wed Jun 13 10:24:13 2012

This archive was generated by hypermail 2.1.8 : Fri Jun 15 2012 - 14:51:31 MDT