Next: , Previous: nc__open, Up: Datasets


2.10 Open a NetCDF Dataset for Parallel Access

This function opens a netCDF-4 dataset for parallel access.

For netcdf-4/HDF5 files, the HDF5 library parallel I/O is used. This opens the file using either MPI-IO or MPI-POSIX.

DAP access is not allowed with parallel I/O.

When netCDF opens a file for parallel access, collective operations are the default. To use independent access on a variable, See nc_var_par_access.

Usage

     int nc_open_par(const char *path, int mode, MPI_Comm comm,
                     MPI_Info info, int *ncidp);
path
File name for netCDF dataset to be opened.
omode
Either the NC_MPIIO or NC_MPIPOSIX flags may be present for a netCDF-4/HDF5 file.

The flag NC_WRITE opens the dataset with read-write access. ("Writing" means any kind of change to the dataset, including appending or changing data, adding or renaming dimensions, variables, and attributes, or deleting attributes.)

All other flags are ignored or not allowed. The NC_NETCDF4 flag is not required, as the file type is detected when the file is opened.

comm
MPI_Comm object returned by the MPI layer.
info
MPI_Info object returned by the MPI layer, or NULL if MPI-POSIX access is desired.
ncidp
Pointer to location where returned netCDF ID is to be stored.

Return Codes

NC_NOERR
No error.
The specified netCDF dataset does not exist.
A meaningless mode was specified.

Example

Here is an example (from nc_test4/tst_parallel2.c) using nc_open_par.

         /* Reopen the file and check it. */
         if (nc_open_par(file_name, NC_NOWRITE, comm, info, &ncid)) ERR;
     
         /* Read all the slabs this process is responsible for. */
         for (i = 0; i < NUM_SLABS / mpi_size; i++)
         {
            start[0] = NUM_SLABS / mpi_size * mpi_rank + i;
            /* Read one slab of data. */
            if (nc_get_vara_int(ncid, varid, start, count, data_in)) ERR;
         }