int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_mapb, void_int *node_mape, int processor) { const char *func_name = "ex_get_processor_node_maps"; char ftype[2]; int status, varid, dimid; size_t start[1], count[1]; int64_t varidx[2]; int nmstat; char errmsg[MAX_ERR_LENGTH]; /*-----------------------------Execution begins-----------------------------*/ ex_check_valid_file_id(exoid); exerrval = 0; /* clear error code */ /* Get the file type */ if (ex_get_file_type(exoid, ftype) != EX_NOERR) { exerrval = EX_MSG; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unable to find file type for file ID %d", exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the status of this node map */ if ((status = nc_inq_varid(exoid, VAR_INT_N_STAT, &varid)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d", VAR_INT_N_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (ftype[0] == 'p') { start[0] = 0; } else { start[0] = processor; } if (nc_get_var1_int(exoid, varid, start, &nmstat) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" in file ID %d", VAR_INT_N_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (nmstat == 1) { /* get the index */ if (ex_get_idx(exoid, VAR_NODE_MAP_INT_IDX, varidx, processor) == -1) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_NODE_MAP_INT_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* check if I need to get the dimension */ if (varidx[1] == -1) { if ((status = nc_inq_dimid(exoid, DIM_NUM_INT_NODES, &dimid)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_INT_NODES, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if ((status = nc_inq_dimlen(exoid, dimid, count)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_INT_NODES, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } varidx[1] = count[0]; } if ((status = nc_inq_varid(exoid, VAR_NODE_MAP_INT, &varid)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d", VAR_NODE_MAP_INT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } start[0] = varidx[0]; count[0] = varidx[1] - varidx[0]; if (ex_int64_status(exoid) & EX_MAPS_INT64_API) { status = nc_get_vara_longlong(exoid, varid, start, count, node_mapi); } else { status = nc_get_vara_int(exoid, varid, start, count, node_mapi); } if (status != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d", VAR_NODE_MAP_INT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } } /* End "if (nmstat == 1)" */ /* Get the status of this node map */ if ((status = nc_inq_varid(exoid, VAR_BOR_N_STAT, &varid)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d", VAR_BOR_N_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (ftype[0] == 'p') { start[0] = 0; } else { start[0] = processor; } if (nc_get_var1_int(exoid, varid, start, &nmstat) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file ID %d", VAR_BOR_N_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (nmstat == 1) { /* get the index */ if (ex_get_idx(exoid, VAR_NODE_MAP_BOR_IDX, varidx, processor) == -1) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_NODE_MAP_BOR_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* check if I need to get the dimension */ if (varidx[1] == -1) { if ((status = nc_inq_dimid(exoid, DIM_NUM_BOR_NODES, &dimid)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_BOR_NODES, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if ((status = nc_inq_dimlen(exoid, dimid, count)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_BOR_NODES, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } varidx[1] = count[0]; } if ((status = nc_inq_varid(exoid, VAR_NODE_MAP_BOR, &varid)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d", VAR_NODE_MAP_BOR, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } start[0] = varidx[0]; count[0] = varidx[1] - varidx[0]; if (ex_int64_status(exoid) & EX_MAPS_INT64_API) { status = nc_get_vara_longlong(exoid, varid, start, count, node_mapb); } else { status = nc_get_vara_int(exoid, varid, start, count, node_mapb); } if (status != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d", VAR_NODE_MAP_BOR, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } } /* End "if (nmstat == 1)" */ /* Get the status of this node map */ if ((status = nc_inq_varid(exoid, VAR_EXT_N_STAT, &varid)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d", VAR_EXT_N_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (ftype[0] == 'p') { start[0] = 0; } else { start[0] = processor; } if (nc_get_var1_int(exoid, varid, start, &nmstat) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file ID %d", VAR_EXT_N_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (nmstat == 1) { /* get the index */ if (ex_get_idx(exoid, VAR_NODE_MAP_EXT_IDX, varidx, processor) == -1) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_NODE_MAP_EXT_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* check if I need to get the dimension */ if (varidx[1] == -1) { if ((status = nc_inq_dimid(exoid, DIM_NUM_EXT_NODES, &dimid)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_EXT_NODES, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if ((status = nc_inq_dimlen(exoid, dimid, count)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_EXT_NODES, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } varidx[1] = count[0]; } if ((status = nc_inq_varid(exoid, VAR_NODE_MAP_EXT, &varid)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d", VAR_NODE_MAP_EXT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } start[0] = varidx[0]; count[0] = varidx[1] - varidx[0]; if (ex_int64_status(exoid) & EX_MAPS_INT64_API) { status = nc_get_vara_longlong(exoid, varid, start, count, node_mape); } else { status = nc_get_vara_int(exoid, varid, start, count, node_mape); } if (status != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d", VAR_NODE_MAP_EXT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } } /* End "if (nmstat == 1)" */ return (EX_NOERR); }
int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_node_cnts, void_int *elem_cmap_ids, void_int *elem_cmap_elem_cnts, int64_t processor ) { const char *func_name="ex_put_cmap_params"; size_t num_n_comm_maps, num_e_comm_maps; size_t ncnt_cmap, ecnt_cmap; size_t icm; int varid, dimid[1], n_varid, e_varid, status; int n_varid_idx, e_varid_idx; size_t start[1]; char ftype[2]; int64_t nl_ncnt_cmap, nl_ecnt_cmap; int nmstat; char errmsg[MAX_ERR_LENGTH]; int index_type = NC_INT; int id_type = NC_INT; int format; nc_inq_format(exoid, &format); if ((ex_int64_status(exoid) & EX_BULK_INT64_DB) || (format == NC_FORMAT_NETCDF4)) { index_type = NC_INT64; } if (ex_int64_status(exoid) & EX_IDS_INT64_DB) { id_type = NC_INT64; } /*-----------------------------Execution begins-----------------------------*/ exerrval = 0; /* clear error code */ /* ** with the new database format, this function sould only ** be used for writing a parallel file */ /* Get the file type */ if (ex_get_file_type(exoid, ftype) != EX_NOERR) { exerrval = EX_MSG; sprintf(errmsg, "Error: failed to get file type from file ID %d\n", exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* make sure that this is a parallel file */ if (ftype[0] != 'p') { exerrval = EX_MSG; sprintf(errmsg, "Error: function for use with parallel files only, file ID %d\n", exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Put NetCDF file into define mode */ if ((status = nc_redef(exoid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to file ID %d into define mode", exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Check to see if there are nodal communications maps in the file */ if ((status = nc_inq_dimid(exoid, DIM_NUM_N_CMAPS, &dimid[0])) != NC_NOERR) { num_n_comm_maps = 0; } else { if ((status = nc_inq_dimlen(exoid, dimid[0], &num_n_comm_maps)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_N_CMAPS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } } /* * Add dimensions for the size of the number of nodal * communication maps. */ if (num_n_comm_maps > 0) { /* add the communications data index variable */ if ((status = nc_def_var(exoid, VAR_N_COMM_DATA_IDX, index_type, 1, dimid, &n_varid_idx)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to add variable \"%s\" in file ID %d", VAR_N_COMM_DATA_IDX, exoid); ex_err(func_name, errmsg, exerrval); /* Leave define mode before returning */ ex_leavedef(exoid, func_name); return (EX_FATAL); } /* Add dimensions for all of the nodal communication maps */ ncnt_cmap = 0; if (ex_int64_status(exoid) & EX_BULK_INT64_API) { for(icm=0; icm < num_n_comm_maps; icm++) { ncnt_cmap += ((int64_t*)node_cmap_node_cnts)[icm]; } } else { for(icm=0; icm < num_n_comm_maps; icm++) { ncnt_cmap += ((int*)node_cmap_node_cnts)[icm]; } } if ((status = nc_def_dim(exoid, DIM_NCNT_CMAP, ncnt_cmap, &dimid[0])) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to add dimension for \"%s\" in file ID %d", DIM_NCNT_CMAP, exoid); ex_err(func_name, errmsg, exerrval); /* Leave define mode before returning */ ex_leavedef(exoid, func_name); return (EX_FATAL); } /* Define variables for the nodal IDS and processor vectors */ if ((status = nc_def_var(exoid, VAR_N_COMM_NIDS, id_type, 1, dimid, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to add variable \"%s\" in file ID %d", VAR_N_COMM_NIDS, exoid); ex_err(func_name, errmsg, exerrval); /* Leave define mode before returning */ ex_leavedef(exoid, func_name); return (EX_FATAL); } ex_compress_variable(exoid, varid, 1); if ((status = nc_def_var(exoid, VAR_N_COMM_PROC, NC_INT, 1, dimid, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to add variable \"%s\" in file ID %d", VAR_N_COMM_PROC, exoid); ex_err(func_name, errmsg, exerrval); /* Leave define mode before returning */ ex_leavedef(exoid, func_name); return (EX_FATAL); } ex_compress_variable(exoid, varid, 1); } /* End "if (num_n_comm_maps > 0)" */ /* Check to see if there are elemental communications maps in the file */ if ((status = nc_inq_dimid(exoid, DIM_NUM_E_CMAPS, &dimid[0])) != NC_NOERR) { num_e_comm_maps = 0; } else{ if ((status = nc_inq_dimlen(exoid, dimid[0], &num_e_comm_maps)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_E_CMAPS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } } /* * Add dimensions for the size of the number of elemental * communication maps. */ if (num_e_comm_maps > 0) { /* add the communications data index variable */ if ((status = nc_def_var(exoid, VAR_E_COMM_DATA_IDX, index_type, 1, dimid, &e_varid_idx)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to add variable \"%s\" in file ID %d", VAR_E_COMM_DATA_IDX, exoid); ex_err(func_name, errmsg, exerrval); /* Leave define mode before returning */ ex_leavedef(exoid, func_name); return (EX_FATAL); } /* Add dimensions for each of the nodal communication maps */ ecnt_cmap = 0; if (ex_int64_status(exoid) & EX_BULK_INT64_API) { for(icm=0; icm < num_e_comm_maps; icm++) ecnt_cmap += ((int64_t*)elem_cmap_elem_cnts)[icm]; } else { for(icm=0; icm < num_e_comm_maps; icm++) ecnt_cmap += ((int*)elem_cmap_elem_cnts)[icm]; } if ((status = nc_def_dim(exoid, DIM_ECNT_CMAP, ecnt_cmap, &dimid[0])) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to add dimension for \"%s\" in file ID %d", DIM_ECNT_CMAP, exoid); ex_err(func_name, errmsg, exerrval); /* Leave define mode before returning */ ex_leavedef(exoid, func_name); return (EX_FATAL); } /* Define variables for the element IDS and processor vectors */ if ((status = nc_def_var(exoid, VAR_E_COMM_EIDS, id_type, 1, dimid, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to add variable \"%s\" in file ID %d", VAR_E_COMM_EIDS, exoid); ex_err(func_name, errmsg, exerrval); /* Leave define mode before returning */ ex_leavedef(exoid, func_name); return (EX_FATAL); } ex_compress_variable(exoid, varid, 1); if ((status = nc_def_var(exoid, VAR_E_COMM_PROC, NC_INT, 1, dimid, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to add variable \"%s\" in file ID %d", VAR_E_COMM_PROC, exoid); ex_err(func_name, errmsg, exerrval); /* Leave define mode before returning */ ex_leavedef(exoid, func_name); return (EX_FATAL); } ex_compress_variable(exoid, varid, 1); if ((status = nc_def_var(exoid, VAR_E_COMM_SIDS, NC_INT, 1, dimid, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to add variable \"%s\" in file ID %d", VAR_E_COMM_SIDS, exoid); ex_err(func_name, errmsg, exerrval); /* Leave define mode before returning */ ex_leavedef(exoid, func_name); return (EX_FATAL); } ex_compress_variable(exoid, varid, 1); } /* End "if (num_e_comm_maps > 0)" */ /* Exit define mode */ ex_leavedef(exoid, func_name); /* Set the status of the nodal communication maps */ if (num_n_comm_maps > 0) { if ((status = nc_inq_varid(exoid, VAR_N_COMM_STAT, &n_varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" in file ID %d", VAR_N_COMM_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } nl_ncnt_cmap = 0; /* reset this for index */ for(icm=0; icm < num_n_comm_maps; icm++) { size_t ncnc; if (ex_int64_status(exoid) & EX_BULK_INT64_API) { ncnc = ((int64_t*)node_cmap_node_cnts)[icm]; } else { ncnc = ((int*)node_cmap_node_cnts)[icm]; } start[0] = icm; if (ncnc > 0) nmstat = 1; else nmstat = 0; if ((status = nc_put_var1_int(exoid, n_varid, start, &nmstat)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: unable to output variable in file ID %d", exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* increment to the next starting position */ nl_ncnt_cmap += ncnc; /* fill the cmap data index */ if ((status = nc_put_var1_longlong(exoid, n_varid_idx, start, (long long*)&nl_ncnt_cmap)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to output int elem map index in file ID %d", exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } } /* End "for(icm=0; icm < num_n_comm_maps; icm++)" */ /* Get the variable ID for the comm map IDs vector */ if ((status = nc_inq_varid(exoid, VAR_N_COMM_IDS, &n_varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" in file ID %d", VAR_N_COMM_IDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Output the nodal comm map IDs */ if (ex_int64_status(exoid) & EX_IDS_INT64_API) { status = nc_put_var_longlong(exoid, n_varid, node_cmap_ids); } else { status = nc_put_var_int(exoid, n_varid, node_cmap_ids); } if (status != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to output variable in file ID %d", exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } } /* End "if (num_n_comm_maps > 0)" */ /* Set the status of the elemental communication maps */ if (num_e_comm_maps > 0) { /* Get variable ID for elemental status vector */ if ((status = nc_inq_varid(exoid, VAR_E_COMM_STAT, &e_varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" in file ID %d", VAR_E_COMM_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } nl_ecnt_cmap = 0; /* reset this for index */ for(icm=0; icm < num_e_comm_maps; icm++) { size_t ecec; if (ex_int64_status(exoid) & EX_BULK_INT64_API) { ecec = ((int64_t*)elem_cmap_elem_cnts)[icm]; } else { ecec = ((int*)elem_cmap_elem_cnts)[icm]; } start[0] = icm; if (ecec > 0) nmstat = 1; else nmstat = 0; if ((status = nc_put_var1_int(exoid, e_varid, start, &nmstat)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: unable to output variable in file ID %d", exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* increment to the next starting position */ nl_ecnt_cmap += ecec; /* fill the cmap data index */ if ((status = nc_put_var1_longlong(exoid, e_varid_idx, start, (long long*)&nl_ecnt_cmap)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to output int elem map index in file ID %d", exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } } /* End "for(icm=0; icm < num_e_comm_maps; icm++)" */ /* Get the variable ID for the elemental comm map IDs vector */ if ((status = nc_inq_varid(exoid, VAR_E_COMM_IDS, &e_varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" in file ID %d", VAR_E_COMM_IDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Output the elemental comm map IDs */ if (ex_int64_status(exoid) & EX_IDS_INT64_API) { status = nc_put_var_longlong(exoid, e_varid, elem_cmap_ids); } else { status = nc_put_var_int(exoid, e_varid, elem_cmap_ids); } if (status != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to output variable in file ID %d", exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } } /* End "if (num_e_comm_maps > 0)" */ return (EX_NOERR); }
int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_mapb, int processor ) { const char *func_name="ex_get_processor_elem_maps"; char ftype[2]; int dimid, varid, status; size_t start[1], count[1]; int64_t varidx[2]; int emstat; char errmsg[MAX_ERR_LENGTH]; /* Get the file type */ if (ex_get_file_type(exoid, ftype) != EX_NOERR) { exerrval = EX_MSG; sprintf(errmsg, "Error: unable to find file type for file ID %d", exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Check the status of the internal element map */ if ((status = nc_inq_varid(exoid, VAR_INT_E_STAT, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" in file ID %d", VAR_INT_E_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (ftype[0] == 'p') start[0] = 0; else start[0] = processor; if ((status = nc_get_var1_int(exoid, varid, start, &emstat)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get status for \"%s\" from file ID %d", VAR_INT_E_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (emstat == 1) { /* get the index */ if (ex_get_idx(exoid, VAR_ELEM_MAP_INT_IDX, varidx, processor) == -1) { exerrval = status; sprintf(errmsg, "Error: failed to find index variable, \"%s\", in file ID %d", VAR_ELEM_MAP_INT_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (varidx[1] == -1) { /* Get the size of the internal element map */ if ((status = nc_inq_dimid(exoid, DIM_NUM_INT_ELEMS, &dimid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_INT_ELEMS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if ((status = nc_inq_dimlen(exoid, dimid, count)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_INT_ELEMS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } varidx[1] = count[0]; } /* Get the map */ if ((status = nc_inq_varid(exoid, VAR_ELEM_MAP_INT, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" in file ID %d", VAR_ELEM_MAP_INT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } start[0] = varidx[0]; count[0] = varidx[1] - varidx[0]; if (ex_int64_status(exoid) & EX_MAPS_INT64_API) { status = nc_get_vara_longlong(exoid, varid, start, count, elem_mapi); } else { status = nc_get_vara_int(exoid, varid, start, count, elem_mapi); } if (status != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get variable \"%s\" from file ID %d", VAR_ELEM_MAP_INT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } } /* End "if (emstat == 1)" */ /* Check the status of the internal element map */ if ((status = nc_inq_varid(exoid, VAR_BOR_E_STAT, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" in file ID %d", VAR_BOR_E_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (ftype[0] == 'p') start[0] = 0; else start[0] = processor; if ((status = nc_get_var1_int(exoid, varid, start, &emstat)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get status for \"%s\" from file ID %d", VAR_INT_E_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (emstat == 1) { /* get the index */ if (ex_get_idx(exoid, VAR_ELEM_MAP_BOR_IDX, varidx, processor) == -1) { exerrval = status; sprintf(errmsg, "Error: failed to find index variable, \"%s\", in file ID %d", VAR_ELEM_MAP_BOR_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (varidx[1] == -1) { /* Get the size of the border element map */ if ((status = nc_inq_dimid(exoid, DIM_NUM_BOR_ELEMS, &dimid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_BOR_ELEMS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if ((status = nc_inq_dimlen(exoid, dimid, count)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_BOR_ELEMS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } varidx[1] = count[0]; } /* Get the map */ if ((status = nc_inq_varid(exoid, VAR_ELEM_MAP_BOR, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" in file ID %d", VAR_ELEM_MAP_BOR, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } start[0] = varidx[0]; count[0] = varidx[1] - varidx[0]; if (ex_int64_status(exoid) & EX_MAPS_INT64_API) { status = nc_get_vara_longlong(exoid, varid, start, count, elem_mapb); } else { status = nc_get_vara_int(exoid, varid, start, count, elem_mapb); } if (status != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get variable \"%s\" from file ID %d", VAR_ELEM_MAP_BOR, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } } /* End "if (emstat == 1)" */ return (EX_NOERR); }
int ex_get_init_info(int exoid, int *num_proc, int *num_proc_in_f, char *ftype ) { const char *func_name="ex_get_init_info"; int dimid, status; size_t ltempsv; char errmsg[MAX_ERR_LENGTH]; /*-----------------------------Execution begins-----------------------------*/ exerrval = 0; /* clear error code */ /* Get the file type */ if (ex_get_file_type(exoid, ftype) != EX_NOERR) { exerrval = EX_MSG; sprintf(errmsg, "Error: failed to get file type for file ID %d", exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if ((status = nc_inq_dimid(exoid, DIM_NUM_PROCS, &dimid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_PROCS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the value of the number of processors */ if ((status = nc_inq_dimlen(exoid, dimid, <empsv)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_PROCS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } *num_proc = ltempsv; /* Get the dimension ID of processors that have info in this file */ if ((status = nc_inq_dimid(exoid, DIM_NUM_PROCS_F, &dimid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_PROCS_F, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the value of the number of processors that have info in this file */ if ((status = nc_inq_dimlen(exoid, dimid, <empsv)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_PROCS_F, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } *num_proc_in_f = ltempsv; return (EX_NOERR); }