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


4.6 Fill a record of a Variable: ncmpi_fill_var_rec

The API ncmpi_fill_var_rec fills a record of a record variable with predefined or user-defined fill values. It is available in version 1.6.1 and later.

Operational Mode

This API is collective and can only be called in collective data mode.

Usage

int ncmpi_fill_var_rec(int        ncid,
                       int        varid,
                       MPI_Offset recno);
ncid

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

varid

Variable ID. This value must be consistent across all calling MPI processes.

recno

index of the record to be filled

Return Error Codes

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

Example

#include <pnetcdf.h>

    ...  /* create a file */

/* define dimensions */
status = ncmpi_def_dim(ncid, "rec_dim", NC_UNLIMITED, &dimids[0]);
if (status != NC_NOERR) handle_error(status);
status = ncmpi_def_dim(ncid, "lon_dim", 1024, &dimids[1]);
if (status != NC_NOERR) handle_error(status);
status = ncmpi_def_dim(ncid, "lat_dim", 1024, &dimids[2]);
if (status != NC_NOERR) handle_error(status);
    ...

/* define variables */
status = ncmpi_def_var(ncid, "rec_var", NC_DOUBLE, 3, dimids, &varid);
if (status != NC_NOERR) handle_error(status);
    ...

status = ncmpi_enddef(ncid);
if (status != NC_NOERR) handle_error(status);

/* fill the first record of variable rec_var */
status = ncmpi_fill_var_rec(ncid, varid, 0);
if (status != NC_NOERR) handle_error(status);

/* fill the second record of variable rec_var */
status = ncmpi_fill_var_rec(ncid, varid, 1);
if (status != NC_NOERR) handle_error(status);

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