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


2.20 Inquire the amount of data put to file so far: ncmpi_inq_put_size

This API reports the amount of data that has actually been written to the file since the file is opened/created. The amount includes the data written/updated to the file header as well as the variables to the file body.

Note in some conditions, metadata (header data) will be cached in the memory and flushed to the file at the file close time. Hence the true write amount after file is closed may be slightly more than the one reported by this API when it is called immediately before file close.

One can use this API to check the amount of data written by a sequence of write 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_put_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) written to the file by far.

Return Error Codes

ncmpi_inq_put_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_put_size after a few calls to the put APIs.

#include <pnetcdf.h>
   ...
int i, ncid, err;
MPI_Offset put_size_1, put_size_2;
   ...
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_put_vara_int_all(ncid, varid, ...);
err = ncmpi_inq_put_size(ncid, &put_size_1);
/* put_size_1 is the amount of data written by this process so far */

err = ncmpi_put_vars_float_all(ncid, varid, ...);
err = ncmpi_put_var_short_all(ncid, varid, ...);
err = ncmpi_inq_put_size(ncid, &put_size_2);
/* (put_size_2 - put_size_1) is the sum of write amounts by the two put APIs (float and short) */


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