This API reports the current file header size (in bytes) of an opened netCDF file. Note this is the amount of space used by the metadata.
Note there might be a gap between the end of file header (true space used by the header) and the first variable stored in the file. The gap allows expansion of the header in case new metadata is added to the header. For example, a program re-enters the define mode and add more metadata. If the size of gap is sufficiently large enough, the new metadata can be accommodated in the gap without moving the existing variables stored in the data section.
Check see ncmpi_inq_header_extent for obtaining the file header extent, which indicates the maximum size the file header can expand without touching the existing variables.
This API is an independent subroutine and can be called while the file is in either define or data mode.
int ncmpi_inq_header_size(int ncid, MPI_Offset *size);
NetCDF ID, from a previous call to ncmpi_open or ncmpi_create.
The size of file header (in bytes).
ncmpi_inq_header_size returns the value NC_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:
Here is an example using ncmpi_inq_header_size after a call to ncmpi_enddef.
#include <pnetcdf.h> ... int ncid, err; MPI_Offset header_size; ... err = ncmpi_create(MPI_COMM_WORLD, "foo.nc", NC_CLOBBER, MPI_INFO_NULL, &ncid); if (err != NC_NOERR) handle_error(err); ... err = ncmpi_enddef(ncid); /* exit define mode */ if (err != NC_NOERR) handle_error(err); ... err = ncmpi_inq_header_size(ncid, &header_size);