Re: NCL-FORTRAN -- flat binary

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 10 2013 - 14:00:53 MDT

Erika,

What does your Fortran code look like? If you wrote a float array in NCL that was nlev x nlat x nlon (10 x 64 x 128), then this is how you might read it in with Fortran:

      parameter (nlev=10, nlat=64, nlon=128)
      real x(nlon,nlat,nlev)

      open (unit=1,
     $ file='dummy_file.bin',
     $ form='unformatted',
     $ access='direct',
     $ recl=nlev*nlat*nlon*4)

c read in each row as a single record

      read (1,rec=1) x

On Jul 10, 2013, at 9:49 AM, Erika Folova <e.folova@gmail.com> wrote:

> Hallo,
> I am testing to produce flat binary using NCL dan Matlab,
> the size of file resulting from both of these tools are equal xxxx.byte.
> But, when once i used the binary files as for the fortran input (form='unformatted',access='direct')
> the result of the calculation are mistaken from the binary produced by NCL. I am using function fbindirwrite.
>
> How can I produce the flat binary as the input of fortran code.
> Thank you
>
> Erika,
>
> --
> Here is my code:
>
> fo = "test.dat"
> f1 = addfile ("rea-uwnd.nc", "r")
> x = f1->uwnd(:,:,{20:40}) ;NH
> printVarSummary(data)
> x1 = x(lat|:,lev|:,time|:)
> printVarSummary(x1)
> fbindirwrite(fo, x)
>
> _______________________________________________
> 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 Jul 10 14:00:59 2013

This archive was generated by hypermail 2.1.8 : Fri Jul 12 2013 - 16:37:39 MDT