geospace-code / nc4fortran

Object-oriented Fortran NetCDF4 interface
MIT License
39 stars 9 forks source link

support for _FillValue? #5

Closed bhelgs closed 2 years ago

bhelgs commented 2 years ago

I was just wondering if _FillValue is currently supported? It seems that if a user attempts to specify the _FillValue attribute after calling the %write method the user will get the error NC_ELATEFILL(-122) caused by calling put before specifying the fill value.

bhelgs commented 2 years ago

P.S. @scivision, thank you for creating this library! It looks really nice and I've been interested in trying it out.

bhelgs commented 2 years ago

I was able to add an optional fill value argument to the writer method.

The adjustment is similar to what's found in the h5netcdf and h5py API's.
Those libraries seem to use fillvalue as a keyword argument to the create_variable/create_dataset. https://github.com/h5netcdf/h5netcdf/blob/70c3de7578c872ec1ba8fe2949185bbe1a919317/h5netcdf/core.py#L714

scivision commented 2 years ago

Thanks for the idea. This initially looks straightforward to add to nc4fortran and h5fortran.

bhelgs commented 2 years ago

yup, a straightforward add. Thanks. sending you an email.

scivision commented 2 years ago

OK great. I just added a fill_value option to h5fortran %create(..., fill_value=) as well. I would guess it's easier for netcdf.

fill syntax example in h5fortran: https://github.com/geospace-code/h5fortran/blob/main/test/test_fill.f90

scivision commented 2 years ago

Fill value is working now in main branch via %create(..., fill_value=)

bhelgs commented 2 years ago

I saw you've done quite a bit lately. Really nice, thanks!