[MITgcm-devel] Re: notice the last checkin?

Ed Hill ed at eh3.com
Tue Jul 20 12:53:27 EDT 2004


On Tue, 2004-07-20 at 12:27, Andrea Molod wrote:
> hi ed,
> just wanted to make sure you took notice of the last
> checkin i did for fizhi. it now does the byteswapping
> if it needs to. i forget whether its big_endian or
> little_endian, but i know that if you make a file on
> a dell you need to do the byteswapping before writing
> to get it all to come out ok. AND that the files you
> will read from my data/bcs directory were created on
> an SGI so need to be byteswapped to be read on the
> linux box.


Hi Andrea,

I'm moving this over to the devel list since I'd like Chris to see it
and am hoping he will correct me if I'm wrong.  [Please!]

The byte-swapping needs to be done for all variables that have a size
greater than one byte.  Thus, code such as:

====== pkg/fizhi/update_ocean_exports.F : Lines 653--661 ======

      read(iunit,rec=nrec,err=500) cname, cdscrip, 
     .     im_32, jm_32, npx_32, npy_32, lat0_32, lon0_32, 
     .     ndatebc_32, undef_32,
     .     (nymdbc_32(i), nhmsbc_32(i), i=1,ndatebc_32)
#ifdef _BYTESWAPIO
      call MDS_BYTESWAPR4( 1, lat0_32)
      call MDS_BYTESWAPR4( 1, lon0_32)
      call MDS_BYTESWAPR4( 1, undef_32)
#endif

====== pkg/fizhi/update_ocean_exports.F : Lines 653--661 ======

will not work with the same input files on both big- and little-endian 
systems because all the variables (including the "integer*4 ndatebc_32" 
in the implied read loop) must be byte-swapped before they can be used.

This byte-swapping problem is one of the many advantages of NetCDF since
all I/O done through calls to NetCDF routines are (transparently to the
caller) correctly byte-swapped.

Ed

-- 
Edward H. Hill III, PhD
office:  MIT Dept. of EAPS;  Rm 54-1424;  77 Massachusetts Ave.
             Cambridge, MA 02139-4307
emails:  eh3 at mit.edu                ed at eh3.com
URLs:    http://web.mit.edu/eh3/    http://eh3.com/
phone:   617-253-0098
fax:     617-253-4464




More information about the MITgcm-devel mailing list