12#ifdef YAC_NETCDF_ENABLED
24#ifndef YAC_NETCDF_ENABLED
28 "ERROR(yac_open_woa_output): "
29 "YAC is built without the NetCDF support");
43#ifndef YAC_NETCDF_ENABLED
47 "ERROR(yac_close_woa_output): "
48 "YAC is built without the NetCDF support");
60#ifndef YAC_NETCDF_ENABLED
66 "ERROR(yac_read_woa_dimensions): "
67 "YAC is built without the NetCDF support");
83 fieldInfo->
varId = varId;
89 (varType == NC_FLOAT) || (varType == NC_DOUBLE),
90 "ERROR(yac_read_woa_dimensions): "
91 "unsupported datatype for variable \"%s\" "
92 "(has to be either NC_DOUBLE or NC_FLOAT)",
fieldName)
98 (varNdims > 0) && (varNdims <= 4),
99 "ERROR(read_woa_dimensions): invalid number of dimensions for "
100 "variable \"%s\" (has to be between 1 and 4)",
fieldName)
103 int varDimids[NC_MAX_VAR_DIMS];
107 for (
int i = 0; i < varNdims; ++i) {
110 char dim_name[NC_MAX_NAME + 1];
114 size_t * count = NULL;
117 if (!strcmp(dim_name,
"time")) {
120 }
else if (!strcmp(dim_name,
"depth")) {
123 }
else if (!strcmp(dim_name,
"lon")) {
126 }
else if (!strcmp(dim_name,
"lat")) {
132 (count != NULL) && (idx != NULL),
133 "ERROR(read_woa_dimensions): "
134 "supported dimension \"%s\" of variable \"%s\"", dim_name,
fieldName)
160 int timeStep,
int level) {
162#ifndef YAC_NETCDF_ENABLED
170 "ERROR(yac_read_woa_timestep_level): "
171 "YAC is built without the NetCDF support");
174 size_t start[4] = {0,0,0,0};
175 size_t count[4] = {1,1,1,1};
180 ((
size_t)level > 0) && ((
size_t)level <= fieldInfo.
nbrLevels),
181 "ERROR(yac_read_woa_timestep_level): "
182 "invalid level (has to be between 1 and %d)",
191 ((
size_t)timeStep > 0) && ((
size_t)timeStep <= fieldInfo.
nbrTimeSteps),
192 "ERROR(yac_read_woa_timestep_level): "
193 "invalid time step (has to be between 1 and %d)",
209 nc_get_vara_double(fileId, fieldInfo.
varId, start, count, cell_data));
void yac_nc_inq_varid(int ncid, char const *name, int *varidp)
void yac_nc_open(const char *path, int omode, int *ncidp)
void yac_read_woa_timestep_level(int fileId, double *cell_data, struct yac_fieldMetadata fieldInfo, int timeStep, int level)
void yac_close_woa_output(int ncid)
int yac_open_woa_output(char const *input_file)
void yac_read_woa_dimensions(int fileId, char const *fieldName, struct yac_fieldMetadata *fieldInfo)
double * yac_get_woa_memory(struct yac_fieldMetadata fieldInfo)
void yac_free_woa_memory(double *data)
general routines for reading WOA output NetCDF files
#define YAC_HANDLE_ERROR(exp)
#define YAC_ASSERT_F(exp, format,...)