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