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


2.21 Inquire the amount of data got from file so far: ncmpi_inq_get_size

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.

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_get_size(int         ncid,
                       MPI_Offset *size);
ncid

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

size

The amount of data (in bytes) read from the file by far.

Return Error Codes

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:

Example

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) */


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