Next: , Previous: , Up: Files   [Index]


2.23 Inquire the file header extent: ncmpi_inq_header_extent

This API reports the current file header extent of an opened netCDF file. The amount is the file space allocated for the file header.

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.

The return value also indicates the starting file offset of the first variable (start file offset of the data section).

Operational Mode

This API is an independent subroutine and can be called while the file is in either define or data mode.

Usage

int ncmpi_inq_header_extent(int         ncid,
                            MPI_Offset *extent);
ncid

NetCDF ID, from a previous call to ncmpi_open or ncmpi_create.

size

The extent of file header (in bytes).

Return Error Codes

ncmpi_inq_header_extent returns the value NC_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:

Example

Here is an example using ncmpi_inq_header_extent after a call ncmpi_enddef.

#include <pnetcdf.h>
   ... 
int ncid, err;
MPI_Offset header_extent;
   ...
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_extent(ncid, &header_extent);

Next: , Previous: , Up: Files   [Index]