This API reports the amount of data that has been actually read from the file since the file is opened/created. The amount includes the data read from the file header as well as the variables from the file body.
One can use this API to check the amount of data read by a sequence of read calls. See the example below.
This API is an independent subroutine and can be called while the file is in either define or data mode.
int ncmpi_inq_get_size(int ncid, MPI_Offset *size);
NetCDF ID, from a previous call to ncmpi_open or ncmpi_create.
The amount of data (in bytes) read from the file by far.
ncmpi_inq_get_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_get_size after a few calls to the get APIs.
#include <pnetcdf.h> ... int i, ncid, err; MPI_Offset get_size_1, get_size_2; ... err = ncmpi_open(MPI_COMM_WORLD, "foo.nc", NC_NOWRITE, MPI_INFO_NULL, &ncid); if (err != NC_NOERR) handle_error(err); ... err = ncmpi_get_vara_int_all(ncid, varid, ...); err = ncmpi_inq_get_size(ncid, &get_size_1); /* get_size_1 is the amount of data read by this process so far */ err = ncmpi_get_vars_float_all(ncid, varid, ...); err = ncmpi_get_var_short_all(ncid, varid, ...); err = ncmpi_inq_get_size(ncid, &get_size_2); /* (get_size_2 - get_size_1) is the sum of read amounts by the two get APIs (float and short) */