NOAA-EMC / NCEPLIBS-ncio

This is a NOAA library used by NCEP GSI system to read the GFS forecast files for use in data assimilation.
Other
1 stars 6 forks source link

probably don't want to use NF90_CLASSIC_MODEL in only one nf90_create() call, other create questions... #6

Open edwardhartnett opened 3 years ago

edwardhartnett commented 3 years ago

In src/module_fv3gfs_ncio.f90:

    ! create netcdf file
    if (dsetin%ishdf5) then
       if (dset%isparallel) then
          if (present(mpicomm)) then
             ncerr = nf90_create(trim(filename), &
                     cmode=IOR(NF90_CLOBBER,NF90_NETCDF4), ncid=dset%ncid, &
                     comm = mpicomm, info = mpi_info_null)
          else
             ncerr = nf90_create(trim(filename), &
                     cmode=IOR(NF90_CLOBBER,NF90_NETCDF4), ncid=dset%ncid, &
                     comm = mpi_comm_world, info = mpi_info_null)
          end if
       else
          ncerr = nf90_create(trim(filename), &
                  cmode=IOR(IOR(NF90_CLOBBER,NF90_NETCDF4),NF90_CLASSIC_MODEL), &
                  !cmode=IOR(NF90_CLOBBER,NF90_NETCDF4), &
                  ncid=dset%ncid)
       end if
       dset%ishdf5 = .true.
    else
       ncerr = nf90_create(trim(filename), &
               cmode=IOR(IOR(NF90_CLOBBER,NF90_64BIT_OFFSET),NF90_SHARE), &
               ncid=dset%ncid)
       dset%ishdf5 = .false.
    endif

Not sure what is going on with NF90_CLASSIC_MODEL. What it does is add a secret attribute in the file, and set a flag within the netcdf-c library, to disallow using any netCDF-4 metadata that does not work in netCDF classic. So, for example, if NF90_CLASSIC_MODEL is used, and we attempt to define an NF90_INT64 variable, we will get an error.

The intent of CLASSIC_MODEL is to allow us to write code is guaranteed to work in any format of netCDF file, so we can easily use the same code for netCDF/HDF5 and classic files.

Perhaps this is what you want, but then probably you would want it everywhere, not just in one nf90_create() call.

NF90_SHARE should probably not be there. Do you have a specific reason for adding it?

NF90_64BIT_OFFSET offers increase to 4 GB var record size. The NF90_CDF5 binary format, based on the work of the pnetcdf team, integrated with netcdf-c, provides a much less restrictive classic format that may be preferrable.

jswhit commented 3 years ago

Ed, I think you are right. I'll make those changes.

edwardhartnett commented 3 years ago

Do we want CLASSIC_MODEL?

And do we want CDF5?

The reason I ask, is that CDF5 includes 64-bit and unsigned int types. CLASSIC_MODEL still forbids these types.

jswhit commented 3 years ago

The module doesn't support things like groups and compound types, so that's probably why I used CLASSIC_MODEL. It would be nice to support 64 bit integers though, so I'll go ahead and just use NF90_NETCDF4 and NF90_CDF5.

jswhit commented 3 years ago

Note that it doesn't support 64 bit integers now.

jswhit commented 3 years ago

Looks like the fortran interface doesn't yet support 64 bit and unsigned integers.

jswhit commented 3 years ago

https://github.com/NOAA-EMC/NCEPLIBS-ncio/pull/16

edwardhartnett commented 3 years ago

Firstly, can you write or wait for test code before making changes?

Secondly, does netcdf-fortran not support CDF5 extra types? Or just the docs? Either way is a bug that should be issued on the netcdf-fortran github site.

jswhit commented 3 years ago

I don't see any of using 64 bit integers with netcdf-fortran 4.5.3.

edwardhartnett commented 3 years ago

Yes, I was afraid of that. I will put in an issue. ;-)