Re: Read 3-D NCL output binary data

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue, 21 Mar 2006 21:30:03 -0700 (MST)

> I output a subset of my 4-D array, Pres(ntim, nlon, nlat, nlev) where
> ntim=13, nlon=315, nlat=306 and nlev=30, as binary data using the following
> NCL code
>
> fout = "Pres_3D.bin"
>
> do i = 4, 16
> fbinrecwrite(fout, -1, Pres(i, :, :, :))
> end do
>
> and my Fortran code looks like this
>
> parameter(ntim=13,nlon=315,nlat=306,nlev=30)
> real pres(ntim, ?, ?, ?)
>
> open(11,file="Pres_3D.bin",form="unformatted",access="sequential")
>
> do i = 1, 13
> read(11) pres(i, :, :, :)
> enddo
>
>
> One thing I am not sure is how to define my pres variable in my Fortran
> code. I used "real pres(ntim, nlon, nlat, nlev)" but did not get the correct
> data format. The NCL webpage does indicate a swap of dimensions order for a
> 2-D array from the NCL code (e.g. u(64,128)) to the Fortran code (e.g. u(128,
> 64)) but there is no example for a 3-D array. Your suggestions on how to
> correctly define the pres variable are greatly appreciated.

        real pres(nlev,nlat,nlon,ntim)

NCL arrays are row major [like C]:
     The rightmost dimension varies fastest, the leftmost varies slowest

fortran:
     The leftmost dimension varies fastest, the rightmost varies fastest

              NCL/C fortran
      x(ntim, nlon, nlat, nlev) <===> x(nlev,nlat,nlon,ntim)

---
NCL/C fastest varying dimension maps into fortran's fastest varying dimension.
       slowest                                       slowest
good luck
D
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Mar 21 2006 - 21:30:03 MST

This archive was generated by hypermail 2.2.0 : Wed Mar 29 2006 - 11:52:49 MST