int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_int *proc_ids, int processor ) { const char *func_name="ex_put_node_cmap"; int map_idx, varid, dimid, status; size_t start[1], count[1], ret_val; int64_t varidx[2]; int value; char errmsg[MAX_ERR_LENGTH]; /*-----------------------------Execution begins-----------------------------*/ exerrval = 0; /* clear error code */ /* get the index for the comm map information variables */ if (ex_get_idx(exoid, VAR_N_COMM_INFO_IDX, varidx, processor) == -1) { sprintf(errmsg, "Error: failed to find index variable, \"%s\", in file ID %d", VAR_N_COMM_INFO_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the index for this map_id */ if ((map_idx=ne_id_lkup(exoid, VAR_N_COMM_IDS, varidx, map_id)) == -1) { sprintf(errmsg, "Error: failed to find index for variable \"%s\" in file ID %d", VAR_N_COMM_IDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* * Find out if this is a NULL comm map by checking it's entry in * the status vector. */ if ((status = nc_inq_varid(exoid, VAR_N_COMM_STAT, &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); } start[0] = map_idx; if ((status = nc_get_var1_int(exoid, varid, start, &value)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: unable to get variable \"%s\" from file ID %d", VAR_N_COMM_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (value == 0) return(EX_NOERR); /* NULL set */ /* now I need to get the comm map data index */ if (ex_get_idx(exoid, VAR_N_COMM_DATA_IDX, varidx, map_idx) == -1) { exerrval = status; sprintf(errmsg, "Error: failed to find index variable, \"%s\", in file ID %d", VAR_N_COMM_DATA_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* check if I need to get the dimension of the cmap data */ if (varidx[1] == -1) { /* Get the size of the comm maps */ if ((status = nc_inq_dimid(exoid, DIM_NCNT_CMAP, &dimid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get dimension ID for \"%s\" in file ID %d", DIM_NCNT_CMAP, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if ((status = nc_inq_dimlen(exoid, dimid, &ret_val)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find length of dimension \"%s\" in file ID %d", DIM_NCNT_CMAP, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } varidx[1] = ret_val; } /* "if (varidx[1]==-1)" */ start[0] = varidx[0]; count[0] = varidx[1] - varidx[0]; /* Output the node IDs for this comm map */ if ((status = nc_inq_varid(exoid, VAR_N_COMM_NIDS, &varid )) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" in file ID %d", VAR_N_COMM_NIDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (ex_int64_status(exoid) & EX_BULK_INT64_API) { status = nc_put_vara_longlong(exoid, varid, start, count, node_ids); } else { status = nc_put_vara_int(exoid, varid, start, count, node_ids); } if (status != NC_NOERR) { fprintf(stderr, "Start, Count = %lu\t%lu\n", (unsigned long)start[0], (unsigned long)count[0]); exerrval = status; sprintf(errmsg, "Error: failed to output vector \"%s\" in file ID %d", VAR_N_COMM_NIDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Output the processor IDs for this map */ if ((status = nc_inq_varid(exoid, VAR_N_COMM_PROC, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" in file ID %d", VAR_N_COMM_PROC, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (ex_int64_status(exoid) & EX_BULK_INT64_API) { status = nc_put_vara_longlong(exoid, varid, start, count, proc_ids); } else { status = nc_put_vara_int(exoid, varid, start, count, proc_ids); } if (status != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to output variable \"%s\" in file ID %d", VAR_N_COMM_PROC, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } return (EX_NOERR); }
int ex_get_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_int *side_ids, void_int *proc_ids, int processor) { const char *func_name = "ex_get_elem_cmap"; int map_idx, dimid, varid[3], status; size_t start[1], count[1]; int64_t varidx[2]; char errmsg[MAX_ERR_LENGTH]; /*-----------------------------Execution begins-----------------------------*/ exerrval = 0; /* clear error code */ /* get the cmap information variables index */ if (ex_get_idx(exoid, VAR_E_COMM_INFO_IDX, varidx, processor) == -1) { exerrval = -1; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_E_COMM_INFO_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* * no need to check if the second index is -1 that is handled * in ne_id_lkup, where the dimension must be looked up anyways */ /* Get the index of the elemental comm map with the given ID */ if ((map_idx = ne_id_lkup(exoid, VAR_E_COMM_IDS, varidx, map_id)) < 0) { exerrval = EX_MSG; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find elemental comm map with ID %" PRId64 " in file \ ID %d", map_id, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* get the cmap data variables index for this map */ if (ex_get_idx(exoid, VAR_E_COMM_DATA_IDX, varidx, map_idx) == -1) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_E_COMM_DATA_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (varidx[1] == -1) { /* Get the dimension of this elemental communication map */ if ((status = nc_inq_dimid(exoid, DIM_ECNT_CMAP, &dimid)) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_ECNT_CMAP, 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_ECNT_CMAP, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } varidx[1] = count[0]; } /* Get the variable ID for the elemental comm map node IDs */ if ((status = nc_inq_varid(exoid, VAR_E_COMM_EIDS, &varid[0])) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d", VAR_E_COMM_EIDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the variable ID for the elemental side set IDs */ if ((status = nc_inq_varid(exoid, VAR_E_COMM_SIDS, &varid[1])) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d", VAR_E_COMM_SIDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the variable ID for the elemental comm map processor IDs */ if ((status = nc_inq_varid(exoid, VAR_E_COMM_PROC, &varid[2])) != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d", VAR_E_COMM_PROC, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the elemental comm map element IDs */ start[0] = varidx[0]; count[0] = varidx[1] - varidx[0]; if (ex_int64_status(exoid) & EX_BULK_INT64_API) { status = nc_get_vara_longlong(exoid, varid[0], start, count, elem_ids); } else { status = nc_get_vara_int(exoid, varid[0], start, count, elem_ids); } if (status != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d", VAR_E_COMM_EIDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the elemental comm map side IDs */ if (ex_int64_status(exoid) & EX_BULK_INT64_API) { status = nc_get_vara_longlong(exoid, varid[1], start, count, side_ids); } else { status = nc_get_vara_int(exoid, varid[1], start, count, side_ids); } if (status != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d", VAR_E_COMM_SIDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the elemental comm map processor IDs */ if (ex_int64_status(exoid) & EX_BULK_INT64_API) { status = nc_get_vara_longlong(exoid, varid[2], start, count, proc_ids); } else { status = nc_get_vara_int(exoid, varid[2], start, count, proc_ids); } if (status != NC_NOERR) { exerrval = status; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d", VAR_E_COMM_PROC, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } return (EX_NOERR); }
int ex_get_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, int processor ) { const char *func_name="ex_get_cmap_params"; size_t cnt, num_n_comm_maps, num_e_comm_maps, start[1], count[1]; int64_t cmap_info_idx[2], cmap_data_idx[2]; int nmstat; int status, map_idx, varid, dimid; char errmsg[MAX_ERR_LENGTH]; /*-----------------------------Execution begins-----------------------------*/ exerrval = 0; /* clear error code */ /*****************************************************************************/ /*****************************************************************************/ /* Nodal communication map(s) */ /*****************************************************************************/ /*****************************************************************************/ /* get the cmap information variables index */ if (ex_get_idx(exoid, VAR_N_COMM_INFO_IDX, cmap_info_idx, processor) == -1) { sprintf(errmsg, "Error: failed to find index variable, \"%s\", in file ID %d", VAR_N_COMM_INFO_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the number of nodal communications maps in the file */ if ((status = nc_inq_dimid(exoid, DIM_NUM_N_CMAPS, &dimid)) == NC_NOERR) { /* check if I need to get the dimension of the nodal comm map */ if (cmap_info_idx[1] == -1) { 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_N_CMAPS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* set the end value for the node map */ cmap_info_idx[1] = count[0]; } /* End "if (cmap_info_idx[1] == -1) */ num_n_comm_maps = cmap_info_idx[1] - cmap_info_idx[0]; if (num_n_comm_maps > 0) { count[0] = num_n_comm_maps; /* Get the variable ID for the vector of nodal comm map IDs */ if ((status = nc_inq_varid(exoid, VAR_N_COMM_IDS, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get variable ID for \"%s\" in file ID %d", VAR_N_COMM_IDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the vector of nodal communication map IDs */ if (node_cmap_ids != NULL) { start[0] = cmap_info_idx[0]; if (ex_int64_status(exoid) & EX_IDS_INT64_API) { status = nc_get_vara_longlong(exoid, varid, start, count, node_cmap_ids); } else { status = nc_get_vara_int(exoid, varid, start, count, node_cmap_ids); } if (status != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get variable \"%s\" from file ID %d", VAR_N_COMM_IDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if ((status = nc_inq_varid(exoid, VAR_N_COMM_STAT, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" from file ID %d", VAR_N_COMM_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (node_cmap_node_cnts != NULL) { /* Get the node counts in each of the nodal communication maps */ for(cnt=0; cnt < num_n_comm_maps; cnt++) { int64_t cmap_id; if (ex_int64_status(exoid) & EX_IDS_INT64_API) { cmap_id = ((int64_t*)node_cmap_ids)[cnt]; } else { cmap_id = ((int*)node_cmap_ids)[cnt]; } if ((map_idx=ne_id_lkup(exoid, VAR_N_COMM_IDS, cmap_info_idx, cmap_id)) < 0) { exerrval = EX_MSG; sprintf(errmsg, "Error: failed to find nodal comm map with ID %"PRId64" in file ID %d", cmap_id, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Check the status of the node map */ start[0] = map_idx; if ((status = nc_get_var1_int(exoid, varid, start, &nmstat)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get status for \"%s\" from file ID %d", VAR_N_COMM_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (nmstat == 1) { /* get the cmap information variables index */ if (ex_get_idx(exoid, VAR_N_COMM_DATA_IDX, cmap_data_idx, map_idx) == -1) { exerrval = status; sprintf(errmsg, "Error: failed to find index variable, \"%s\", in file ID %d", VAR_N_COMM_DATA_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (cmap_data_idx[1] == -1) { /* * Find the dimension ID of the variable containing the * node count */ if ((status = nc_inq_dimid(exoid, DIM_NCNT_CMAP, &dimid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find dimension ID for \"%s\" in file ID %d", DIM_NCNT_CMAP, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Find the value of the number of nodes in this nodal comm map */ 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_NCNT_CMAP, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } cmap_data_idx[1] = count[0]; } if (ex_int64_status(exoid) & EX_BULK_INT64_API) { ((int64_t*)node_cmap_node_cnts)[cnt] = cmap_data_idx[1] - cmap_data_idx[0]; } else { ((int*)node_cmap_node_cnts)[cnt] = cmap_data_idx[1] - cmap_data_idx[0]; } } else if (ex_int64_status(exoid) & EX_BULK_INT64_API) { ((int64_t*)node_cmap_node_cnts)[cnt] = 0; } else { ((int*)node_cmap_node_cnts)[cnt] = 0; } } /* "for(cnt=0; cnt < num_n_comm_maps; cnt++)" */ } /* "if (node_cmap_node_cnts != NULL)" */ } /* "if (node_cmap_ids != NULL)" */ } /* "if (num_n_comm_maps > 0)" */ } /* End "if ((dimid = nc_inq_dimid(exoid, DIM_NUM_N_CMAPS)) != -1)" */ /*****************************************************************************/ /*****************************************************************************/ /* Elemental communication map(s) */ /*****************************************************************************/ /*****************************************************************************/ /* get the cmap information variables index */ if (ex_get_idx(exoid, VAR_E_COMM_INFO_IDX, cmap_info_idx, processor) == -1) { exerrval = status; sprintf(errmsg, "Error: failed to find index variable, \"%s\", in file ID %d", VAR_E_COMM_INFO_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the number of elemental communications maps in the file */ if ((status = nc_inq_dimid(exoid, DIM_NUM_E_CMAPS, &dimid)) == NC_NOERR) { /* check if I need to get the dimension of the nodal comm map */ if (cmap_info_idx[1] == -1) { 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_E_CMAPS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* set the end value for the node map */ cmap_info_idx[1] = count[0]; } /* End "if (cmap_info_idx[1] == -1) */ num_e_comm_maps = cmap_info_idx[1] - cmap_info_idx[0]; if (num_e_comm_maps > 0) { count[0] = num_e_comm_maps; /* Get the variable ID for the vector of nodal comm map IDs */ if ((status = nc_inq_varid(exoid, VAR_E_COMM_IDS, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get variable ID for \"%s\" in file ID %d", VAR_E_COMM_IDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the vector of elemental communication map IDs */ if (elem_cmap_ids != NULL) { start[0] = cmap_info_idx[0]; if (ex_int64_status(exoid) & EX_IDS_INT64_API) { status = nc_get_vara_longlong(exoid, varid, start, count, elem_cmap_ids); } else { status = nc_get_vara_int(exoid, varid, start, count, elem_cmap_ids); } if (status != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get variable \"%s\" from file ID %d", VAR_E_COMM_IDS, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if ((status = nc_inq_varid(exoid, VAR_E_COMM_STAT, &varid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" from file ID %d", VAR_E_COMM_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (elem_cmap_elem_cnts != NULL) { /* * Get the element counts in each of the elemental * communication maps */ for(cnt=0; cnt < num_e_comm_maps; cnt++) { int64_t cmap_id; if (ex_int64_status(exoid) & EX_IDS_INT64_API) { cmap_id = ((int64_t*)elem_cmap_ids)[cnt]; } else { cmap_id = ((int*)elem_cmap_ids)[cnt]; } if ((map_idx=ne_id_lkup(exoid, VAR_E_COMM_IDS, cmap_info_idx, cmap_id)) < 0) { exerrval = EX_MSG; sprintf(errmsg, "Error: failed to find elemental comm map with ID %"PRId64" in file ID %d", cmap_id, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Check the status of the requested elemental map */ start[0] = map_idx; if ((status = nc_get_var1_int(exoid, varid, start, &nmstat)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get status for \"%s\" from file ID %d", VAR_E_COMM_STAT, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (nmstat == 1) { /* get the cmap information variables index */ if (ex_get_idx(exoid, VAR_E_COMM_DATA_IDX, cmap_data_idx, map_idx) == -1) { exerrval = status; sprintf(errmsg, "Error: failed to find index variable, \"%s\", in file ID %d", VAR_E_COMM_DATA_IDX, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (cmap_data_idx[1] == -1) { /* * Find the dimension ID of the variable containing the * element count */ if ((status = nc_inq_dimid(exoid, DIM_ECNT_CMAP, &dimid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find dimension ID for \"%s\" in file ID %d", DIM_ECNT_CMAP, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* * Find the value of the number of elements in this elemental * comm map */ 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_ECNT_CMAP, exoid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } cmap_data_idx[1] = count[0]; } if (ex_int64_status(exoid) & EX_BULK_INT64_API) { ((int64_t*)elem_cmap_elem_cnts)[cnt] = cmap_data_idx[1] - cmap_data_idx[0]; } else { ((int*)elem_cmap_elem_cnts)[cnt] = cmap_data_idx[1] - cmap_data_idx[0]; } } else if (ex_int64_status(exoid) & EX_BULK_INT64_API) { ((int64_t*)elem_cmap_elem_cnts)[cnt] = 0; } else { ((int*)elem_cmap_elem_cnts)[cnt] = 0; } } /* "for(cnt=0; cnt < num_e_comm_maps; cnt++)" */ } /* "if (elem_cmap_elem_cnts != NULL)" */ } /* "if (elem_cmap_ids != NULL)" */ } /* "if (num_e_comm_maps > 0)" */ } /* End "if ((dimid = nc_inq_dimid(exoid, DIM_NUM_E_CMAPS(processor))) != -1)" */ return (EX_NOERR); }
int ne_get_node_cmap(int neid, int map_id, int *node_ids, int *proc_ids, int processor ) { char *func_name="ne_get_node_cmap"; int map_idx, dimid, varid[2], status; size_t start[1], count[1]; size_t varidx[2]; char errmsg[MAX_ERR_LENGTH]; exerrval = 0; /* clear error code */ /* get the cmap information variables index */ if (ne_get_idx(neid, VAR_N_COMM_INFO_IDX, varidx, processor) == -1) { sprintf(errmsg, "Error: failed to find index variable, \"%s\", in file ID %d", VAR_N_COMM_INFO_IDX, neid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* * no need to check if the second index is -1 that is handled * in ne_id_lkup, where the dimension must be looked up anyways */ /* Get the index of the nodal comm map with the given ID */ if ((map_idx=ne_id_lkup(neid, VAR_N_COMM_IDS, varidx, map_id)) < 0) { exerrval = EX_MSG; sprintf(errmsg, "Error: failed to find nodal comm map with ID %d in file ID %d", map_id, neid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* get the cmap data variables index for this map */ if (ne_get_idx(neid, VAR_N_COMM_DATA_IDX, varidx, map_idx) == -1) { sprintf(errmsg, "Error: failed to find index variable, \"%s\", in file ID %d", VAR_N_COMM_DATA_IDX, neid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if (varidx[1] == -1) { /* Get the dimension of this nodal communication map */ if ((status = nc_inq_dimid(neid, DIM_NCNT_CMAP, &dimid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find dimension ID for \"%s\" in file ID %d", DIM_NCNT_CMAP, neid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } if ((status = nc_inq_dimlen(neid, dimid,count)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find length of dimension \"%s\" in file ID %d", DIM_NCNT_CMAP, neid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } varidx[1] = count[0]; } /* Get the variable ID for the nodal comm map node IDs */ if ((status = nc_inq_varid(neid, VAR_N_COMM_NIDS, &varid[0])) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" in file ID %d", VAR_N_COMM_NIDS, neid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the variable ID for the nodal comm map processor IDs */ if ((status = nc_inq_varid(neid, VAR_N_COMM_PROC, &varid[1])) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to find variable ID for \"%s\" in file ID %d", VAR_N_COMM_PROC, neid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the nodal comm map node IDs */ start[0] = varidx[0]; count[0] = varidx[1] - varidx[0]; status = nc_get_vara_int(neid, varid[0], start, count, node_ids); if (status != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get variable \"%s\" from file ID %d", VAR_N_COMM_NIDS, neid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } /* Get the nodal comm map processor IDs */ status = nc_get_vara_int(neid, varid[1], start, count, proc_ids); if (status != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to get variable \"%s\" from file ID %d", VAR_N_COMM_PROC, neid); ex_err(func_name, errmsg, exerrval); return (EX_FATAL); } return (EX_NOERR); }