[Thread Prev][Thread Next][Index]

Re: [ferret_users] binary file output is garbled Re: question about binary file writing in ferret: doubling of size with repeat



Hi Ansley;
	I had already tried reading the data as real*8,
	and just reading the first field value gave a  garbled result:
        1.857317845909682E-313 (supposed to be -4227.)

and
INTEGER, PARMETER :: nlond=360*60+1
real*8 rh1(nlond)
read(iu) rh1(1:2)
gives:
Fortran runtime error: Short record on unformatted read

version
 	FERRET v6.93
 	Linux 2.6.9-89.ELsmp 64-bit - 11/18/14


Lev Tarasov -   Dept of Physics and Physical Oceanography,
		Memorial University of Newfoundland.
                email: lev@xxxxxx
                http://www.physics.mun.ca/~lev/
		Tel (709)-864-2675
		Fax (709)-864-8739

On Tue, 19 Jan 2016, Ansley C. Manke wrote:

Hi Lev,
Double -precision Ferret will write double-precision output. So that would be the first thing to test; perhaps write some small test files and read the data using a short Fortran test program, reading into variables declared as real*8.

There is not an option to write single-precision data with double-precision versions of Ferret; binary and stream file IO is in Ferret but not actively supported.

Ansley


On 1/19/2016 7:39 AM, Lev Tarasov wrote:
Should have checked the output first:

Ferret Binary output is garbled when read in fortran:

file was output in ferret as

 set region /J=10801
 LIST /FORMAT=UNF/FILE=GEBCO_2D_1min.bincollatrec ELEVATION

 can region
repeat /J=10800:1:-1 LIST /FORMAT=UNF/APP/FILE=GEBCO_2D_1min.bincollatrec ELEVATION

and the data set should have 21601 entries from just the first list command:

    1> ./GEBCO_global_2D_1min.nc  (default)
name title I J K L M N
 ELEVATION
Elevation relative to sea level 1:21601 1:10801 ... ... ... ...


in my fortran code I have:

      real*4 rh1(nlond)
..
      open(unit=iu,file=fname,FORM='UNFORMATTED',status='old')
           read(iu) rh1(1:2)
            print *, rh1(1:2)

-5.515991      1.1210388E-44

but this does not match the source data:

yes? list ELEVATION[i=1:2,j=10801]
 180E      / 1: -4227.
 179.983W  / 2: -4227.

And if I try to read the first first 5 values of the binary data,
I get an runtime error:
Fortran runtime error: Short record on unformatted read

What gives?

Cheers,

Lev Tarasov -   Dept of Physics and Physical Oceanography,
        Memorial University of Newfoundland.
                email: lev@xxxxxx
                http://www.physics.mun.ca/~lev/
        Tel (709)-864-2675
        Fax (709)-864-8739

On Tue, 19 Jan 2016, Lev Tarasov wrote:

Hi all;
    to facilitate reuse of some old code, I needed to convert
a netcdf DEM to binary, with sequential records for each latitude (and colatitude ordering):
ie:
set region /J=10801
LIST /FORMAT=UNF/FILE=GEBCO_2D_1min.bincollatrec ELEVATION
can region
repeat /J=10800:1:-1 LIST /FORMAT=UNF/APP/FILE=GEBCO_2D_1min.bincollatrec ELEVATION

this gave
-rw-r----- 1 3732998416 Jan 19 10:50 GEBCO_2D_1min.bincollatrec

This nearly doubled the size of the file compared to simply
LIST /FORMAT=UNF/FILE=GEBCO_2D_1min.bin ELEVATION

-rw-r----- 1 1866585616 Jan 19 09:04 GEBCO_2D_1min.bin

Why the doubling?

Cheers,

Lev

Lev Tarasov -   Dept of Physics and Physical Oceanography,
        Memorial University of Newfoundland.
               email: lev@xxxxxx
               http://www.physics.mun.ca/~lev/
        Tel (709)-864-2675
        Fax (709)-864-8739






[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement