[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 991222: netcdf on O2K vs Cray j90



Ben,

> I don't think there *are* any netcdf libs compiled with 8-byte
> reals, except on the Crays, where it is the default. I.e.,
> there are no r8i4/libnetcdf.a on non-unicos machines.

I'm confused about whether you're referring to external (on disk) or
internal (in memory) data types.  NF_FLOAT always refers to 32-bit
external reals, no matter what the internal real type is.  So on any
platform, when you write to an NF_FLOAT variable, it is stored
externally using 32-bits no matter what compile flags were used in
building the application or library.  There may be conversion between
internal 64-bit reals and external 32-bit reals on reading and writing
the netCDF variable values, depending on compiler flags.

> I would think the problem is more that NF_FLOAT means 32-bit
> reals on both platforms, and netcdf does not know that I
> compiled with -r8 on the SGI -- it sees that the machine is an
> SGI and assumes my reals are 32-bit. Maybe I should try something 
> like:
> 
> integer :: ncrealtype
> #ifdef UNICOS
>   ncrealtype = NF_FLOAT
> #else
>   ncrealtype = NF_DOUBLE
> #endif
> 
> call nf_def_var(..ncrealtype..)

I don't understand why the above should ever be necessary.  NF_FLOAT
means 32-bit external data, whether on UNICOS or SGI.  NF_DOUBLE means
64-bit external data, similarly, independent of platform or language.
The netCDF interface is supposed to make it possible to run the same
code without such conditional compilation on any supported platform,
because the platform dependencies are taken care of in the library
layer, hidden from the applications.

But I think you have to compile your applications using compiler flags
that are consistent with the way the libraries you link against were
compiled.  If the netCDF library is compiled without -r8 and the
application is compiled with -r8, the netCDF library won't do the
necessary conversions between external 4-byte and internal 8-byte
reals when you use nf_put_var and nf_get_var.  If you always want
8-byte external reals, you should be using NF_DOUBLE instead of
NF_FLOAT to define the variable.

If you want to use applications compiled with -r8, you will need to
build a version of the netCDF library that represents reals internally
as 8 bytes.

See

  http://www.unidata.ucar.edu/packages/netcdf/guidef/guidef-8.html#HEADING8-0

for an attempt to explain this in the Users Guide for Fortran.

--Russ