int ex_get_var(int exoid, int time_step, ex_entity_type var_type, int var_index, ex_entity_id obj_id, int64_t num_entry_this_obj, void *var_vals) { int status; int varid, obj_id_ndx; size_t start[2], count[2]; char errmsg[MAX_ERR_LENGTH]; EX_FUNC_ENTER(); ex_check_valid_file_id(exoid, __func__); /* Verify that time_step is within bounds */ { int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME); if (time_step <= 0 || time_step > num_time_steps) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: time_step is out-of-range. Value = %d, valid " "range is 1 to %d in file id %d", time_step, num_time_steps, exoid); ex_err(__func__, errmsg, EX_BADPARAM); EX_FUNC_LEAVE(EX_FATAL); } } if (var_type == EX_NODAL) { /* FIXME: Special case: ignore obj_id, possible large_file complications, * etc. */ status = ex_get_nodal_var_int(exoid, time_step, var_index, num_entry_this_obj, var_vals); EX_FUNC_LEAVE(status); } if (var_type == EX_GLOBAL) { /* FIXME: Special case: all vars stored in 2-D single array. */ status = ex_get_glob_vars_int(exoid, time_step, num_entry_this_obj, var_vals); EX_FUNC_LEAVE(status); } /* Determine index of obj_id in VAR_ID_EL_BLK array */ obj_id_ndx = ex_id_lkup(exoid, var_type, obj_id); if (obj_id_ndx <= 0) { ex_get_err(NULL, NULL, &status); if (status != 0) { if (status == EX_NULLENTITY) { snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %s variables for NULL block %" PRId64 " in file id %d", ex_name_of_object(var_type), obj_id, exoid); ex_err(__func__, errmsg, EX_NULLENTITY); EX_FUNC_LEAVE(EX_WARN); } snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s id %" PRId64 " in id variable in file id %d", ex_name_of_object(var_type), obj_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } /* inquire previously defined variable */ if ((status = nc_inq_varid(exoid, ex_name_var_of_object(var_type, var_index, obj_id_ndx), &varid)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s %" PRId64 " var %d in file id %d", ex_name_of_object(var_type), obj_id, var_index, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } /* read values of element variable */ start[0] = --time_step; start[1] = 0; count[0] = 1; count[1] = num_entry_this_obj; if (ex_comp_ws(exoid) == 4) { status = nc_get_vara_float(exoid, varid, start, count, var_vals); } else { status = nc_get_vara_double(exoid, varid, start, count, var_vals); } if (status != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s %" PRId64 " variable %d in file id %d", ex_name_of_object(var_type), obj_id, var_index, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } EX_FUNC_LEAVE(EX_NOERR); }
int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_int *nodeconn, void_int *edgeconn, void_int *faceconn) { int connid = -1; int econnid = -1; int fconnid = -1; int blk_id_ndx, status; int numnodperentdim = -1; int numedgperentdim = -1; int numfacperentdim = -1; size_t num_nodes_per_entry = 0; size_t num_edges_per_entry = 0; size_t num_faces_per_entry = 0; char errmsg[MAX_ERR_LENGTH]; const char *dnumnodent = NULL; const char *dnumedgent = NULL; const char *dnumfacent = NULL; const char *vnodeconn = NULL; const char *vedgeconn = NULL; const char *vfaceconn = NULL; EX_FUNC_ENTER(); ex_check_valid_file_id(exoid, __func__); /* Should we warn if edgeconn or faceconn are non-NULL? * No, fail silently so the same code can be used to read any type of block * info. * However, we will warn if edgeconn or faceconn are NULL but * num_edges_per_entry * or num_faces_per_entry (respectively) are positive. */ /* Locate index of element block id in VAR_ID_EL_BLK array */ blk_id_ndx = ex_id_lkup(exoid, blk_type, blk_id); if (blk_id_ndx <= 0) { ex_get_err(NULL, NULL, &status); if (status != 0) { if (status == EX_NULLENTITY) { snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no connectivity array for NULL %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, EX_NULLENTITY); EX_FUNC_LEAVE(EX_WARN); /* no connectivity array for this element block */ } snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s id %" PRId64 " in id array in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } switch (blk_type) { case EX_EDGE_BLOCK: dnumnodent = DIM_NUM_NOD_PER_ED(blk_id_ndx); dnumedgent = 0; dnumfacent = 0; vnodeconn = VAR_EBCONN(blk_id_ndx); vedgeconn = 0; vfaceconn = 0; break; case EX_FACE_BLOCK: dnumnodent = DIM_NUM_NOD_PER_FA(blk_id_ndx); dnumedgent = 0; dnumfacent = 0; vnodeconn = VAR_FBCONN(blk_id_ndx); vedgeconn = 0; vfaceconn = 0; break; case EX_ELEM_BLOCK: dnumnodent = DIM_NUM_NOD_PER_EL(blk_id_ndx); dnumedgent = DIM_NUM_EDG_PER_EL(blk_id_ndx); dnumfacent = DIM_NUM_FAC_PER_EL(blk_id_ndx); vnodeconn = VAR_CONN(blk_id_ndx); vedgeconn = VAR_ECONN(blk_id_ndx); vfaceconn = VAR_FCONN(blk_id_ndx); break; default: snprintf(errmsg, MAX_ERR_LENGTH, "Internal ERROR: unrecognized block type in switch: %d in file id %d", blk_type, exoid); ex_err(__func__, errmsg, EX_BADPARAM); EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */ } /* inquire id's of previously defined dimensions */ num_nodes_per_entry = 0; if (nodeconn && dnumnodent) { if ((status = nc_inq_dimid(exoid, dnumnodent, &numnodperentdim)) != NC_NOERR) { numnodperentdim = -1; } else { if ((status = nc_inq_dimlen(exoid, numnodperentdim, &num_nodes_per_entry)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of nodes/entity for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } } if (edgeconn && dnumedgent) { num_edges_per_entry = 0; if ((status = nc_inq_dimid(exoid, dnumedgent, &numedgperentdim)) != NC_NOERR) { numedgperentdim = -1; } else { if ((status = nc_inq_dimlen(exoid, numedgperentdim, &num_edges_per_entry)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of edges/entry for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } } if (faceconn && dnumfacent) { num_faces_per_entry = 0; if ((status = nc_inq_dimid(exoid, dnumfacent, &numfacperentdim)) != NC_NOERR) { numfacperentdim = -1; } else { if ((status = nc_inq_dimlen(exoid, numfacperentdim, &num_faces_per_entry)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of faces/entry for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } } status = 0; if (nodeconn && (numnodperentdim >= 0) && ((status = nc_inq_varid(exoid, vnodeconn, &connid)) != NC_NOERR)) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate node connectivity array for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } status = 0; if (edgeconn && (numedgperentdim >= 0) && ((status = nc_inq_varid(exoid, vedgeconn, &econnid)) != NC_NOERR)) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate edge connectivity array for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } if (faceconn && (numfacperentdim >= 0) && ((status = nc_inq_varid(exoid, vfaceconn, &fconnid)) != NC_NOERR)) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate face connectivity array for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } /* read in the connectivity array */ if (edgeconn && num_edges_per_entry > 0) { if (ex_int64_status(exoid) & EX_BULK_INT64_API) { status = nc_get_var_longlong(exoid, econnid, edgeconn); } else { status = nc_get_var_int(exoid, econnid, edgeconn); } if (status != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get edge connectivity array for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } if (faceconn && num_faces_per_entry > 0) { if (ex_int64_status(exoid) & EX_BULK_INT64_API) { status = nc_get_var_longlong(exoid, fconnid, faceconn); } else { status = nc_get_var_int(exoid, fconnid, faceconn); } if (status != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get face connectivity array for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } if (nodeconn && num_nodes_per_entry > 0) { if (ex_int64_status(exoid) & EX_BULK_INT64_API) { status = nc_get_var_longlong(exoid, connid, nodeconn); } else { status = nc_get_var_int(exoid, connid, nodeconn); } if (status != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get node connectivity array for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } EX_FUNC_LEAVE(EX_NOERR); }
int ex_put_partial_attr(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, int64_t start_entity, int64_t num_entity, const void *attrib) { int status; int attrid; int blk_id_ndx = 0; int numattrdim; size_t start[2], count[2]; size_t num_attr; char errmsg[MAX_ERR_LENGTH]; EX_FUNC_ENTER(); ex_check_valid_file_id(exoid, __func__); if (blk_type != EX_NODAL) { /* Determine index of blk_id in VAR_ID_EL_BLK array */ blk_id_ndx = ex_id_lkup(exoid, blk_type, blk_id); if (blk_id_ndx <= 0) { ex_get_err(NULL, NULL, &status); if (status != 0) { if (status == EX_NULLENTITY) { snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no attributes allowed for NULL %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, EX_NULLENTITY); EX_FUNC_LEAVE(EX_WARN); /* no attributes for this block */ } snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %s id %" PRId64 " in in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } } switch (blk_type) { case EX_SIDE_SET: status = nc_inq_varid(exoid, VAR_SSATTRIB(blk_id_ndx), &attrid); break; case EX_NODE_SET: status = nc_inq_varid(exoid, VAR_NSATTRIB(blk_id_ndx), &attrid); break; case EX_EDGE_SET: status = nc_inq_varid(exoid, VAR_ESATTRIB(blk_id_ndx), &attrid); break; case EX_FACE_SET: status = nc_inq_varid(exoid, VAR_FSATTRIB(blk_id_ndx), &attrid); break; case EX_ELEM_SET: status = nc_inq_varid(exoid, VAR_ELSATTRIB(blk_id_ndx), &attrid); break; case EX_NODAL: status = nc_inq_varid(exoid, VAR_NATTRIB, &attrid); break; case EX_EDGE_BLOCK: status = nc_inq_varid(exoid, VAR_EATTRIB(blk_id_ndx), &attrid); break; case EX_FACE_BLOCK: status = nc_inq_varid(exoid, VAR_FATTRIB(blk_id_ndx), &attrid); break; case EX_ELEM_BLOCK: status = nc_inq_varid(exoid, VAR_ATTRIB(blk_id_ndx), &attrid); break; default: snprintf(errmsg, MAX_ERR_LENGTH, "Internal ERROR: unrecognized object type in switch: %d in file id %d", blk_type, exoid); ex_err(__func__, errmsg, EX_BADPARAM); EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */ } if (status != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate attribute variable for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } /* Determine number of attributes */ switch (blk_type) { case EX_SIDE_SET: status = nc_inq_dimid(exoid, DIM_NUM_ATT_IN_SS(blk_id_ndx), &numattrdim); break; case EX_NODE_SET: status = nc_inq_dimid(exoid, DIM_NUM_ATT_IN_NS(blk_id_ndx), &numattrdim); break; case EX_EDGE_SET: status = nc_inq_dimid(exoid, DIM_NUM_ATT_IN_ES(blk_id_ndx), &numattrdim); break; case EX_FACE_SET: status = nc_inq_dimid(exoid, DIM_NUM_ATT_IN_FS(blk_id_ndx), &numattrdim); break; case EX_ELEM_SET: status = nc_inq_dimid(exoid, DIM_NUM_ATT_IN_ELS(blk_id_ndx), &numattrdim); break; case EX_NODAL: status = nc_inq_dimid(exoid, DIM_NUM_ATT_IN_NBLK, &numattrdim); break; case EX_EDGE_BLOCK: status = nc_inq_dimid(exoid, DIM_NUM_ATT_IN_EBLK(blk_id_ndx), &numattrdim); break; case EX_FACE_BLOCK: status = nc_inq_dimid(exoid, DIM_NUM_ATT_IN_FBLK(blk_id_ndx), &numattrdim); break; case EX_ELEM_BLOCK: status = nc_inq_dimid(exoid, DIM_NUM_ATT_IN_BLK(blk_id_ndx), &numattrdim); break; default: /* No need for error message, handled in previous switch; just to quiet * compiler. */ EX_FUNC_LEAVE(EX_FATAL); } if (status != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: number of attributes not defined for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */ } if ((status = nc_inq_dimlen(exoid, numattrdim, &num_attr)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of attributes for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } /* write out the attributes */ start[0] = --start_entity; start[1] = 0; count[0] = num_entity; count[1] = num_attr; if (count[0] == 0) { start[0] = 0; } if (ex_comp_ws(exoid) == 4) { status = nc_put_vara_float(exoid, attrid, start, count, attrib); } else { status = nc_put_vara_double(exoid, attrid, start, count, attrib); } if (status != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put attributes for %s %" PRId64 " in file id %d", ex_name_of_object(blk_type), blk_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } EX_FUNC_LEAVE(EX_NOERR); }
int ex_get_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_id set_id, void *set_dist_fact) { int dimid, dist_id, set_id_ndx; int status; char errmsg[MAX_ERR_LENGTH]; char *factptr = NULL; EX_FUNC_ENTER(); ex_check_valid_file_id(exoid, __func__); /* first check if any sets are specified */ if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(set_type), &dimid)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %s sets stored in file id %d", ex_name_of_object(set_type), exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_WARN); } /* Lookup index of set id in VAR_*S_IDS array */ set_id_ndx = ex_id_lkup(exoid, set_type, set_id); if (set_id_ndx <= 0) { ex_get_err(NULL, NULL, &status); if (status != 0) { if (status == EX_NULLENTITY) { snprintf(errmsg, MAX_ERR_LENGTH, "Warning: %s set %" PRId64 " is NULL in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, EX_NULLENTITY); EX_FUNC_LEAVE(EX_WARN); } snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s set %" PRId64 " in VAR_*S_IDS array in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } /* setup more pointers based on set_type */ if (set_type == EX_NODE_SET) { factptr = VAR_FACT_NS(set_id_ndx); } else if (set_type == EX_EDGE_SET) { factptr = VAR_FACT_ES(set_id_ndx); } else if (set_type == EX_FACE_SET) { factptr = VAR_FACT_FS(set_id_ndx); } else if (set_type == EX_SIDE_SET) { factptr = VAR_FACT_SS(set_id_ndx); } if (set_type == EX_ELEM_SET) { factptr = VAR_FACT_ELS(set_id_ndx); } /* inquire id's of previously defined dimensions and variables */ if ((status = nc_inq_varid(exoid, factptr, &dist_id)) != NC_NOERR) { /* not an error for node sets because this is how we check that df's exist */ if (set_type == EX_NODE_SET) { snprintf(errmsg, MAX_ERR_LENGTH, "Warning: dist factors not stored for %s set %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_WARN); /* complain - but not too loud */ } /* is an error for other sets */ snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate dist factors list for %s set %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } /* read in the distribution factors array */ if (ex_comp_ws(exoid) == 4) { status = nc_get_var_float(exoid, dist_id, set_dist_fact); } else { status = nc_get_var_double(exoid, dist_id, set_dist_fact); } if (status != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get dist factors list for %s set %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } EX_FUNC_LEAVE(EX_NOERR); }
int ex_get_set(int exoid, ex_entity_type set_type, ex_entity_id set_id, void_int *set_entry_list, void_int *set_extra_list) /* NULL if dont want to retrieve data */ { int dimid, entry_list_id, extra_list_id, status; int set_id_ndx; char errmsg[MAX_ERR_LENGTH]; char *entryptr = NULL; char *extraptr = NULL; EX_FUNC_ENTER(); ex_check_valid_file_id(exoid, __func__); /* first check if any sets are specified */ if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(set_type), &dimid)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %ss stored in file id %d", ex_name_of_object(set_type), exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_WARN); } /* Lookup index of set id in VAR_*S_IDS array */ set_id_ndx = ex_id_lkup(exoid, set_type, set_id); if (set_id_ndx <= 0) { ex_get_err(NULL, NULL, &status); if (status != 0) { if (status == EX_NULLENTITY) { snprintf(errmsg, MAX_ERR_LENGTH, "Warning: %s %" PRId64 " is NULL in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, EX_NULLENTITY); EX_FUNC_LEAVE(EX_WARN); } snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s id %" PRId64 " in VAR_*S_IDS array in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } /* setup more pointers based on set_type */ if (set_type == EX_NODE_SET) { entryptr = VAR_NODE_NS(set_id_ndx); extraptr = NULL; } else if (set_type == EX_EDGE_SET) { entryptr = VAR_EDGE_ES(set_id_ndx); extraptr = VAR_ORNT_ES(set_id_ndx); } else if (set_type == EX_FACE_SET) { entryptr = VAR_FACE_FS(set_id_ndx); extraptr = VAR_ORNT_FS(set_id_ndx); } else if (set_type == EX_SIDE_SET) { entryptr = VAR_ELEM_SS(set_id_ndx); extraptr = VAR_SIDE_SS(set_id_ndx); } if (set_type == EX_ELEM_SET) { entryptr = VAR_ELEM_ELS(set_id_ndx); extraptr = NULL; } /* inquire id's of previously defined dimensions and variables */ if ((status = nc_inq_varid(exoid, entryptr, &entry_list_id)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate entry list for %s %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } /* If client doet not pass in an array to store the extra list, don't access it at all */ /* only do extra list for edge, face and side sets */ if (set_extra_list) { if ((status = nc_inq_varid(exoid, extraptr, &extra_list_id)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate extra list for %s %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } /* read in the entry list and extra list arrays unless they are NULL */ if (set_entry_list) { if (ex_int64_status(exoid) & EX_BULK_INT64_API) { status = nc_get_var_longlong(exoid, entry_list_id, set_entry_list); } else { status = nc_get_var_int(exoid, entry_list_id, set_entry_list); } if (status != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get entry list for %s %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } /* only do extra list for edge, face and side sets */ if (set_extra_list) { if (ex_int64_status(exoid) & EX_BULK_INT64_API) { status = nc_get_var_longlong(exoid, extra_list_id, set_extra_list); } else { status = nc_get_var_int(exoid, extra_list_id, set_extra_list); } if (status != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get extra list for %s %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } EX_FUNC_LEAVE(EX_NOERR); }
int ex_put_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id, int64_t offset, int64_t num_to_put, const void_int *set_entry_list, const void_int *set_extra_list) { int dimid, status; int entry_list_id, extra_list_id, set_id_ndx; size_t start[1], count[1]; char errmsg[MAX_ERR_LENGTH]; char * entryptr = NULL; char * extraptr = NULL; EX_FUNC_ENTER(); ex_check_valid_file_id(exoid, __func__); /* first check if any sets are specified */ if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(set_type), &dimid)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %ss defined in file id %d", ex_name_of_object(set_type), exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } /* Lookup index of set id in VAR_*S_IDS array */ set_id_ndx = ex_id_lkup(exoid, set_type, set_id); if (set_id_ndx <= 0) { ex_get_err(NULL, NULL, &status); if (status != 0) { if (status == EX_NULLENTITY) { snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no data allowed for NULL %s %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, EX_NULLENTITY); EX_FUNC_LEAVE(EX_WARN); } snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s id %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } /* setup more pointers based on set_type */ if (set_type == EX_NODE_SET) { entryptr = VAR_NODE_NS(set_id_ndx); extraptr = NULL; } else if (set_type == EX_EDGE_SET) { entryptr = VAR_EDGE_ES(set_id_ndx); extraptr = VAR_ORNT_ES(set_id_ndx); } else if (set_type == EX_FACE_SET) { entryptr = VAR_FACE_FS(set_id_ndx); extraptr = VAR_ORNT_FS(set_id_ndx); } else if (set_type == EX_SIDE_SET) { entryptr = VAR_ELEM_SS(set_id_ndx); extraptr = VAR_SIDE_SS(set_id_ndx); } else if (set_type == EX_ELEM_SET) { entryptr = VAR_ELEM_ELS(set_id_ndx); extraptr = NULL; } /* inquire id's of previously defined variables */ if ((status = nc_inq_varid(exoid, entryptr, &entry_list_id)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate entry list for %s %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } /* write out the entry list and extra list arrays */ if (set_entry_list != NULL || ex_is_parallel(exoid)) { start[0] = offset - 1; count[0] = num_to_put; if (count[0] == 0) { start[0] = 0; } if (ex_int64_status(exoid) & EX_BULK_INT64_API) { status = nc_put_vara_longlong(exoid, entry_list_id, start, count, set_entry_list); } else { status = nc_put_vara_int(exoid, entry_list_id, start, count, set_entry_list); } if (status != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store entry list for %s %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } /* only do for edge, face and side sets */ if (extraptr && (set_extra_list != NULL || ex_is_parallel(exoid))) { if ((status = nc_inq_varid(exoid, extraptr, &extra_list_id)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate extra list for %s %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } start[0] = offset - 1; count[0] = num_to_put; if (count[0] == 0) { start[0] = 0; } if (ex_int64_status(exoid) & EX_BULK_INT64_API) { status = nc_put_vara_longlong(exoid, extra_list_id, start, count, set_extra_list); } else { status = nc_put_vara_int(exoid, extra_list_id, start, count, set_extra_list); } if (status != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store extra list for %s %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } } /* warn if extra data was sent in for node sets and elem sets */ if ((set_type == EX_NODE_SET || set_type == EX_ELEM_SET) && set_extra_list != NULL) { snprintf(errmsg, MAX_ERR_LENGTH, "Warning: extra list was ignored for %s %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, EX_BADPARAM); EX_FUNC_LEAVE(EX_WARN); } EX_FUNC_LEAVE(EX_NOERR); }