| 1 |
/* |
| 2 |
* Copyright(C) 1999-2020 National Technology & Engineering Solutions |
| 3 |
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 4 |
* NTESS, the U.S. Government retains certain rights in this software. |
| 5 |
* |
| 6 |
* See packages/seacas/LICENSE for details |
| 7 |
*/ |
| 8 |
/*****************************************************************************/ |
| 9 |
/*****************************************************************************/ |
| 10 |
/* Function(s) contained in this file: |
| 11 |
* ex_get_eb_info_global() |
| 12 |
***************************************************************************** |
| 13 |
* This function retrieves the global parameters of all the element blocks |
| 14 |
* associated with a geometry. |
| 15 |
***************************************************************************** |
| 16 |
* Variable Index: |
| 17 |
* exoid - The NetCDF ID of an already open NemesisI file. |
| 18 |
* el_blk_ids - Pointer to vector of global element block IDs. |
| 19 |
* el_blk_cnts - Pointer to vector of global element block counts. |
| 20 |
*/ |
| 21 |
/*****************************************************************************/ |
| 22 |
/*****************************************************************************/ |
| 23 |
/*****************************************************************************/ |
| 24 |
|
| 25 |
#include <exodusII.h> // for ex_err, etc |
| 26 |
#include <exodusII_int.h> // for EX_FATAL, etc |
| 27 |
|
| 28 |
int ex_get_eb_info_global(int exoid, void_int *el_blk_ids, void_int *el_blk_cnts) |
| 29 |
{ |
| 30 |
int varid, status; |
| 31 |
|
| 32 |
char errmsg[MAX_ERR_LENGTH]; |
| 33 |
/*-----------------------------Execution begins-----------------------------*/ |
| 34 |
|
| 35 |
EX_FUNC_ENTER(); |
| 36 |
if (exi_check_valid_file_id(exoid, __func__) == EX_FATAL) { |
| 37 |
EX_FUNC_LEAVE(EX_FATAL); |
| 38 |
} |
| 39 |
|
| 40 |
/* Find the variable ID for the element block IDs */ |
| 41 |
if ((status = nc_inq_varid(exoid, VAR_ELBLK_IDS_GLOBAL, &varid)) != NC_NOERR) { |
| 42 |
snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d", |
| 43 |
VAR_ELBLK_IDS_GLOBAL, exoid); |
| 44 |
ex_err_fn(exoid, __func__, errmsg, status); |
| 45 |
|
| 46 |
EX_FUNC_LEAVE(EX_FATAL); |
| 47 |
} |
| 48 |
|
| 49 |
/* Get the global element block IDs */ |
| 50 |
if (ex_int64_status(exoid) & EX_IDS_INT64_API) { |
| 51 |
status = nc_get_var_longlong(exoid, varid, el_blk_ids); |
| 52 |
} |
| 53 |
else { |
| 54 |
status = nc_get_var_int(exoid, varid, el_blk_ids); |
| 55 |
} |
| 56 |
if (status != NC_NOERR) { |
| 57 |
snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d", |
| 58 |
VAR_ELBLK_IDS_GLOBAL, exoid); |
| 59 |
ex_err_fn(exoid, __func__, errmsg, status); |
| 60 |
|
| 61 |
EX_FUNC_LEAVE(EX_FATAL); |
| 62 |
} |
| 63 |
|
| 64 |
/* Find the variable ID for the element block counts */ |
| 65 |
if ((status = nc_inq_varid(exoid, VAR_ELBLK_CNT_GLOBAL, &varid)) != NC_NOERR) { |
| 66 |
snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d", |
| 67 |
VAR_ELBLK_CNT_GLOBAL, exoid); |
| 68 |
ex_err_fn(exoid, __func__, errmsg, status); |
| 69 |
|
| 70 |
EX_FUNC_LEAVE(EX_FATAL); |
| 71 |
} |
| 72 |
|
| 73 |
/* Get the global element block counts */ |
| 74 |
if (ex_int64_status(exoid) & EX_BULK_INT64_API) { |
| 75 |
status = nc_get_var_longlong(exoid, varid, el_blk_cnts); |
| 76 |
} |
| 77 |
else { |
| 78 |
status = nc_get_var_int(exoid, varid, el_blk_cnts); |
| 79 |
} |
| 80 |
if (status != NC_NOERR) { |
| 81 |
snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d", |
| 82 |
VAR_ELBLK_CNT_GLOBAL, exoid); |
| 83 |
ex_err_fn(exoid, __func__, errmsg, status); |
| 84 |
|
| 85 |
EX_FUNC_LEAVE(EX_FATAL); |
| 86 |
} |
| 87 |
EX_FUNC_LEAVE(EX_NOERR); |
| 88 |
} |