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


2.24 Synchronize the number of records in memory across all processes: ncmpi_sync_numrecs

This API synchronizes the number of records among all processes and flush it to the file.

This API is useful when the file is in independent data mode. In independent mode, some processes’ writes may cause the number of records increased but others may not. To ensure all processes have an up-to-date value of number of records, users should call this API to update/synchronize the value among all processes and the file.

This API has no effect while the file is in collective data mode, because the number of records is always synchronized in collective mode.

Operational Mode

This API is collective and can only be called in data mode (collective or independent).

Usage

int ncmpi_sync_numrecs(int ncid);
ncid

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

Return Error Codes

ncmpi_sync_numrecs 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_sync_numrecs.

#include <pnetcdf.h>
   ...
int ncid, varid, err;
   ...
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_put_vars_float_all(ncid, varid, ...);
err = ncmpi_put_var_short_all(ncid, varid, ...);
   ...
err = ncmpi_sync_numrecs(ncid);
if (err != NC_NOERR) handle_error(err);
   ...

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