NetCDF  4.6.1
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
dparallel.c
Go to the documentation of this file.
1 
9 #include "config.h"
10 #include "ncdispatch.h"
11 
88 int nc_create_par(const char *path, int cmode, MPI_Comm comm,
89  MPI_Info info, int *ncidp)
90 {
91 #ifndef USE_PARALLEL
92  return NC_ENOPAR;
93 #else
94  NC_MPI_INFO data;
95 
96  /* One of these two parallel IO modes must be chosen by the user,
97  * or else pnetcdf must be in use. */
98  if (!(cmode & NC_MPIIO || cmode & NC_MPIPOSIX) &&
99  !(cmode & NC_PNETCDF))
100  return NC_EINVAL;
101 
102  data.comm = comm;
103  data.info = info;
104  return NC_create(path, cmode, 0, 0, NULL, 1, &data, ncidp);
105 #endif /* USE_PARALLEL */
106 }
107 
177 int
178 nc_open_par(const char *path, int mode, MPI_Comm comm,
179  MPI_Info info, int *ncidp)
180 {
181 #ifndef USE_PARALLEL
182  return NC_ENOPAR;
183 #else
184  NC_MPI_INFO mpi_data;
185 
186  /* One of these two parallel IO modes must be chosen by the user,
187  * or else pnetcdf must be in use. */
188  if ((mode & NC_MPIIO) || (mode & NC_MPIPOSIX)) {
189  /* ok */
190  } else if(mode & NC_PNETCDF) {
191  /* ok */
192  } else
193  return NC_EINVAL;
194 
195  mpi_data.comm = comm;
196  mpi_data.info = info;
197 
198  return NC_open(path, mode, 0, NULL, 1, &mpi_data, ncidp);
199 #endif /* USE_PARALLEL */
200 }
201 
236 int
237 nc_open_par_fortran(const char *path, int mode, int comm,
238  int info, int *ncidp)
239 {
240 #ifndef USE_PARALLEL
241  return NC_ENOPAR;
242 #else
243  MPI_Comm comm_c;
244  MPI_Info info_c;
245 
246  /* Convert fortran comm and info to C comm and info, if there is a
247  * function to do so. Otherwise just pass them. */
248 #ifdef HAVE_MPI_COMM_F2C
249  comm_c = MPI_Comm_f2c(comm);
250  info_c = MPI_Info_f2c(info);
251 #else
252  comm_c = (MPI_Comm)comm;
253  info_c = (MPI_Info)info;
254 #endif
255 
256  return nc_open_par(path, mode, comm_c, info_c, ncidp);
257 #endif
258 }
259 
321 int
322 nc_var_par_access(int ncid, int varid, int par_access)
323 {
324  NC* ncp;
325 
326  int stat = NC_NOERR;
327 
328  if ((stat = NC_check_id(ncid, &ncp)))
329  return stat;
330 
331 #ifndef USE_PARALLEL
332  return NC_ENOPAR;
333 #else
334  return ncp->dispatch->var_par_access(ncid,varid,par_access);
335 #endif
336 }
337 
372 int
373 nc_create_par_fortran(const char *path, int cmode, int comm,
374  int info, int *ncidp)
375 {
376 #ifndef USE_PARALLEL
377  return NC_ENOPAR;
378 #else
379  MPI_Comm comm_c;
380  MPI_Info info_c;
381 
382  /* Convert fortran comm and info to C comm and info, if there is a
383  * function to do so. Otherwise just pass them. */
384 #ifdef HAVE_MPI_COMM_F2C
385  comm_c = MPI_Comm_f2c(comm);
386  info_c = MPI_Info_f2c(info);
387 #else
388  comm_c = (MPI_Comm)comm;
389  info_c = (MPI_Info)info;
390 #endif
391 
392  return nc_create_par(path, cmode, comm_c, info_c, ncidp);
393 #endif
394 }
#define NC_PNETCDF
Use parallel-netcdf library; alias for NC_MPIIO.
Definition: netcdf.h:159
#define NC_MPIIO
Turn on MPI I/O.
Definition: netcdf.h:152
int nc_open_par(const char *path, int mode, MPI_Comm comm, MPI_Info info, int *ncidp)
Open an existing netCDF file for parallel I/O.
Definition: dparallel.c:178
#define NC_EINVAL
Invalid Argument.
Definition: netcdf.h:325
int nc_create_par(const char *path, int cmode, MPI_Comm comm, MPI_Info info, int *ncidp)
Create a netCDF file for parallel I/O.
Definition: dparallel.c:88
int nc_open_par_fortran(const char *path, int mode, int comm, int info, int *ncidp)
This is the same as nc_open_par(), but accepts the MPI comm/info as integers.
Definition: dparallel.c:237
int nc_create_par_fortran(const char *path, int cmode, int comm, int info, int *ncidp)
Create a netCDF file for parallel access from the Fortran API.
Definition: dparallel.c:373
int nc_var_par_access(int ncid, int varid, int par_access)
This function will change the parallel access of a variable from independent to collective.
Definition: dparallel.c:322
#define NC_ENOPAR
Parallel operation on file opened for non-parallel access.
Definition: netcdf.h:440
#define NC_NOERR
No Error.
Definition: netcdf.h:315
#define NC_MPIPOSIX
Turn on MPI POSIX I/O.
Definition: netcdf.h:155

Return to the Main Unidata NetCDF page.
Generated on Fri May 11 2018 21:22:25 for NetCDF. NetCDF is a Unidata library.