JohnLCaron / cdm-kotlin

2 stars 1 forks source link

Change dimension lengths to int64 #86

Closed JohnLCaron closed 1 year ago

JohnLCaron commented 1 year ago

Im looking over the pnetcdf format to remember why we didnt implement it. It seems that the main problem is that dimension lengths are int64s, whereas in the classic model they are int32s. Its not a big deal to widen, but its a breaking change to the API in lots of places, since indices have to also be int64.

Im looking at the netcdf4 api to understand how it supports pnetcdf. It is using size_t everywhere for dimension lengths and indexes, which i didnt realize until now.

so, we could switch to using int64 for dimensions and indices in netcdf-java, but it would be a breaking change.

https://github.com/Unidata/netcdf-java/discussions/1161#discussioncomment-5567507

JohnLCaron commented 1 year ago

Changed dimension lengths to signed longs in PR#87. This allows support for pnetcdf and hdf5/netcdf4 long dimensions.

hdf5 has DataspaceMessage.dims as 8 byte integers, C API uses hsize_t:

typedef int64_t hssize_t

hdf4 uses 4 byte integers for dimension lengths. We are using signed ints, might be better to use unsigned ints then convert to signed longs, but HDF4 API uses int32:

intn SDdiminfo(int32 dim_id, char *name, int32 *size, int32 *ntype, int32 *num_attrs)