The function nc_var_par_access changes whether read/write operations on a parallel file system are performed collectively (the default) or independently on the variable. This function can only be called if the file was created with nc_create_par (see nc_create_par) or opened with nc_open_par (see nc_open_par).
Calling this function affects only the open file - information about whether a variable is to be accessed collectively or independently is not written to the data file. Every time you open a file on a parallel file system, all variables default to collective operations. The change a variable to independent lasts only as long as that file is open.
The variable can be changed from collective to independent, and back, as often as desired.
Note that classic and 64-bit offset files are access using the parallel-netcdf library, which does not allow per-variable setting of the parallel access mode. For these files, calling nc_var_par_access sets the access for all of the variables in the file.
int nc_var_par_access(int ncid, int varid, int access);
ncid
varid
access
NC_NOERR
Here is an example using nc_var_par_access:
#include <netcdf.h> ... int ncid, v1id, dimids[NDIMS]; int data[DIMSIZE*DIMSIZE], j, i, res; ... /* Create a parallel netcdf-4 file. */ if ((res = nc_create_par(FILE, NC_NETCDF4|NC_MPIIO, comm, info, &ncid))) BAIL(res); /* Create two dimensions. */ if ((res = nc_def_dim(ncid, "d1", DIMSIZE, dimids))) BAIL(res); if ((res = nc_def_dim(ncid, "d2", DIMSIZE, &dimids[1]))) BAIL(res); /* Create one var. */ if ((res = nc_def_var(ncid, "v1", NC_INT, NDIMS, dimids, &v1id))) BAIL(res); if ((res = nc_enddef(ncid))) BAIL(res); /* Tell HDF5 to use independent parallel access for this var. */ if ((res = nc_var_par_access(ncid, v1id, NC_INDEPENDENT))) BAIL(res); /* Write slabs of phony data. */ if ((res = nc_put_vara_int(ncid, v1id, start, count, &data[mpi_rank*QTR_DATA]))) BAIL(res);