17 #include "nc4internal.h" 18 #include "nc4dispatch.h" 19 #include <H5DSpublic.h> 20 #include <H5Fpublic.h> 27 #define CD_NELEMS_ZLIB 1 38 hdf5free(
void* memory)
43 #ifdef HDF5_HAS_H5FREE 44 if(memory != NULL) H5free_memory(memory);
47 if(memory != NULL) free(memory);
74 get_netcdf_type(NC_HDF5_FILE_INFO_T *h5, hid_t native_typeid,
79 htri_t is_str, equal = 0;
83 if ((
class = H5Tget_class(native_typeid)) < 0)
88 if (
class == H5T_STRING)
90 if ((is_str = H5Tis_variable_str(native_typeid)) < 0)
98 else if (
class == H5T_INTEGER ||
class == H5T_FLOAT)
102 if ((equal = H5Tequal(native_typeid, H5T_NATIVE_SCHAR)) < 0)
109 if ((equal = H5Tequal(native_typeid, H5T_NATIVE_SHORT)) < 0)
116 if ((equal = H5Tequal(native_typeid, H5T_NATIVE_INT)) < 0)
123 if ((equal = H5Tequal(native_typeid, H5T_NATIVE_FLOAT)) < 0)
130 if ((equal = H5Tequal(native_typeid, H5T_NATIVE_DOUBLE)) < 0)
137 if ((equal = H5Tequal(native_typeid, H5T_NATIVE_UCHAR)) < 0)
144 if ((equal = H5Tequal(native_typeid, H5T_NATIVE_USHORT)) < 0)
151 if ((equal = H5Tequal(native_typeid, H5T_NATIVE_UINT)) < 0)
158 if ((equal = H5Tequal(native_typeid, H5T_NATIVE_LLONG)) < 0)
165 if ((equal = H5Tequal(native_typeid, H5T_NATIVE_ULLONG)) < 0)
176 if((type = nc4_rec_find_hdf_type(h5->root_grp, native_typeid)))
178 *xtype = type->nc_typeid;
198 read_hdf5_att(NC_GRP_INFO_T *grp, hid_t attid, NC_ATT_INFO_T *att)
200 hid_t spaceid = 0, file_typeid = 0;
201 hsize_t dims[1] = {0};
205 hssize_t att_npoints;
206 H5T_class_t att_class;
207 int fixed_len_string = 0;
208 size_t fixed_size = 0;
211 LOG((5,
"%s: att->attnum %d att->name %s att->nc_typeid %d att->len %d",
212 __func__, att->attnum, att->name, (
int)att->nc_typeid, att->len));
215 if ((file_typeid = H5Aget_type(attid)) < 0)
217 if ((att->native_hdf_typeid = H5Tget_native_type(file_typeid, H5T_DIR_DEFAULT)) < 0)
219 if ((att_class = H5Tget_class(att->native_hdf_typeid)) < 0)
221 if (att_class == H5T_STRING && !H5Tis_variable_str(att->native_hdf_typeid))
224 if (!(fixed_size = H5Tget_size(att->native_hdf_typeid)))
227 if ((retval = get_netcdf_type(grp->nc4_info, att->native_hdf_typeid, &(att->nc_typeid))))
232 if ((spaceid = H5Aget_space(attid)) < 0)
234 if ((att_ndims = H5Sget_simple_extent_ndims(spaceid)) < 0)
236 if ((att_npoints = H5Sget_simple_extent_npoints(spaceid)) < 0)
241 if (att_ndims == 0 && att_npoints == 0)
244 dims[0] = att_npoints;
245 else if (att->nc_typeid ==
NC_CHAR)
251 if (!(dims[0] = H5Tget_size(file_typeid)))
258 dims[0] = att_npoints;
263 H5S_class_t space_class;
270 if ((space_class = H5Sget_simple_extent_type(spaceid)) < 0)
274 if (H5S_NULL == space_class)
278 if (H5S_SCALAR == space_class)
283 if (H5Sget_simple_extent_dims(spaceid, dims, NULL) < 0)
295 if ((retval = nc4_get_typelen_mem(grp->nc4_info, att->nc_typeid, 0,
298 if (att_class == H5T_VLEN)
300 if (!(att->vldata = malloc((
unsigned int)(att->len *
sizeof(hvl_t)))))
302 if (H5Aread(attid, att->native_hdf_typeid, att->vldata) < 0)
307 if (!(att->stdata = calloc(att->len,
sizeof(
char *))))
320 if (fixed_len_string)
323 char *contig_buf, *cur;
326 if (!(contig_buf = malloc(att->len * fixed_size *
sizeof(
char))))
330 if (H5Aread(attid, att->native_hdf_typeid, contig_buf) < 0) {
339 for (i = 0; i < att->len; i++)
341 if (!(att->stdata[i] = malloc(fixed_size))) {
345 strncpy(att->stdata[i], cur, fixed_size);
355 if (H5Aread(attid, att->native_hdf_typeid, att->stdata) < 0)
361 if (!(att->data = malloc((
unsigned int)(att->len * type_size))))
363 if (H5Aread(attid, att->native_hdf_typeid, att->data) < 0)
368 if (H5Tclose(file_typeid) < 0)
370 if (H5Sclose(spaceid) < 0)
376 if (H5Tclose(file_typeid) < 0)
378 if (spaceid > 0 && H5Sclose(spaceid) < 0)
398 att_read_var_callbk(hid_t loc_id,
const char *att_name,
const H5A_info_t *ainfo,
void *att_data)
404 att_iter_info *att_info = (att_iter_info *)att_data;
405 const char** reserved;
408 for(reserved=NC_RESERVED_VARATT_LIST;*reserved;reserved++) {
409 if (strcmp(att_name, *reserved)==0)
break;
412 if(*reserved == NULL) {
414 if ((attid = H5Aopen(loc_id, att_name, H5P_DEFAULT)) < 0)
416 LOG((4,
"%s:: att_name %s", __func__, att_name));
418 if ((retval = nc4_att_list_add(&att_info->var->att, &att)))
421 att->attnum = att_info->var->natts++;
422 if (!(att->name = strdup(att_name)))
427 if ((retval = read_hdf5_att(att_info->grp, attid, att)))
431 if ((retval = nc4_att_list_del(&att_info->var->att, att)))
440 att->created = NC_TRUE;
442 if (attid > 0 && H5Aclose(attid) < 0)
450 if (attid > 0 && H5Aclose(attid) < 0)
462 extern void reportopenobjects(
int log, hid_t);
468 typedef struct NC4_rec_read_metadata_obj_info
473 struct NC4_rec_read_metadata_obj_info *next;
474 } NC4_rec_read_metadata_obj_info_t;
481 typedef struct NC4_rec_read_metadata_ud
483 NC4_rec_read_metadata_obj_info_t *grps_head, *grps_tail;
485 } NC4_rec_read_metadata_ud_t;
488 static int NC4_enddef(
int ncid);
489 static int nc4_rec_read_metadata(NC_GRP_INFO_T *grp);
501 sync_netcdf4_file(NC_HDF5_FILE_INFO_T *h5)
506 LOG((3,
"%s", __func__));
510 if (h5->flags & NC_INDEF)
516 h5->flags ^= NC_INDEF;
519 h5->redef = NC_FALSE;
525 log_metadata_nc(h5->root_grp->nc4_info->controller);
531 nc_bool_t bad_coord_order = NC_FALSE;
533 if ((retval = nc4_rec_write_groups_types(h5->root_grp)))
535 if ((retval = nc4_rec_detect_need_to_preserve_dimids(h5->root_grp, &bad_coord_order)))
537 if ((retval = nc4_rec_write_metadata(h5->root_grp, bad_coord_order)))
541 if (H5Fflush(h5->hdfid, H5F_SCOPE_GLOBAL) < 0)
559 close_netcdf4_file(NC_HDF5_FILE_INFO_T *h5,
int abort)
563 assert(h5 && h5->root_grp);
564 LOG((3,
"%s: h5->path %s abort %d", __func__, h5->controller->path, abort));
567 if (h5->flags & NC_INDEF)
568 h5->flags ^= NC_INDEF;
572 if (!h5->no_write && !abort)
573 if ((retval = sync_netcdf4_file(h5)))
578 if ((retval = nc4_rec_grp_del(&h5->root_grp, h5->root_grp)))
586 if(MPI_COMM_NULL != h5->comm)
587 MPI_Comm_free(&h5->comm);
588 if(MPI_INFO_NULL != h5->info)
589 MPI_Info_free(&h5->info);
593 if(h5->fileinfo) free(h5->fileinfo);
595 if (H5Fclose(h5->hdfid) < 0)
599 nobjs = H5Fget_obj_count(h5->hdfid, H5F_OBJ_ALL);
603 }
else if(nobjs > 0) {
611 snprintf(msg,
sizeof(msg),
"There are %d HDF5 objects open!", nobjs);
618 reportopenobjects(logit,h5->hdfid);
625 if(!retval && h5 != NULL)
635 const char* NC_RESERVED_VARATT_LIST[] = {
636 NC_ATT_REFERENCE_LIST,
638 NC_ATT_DIMENSION_LIST,
650 const char* NC_RESERVED_ATT_LIST[] = {
663 const char* NC_RESERVED_SPECIAL_LIST[] = {
679 static hid_t h5_native_type_constant_g[NUM_TYPES]; 683 "int",
"float",
"double",
"ubyte",
684 "ushort",
"uint",
"int64",
694 static const int nc_type_size_g[
NUM_TYPES] = {
sizeof(char),
sizeof(
char),
sizeof(short),
695 sizeof(
int),
sizeof(float),
sizeof(
double),
sizeof(
unsigned char),
696 sizeof(
unsigned short),
sizeof(
unsigned int),
sizeof(
long long),
697 sizeof(
unsigned long long),
sizeof(
char *)};
714 if (preemption < 0 || preemption > 1)
759 nc_set_chunk_cache_ints(
int size,
int nelems,
int preemption)
761 if (size <= 0 || nelems <= 0 || preemption < 0 || preemption > 100)
781 nc_get_chunk_cache_ints(
int *sizep,
int *nelemsp,
int *preemptionp)
841 nc4_create_file(
const char *path,
int cmode, MPI_Comm comm, MPI_Info info,
844 hid_t fcpl_id, fapl_id = -1;
848 NC_HDF5_FILE_INFO_T* nc4_info = NULL;
857 LOG((3,
"%s: path %s mode 0x%x", __func__, path, cmode));
860 flags = H5F_ACC_TRUNC;
862 flags = H5F_ACC_EXCL;
864 flags = H5F_ACC_TRUNC;
868 if (cmode & NC_DISKLESS) {
869 #ifndef USE_PARALLEL4 873 }
else if ((cmode & NC_NOCLOBBER) && (fp = fopen(path,
"r"))) {
879 if ((retval = nc4_nc4f_list_add(nc, path, (
NC_WRITE | cmode))))
881 nc4_info = NC4_DATA(nc);
882 assert(nc4_info && nc4_info->root_grp);
887 if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
889 if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI))
897 nc4_info->parallel = NC_TRUE;
898 if (cmode & NC_MPIIO)
900 LOG((4,
"creating parallel file with MPI/IO"));
901 if (H5Pset_fapl_mpio(fapl_id, comm, info) < 0)
904 #ifdef USE_PARALLEL_POSIX 907 LOG((4,
"creating parallel file with MPI/posix"));
908 if (H5Pset_fapl_mpiposix(fapl_id, comm, 0) < 0)
921 if (MPI_SUCCESS != MPI_Comm_dup(comm, &nc4_info->comm))
924 if (MPI_INFO_NULL != info)
926 if (MPI_SUCCESS != MPI_Info_dup(info, &nc4_info->info))
933 nc4_info->info = info;
937 if(cmode & NC_DISKLESS) {
938 if (H5Pset_fapl_core(fapl_id, 4096, persist))
944 LOG((4,
"%s: set HDF raw chunk cache to size %d nelems %d preemption %f",
948 #ifdef HDF5_HAS_LIBVER_BOUNDS 949 if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0)
954 if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0)
958 if (H5Pset_obj_track_times(fcpl_id,0)<0)
964 if (H5Pset_link_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED |
965 H5P_CRT_ORDER_INDEXED)) < 0)
967 if (H5Pset_attr_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED |
968 H5P_CRT_ORDER_INDEXED)) < 0)
972 #ifdef HDF5_HAS_COLL_METADATA_OPS 973 H5Pset_all_coll_metadata_ops(fapl_id, 1 );
974 H5Pset_coll_metadata_write(fapl_id, 1);
977 if ((nc4_info->hdfid = H5Fcreate(path, flags, fcpl_id, fapl_id)) < 0)
983 if ((nc4_info->root_grp->hdf_grpid = H5Gopen2(nc4_info->hdfid,
"/",
988 if (H5Pclose(fapl_id) < 0 || H5Pclose(fcpl_id) < 0)
992 nc4_info->flags |= NC_INDEF;
995 NC4_put_propattr(nc4_info);
1000 #ifdef USE_PARALLEL4 1001 if (comm_duped) MPI_Comm_free(&nc4_info->comm);
1002 if (info_duped) MPI_Info_free(&nc4_info->info);
1004 if (fapl_id != H5P_DEFAULT) H5Pclose(fapl_id);
1005 if(!nc4_info)
return retval;
1006 close_netcdf4_file(nc4_info,1);
1030 NC4_create(
const char* path,
int cmode,
size_t initialsz,
int basepe,
1031 size_t *chunksizehintp,
int use_parallel,
void *parameters,
1032 NC_Dispatch *dispatch, NC* nc_file)
1034 MPI_Comm comm = MPI_COMM_WORLD;
1035 MPI_Info info = MPI_INFO_NULL;
1038 assert(nc_file && path);
1040 LOG((1,
"%s: path %s cmode 0x%x comm %d info %d",
1041 __func__, path, cmode, comm, info));
1043 #ifdef USE_PARALLEL4 1046 comm = ((NC_MPI_INFO *)parameters)->comm;
1047 info = ((NC_MPI_INFO *)parameters)->info;
1053 nc4_hdf5_initialize();
1056 if((cmode & ILLEGAL_CREATE_FLAGS) != 0)
1067 #ifndef USE_PARALLEL_POSIX 1073 cmode &= ~NC_MPIPOSIX;
1088 LOG((2,
"cmode after applying default format: 0x%x", cmode));
1090 nc_file->int_ncid = nc_file->ext_ncid;
1092 res = nc4_create_file(path, cmode, comm, info, nc_file);
1118 read_scale(NC_GRP_INFO_T *grp, hid_t datasetid,
const char *obj_name,
1119 const H5G_stat_t *statbuf, hsize_t scale_size, hsize_t max_scale_size,
1120 NC_DIM_INFO_T **dim)
1122 NC_DIM_INFO_T *new_dim;
1124 htri_t attr_exists = -1;
1126 int dimscale_created = 0;
1127 short initial_next_dimid = grp->nc4_info->next_dimid;
1131 if ((retval = nc4_dim_list_add(&grp->dim, &new_dim)))
1137 if ((attr_exists = H5Aexists(datasetid, NC_DIMID_ATT_NAME)) < 0)
1141 if ((attid = H5Aopen_name(datasetid, NC_DIMID_ATT_NAME)) < 0)
1144 if (H5Aread(attid, H5T_NATIVE_INT, &new_dim->dimid) < 0)
1148 if (new_dim->dimid >= grp->nc4_info->next_dimid)
1149 grp->nc4_info->next_dimid = new_dim->dimid + 1;
1154 new_dim->dimid = grp->nc4_info->next_dimid++;
1157 if (!(new_dim->name = strdup(obj_name)))
1159 if (SIZEOF_SIZE_T < 8 && scale_size >
NC_MAX_UINT)
1162 new_dim->too_long = NC_TRUE;
1165 new_dim->len = scale_size;
1166 new_dim->hdf5_objid.fileno[0] = statbuf->fileno[0];
1167 new_dim->hdf5_objid.fileno[1] = statbuf->fileno[1];
1168 new_dim->hdf5_objid.objno[0] = statbuf->objno[0];
1169 new_dim->hdf5_objid.objno[1] = statbuf->objno[1];
1170 new_dim->hash = hash_fast(obj_name, strlen(obj_name));
1174 if (max_scale_size == H5S_UNLIMITED)
1175 new_dim->unlimited = NC_TRUE;
1180 if (H5DSget_scale_name(datasetid, dimscale_name_att,
NC_MAX_NAME) >= 0)
1182 if (!strncmp(dimscale_name_att, DIM_WITHOUT_VARIABLE,
1183 strlen(DIM_WITHOUT_VARIABLE)))
1185 if (new_dim->unlimited)
1187 size_t len = 0, *lenp = &len;
1189 if ((retval = nc4_find_dim_len(grp, new_dim->dimid, &lenp)))
1191 new_dim->len = *lenp;
1195 new_dim->hdf_dimscaleid = datasetid;
1196 H5Iinc_ref(new_dim->hdf_dimscaleid);
1205 if (attid > 0 && H5Aclose(attid) < 0)
1209 if (retval < 0 && dimscale_created)
1212 if ((retval = nc4_dim_list_del(&grp->dim, new_dim)))
1216 grp->nc4_info->next_dimid = initial_next_dimid;
1233 read_coord_dimids(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var)
1235 hid_t coord_att_typeid = -1, coord_attid = -1, spaceid = -1;
1243 if ((coord_attid = H5Aopen_name(var->hdf_datasetid, COORDINATES)) < 0) ret++;
1244 if (!ret && (coord_att_typeid = H5Aget_type(coord_attid)) < 0) ret++;
1247 if (!ret && (spaceid = H5Aget_space(coord_attid)) < 0) ret++;
1248 if (!ret && (npoints = H5Sget_simple_extent_npoints(spaceid)) < 0) ret++;
1252 if (!ret && npoints != var->ndims) ret++;
1254 if (!ret && H5Aread(coord_attid, coord_att_typeid, var->dimids) < 0) ret++;
1255 LOG((4,
"dimscale %s is multidimensional and has coords", var->name));
1258 for (d = 0; d < var->ndims; d++) {
1260 nc4_find_dim(grp, var->dimids[d], &var->dim[d], NULL);
1264 if (spaceid >= 0 && H5Sclose(spaceid) < 0) ret++;
1265 if (coord_att_typeid >= 0 && H5Tclose(coord_att_typeid) < 0) ret++;
1266 if (coord_attid >= 0 && H5Aclose(coord_attid) < 0) ret++;
1283 dimscale_visitor(hid_t did,
unsigned dim, hid_t dsid,
1284 void *dimscale_hdf5_objids)
1289 if (H5Gget_objinfo(dsid,
".", 1, &statbuf) < 0)
1293 (*(HDF5_OBJID_T *)dimscale_hdf5_objids).fileno[0] = statbuf.fileno[0];
1294 (*(HDF5_OBJID_T *)dimscale_hdf5_objids).fileno[1] = statbuf.fileno[1];
1295 (*(HDF5_OBJID_T *)dimscale_hdf5_objids).objno[0] = statbuf.objno[0];
1296 (*(HDF5_OBJID_T *)dimscale_hdf5_objids).objno[1] = statbuf.objno[1];
1316 get_type_info2(NC_HDF5_FILE_INFO_T *h5, hid_t datasetid,
1317 NC_TYPE_INFO_T **type_info)
1319 htri_t is_str, equal = 0;
1321 hid_t native_typeid, hdf_typeid;
1325 assert(h5 && type_info);
1333 if (!h5_native_type_constant_g[1])
1335 h5_native_type_constant_g[1] = H5T_NATIVE_SCHAR;
1336 h5_native_type_constant_g[2] = H5T_NATIVE_SHORT;
1337 h5_native_type_constant_g[3] = H5T_NATIVE_INT;
1338 h5_native_type_constant_g[4] = H5T_NATIVE_FLOAT;
1339 h5_native_type_constant_g[5] = H5T_NATIVE_DOUBLE;
1340 h5_native_type_constant_g[6] = H5T_NATIVE_UCHAR;
1341 h5_native_type_constant_g[7] = H5T_NATIVE_USHORT;
1342 h5_native_type_constant_g[8] = H5T_NATIVE_UINT;
1343 h5_native_type_constant_g[9] = H5T_NATIVE_LLONG;
1344 h5_native_type_constant_g[10] = H5T_NATIVE_ULLONG;
1348 if ((hdf_typeid = H5Dget_type(datasetid)) < 0)
1353 if ((native_typeid = H5Tget_native_type(hdf_typeid, H5T_DIR_DEFAULT)) < 0)
1357 if ((
class = H5Tget_class(native_typeid)) < 0)
1361 if (
class == H5T_STRING ||
class == H5T_INTEGER ||
class == H5T_FLOAT)
1364 if (!(*type_info = calloc(1,
sizeof(NC_TYPE_INFO_T))))
1369 if (
class == H5T_STRING)
1371 if ((is_str = H5Tis_variable_str(native_typeid)) < 0)
1374 if (is_str || H5Tget_size(hdf_typeid) > 1)
1378 (*type_info)->nc_type_class =
NC_STRING;
1384 (*type_info)->nc_type_class =
NC_CHAR;
1387 else if (
class == H5T_INTEGER ||
class == H5T_FLOAT)
1391 if ((equal = H5Tequal(native_typeid, h5_native_type_constant_g[t])) < 0)
1403 if((order = H5Tget_order(hdf_typeid)) < 0)
1406 if(order == H5T_ORDER_LE)
1408 else if(order == H5T_ORDER_BE)
1413 if(
class == H5T_INTEGER)
1414 (*type_info)->nc_type_class =
NC_INT;
1416 (*type_info)->nc_type_class =
NC_FLOAT;
1418 (*type_info)->nc_typeid = nc_type_constant_g[t];
1419 (*type_info)->size = nc_type_size_g[t];
1420 if (!((*type_info)->name = strdup(nc_type_name_g[t])))
1422 (*type_info)->hdf_typeid = hdf_typeid;
1423 (*type_info)->native_hdf_typeid = native_typeid;
1428 NC_TYPE_INFO_T *type;
1431 if((type = nc4_rec_find_hdf_type(h5->root_grp, native_typeid)))
1437 if (H5Tclose(native_typeid) < 0)
1439 if (H5Tclose(hdf_typeid) < 0)
1464 read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid,
char *type_name)
1466 NC_TYPE_INFO_T *type;
1468 hid_t native_typeid;
1472 assert(grp && type_name);
1474 LOG((4,
"%s: type_name %s grp->name %s", __func__, type_name, grp->name));
1477 if ((native_typeid = H5Tget_native_type(hdf_typeid, H5T_DIR_DEFAULT)) < 0)
1481 if (!(type_size = H5Tget_size(native_typeid)))
1483 LOG((5,
"type_size %d", type_size));
1486 if ((retval = nc4_type_list_add(grp, type_size, type_name, &type)))
1490 type->committed = NC_TRUE;
1491 type->hdf_typeid = hdf_typeid;
1492 H5Iinc_ref(type->hdf_typeid);
1493 type->native_hdf_typeid = native_typeid;
1496 if ((
class = H5Tget_class(hdf_typeid)) < 0)
1508 char* member_name = NULL;
1515 if ((nmembers = H5Tget_nmembers(hdf_typeid)) < 0)
1517 LOG((5,
"compound type has %d members", nmembers));
1518 for (m = 0; m < nmembers; m++)
1520 hid_t member_hdf_typeid;
1521 hid_t member_native_typeid;
1522 size_t member_offset;
1523 H5T_class_t mem_class;
1529 if ((member_hdf_typeid = H5Tget_member_type(type->native_hdf_typeid, m)) < 0)
1532 if ((member_native_typeid = H5Tget_native_type(member_hdf_typeid, H5T_DIR_DEFAULT)) < 0)
1536 member_name = H5Tget_member_name(type->native_hdf_typeid, m);
1537 if (!member_name || strlen(member_name) >
NC_MAX_NAME) {
1543 strncpy(jna,member_name,1000);
1549 member_offset = H5Tget_member_offset(type->native_hdf_typeid, m);
1552 if ((mem_class = H5Tget_class(member_hdf_typeid)) < 0)
1554 if (mem_class == H5T_ARRAY)
1560 if ((ndims = H5Tget_array_ndims(member_hdf_typeid)) < 0) {
1564 if (H5Tget_array_dims(member_hdf_typeid, dims, NULL) != ndims) {
1568 for (d = 0; d < ndims; d++)
1569 dim_size[d] = dims[d];
1572 if ((retval = get_netcdf_type(grp->nc4_info, H5Tget_super(member_hdf_typeid),
1577 if ((retval = nc4_field_list_add(&type->u.c.field, type->u.c.num_fields++, member_name,
1578 member_offset, H5Tget_super(member_hdf_typeid),
1579 H5Tget_super(member_native_typeid),
1580 member_xtype, ndims, dim_size)))
1586 if ((retval = get_netcdf_type(grp->nc4_info, member_native_typeid,
1591 if ((retval = nc4_field_list_add(&type->u.c.field, type->u.c.num_fields++, member_name,
1592 member_offset, member_hdf_typeid, member_native_typeid,
1593 member_xtype, 0, NULL)))
1597 hdf5free(member_name);
1600 hdf5free(member_name);
1615 if ((ret = H5Tis_variable_str(hdf_typeid)) < 0)
1621 hid_t base_hdf_typeid;
1624 type->nc_type_class =
NC_VLEN;
1628 if (!(base_hdf_typeid = H5Tget_super(native_typeid)))
1632 if (!(type_size = H5Tget_size(base_hdf_typeid)))
1636 if ((retval = get_netcdf_type(grp->nc4_info, base_hdf_typeid,
1639 LOG((5,
"base_hdf_typeid 0x%x type_size %d base_nc_type %d",
1640 base_hdf_typeid, type_size, base_nc_type));
1643 type->u.v.base_nc_typeid = base_nc_type;
1644 type->u.v.base_hdf_typeid = base_hdf_typeid;
1655 hid_t base_hdf_typeid;
1659 char *member_name = NULL;
1664 type->nc_type_class =
NC_ENUM;
1668 if (!(base_hdf_typeid = H5Tget_super(hdf_typeid)))
1671 if (!(type_size = H5Tget_size(base_hdf_typeid)))
1674 if ((retval = get_netcdf_type(grp->nc4_info, base_hdf_typeid,
1677 LOG((5,
"base_hdf_typeid 0x%x type_size %d base_nc_type %d",
1678 base_hdf_typeid, type_size, base_nc_type));
1681 type->u.e.base_nc_typeid = base_nc_type;
1682 type->u.e.base_hdf_typeid = base_hdf_typeid;
1685 if ((type->u.e.num_members = H5Tget_nmembers(hdf_typeid)) < 0)
1689 if (!(value = calloc(1, type_size)))
1693 for (i = 0; i < type->u.e.num_members; i++)
1697 if (!(member_name = H5Tget_member_name(hdf_typeid, i)))
1703 strncpy(jna,member_name,1000);
1712 if (H5Tget_member_value(hdf_typeid, i, value) < 0)
1719 if ((retval = nc4_enum_member_add(&type->u.e.enum_member, type->size,
1720 member_name, value)))
1725 hdf5free(member_name);
1728 hdf5free(member_name);
1730 if(value) free(value);
1737 LOG((0,
"unknown class"));
1761 read_var(NC_GRP_INFO_T *grp, hid_t datasetid,
const char *obj_name,
1762 size_t ndims, NC_DIM_INFO_T *dim)
1764 NC_VAR_INFO_T *var = NULL;
1765 hid_t access_pid = 0;
1768 att_iter_info att_info;
1769 H5Z_filter_t filter;
1774 H5D_fill_value_t fill_status;
1775 H5D_layout_t layout;
1781 assert(obj_name && grp);
1782 LOG((4,
"%s: obj_name %s", __func__, obj_name));
1785 if ((retval = nc4_var_add(&var)))
1789 var->hdf_datasetid = datasetid;
1790 H5Iinc_ref(var->hdf_datasetid);
1792 var->varid = grp->nvars++;
1793 var->created = NC_TRUE;
1800 if (!(var->dim = calloc(var->ndims,
sizeof(NC_DIM_INFO_T *))))
1802 if (!(var->dimids = calloc(var->ndims,
sizeof(
int))))
1807 if ((access_pid = H5Dget_access_plist(datasetid)) < 0)
1811 if ((H5Pget_chunk_cache(access_pid, &(var->chunk_cache_nelems),
1812 &(var->chunk_cache_size), &rdcc_w0)) < 0)
1814 var->chunk_cache_preemption = rdcc_w0;
1819 if (strlen(obj_name) > strlen(NON_COORD_PREPEND) &&
1820 !strncmp(obj_name, NON_COORD_PREPEND, strlen(NON_COORD_PREPEND)))
1823 if (!(var->name = malloc(((strlen(obj_name) - strlen(NON_COORD_PREPEND))+ 1) *
sizeof(
char))))
1826 strcpy(var->name, &obj_name[strlen(NON_COORD_PREPEND)]);
1829 if (!(var->hdf5_name = malloc((strlen(obj_name) + 1) *
sizeof(
char))))
1832 strcpy(var->hdf5_name, obj_name);
1837 if (!(var->name = malloc((strlen(obj_name) + 1) *
sizeof(
char))))
1840 strcpy(var->name, obj_name);
1843 var->hash = hash_fast(var->name, strlen(var->name));
1847 if ((propid = H5Dget_create_plist(datasetid)) < 0)
1851 if ((layout = H5Pget_layout(propid)) < -1)
1853 if (layout == H5D_CHUNKED)
1857 if (!(var->chunksizes = malloc(var->ndims *
sizeof(
size_t))))
1859 for (d = 0; d < var->ndims; d++)
1860 var->chunksizes[d] = chunksize[d];
1862 else if (layout == H5D_CONTIGUOUS || layout == H5D_COMPACT)
1863 var->contiguous = NC_TRUE;
1867 if ((num_filters = H5Pget_nfilters(propid)) < 0)
1869 for (f = 0; f < num_filters; f++)
1871 if ((filter = H5Pget_filter2(propid, f, NULL, &cd_nelems,
1872 cd_values_zip, 0, NULL, NULL)) < 0)
1876 case H5Z_FILTER_SHUFFLE:
1877 var->shuffle = NC_TRUE;
1880 case H5Z_FILTER_FLETCHER32:
1881 var->fletcher32 = NC_TRUE;
1884 case H5Z_FILTER_DEFLATE:
1885 var->deflate = NC_TRUE;
1888 var->deflate_level = cd_values_zip[0];
1892 var->filterid = filter;
1893 var->nparams = cd_nelems;
1898 var->params = (
unsigned int*)calloc(1,
sizeof(
unsigned int)*var->nparams);
1899 if(var->params == NULL)
1901 if((filter = H5Pget_filter2(propid, f, NULL, &cd_nelems,
1902 var->params, 0, NULL, NULL)) < 0)
1910 if ((retval = get_type_info2(grp->nc4_info, datasetid,
1915 var->type_info->rc++;
1918 if (H5Pfill_value_defined(propid, &fill_status) < 0)
1922 if (fill_status == H5D_FILL_VALUE_USER_DEFINED)
1925 if (!var->fill_value)
1927 if (var->type_info->nc_type_class ==
NC_VLEN)
1929 if (!(var->fill_value = malloc(
sizeof(
nc_vlen_t))))
1932 else if (var->type_info->nc_type_class ==
NC_STRING)
1934 if (!(var->fill_value = malloc(
sizeof(
char *))))
1939 assert(var->type_info->size);
1940 if (!(var->fill_value = malloc(var->type_info->size)))
1946 if (H5Pget_fill_value(propid, var->type_info->native_hdf_typeid,
1947 var->fill_value) < 0)
1951 var->no_fill = NC_TRUE;
1957 var->dimscale = NC_TRUE;
1960 if ((retval = read_coord_dimids(grp, var)))
1966 assert(0 == strcmp(var->name, dim->name));
1968 var->dimids[0] = dim->dimid;
1971 dim->coord_var = var;
1983 num_scales = H5DSget_num_scales(datasetid, 0);
1987 if (num_scales && ndims)
1991 if (NULL == (var->dimscale_attached = calloc(ndims,
sizeof(nc_bool_t))))
1996 if (NULL == (var->dimscale_hdf5_objids = malloc(ndims *
sizeof(
struct hdf5_objid))))
1998 for (d = 0; d < var->ndims; d++)
2000 if (H5DSiterate_scales(var->hdf_datasetid, d, NULL, dimscale_visitor,
2001 &(var->dimscale_hdf5_objids[d])) < 0)
2003 var->dimscale_attached[d] = NC_TRUE;
2014 if ((H5Aiterate2(var->hdf_datasetid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL,
2015 att_read_var_callbk, &att_info)) < 0)
2019 if ((retval = nc4_vararray_add(grp, var)))
2024 if ((retval = nc4_adjust_var_cache(grp, var)))
2030 if (incr_id_rc && H5Idec_ref(datasetid) < 0)
2032 if (var && nc4_var_del(var))
2035 if (access_pid && H5Pclose(access_pid) < 0)
2037 if (propid > 0 && H5Pclose(propid) < 0)
2054 read_grp_atts(NC_GRP_INFO_T *grp)
2059 NC_TYPE_INFO_T *type;
2060 char obj_name[NC_MAX_HDF5_NAME + 1];
2065 num_obj = H5Aget_num_attrs(grp->hdf_grpid);
2066 for (i = 0; i < num_obj; i++)
2068 if ((attid = H5Aopen_idx(grp->hdf_grpid, (
unsigned int)i)) < 0)
2070 if (H5Aget_name(attid,
NC_MAX_NAME + 1, obj_name) < 0)
2072 LOG((3,
"reading attribute of _netCDF group, named %s", obj_name));
2075 if(grp->nc4_info->root_grp == grp) {
2076 const char** reserved = NC_RESERVED_ATT_LIST;
2078 for(;*reserved;reserved++) {
2079 if(strcmp(*reserved,obj_name)==0) {
2090 if(strcmp(obj_name, NC3_STRICT_ATT_NAME)==0)
2094 if ((retval = nc4_att_list_add(&grp->att, &att)))
2099 if (!(att->name = malloc((max_len + 1) *
sizeof(
char))))
2101 strncpy(att->name, obj_name, max_len);
2102 att->name[max_len] = 0;
2103 att->attnum = grp->natts++;
2104 retval = read_hdf5_att(grp, attid, att);
2106 if((retval = nc4_att_list_del(&grp->att, att)))
2111 att->created = NC_TRUE;
2112 if ((retval = nc4_find_type(grp->nc4_info, att->nc_typeid, &type)))
2123 if(H5Aclose(attid) < 0)
2144 read_dataset(NC_GRP_INFO_T *grp, hid_t datasetid,
const char *obj_name,
2145 const H5G_stat_t *statbuf)
2147 NC_DIM_INFO_T *dim = NULL;
2154 if ((spaceid = H5Dget_space(datasetid)) < 0)
2156 if ((ndims = H5Sget_simple_extent_ndims(spaceid)) < 0)
2160 if ((is_scale = H5DSis_scale(datasetid)) < 0)
2164 hsize_t dims[H5S_MAX_RANK];
2165 hsize_t max_dims[H5S_MAX_RANK];
2168 if (H5Sget_simple_extent_dims(spaceid, dims, max_dims) < 0)
2172 if ((retval = read_scale(grp, datasetid, obj_name, statbuf, dims[0],
2173 max_dims[0], &dim)))
2180 if (NULL == dim || (dim && !dim->hdf_dimscaleid))
2181 if ((retval = read_var(grp, datasetid, obj_name, ndims, dim)))
2185 if (spaceid && H5Sclose(spaceid) <0)
2203 nc4_rec_read_metadata_cb_list_add(NC4_rec_read_metadata_obj_info_t **head,
2204 NC4_rec_read_metadata_obj_info_t **tail,
2205 const NC4_rec_read_metadata_obj_info_t *oinfo)
2207 NC4_rec_read_metadata_obj_info_t *new_oinfo;
2210 if (!(new_oinfo = calloc(1,
sizeof(*new_oinfo))))
2214 memcpy(new_oinfo, oinfo,
sizeof(*oinfo));
2219 (*tail)->next = new_oinfo;
2224 assert(NULL == *head);
2225 *head = *tail = new_oinfo;
2244 nc4_rec_read_metadata_cb(hid_t grpid,
const char *name,
const H5L_info_t *info,
2247 NC4_rec_read_metadata_ud_t *udata = (NC4_rec_read_metadata_ud_t *)_op_data;
2248 NC4_rec_read_metadata_obj_info_t oinfo;
2249 int retval = H5_ITER_CONT;
2252 memset(&oinfo, 0,
sizeof(oinfo));
2255 if ((oinfo.oid = H5Oopen(grpid, name, H5P_DEFAULT)) < 0)
2256 BAIL(H5_ITER_ERROR);
2259 if (H5Gget_objinfo(oinfo.oid,
".", 1, &oinfo.statbuf) < 0)
2260 BAIL(H5_ITER_ERROR);
2265 switch(oinfo.statbuf.type)
2268 LOG((3,
"found group %s", oinfo.oname));
2274 if (nc4_rec_read_metadata_cb_list_add(&udata->grps_head, &udata->grps_tail, &oinfo))
2275 BAIL(H5_ITER_ERROR);
2279 LOG((3,
"found dataset %s", oinfo.oname));
2283 if ((retval = read_dataset(udata->grp, oinfo.oid, oinfo.oname, &oinfo.statbuf)))
2291 BAIL(H5_ITER_ERROR);
2293 retval = H5_ITER_CONT;
2297 if (H5Oclose(oinfo.oid) < 0)
2298 BAIL(H5_ITER_ERROR);
2302 LOG((3,
"found datatype %s", oinfo.oname));
2305 if (read_type(udata->grp, oinfo.oid, oinfo.oname))
2306 BAIL(H5_ITER_ERROR);
2309 if (H5Oclose(oinfo.oid) < 0)
2310 BAIL(H5_ITER_ERROR);
2314 LOG((0,
"Unknown object class %d in %s!", oinfo.statbuf.type, __func__));
2315 BAIL(H5_ITER_ERROR);
2321 if (oinfo.oid > 0 && H5Oclose(oinfo.oid) < 0)
2322 BAIL2(H5_ITER_ERROR);
2343 nc4_rec_read_metadata(NC_GRP_INFO_T *grp)
2345 NC4_rec_read_metadata_ud_t udata;
2346 NC4_rec_read_metadata_obj_info_t *oinfo;
2349 unsigned crt_order_flags = 0;
2350 H5_index_t iter_index;
2353 assert(grp && grp->name);
2354 LOG((3,
"%s: grp->name %s", __func__, grp->name));
2357 memset(&udata, 0,
sizeof(udata));
2361 if (!grp->hdf_grpid)
2365 if ((grp->hdf_grpid = H5Gopen2(grp->parent->hdf_grpid,
2366 grp->name, H5P_DEFAULT)) < 0)
2371 if ((grp->hdf_grpid = H5Gopen2(grp->nc4_info->hdfid,
2372 "/", H5P_DEFAULT)) < 0)
2376 assert(grp->hdf_grpid > 0);
2379 pid = H5Gget_create_plist(grp->hdf_grpid);
2380 H5Pget_link_creation_order(pid, &crt_order_flags);
2381 if (H5Pclose(pid) < 0)
2385 if (crt_order_flags & H5P_CRT_ORDER_TRACKED)
2386 iter_index = H5_INDEX_CRT_ORDER;
2389 NC_HDF5_FILE_INFO_T *h5 = grp->nc4_info;
2395 iter_index = H5_INDEX_NAME;
2404 if (H5Literate(grp->hdf_grpid, iter_index, H5_ITER_INC, &idx,
2405 nc4_rec_read_metadata_cb, (
void *)&udata) < 0)
2412 for (oinfo = udata.grps_head; oinfo; oinfo = udata.grps_head)
2414 NC_GRP_INFO_T *child_grp;
2415 NC_HDF5_FILE_INFO_T *h5 = grp->nc4_info;
2418 if ((retval = nc4_grp_list_add(&(grp->children), h5->next_nc_grpid++,
2419 grp, grp->nc4_info->controller, oinfo->oname, &child_grp)))
2423 if ((retval = nc4_rec_read_metadata(child_grp)))
2427 if (H5Oclose(oinfo->oid) < 0)
2431 udata.grps_head = oinfo->next;
2436 if ((retval = read_grp_atts(grp)))
2440 for (i=0; i<grp->vars.nelems; i++)
2441 grp->vars.value[i]->written_to = NC_TRUE;
2447 for (oinfo = udata.grps_head; oinfo; oinfo = udata.grps_head)
2450 if (H5Oclose(oinfo->oid) < 0)
2454 udata.grps_head = oinfo->next;
2476 nc4_open_file(
const char *path,
int mode,
void* parameters, NC *nc)
2478 hid_t fapl_id = H5P_DEFAULT;
2479 unsigned flags = (mode &
NC_WRITE) ?
2480 H5F_ACC_RDWR : H5F_ACC_RDONLY;
2482 NC_HDF5_FILE_INFO_T* nc4_info = NULL;
2484 NC_MEM_INFO* meminfo = (NC_MEM_INFO*)parameters;
2485 #ifdef USE_PARALLEL4 2486 NC_MPI_INFO* mpiinfo = (NC_MPI_INFO*)parameters;
2491 LOG((3,
"%s: path %s mode %d", __func__, path, mode));
2495 if ((retval = nc4_nc4f_list_add(nc, path, mode)))
2497 nc4_info = NC4_DATA(nc);
2498 assert(nc4_info && nc4_info->root_grp);
2503 if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
2506 if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI))
2509 #ifdef USE_PARALLEL4 2514 nc4_info->parallel = NC_TRUE;
2517 LOG((4,
"opening parallel file with MPI/IO"));
2518 if (H5Pset_fapl_mpio(fapl_id, mpiinfo->comm, mpiinfo->info) < 0)
2521 #ifdef USE_PARALLEL_POSIX 2524 LOG((4,
"opening parallel file with MPI/posix"));
2525 if (H5Pset_fapl_mpiposix(fapl_id, mpiinfo->comm, 0) < 0)
2538 if (MPI_SUCCESS != MPI_Comm_dup(mpiinfo->comm, &nc4_info->comm))
2541 if (MPI_INFO_NULL != mpiinfo->info)
2543 if (MPI_SUCCESS != MPI_Info_dup(mpiinfo->info, &nc4_info->info))
2550 nc4_info->info = mpiinfo->info;
2557 LOG((4,
"%s: set HDF raw chunk cache to size %d nelems %d preemption %f",
2564 #ifdef HDF5_HAS_COLL_METADATA_OPS 2565 H5Pset_all_coll_metadata_ops(fapl_id, 1 );
2568 if((nc4_info->hdfid = H5LTopen_file_image(meminfo->memory,meminfo->size,
2569 H5LT_FILE_IMAGE_DONT_COPY|H5LT_FILE_IMAGE_DONT_RELEASE
2572 nc4_info->no_write = NC_TRUE;
2573 }
else if ((nc4_info->hdfid = H5Fopen(path, flags, fapl_id)) < 0)
2578 nc4_info->no_write = NC_TRUE;
2584 if ((retval = nc4_rec_read_metadata(nc4_info->root_grp)))
2589 if ((retval = nc4_rec_match_dimscales(nc4_info->root_grp)))
2595 log_metadata_nc(nc);
2599 if (H5Pclose(fapl_id) < 0)
2602 NC4_get_fileinfo(nc4_info,NULL);
2607 #ifdef USE_PARALLEL4 2608 if (comm_duped) MPI_Comm_free(&nc4_info->comm);
2609 if (info_duped) MPI_Info_free(&nc4_info->info);
2611 if (fapl_id != H5P_DEFAULT) H5Pclose(fapl_id);
2612 if (!nc4_info)
return retval;
2613 close_netcdf4_file(nc4_info,1);
2634 NC4_open(
const char *path,
int mode,
int basepe,
size_t *chunksizehintp,
2635 int use_parallel,
void *parameters, NC_Dispatch *dispatch, NC *nc_file)
2638 #ifdef USE_PARALLEL4 2639 NC_MPI_INFO mpidfalt = {MPI_COMM_WORLD, MPI_INFO_NULL};
2641 #if defined USE_PARALLEL4 2645 assert(nc_file && path);
2647 LOG((1,
"%s: path %s mode %d params %x",
2648 __func__, path, mode, parameters));
2650 #ifdef USE_PARALLEL4 2651 if (!inmemory && use_parallel && parameters == NULL)
2652 parameters = &mpidfalt;
2657 nc4_hdf5_initialize();
2660 if((mode & ILLEGAL_OPEN_FLAGS) != 0)
2667 #ifndef USE_PARALLEL_POSIX 2673 mode &= ~NC_MPIPOSIX;
2682 nc_file->int_ncid = nc_file->ext_ncid;
2683 res = nc4_open_file(path, mode, parameters, nc_file);
2704 NC4_set_fill(
int ncid,
int fillmode,
int *old_modep)
2707 NC_HDF5_FILE_INFO_T* nc4_info;
2709 LOG((2,
"%s: ncid 0x%x fillmode %d", __func__, ncid, fillmode));
2711 if (!(nc = nc4_find_nc_file(ncid,&nc4_info)))
2716 if (nc4_info->no_write)
2725 *old_modep = nc4_info->fill_mode;
2727 nc4_info->fill_mode = fillmode;
2745 NC_HDF5_FILE_INFO_T* nc4_info;
2747 LOG((1,
"%s: ncid 0x%x", __func__, ncid));
2750 if (!(nc4_find_nc_file(ncid,&nc4_info)))
2755 if (nc4_info->flags & NC_INDEF)
2759 if (nc4_info->no_write)
2763 nc4_info->flags |= NC_INDEF;
2767 nc4_info->redef = NC_TRUE;
2786 NC4__enddef(
int ncid,
size_t h_minfree,
size_t v_align,
2787 size_t v_minfree,
size_t r_align)
2789 if (nc4_find_nc_file(ncid,NULL) == NULL)
2792 return NC4_enddef(ncid);
2804 static int NC4_enddef(
int ncid)
2807 NC_HDF5_FILE_INFO_T* nc4_info;
2811 LOG((1,
"%s: ncid 0x%x", __func__, ncid));
2813 if (!(nc = nc4_find_nc_file(ncid,&nc4_info)))
2818 if (!(grp = nc4_rec_find_grp(nc4_info->root_grp, (ncid & GRP_ID_MASK))))
2822 for (i=0; i<grp->vars.nelems; i++)
2823 grp->vars.value[i]->written_to = NC_TRUE;
2825 return nc4_enddef_netcdf4_file(nc4_info);
2842 NC_HDF5_FILE_INFO_T* nc4_info;
2844 LOG((2,
"%s: ncid 0x%x", __func__, ncid));
2846 if (!(nc = nc4_find_nc_file(ncid,&nc4_info)))
2851 if (nc4_info && nc4_info->flags & NC_INDEF)
2855 if ((retval = NC4_enddef(ncid)))
2859 return sync_netcdf4_file(nc4_info);
2879 int delete_file = 0;
2882 NC_HDF5_FILE_INFO_T* nc4_info;
2884 LOG((2,
"%s: ncid 0x%x", __func__, ncid));
2887 if (!(nc = nc4_find_nc_file(ncid,&nc4_info)))
2893 if (nc4_info->flags & NC_INDEF && !nc4_info->redef)
2901 if ((retval = close_netcdf4_file(nc4_info, 1)))
2906 if (
remove(path) < 0)
2925 NC_HDF5_FILE_INFO_T *h5;
2928 LOG((1,
"%s: ncid 0x%x", __func__, ncid));
2931 if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
2934 assert(nc && h5 && grp);
2941 if ((retval = close_netcdf4_file(grp->nc4_info, 0)))
2965 NC4_inq(
int ncid,
int *ndimsp,
int *nvarsp,
int *nattsp,
int *unlimdimidp)
2968 NC_HDF5_FILE_INFO_T *h5;
2974 LOG((2,
"%s: ncid 0x%x", __func__, ncid));
2977 if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
2980 assert(h5 && grp && nc);
2986 for (dim = grp->dim; dim; dim = dim->l.next)
2993 for (i=0; i < grp->vars.nelems; i++)
2995 if (grp->vars.value[i])
3002 for (att = grp->att; att; att = att->l.next)
3015 for (dim = grp->dim; dim; dim = dim->l.next)
3018 *unlimdimidp = dim->dimid;
3035 nc4_enddef_netcdf4_file(NC_HDF5_FILE_INFO_T *h5)
3038 LOG((3,
"%s", __func__));
3041 if (!(h5->flags & NC_INDEF))
3045 h5->flags ^= NC_INDEF;
3048 h5->redef = NC_FALSE;
3050 return sync_netcdf4_file(h5);
struct NCPROPINFO globalpropinfo
Global property info.
#define NC_ENOMEM
Memory allocation (malloc) failure.
#define NC_CHAR
ISO/ASCII character.
#define NC_ECANTWRITE
Can't write.
#define NC_FORMATX_NC4
alias
#define NC_UBYTE
unsigned 1 byte int
#define NC_CLASSIC_MODEL
Enforce classic model on netCDF-4.
#define NC_MAX_VAR_DIMS
max per variable dimensions
#define NC_UINT
unsigned 4-byte int
#define NC_NOCLOBBER
Don't destroy existing file.
#define NC_INMEMORY
Read from memory.
#define NC_EHDFERR
Error at HDF5 layer.
#define NC_OPAQUE
opaque types
#define NC_MPIIO
Turn on MPI I/O.
#define NC_INT64
signed 8-byte int
#define NC_ENOTINDEFINE
Operation not allowed in data mode.
#define NC_DOUBLE
double precision floating point number
#define NC_EBADCLASS
Bad class.
int nc_type
The nc_type type is just an int.
#define NC_64BIT_OFFSET
Use large (64-bit) file offsets.
#define NC_NOWRITE
Set read-only access for nc_open().
#define NC_BYTE
signed 1 byte integer
#define NC_EINDEFINE
Operation not allowed in define mode.
#define NC_FORMAT_CDF5
Format specifier for nc_set_default_format() and returned by nc_inq_format.
#define NC_ENDIAN_LITTLE
In HDF5 files you can set the endianness of variables with nc_def_var_endian().
#define NC_EATTMETA
Problem with attribute metadata.
#define NUM_TYPES
Number of netCDF atomic types.
#define NC_VLEN
vlen (variable-length) types
#define NC_EMPI
MPI operation failed.
#define NC_EDISKLESS
Error in using diskless access.
int nc4_hdf5_initialized
True if initialization has happened.
#define NC_EFILEMETA
Problem with file metadata.
#define NC_EBADTYPE
Not a netcdf data type.
#define NC_EBADNAME
Attribute or variable name contains illegal characters.
#define NC_MAX_DEFLATE_LEVEL
Maximum deflate level.
size_t nc4_chunk_cache_nelems
Default chunk cache number of elements.
#define NC_EINVAL
Invalid Argument.
#define CD_NELEMS_ZLIB
Number of parameters needed for ZLIB filter.
size_t nc4_chunk_cache_size
Default chunk cache size.
#define NC_INT
signed 4 byte integer
#define NC_EBADGRPID
Bad group ID.
#define NC_NOFILL
Argument to nc_set_fill() to turn off filling of data.
#define NC_ENDIAN_BIG
In HDF5 files you can set the endianness of variables with nc_def_var_endian().
#define NC_MAX_NAME
Maximum for classic library.
#define NC_ECANTREMOVE
Can't remove file.
#define NC_NAT
Not A Type.
#define NC_EBADTYPID
Bad type ID.
#define NC_USHORT
unsigned 2-byte int
int nc_set_chunk_cache(size_t size, size_t nelems, float preemption)
Set chunk cache size.
#define NC_EPARINIT
Error initializing for parallel access.
#define NC_NETCDF4
Use netCDF-4/HDF5 format.
#define NC_EEXIST
netcdf file exists && NC_NOCLOBBER
#define NC_FORMAT_NETCDF4_CLASSIC
Format specifier for nc_set_default_format() and returned by nc_inq_format.
#define NC_EBADID
Not a netcdf id.
#define NC_EVARMETA
Problem with variable metadata.
This is the type of arrays of vlens.
#define NC_MAX_UINT
Max or min values for a type.
int nc_get_chunk_cache(size_t *sizep, size_t *nelemsp, float *preemptionp)
Get chunk cache size.
#define NC_SHORT
signed 2 byte integer
#define NC_CDF5
Alias NC_CDF5 to NC_64BIT_DATA.
float nc4_chunk_cache_preemption
Default chunk cache preemption.
#define NC_WRITE
Set read-write access for nc_open().
#define NC_EPERM
Write to read only.
#define NC_NOERR
No Error.
#define NC_ENUM
enum types
#define NC_DISKLESS
Use diskless file.
#define NC_COMPOUND
compound types
#define NC_FORMAT_64BIT_OFFSET
Format specifier for nc_set_default_format() and returned by nc_inq_format.
#define NC_MMAP
Use diskless file with mmap.
#define NC_FILL
Argument to nc_set_fill() to clear NC_NOFILL.
#define NC_FLOAT
single precision floating point number
#define NC_UINT64
unsigned 8-byte int
#define NC_MPIPOSIX
Turn on MPI POSIX I/O.