Using the PnetCDF API
PnetCDF has two modes of accessing files:
- Create a new file
- Describe the file content by defining variables, dimensions and attributes
- Store data / read data if already stored
- Close the file
The next few pages cover these basic file operations using the PnetCDF API.
Data Mode Options
Parallel I/O operations can be performed independently or collectively by a set of MPI processes or tasks. The default data mode in PnetCDF is "collective". Thus, to switch from collective mode to an "independent" mode, PnetCDF provides a pair of functions in its API: ncmpi_begin_indep_data()
and ncmpi_end_indep_data()
. Any I/O operations performed between these calls are independent I/O operations.
- Independent I/O
-
In an independent I/O operation, each process handles its I/O exclusively. As mentioned previously, these calls have to be enclosed within
ncmpi_begin_indep_data()
andncmpi_end_indep_data()
calls. The PnetCDF independent I/O calls are similar to the original netCDF calls prepended with the ncmpi_ string, for example,ncmpi_put_vara_int()
.
- Collective I/O
-
The default I/O calls in PnetCDF are collective in nature. The PnetCDF collective I/O calls are similar to the original netCDF calls prepended with the
ncmpi_
string and appended with_all
, for example,ncmpi_put_vara_int_all()
.