Loading...
Searching...
No Matches
dparallel.c
Go to the documentation of this file.
/* Copyright 2018 University Corporation for Atmospheric
Research/Unidata. See COPYRIGHT file for more info. */
#include "config.h"
#include "ncdispatch.h"
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
int nc_create_par(const char *path, int cmode, MPI_Comm comm,
MPI_Info info, int *ncidp)
{
#ifndef USE_PARALLEL
NC_UNUSED(path);
NC_UNUSED(cmode);
NC_UNUSED(comm);
NC_UNUSED(info);
NC_UNUSED(ncidp);
return NC_ENOPAR;
#else
NC_MPI_INFO data;
#ifndef USE_PNETCDF
/* PnetCDF is disabled but user wants to create classic file in parallel */
if (!(cmode & NC_NETCDF4))
return NC_ENOTBUILT;
#endif
#ifndef USE_NETCDF4
/* NETCDF4 is disabled but user wants to create NETCDF4 file in parallel */
if (cmode & NC_NETCDF4)
return NC_ENOTBUILT;
#endif
/* Can't use both parallel and diskless|inmemory|mmap. */
if (cmode & (NC_DISKLESS|NC_INMEMORY|NC_MMAP))
return NC_EINVAL;
data.comm = comm;
data.info = info;
return NC_create(path, cmode, 0, 0, NULL, 1, &data, ncidp);
#endif /* USE_PARALLEL */
}
int
nc_open_par(const char *path, int omode, MPI_Comm comm,
MPI_Info info, int *ncidp)
{
#ifndef USE_PARALLEL
NC_UNUSED(path);
NC_UNUSED(omode);
NC_UNUSED(comm);
NC_UNUSED(info);
NC_UNUSED(ncidp);
return NC_ENOPAR;
#else
NC_MPI_INFO mpi_data;
mpi_data.comm = comm;
mpi_data.info = info;
return NC_open(path, omode, 0, NULL, 1, &mpi_data, ncidp);
#endif /* USE_PARALLEL */
}
int
nc_open_par_fortran(const char *path, int omode, int comm,
int info, int *ncidp)
{
#ifndef USE_PARALLEL
NC_UNUSED(path);
NC_UNUSED(omode);
NC_UNUSED(comm);
NC_UNUSED(info);
NC_UNUSED(ncidp);
return NC_ENOPAR;
#else
MPI_Comm comm_c;
MPI_Info info_c;
/* Convert fortran comm and info to C comm and info, if there is a
* function to do so. Otherwise just pass them. */
#ifdef HAVE_MPI_COMM_F2C
comm_c = MPI_Comm_f2c(comm);
#else
comm_c = (MPI_Comm)comm;
#endif
#ifdef HAVE_MPI_INFO_F2C
info_c = MPI_Info_f2c(info);
#else
info_c = (MPI_Info)info;
#endif
return nc_open_par(path, omode, comm_c, info_c, ncidp);
#endif
}
int
nc_var_par_access(int ncid, int varid, int par_access)
{
#ifndef USE_PARALLEL
NC_UNUSED(ncid);
NC_UNUSED(varid);
NC_UNUSED(par_access);
return NC_ENOPAR;
#else
int stat = NC_NOERR;
NC* ncp;
if ((stat = NC_check_id(ncid, &ncp)))
return stat;
return ncp->dispatch->var_par_access(ncid,varid,par_access);
#endif
}
int
nc_create_par_fortran(const char *path, int cmode, int comm,
int info, int *ncidp)
{
#ifndef USE_PARALLEL
NC_UNUSED(path);
NC_UNUSED(cmode);
NC_UNUSED(comm);
NC_UNUSED(info);
NC_UNUSED(ncidp);
return NC_ENOPAR;
#else
MPI_Comm comm_c;
MPI_Info info_c;
/* Convert fortran comm and info to C comm and info, if there is a
* function to do so. Otherwise just pass them. */
#ifdef HAVE_MPI_COMM_F2C
comm_c = MPI_Comm_f2c(comm);
#else
comm_c = (MPI_Comm)comm;
#endif
#ifdef HAVE_MPI_INFO_F2C
info_c = MPI_Info_f2c(info);
#else
info_c = (MPI_Info)info;
#endif
return nc_create_par(path, cmode, comm_c, info_c, ncidp);
#endif
}
nc_open_par
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:208
nc_create_par
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:100
nc_var_par_access
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:381
nc_open_par_fortran
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:261
nc_create_par_fortran
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:438
NC_NETCDF4
#define NC_NETCDF4
Use netCDF-4/HDF5 format.
Definition netcdf.h:162
NC_MMAP
#define NC_MMAP
Definition netcdf.h:141
NC_INMEMORY
#define NC_INMEMORY
Read from memory.
Definition netcdf.h:172
NC_DISKLESS
#define NC_DISKLESS
Use diskless file.
Definition netcdf.h:140
NC_EINVAL
#define NC_EINVAL
Invalid Argument.
Definition netcdf.h:388
NC_NOERR
#define NC_NOERR
No Error.
Definition netcdf.h:378
NC_ENOPAR
#define NC_ENOPAR
Parallel operation on file opened for non-parallel access.
Definition netcdf.h:504
NC_ENOTBUILT
#define NC_ENOTBUILT
Attempt to use feature that was not turned on when netCDF was built.
Definition netcdf.h:518