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

[netCDF #TKJ-808949]: integer types in NetCDF4



Hi Mark,

> I am collaborating with Annette Koontz at PNNL on their IO library for
> GCRM climate data, and we're concerned about being able to write
> 32-bit integer data into a NetCDF variable that uses 64-bit integer
> indices. The problem is that NetCDF is using the default Fortran
> "integer" type for both indices and integer data. To enable 64-bit
> indices, we have to specify the "-i8" Fortran compile flag (or
> "-default64" for our Cray XT compiler) so that the "integer" type
> defaults to 64-bit. However, the only integer put_var functions
> available in "fortran/netcdf.inc" are:
> 
> integer         nf_put_var_int1
> !                         (integer             ncid,
> !                          integer             varid,
> !                          nf_int1_t           i1vals(1))
> external        nf_put_var_int1
> 
> integer         nf_put_var_int2
> !                         (integer             ncid,
> !                          integer             varid,
> !                          nf_int2_t           i2vals(1))
> external        nf_put_var_int2
> 
> integer         nf_put_var_int
> !                         (integer             ncid,
> !                          integer             varid,
> !                          integer             ivals(1))
> external        nf_put_var_int
> 
> So the nf_put_var_int function uses 64-bit integer values when using
> 64-bit indices and there is no 32-bit version. Would it be possible to
> add nf_put_var_int4 and nf_put_var_int8 functions, similar to the 1-
> and 2-byte variants?

It actually does no good to enable 64-bit indices for netCDF, unless
you are using an HDF5-based format (such as netCDF-4 classic model),
because dimension sizes for netCDF classic or 64-bit offset formats
are limited by the formats to 32-bits, even if you compile in a 64-bit
memory model.  There's more information about that limitation in the 
answer to the set of FAQs that starts here:

  http://www.unidata.ucar.edu/netcdf/docs/faq.html#Large%20File%20Support10

There's also work underway and some test software from the parallel-netcdf 
group at Argonne/Northwestern on an approach to getting around those
limitations:

  http://trac.mcs.anl.gov/projects/parallel-netcdf/wiki/NewFileFormat

and they even have "friendly user" code available for testing:

  http://trac.mcs.anl.gov/projects/parallel-netcdf/wiki/NewFileFormatCode

However the netCDF format limitation to 32-bit dimension sizes means
you don't have to compile with "-i8", so you should be able to write
32-bit integer data with no problem.  In the netCDF-4 enhanced data model,
nf90_int is a 32-bit integer and nf90_int64 is a 64-bit integer, and
data of both types can be written through the netCDF-4 Fortran-90 API.

--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: TKJ-808949
Department: Support netCDF
Priority: Normal
Status: Closed