[379] | 1 | #ifndef __XIOS_NETCDF_HPP__ |
---|
| 2 | #define __XIOS_NETCDF_HPP__ |
---|
[1134] | 3 | #include "mpi_std.hpp" |
---|
[379] | 4 | #define MPI_INCLUDED |
---|
| 5 | #include <netcdf.h> |
---|
| 6 | |
---|
[412] | 7 | #if defined(USING_NETCDF_INTERNAL) |
---|
| 8 | const bool using_netcdf_internal=true ; |
---|
| 9 | #else |
---|
| 10 | const bool using_netcdf_internal=false ; |
---|
| 11 | #endif |
---|
| 12 | |
---|
[379] | 13 | #include "netcdf_version.hpp" |
---|
| 14 | |
---|
| 15 | #if NETCDF_VERSION >= 4110 |
---|
| 16 | |
---|
| 17 | # if defined(USING_NETCDF_PAR) |
---|
| 18 | extern "C" |
---|
| 19 | { |
---|
[1328] | 20 | # include <netcdf_par.h> |
---|
[379] | 21 | } |
---|
| 22 | # endif |
---|
| 23 | #endif |
---|
| 24 | |
---|
[480] | 25 | #if !defined(USING_NETCDF_PAR) |
---|
[525] | 26 | #define NC_INDEPENDENT 0 |
---|
| 27 | #define NC_COLLECTIVE 1 |
---|
[480] | 28 | #endif |
---|
| 29 | |
---|
[379] | 30 | namespace xios |
---|
| 31 | { |
---|
[1138] | 32 | inline int nc_create_par(const char *path, int cmode, MPI_Comm comm, MPI_Info info,int *ncidp) |
---|
[379] | 33 | { |
---|
| 34 | #if defined(USING_NETCDF_PAR) |
---|
[1555] | 35 | int status; |
---|
| 36 | #pragma omp critical (_netcdf) |
---|
| 37 | { |
---|
| 38 | status = ::nc_create_par(path, cmode, comm, info, ncidp) ; |
---|
| 39 | } |
---|
| 40 | return status; |
---|
[379] | 41 | #else |
---|
| 42 | ERROR("int nc_create_par(const char *path, int cmode, MPI_Comm comm, MPI_Info info,int *ncidp)", |
---|
| 43 | << "must not be use with netcdf sequential version") ; |
---|
| 44 | return -1 ; |
---|
| 45 | #endif |
---|
| 46 | } |
---|
[525] | 47 | |
---|
[1138] | 48 | inline int nc_open_par(const char *path, int mode, MPI_Comm comm, MPI_Info info,int *ncidp) |
---|
[525] | 49 | { |
---|
[379] | 50 | #if defined(USING_NETCDF_PAR) |
---|
[1555] | 51 | int status; |
---|
| 52 | #pragma omp critical (_netcdf) |
---|
| 53 | { |
---|
| 54 | status = ::nc_open_par(path, mode, comm, info, ncidp) ; |
---|
| 55 | } |
---|
| 56 | return status; |
---|
[379] | 57 | #else |
---|
| 58 | ERROR("int nc_open_par(const char *path, int mode, MPI_Comm comm, MPI_Info info,int *ncidp)", |
---|
| 59 | << "must not be use with netcdf sequential version") ; |
---|
| 60 | return -1 ; |
---|
| 61 | #endif |
---|
| 62 | } |
---|
[525] | 63 | |
---|
[379] | 64 | inline int nc_var_par_access(int ncid, int varid, int par_access) |
---|
| 65 | { |
---|
| 66 | #if defined(USING_NETCDF_PAR) |
---|
[1555] | 67 | int status = ::nc_var_par_access(ncid, varid, par_access) ; |
---|
| 68 | |
---|
| 69 | return status; |
---|
[379] | 70 | #else |
---|
| 71 | ERROR("int nc_var_par_access(int ncid, int varid, int par_access)", |
---|
| 72 | << "must not be use with netcdf sequential version") ; |
---|
| 73 | return -1 ; |
---|
| 74 | #endif |
---|
| 75 | } |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | #endif |
---|