Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

Previous: nc_copy_var, Up: Variables


6.33 Change between Collective and Independent Parallel Access: nc_var_par_access

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.

Usage

int nc_var_par_access(int ncid, int varid, int access);

ncid
NetCDF ID, from a previous call to nc_open_par (see nc_open_par) or nc_create_par (see nc_create_par).
varid
Variable ID.
access
NC_INDEPENDENT to set this variable to independent operations.NC_COLLECTIVE to set it to collective operations.

Return Values

NC_NOERR
No error.

Example

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_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);
     
 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690