You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a description of the issue with the steps needed to reproduce it
The python interface does not allow to create dimensions with value=0, as they will be interpreted as unlimited.
It would be nice to enable the possibility to set a dimension with size 0; with C/C++ interface this is possible
I don't think we can change this now without potentially breaking a lot of code. Curious what the use case is? Note that you can create scalar variables by using an empty tuple for the dimension argument in createVariable.
I think a dimension with size 0 is technically not allowed in netcdf unless the dimension is unlimited (the NC_UNLIMITED size argument is set to 0 in netcdf.h).
... It would be nice to enable the possibility to set a dimension with size 0; with C/C++ interface this is possible
@davide-f I do not think this is possible, even with the C/C++ interface. My understanding is that this would contradict the netCDF data model, which requires all dimensions be non-zero for fixed-size variables. My understanding is that the netcdf-C library enforces this. Size zero is supported only for unlimited dimensions, as you noted.
If you do not agree, would you please show a minimal example in C?
Activity
jswhit commentedon Apr 25, 2026
I don't think we can change this now without potentially breaking a lot of code. Curious what the use case is? Note that you can create scalar variables by using an empty tuple for the dimension argument in createVariable.
davide-f commentedon Apr 27, 2026
In smspp-project, a tool for optimization, we have indices that may be empty and as such indexed over a 0-valued index.
What about adding an optional argumwnt such as enable_unlimited
X.createDimension(name, value=None, enable_unlimited=True)
Such that when enable_unlimited is false, 0 is treated as number?
This is back compatible. I understand the behavior must not change given usage
jswhit commentedon Apr 27, 2026
I think a dimension with size 0 is technically not allowed in netcdf unless the dimension is unlimited (the NC_UNLIMITED size argument is set to 0 in netcdf.h).
Dave-Allured commentedon Jul 31, 2026
@davide-f I do not think this is possible, even with the C/C++ interface. My understanding is that this would contradict the netCDF data model, which requires all dimensions be non-zero for fixed-size variables. My understanding is that the netcdf-C library enforces this. Size zero is supported only for unlimited dimensions, as you noted.
If you do not agree, would you please show a minimal example in C?