9#ifdef YAC_NETCDF_ENABLED
19#ifdef YAC_NETCDF_ENABLED
22 for (
int i = 0; i < 2; ++i) {
27 "ERROR(check_dimension): coordinate array has more than one dimension")
31 for (
int i = 0; i < 2; ++i)
35 dimids[0] == dimids[1],
36 "ERROR(check_dimension): "
37 "lon lat coordinate arrays have differing dimensions")
47#ifndef YAC_NETCDF_ENABLED
51 die(
"ERROR(yac_check_coord_units): YAC is built without the NetCDF support");
59 int status = nc_inq_att(ncid, varid,
"units", &att_type, &att_len);
61 if (status != NC_ENOTATT) {
65 (att_type == NC_CHAR) && (att_len <= 8),
66 "ERROR(yac_check_coord_units): invalid units type or len")
68 memset(units, 0, 8 *
sizeof(units[0]));
70 is_degree = !strcmp(units,
"degree");
72 is_degree || !strcmp(units,
"radian"),
73 "ERROR(yac_check_coord_units): unsupported units type")
79#ifdef YAC_NETCDF_ENABLED
80static double *
read_coord(
int ncid,
int varid,
size_t varlen) {
84 double * coord =
xmalloc(varlen *
sizeof(*coord));
88 if (is_degree)
for (
size_t i = 0; i < varlen; ++i) coord[i] *=
YAC_RAD;
95 int ncid,
char const * lon_name,
char const * lat_name,
96 double ** lon,
double ** lat,
size_t * len) {
98#ifndef YAC_NETCDF_ENABLED
106 die(
"ERROR(yac_read_coords): YAC is built without the NetCDF support");
113 size_t varlen = (*len =
check_dimension(ncid, (
int[]){vlonid, vlatid}));
void yac_nc_inq_varid(int ncid, char const *name, int *varidp)
#define YAC_HANDLE_ERROR(exp)
static size_t check_dimension(int ncid, int varids[2])
int yac_check_coord_units(int ncid, int varid)
void yac_read_coords(int ncid, char const *lon_name, char const *lat_name, double **lon, double **lat, size_t *len)
static double * read_coord(int ncid, int varid, size_t varlen)
#define YAC_ASSERT(exp, msg)