📄 exinq.c
字号:
ex_err("ex_inquire",errmsg,exerrval); free (ids); return (EX_FATAL); } if ((status = nc_inq_dimlen (exoid, dimid, &idum)) != NC_NOERR) { *ret_int = 0; exerrval = status; sprintf(errmsg, "Error: failed to get number of nodes in node set %d in file id %d", ids[i],exoid); ex_err("ex_inquire",errmsg,exerrval); free(ids); return (EX_FATAL); } } *ret_int += idum; } free(ids); } break; case EX_INQ_SIDE_SETS: /* returns the number of side sets */ if (ex_get_dimension(exoid, DIM_NUM_SS, "side sets", &ldum, &dimid, NULL) != NC_NOERR) *ret_int = 0; else *ret_int = ldum; break; case EX_INQ_SS_NODE_LEN: /* returns the length of the concatenated side sets node list */ *ret_int = 0; /* default return value */ if (nc_inq_dimid (exoid, DIM_NUM_SS, &dimid) == NC_NOERR) { if ((status = nc_inq_dimlen(exoid, dimid, &num_sets)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get number of side sets in file id %d", exoid); ex_err("ex_inquire",errmsg,exerrval); return (EX_FATAL); } if (!(ids = malloc(num_sets*sizeof(int)))) { exerrval = EX_MEMFAIL; sprintf(errmsg, "Error: failed to allocate memory for side set ids for file id %d", exoid); ex_err("ex_inquire",errmsg,exerrval); return (EX_FATAL); } if (ex_get_side_set_ids (exoid, ids) == EX_FATAL) { sprintf(errmsg, "Error: failed to get side set ids in file id %d", exoid); ex_err("ex_inquire",errmsg,exerrval); free(ids); return (EX_FATAL); } /* allocate space for stat array */ if (!(stat_vals = malloc((int)num_sets*sizeof(int)))) { exerrval = EX_MEMFAIL; free (ids); sprintf(errmsg, "Error: failed to allocate memory for side set status array for file id %d", exoid); ex_err("ex_inquire",errmsg,exerrval); return (EX_FATAL); } /* get variable id of status array */ if ((status = nc_inq_varid (exoid, VAR_SS_STAT, &varid)) == NC_NOERR) { /* if status array exists, use it, otherwise assume, object exists to be backward compatible */ if ((status = nc_get_var_int(exoid, varid, stat_vals)) != NC_NOERR) { exerrval = status; free (ids); free(stat_vals); sprintf(errmsg, "Error: failed to get element block status array from file id %d", exoid); ex_err("ex_inquire",errmsg,exerrval); return (EX_FATAL); } } else /* default: status is true */ for(i=0;i<num_sets;i++) stat_vals[i]=1; /* walk id list, get each side set node length and sum for total */ for (i=0; i<num_sets; i++) { if (stat_vals[i] == 0) /* is this object null? */ continue; if ((status = ex_get_side_set_node_list_len(exoid, ids[i], &tmp_num)) != NC_NOERR) { *ret_int = 0; exerrval = status; sprintf(errmsg, "Error: failed to side set %d node length in file id %d", ids[i],exoid); ex_err("ex_inquire",errmsg,exerrval); free(stat_vals); free(ids); return (EX_FATAL); } *ret_int += tmp_num; } free(stat_vals); free (ids); } break; case EX_INQ_SS_ELEM_LEN: /* returns the length of the concatenated side sets element list */ EX_GET_CONCAT_SET_LEN(ret_int,"side",EX_SIDE_SET,DIM_NUM_SS,VAR_SS_STAT,DIM_NUM_SIDE_SS,0); break; case EX_INQ_SS_DF_LEN: /* returns the length of the concatenated side sets dist factor list */ /* Determine the concatenated side sets distribution factor length: 1. Get the side set ids list. 2. Check see if the dist factor dimension for a side set id exists. 3. If it exists, goto step 4, else set the individual length to zero. 4. Sum the dimension value into the running total length. */ *ret_int = 0; /* first check see if any side sets exist */ if (nc_inq_dimid (exoid, DIM_NUM_SS, &dimid) == NC_NOERR) { if ((status = nc_inq_dimlen (exoid, dimid, &num_sets)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get number of side sets in file id %d", exoid); ex_err("ex_inquire",errmsg,exerrval); return (EX_FATAL); } if (!(ids = malloc(num_sets*sizeof(int)))) { exerrval = EX_MEMFAIL; sprintf(errmsg, "Error: failed to allocate memory for side set ids for file id %d", exoid); ex_err("ex_inquire",errmsg,exerrval); return (EX_FATAL); } if (ex_get_side_set_ids (exoid, ids) == EX_FATAL) { sprintf(errmsg, "Error: failed to get side sets in file id %d", exoid); /* pass back error code from ex_get_side_set_ids (in exerrval) */ ex_err("ex_inquire",errmsg,exerrval); free (ids); return (EX_FATAL); } for (i=0; i<num_sets; i++) { if ((status = nc_inq_dimid (exoid, DIM_NUM_DF_SS(i+1), &dimid)) != NC_NOERR) { if (status == NC_EBADDIM) { ldum = 0; /* this dist factor doesn't exist */ } else { *ret_int = 0; exerrval = status; sprintf(errmsg, "Error: failed to locate number of dist fact for side set %d in file id %d", ids[i], exoid); ex_err("ex_inquire",errmsg,exerrval); free (ids); return (EX_FATAL); } } else { if ((status = nc_inq_dimlen (exoid, dimid, &ldum)) != NC_NOERR) { *ret_int = 0; exerrval = status; sprintf(errmsg, "Error: failed to get number of dist factors in side set %d in file id %d", ids[i], exoid); ex_err("ex_inquire",errmsg,exerrval); free (ids); return (EX_FATAL); } } *ret_int += ldum; } free (ids); } break; case EX_INQ_QA: /* returns the number of QA records */ if (ex_get_dimension(exoid, DIM_NUM_QA, "QA records", &ldum, &dimid, NULL) != NC_NOERR) *ret_int = 0; else *ret_int = ldum; break; case EX_INQ_INFO: /* returns the number of information records */ if (ex_get_dimension(exoid, DIM_NUM_INFO, "info records", &ldum, &dimid, NULL) != NC_NOERR) *ret_int = 0; else *ret_int = ldum; break; case EX_INQ_TIME: /* returns the number of time steps stored in the database */ if (ex_get_dimension(exoid, DIM_TIME, "time dimension", &ldum, &dimid, "ex_inquire") != NC_NOERR) return EX_FATAL; *ret_int = ldum; break; case EX_INQ_EB_PROP: /* returns the number of element block properties */ *ret_int = ex_get_num_props (exoid, EX_ELEM_BLOCK); break; case EX_INQ_NS_PROP: /* returns the number of node set properties */ *ret_int = ex_get_num_props (exoid, EX_NODE_SET); break; case EX_INQ_SS_PROP: /* returns the number of side set properties */ *ret_int = ex_get_num_props (exoid, EX_SIDE_SET); break; case EX_INQ_ELEM_MAP: /* returns the number of element maps */ if (ex_get_dimension(exoid, DIM_NUM_EM, "element maps", &ldum, &dimid, NULL) != NC_NOERR) *ret_int = 0; else *ret_int = ldum; break; case EX_INQ_EM_PROP: /* returns the number of element map properties */ *ret_int = ex_get_num_props (exoid, EX_ELEM_MAP); break; case EX_INQ_NODE_MAP: /* returns the number of node maps */ if (ex_get_dimension(exoid, DIM_NUM_NM, "node maps", &ldum, &dimid, NULL) != NC_NOERR) *ret_int = 0; else *ret_int = ldum; break; case EX_INQ_NM_PROP: /* returns the number of node map properties */ *ret_int = ex_get_num_props (exoid, EX_NODE_MAP); break; case EX_INQ_EDGE: /* returns the number of edges (defined across all edge blocks). */ EX_GET_DIMENSION_VALUE(ret_int, 0, DIM_NUM_EDGE, 1); break; case EX_INQ_EDGE_BLK: /* returns the number of edge blocks. */ EX_GET_DIMENSION_VALUE(ret_int, 0, DIM_NUM_ED_BLK, 1); break; case EX_INQ_EDGE_SETS: /* returns the number of edge sets. */ EX_GET_DIMENSION_VALUE(ret_int, 0, DIM_NUM_ES, 1); break; case EX_INQ_ES_LEN: /* returns the length of the concatenated edge set edge list. */ EX_GET_CONCAT_SET_LEN(ret_int,"edge",EX_EDGE_SET,DIM_NUM_ES,VAR_ES_STAT,DIM_NUM_EDGE_ES,0); break; case EX_INQ_ES_DF_LEN: /* returns the length of the concatenated edge set distribution factor list. */ EX_GET_CONCAT_SET_LEN(ret_int,"edge",EX_EDGE_SET,DIM_NUM_ES,VAR_ES_STAT,DIM_NUM_DF_ES,1); break; case EX_INQ_EDGE_PROP: /* returns the number of integer properties stored for each edge block. This includes the "ID" property. */ *ret_int = ex_get_num_props( exoid, EX_EDGE_BLOCK ); break; case EX_INQ_ES_PROP: /* returns the number of integer properties stored for each edge set.. This includes the "ID" property */ *ret_int = ex_get_num_props( exoid, EX_EDGE_SET ); break; case EX_INQ_FACE: /* returns the number of faces (defined across all face blocks). */ EX_GET_DIMENSION_VALUE(ret_int, 0, DIM_NUM_FACE, 1); break; case EX_INQ_FACE_BLK: /* returns the number of face blocks. */ EX_GET_DIMENSION_VALUE(ret_int, 0, DIM_NUM_FA_BLK, 1); break; case EX_INQ_FACE_SETS: /* returns the number of face sets. */ EX_GET_DIMENSION_VALUE(ret_int, 0, DIM_NUM_FS, 1); break; case EX_INQ_FS_LEN: /* returns the length of the concatenated edge set edge list. */ EX_GET_CONCAT_SET_LEN(ret_int,"face",EX_FACE_SET,DIM_NUM_FS,VAR_FS_STAT,DIM_NUM_FACE_FS,0); break; case EX_INQ_FS_DF_LEN: /* returns the length of the concatenated edge set distribution factor list. */ EX_GET_CONCAT_SET_LEN(ret_int,"face",EX_FACE_SET,DIM_NUM_FS,VAR_FS_STAT,DIM_NUM_DF_FS,1); break; case EX_INQ_FACE_PROP: /* returns the number of integer properties stored for each edge block. This includes the "ID" property. */ *ret_int = ex_get_num_props( exoid, EX_FACE_BLOCK ); break; case EX_INQ_FS_PROP: /* returns the number of integer properties stored for each edge set.. This includes the "ID" property */ *ret_int = ex_get_num_props( exoid, EX_FACE_SET ); break; case EX_INQ_ELEM_SETS: /* returns the number of element sets. */ EX_GET_DIMENSION_VALUE(ret_int, 0, DIM_NUM_ELS, 1); break; case EX_INQ_ELS_LEN: /* returns the length of the concatenated element set element list. */ EX_GET_CONCAT_SET_LEN(ret_int,"element",EX_ELEM_SET,DIM_NUM_ELS,VAR_ELS_STAT,DIM_NUM_ELE_ELS,0); break; case EX_INQ_ELS_DF_LEN: /* returns the length of the concatenated element set distribution factor list. */ EX_GET_CONCAT_SET_LEN(ret_int,"element",EX_ELEM_SET,DIM_NUM_ELS,VAR_ELS_STAT,DIM_NUM_DF_ELS,1); break; case EX_INQ_ELS_PROP: /* returns the number of integer properties stored for each element set. */ *ret_int = ex_get_num_props( exoid, EX_ELEM_SET ); break; case EX_INQ_EDGE_MAP: /* returns the number of edge maps. */ EX_GET_DIMENSION_VALUE(ret_int, 0, DIM_NUM_EDM, 1); break; case EX_INQ_FACE_MAP: /* returns the number of face maps. */ EX_GET_DIMENSION_VALUE(ret_int, 0, DIM_NUM_FAM, 1); break; default: *ret_int = 0; exerrval = EX_FATAL; sprintf(errmsg, "Error: invalid inquiry %d", req_info); ex_err("ex_inquire",errmsg,exerrval); return(EX_FATAL); } return (EX_NOERR);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -