Fix returning wrong type

This commit is contained in:
Peter Hill 2024-01-15 13:26:40 +00:00
parent 472b30f313
commit b94199874d
No known key found for this signature in database
GPG Key ID: 0C6B9742E72848EE

View File

@ -24,6 +24,7 @@
#include <stdarg.h>
#include <assert.h>
#include <netcdf.h>
#include "nctime.h"
#include "utils.h"
#include "nccomps.h"
#include "dumplib.h" /* for sbuf_... prototypes */
@ -55,12 +56,11 @@ bounds_add(char *bounds_name, int ncid, int varid) {
* calendar type, if present. */
cdCalenType
calendar_type(int ncid, int varid) {
int ctype;
int stat;
ncatt_t catt;
static struct {
char* attname;
int type;
cdCalenType type;
} calmap[] = {
{"gregorian", cdMixed},
{"standard", cdMixed}, /* synonym */
@ -77,7 +77,7 @@ calendar_type(int ncid, int varid) {
};
#define CF_CAL_ATT_NAME "calendar"
int ncals = (sizeof calmap)/(sizeof calmap[0]);
ctype = cdMixed; /* default mixed Gregorian/Julian ala udunits */
cdCalenType ctype = cdMixed; /* default mixed Gregorian/Julian ala udunits */
stat = nc_inq_att(ncid, varid, CF_CAL_ATT_NAME, &catt.type, &catt.len);
if(stat == NC_NOERR && (catt.type == NC_CHAR || catt.type == NC_STRING) && catt.len > 0) {
char *calstr;