mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
added function check_for_classic_model()
This commit is contained in:
parent
93278a8561
commit
401bc33339
@ -2465,6 +2465,40 @@ exit:
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Check for the attribute that indicates that netcdf
|
||||
* classic model is in use.
|
||||
*
|
||||
* @param root_grp pointer to the group info for the root group of the
|
||||
* file.
|
||||
*
|
||||
* @return NC_NOERR No error.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
static int
|
||||
check_for_classic_model(NC_GRP_INFO_T *root_grp, int *is_classic)
|
||||
{
|
||||
hid_t attid;
|
||||
|
||||
/* Check inputs. */
|
||||
assert(!root_grp->parent && is_classic);
|
||||
|
||||
/* If this attribute exists in the root group, then classic model
|
||||
* is in effect. */
|
||||
if ((attid = H5Aopen_name(root_grp->hdf_grpid, NC3_STRICT_ATT_NAME)) < 0)
|
||||
{
|
||||
*is_classic = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*is_classic = 1;
|
||||
if (H5Aclose(attid) < 0)
|
||||
return NC_EHDFERR;
|
||||
}
|
||||
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Open a netcdf-4 file. Things have already been kicked off
|
||||
* in ncfunc.c in nc_open, but here the netCDF-4 part of opening a
|
||||
@ -2484,7 +2518,8 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc)
|
||||
hid_t fapl_id = H5P_DEFAULT;
|
||||
int retval;
|
||||
unsigned flags;
|
||||
NC_HDF5_FILE_INFO_T* nc4_info = NULL;
|
||||
NC_HDF5_FILE_INFO_T *nc4_info = NULL;
|
||||
int is_classic;
|
||||
|
||||
#ifdef USE_PARALLEL4
|
||||
NC_MPI_INFO* mpiinfo = NULL;
|
||||
@ -2605,6 +2640,12 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc)
|
||||
} else if ((nc4_info->hdfid = H5Fopen(path, flags, fapl_id)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
/* Check for classic model attribute. */
|
||||
if ((retval = check_for_classic_model(nc4_info->root_grp, &is_classic)))
|
||||
BAIL(retval);
|
||||
if (is_classic)
|
||||
nc4_info->cmode |= NC_CLASSIC_MODEL;
|
||||
|
||||
/* Now read in all the metadata. Some types and dimscale
|
||||
* information may be difficult to resolve here, if, for example, a
|
||||
* dataset of user-defined type is encountered before the
|
||||
|
Loading…
Reference in New Issue
Block a user