NetCDF  4.6.2
dparallel.c
Go to the documentation of this file.
1 /* Copyright 2010 University Corporation for Atmospheric
2  Research/Unidata. See COPYRIGHT file for more info. */
8 #include "config.h"
9 #include "ncdispatch.h"
10 
97 int nc_create_par(const char *path, int cmode, MPI_Comm comm,
98  MPI_Info info, int *ncidp)
99 {
100 #ifndef USE_PARALLEL
101  return NC_ENOPAR;
102 #else
103  NC_MPI_INFO data;
104 
105 #ifndef USE_PNETCDF
106  /* PnetCDF is disabled but user wants to create classic file in parallel */
107  if (!(cmode & NC_NETCDF4))
108  return NC_ENOTBUILT;
109 #endif
110 
111 #ifndef USE_NETCDF4
112  /* NETCDF4 is disabled but user wants to create NETCDF4 file in parallel */
113  if (cmode & NC_NETCDF4)
114  return NC_ENOTBUILT;
115 #endif
116 
117  data.comm = comm;
118  data.info = info;
119  return NC_create(path, cmode, 0, 0, NULL, 1, &data, ncidp);
120 #endif /* USE_PARALLEL */
121 }
122 
195 int
196 nc_open_par(const char *path, int omode, MPI_Comm comm,
197  MPI_Info info, int *ncidp)
198 {
199 #ifndef USE_PARALLEL
200  return NC_ENOPAR;
201 #else
202  NC_MPI_INFO mpi_data;
203 
204  mpi_data.comm = comm;
205  mpi_data.info = info;
206 
207  return NC_open(path, omode, 0, NULL, 1, &mpi_data, ncidp);
208 #endif /* USE_PARALLEL */
209 }
210 
243 int
244 nc_open_par_fortran(const char *path, int omode, int comm,
245  int info, int *ncidp)
246 {
247 #ifndef USE_PARALLEL
248  return NC_ENOPAR;
249 #else
250  MPI_Comm comm_c;
251  MPI_Info info_c;
252 
253  /* Convert fortran comm and info to C comm and info, if there is a
254  * function to do so. Otherwise just pass them. */
255 #ifdef HAVE_MPI_COMM_F2C
256  comm_c = MPI_Comm_f2c(comm);
257 #else
258  comm_c = (MPI_Comm)comm;
259 #endif
260 #ifdef HAVE_MPI_INFO_F2C
261  info_c = MPI_Info_f2c(info);
262 #else
263  info_c = (MPI_Info)info;
264 #endif
265 
266  return nc_open_par(path, omode, comm_c, info_c, ncidp);
267 #endif
268 }
269 
343 int
344 nc_var_par_access(int ncid, int varid, int par_access)
345 {
346 #ifndef USE_PARALLEL
347  return NC_ENOPAR;
348 #else
349  int stat = NC_NOERR;
350  NC* ncp;
351 
352  if ((stat = NC_check_id(ncid, &ncp)))
353  return stat;
354 
355  return ncp->dispatch->var_par_access(ncid,varid,par_access);
356 #endif
357 }
358 
397 int
398 nc_create_par_fortran(const char *path, int cmode, int comm,
399  int info, int *ncidp)
400 {
401 #ifndef USE_PARALLEL
402  return NC_ENOPAR;
403 #else
404  MPI_Comm comm_c;
405  MPI_Info info_c;
406 
407  /* Convert fortran comm and info to C comm and info, if there is a
408  * function to do so. Otherwise just pass them. */
409 #ifdef HAVE_MPI_COMM_F2C
410  comm_c = MPI_Comm_f2c(comm);
411 #else
412  comm_c = (MPI_Comm)comm;
413 #endif
414 #ifdef HAVE_MPI_INFO_F2C
415  info_c = MPI_Info_f2c(info);
416 #else
417  info_c = (MPI_Info)info;
418 #endif
419 
420  return nc_create_par(path, cmode, comm_c, info_c, ncidp);
421 #endif
422 }
int nc_open_par(const char *path, int omode, MPI_Comm comm, MPI_Info info, int *ncidp)
Open an existing netCDF file for parallel I/O.
Definition: dparallel.c:196
#define NC_ENOTBUILT
Attempt to use feature that was not turned on when netCDF was built.
Definition: netcdf.h:462
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:97
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:398
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 and vice v...
Definition: dparallel.c:344
#define NC_NETCDF4
Use netCDF-4/HDF5 format.
Definition: netcdf.h:150
#define NC_ENOPAR
Parallel operation on file opened for non-parallel access.
Definition: netcdf.h:448
int nc_open_par_fortran(const char *path, int omode, 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:244
#define NC_NOERR
No Error.
Definition: netcdf.h:322

Return to the Main Unidata NetCDF page.
Generated on Tue Nov 20 2018 06:04:35 for NetCDF. NetCDF is a Unidata library.