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


4.31 Inqire the usage of the attached buffer in buffered write requests: ncmpi_inq_buffer_usage

This API reporsts the usage of the attached buffer in buffered write requests

Usage

int ncmpi_inq_buffer_usage(int ncid, MPI_Offset *usage);
ncid

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

usage

The current usage (in number of bytes) of the attached buffer by the buffered write APIs.

Errors

The APIs return 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_buffer_usage.

#include <pnetcdf.h>
   ...
int varid1, varid2, varid3, nreqs, err;
int i_buf[8], req_ids[10], st[10];
long long ll_buf[10];
double d_buf[20], d2_buf[12];
MPI_Offset start1[2], count1[2], start2[3], count2[3];
MPI_Offset start3[2], count3[2], usage;
   ...

/* attach buffer of size 1MB */
ncmpi_buffer_attach(ncid, 1048576);

/* several writes into netCDF variables */
ncmpi_bput_vara_double(ncid, varid1, start1, count1, d_buf, &request[0]);

ncmpi_bput_vara_int(ncid, varid2, start2, count2, i_buf, &request[1]);

ncmpi_bput_vars_longlong(ncid, varid3, start3, count3, stride3, ll_buf, &request[2]);

/* check the usage of the buffer */
status = ncmpi_inq_buffer_usage(ncid, &usage);
if (status != NC_NOERR) handle_error(status);

ncmpi_bput_var_double(ncid, varid4, d2_buf, &request[3]);

/* wait here for all 4 nonblocking APIs to complete */
ncmpi_wait_all(ncid, 4, request, st);

/* release buffer */
ncmpi_buffer_detach(ncid);