The function NF90_VAR_PAR_ACCESS changes whether read/write operations on a parallel file system are performed collectively or independently (the default) on the variable. This function can only be called if the file was created (see NF90_CREATE) or opened (see NF90_OPEN) for parallel I/O.
This function is only available if the netCDF library was built with parallel I/O enabled.
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 independent operations. The change of a variable to collective access lasts only as long as that file is open.
The variable can be changed from collective to independent, and back, as often as desired.
Classic and 64-bit offset files, when opened for parallel access, use the parallel-netcdf (a.k.a. pnetcdf) library, which does not allow per-variable changes of access mode - the entire file must be access independently or collectively. For classic and 64-bit offset files, the nf90_var_par_access function changes the access for all variables in the file.
function nf90_var_par_access(ncid, varid, access) integer, intent(in) :: ncid integer, intent(in) :: varid integer, intent(in) :: access integer :: nf90_var_par_access end function nf90_var_par_access
ncid
varid
access
NF90_NOERR
NF90_ENOTVAR
NF90_NOPAR
This example comes from test program nf_test/f90tst_parallel.f90. For this test to be run, netCDF must have been built with a parallel-enabled HDF5, and –enable-parallel-tests must have been used when configuring netcdf.
! Reopen the file. call handle_err(nf90_open(FILE_NAME, nf90_nowrite, ncid, comm = MPI_COMM_WORLD, & info = MPI_INFO_NULL)) ! Set collective access on this variable. This will cause all ! reads/writes to happen together on every processor. call handle_err(nf90_var_par_access(ncid, varid, nf90_collective)) ! Read this processor's data. call handle_err(nf90_get_var(ncid, varid, data_in, start = start, count = count))