| 1 |
/* |
| 2 |
* Copyright(C) 1999-2021 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 |
#include "exodusII.h" |
| 10 |
#include <inttypes.h> |
| 11 |
#include <stdio.h> |
| 12 |
#include <stdlib.h> |
| 13 |
#include <string.h> |
| 14 |
|
| 15 |
#define STRINGIFY(x) #x |
| 16 |
#define TOSTRING(x) STRINGIFY(x) |
| 17 |
|
| 18 |
#define EXCHECK(funcall) \ |
| 19 |
do { \ |
| 20 |
error = (funcall); \ |
| 21 |
printf("after %s, error = %d\n", TOSTRING(funcall), error); \ |
| 22 |
if (error != EX_NOERR) { \ |
| 23 |
fprintf(stderr, "Error calling %s\n", TOSTRING(funcall)); \ |
| 24 |
ex_close(exoid); \ |
| 25 |
exit(-1); \ |
| 26 |
} \ |
| 27 |
} while (0) |
| 28 |
|
| 29 |
int main(int argc, char **argv) |
| 30 |
{ |
| 31 |
int exoid; |
| 32 |
int error; |
| 33 |
int CPU_word_size; |
| 34 |
int IO_word_size; |
| 35 |
int idum; |
| 36 |
|
| 37 |
float version; |
| 38 |
float fdum; |
| 39 |
|
| 40 |
char *cdum = NULL; |
| 41 |
|
| 42 |
CPU_word_size = 0; /* sizeof(float) */ |
| 43 |
IO_word_size = 0; /* use what is stored in file */ |
| 44 |
|
| 45 |
ex_opts(EX_VERBOSE | EX_ABORT); |
| 46 |
|
| 47 |
/* open EXODUS II files */ |
| 48 |
exoid = ex_open("test-assembly.exo", /* filename path */ |
| 49 |
EX_WRITE, /* access mode = READ */ |
| 50 |
&CPU_word_size, /* CPU word size */ |
| 51 |
&IO_word_size, /* IO word size */ |
| 52 |
&version); /* ExodusII library version */ |
| 53 |
|
| 54 |
printf("\nafter ex_open\n"); |
| 55 |
if (exoid < 0) { |
| 56 |
exit(1); |
| 57 |
} |
| 58 |
|
| 59 |
printf("test-assembly.exo is an EXODUSII file; version %4.2f\n", version); |
| 60 |
/* printf (" CPU word size %1d\n",CPU_word_size); */ |
| 61 |
printf(" I/O word size %1d\n", IO_word_size); |
| 62 |
ex_inquire(exoid, EX_INQ_API_VERS, &idum, &version, cdum); |
| 63 |
printf("EXODUSII API; version %4.2f\n", version); |
| 64 |
|
| 65 |
ex_inquire(exoid, EX_INQ_LIB_VERS, &idum, &version, cdum); |
| 66 |
printf("EXODUSII Library API; version %4.2f (%d)\n", version, idum); |
| 67 |
|
| 68 |
/* read database parameters */ |
| 69 |
{ |
| 70 |
ex_init_params par; |
| 71 |
EXCHECK(ex_get_init_ext(exoid, &par)); |
| 72 |
|
| 73 |
printf("database parameters:\n"); |
| 74 |
printf("title = '%s'\n", par.title); |
| 75 |
printf("num_dim = %" PRId64 "\n", par.num_dim); |
| 76 |
printf("num_assembly = %" PRId64 "\n", par.num_assembly); |
| 77 |
printf("num_nodes = %" PRId64 "\n", par.num_nodes); |
| 78 |
printf("num_edge = %" PRId64 "\n", par.num_edge); |
| 79 |
printf("num_face = %" PRId64 "\n", par.num_face); |
| 80 |
printf("num_elem = %" PRId64 "\n", par.num_elem); |
| 81 |
printf("num_elem_blk = %" PRId64 "\n", par.num_elem_blk); |
| 82 |
printf("num_node_sets = %" PRId64 "\n", par.num_node_sets); |
| 83 |
printf("num_side_sets = %" PRId64 "\n", par.num_side_sets); |
| 84 |
|
| 85 |
/* Check that ex_inquire gives same title */ |
| 86 |
char title_chk[MAX_LINE_LENGTH + 1]; |
| 87 |
EXCHECK(ex_inquire(exoid, EX_INQ_TITLE, &idum, &fdum, title_chk)); |
| 88 |
if (strcmp(par.title, title_chk) != 0) { |
| 89 |
printf("error in ex_inquire for EX_INQ_TITLE %s, vs %s\n", par.title, title_chk); |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
/* See if we can add a new assembly to an existing file... */ |
| 94 |
{ |
| 95 |
int64_t list_222[] = {100, 200, 300, 400}; |
| 96 |
ex_assembly assembly = {222, "NewAssembly", EX_ASSEMBLY, 4, NULL}; |
| 97 |
EXCHECK(ex_put_assembly(exoid, assembly)); |
| 98 |
|
| 99 |
assembly.entity_list = list_222; |
| 100 |
EXCHECK(ex_put_assembly(exoid, assembly)); |
| 101 |
} |
| 102 |
EXCHECK(ex_close(exoid)); |
| 103 |
return 0; |
| 104 |
} |