Debian Codegraph @

packages/seacas/libraries/exodus/src/ex_put_loadbal_param_cc.c

raw
1 /*
2 * Copyright(C) 1999-2020, 2022 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 /*****************************************************************************/
11 /*****************************************************************************/
12 /* Function(s) contained in this file:
13 * ex_put_loadbal_param_cc()
14 *****************************************************************************
15 * This function outputs the concatenated list of load-balance parameters.
16 *****************************************************************************
17 * Variable Index:
18 * exoid - The NetCDF ID of an already open NemesisI file.
19 * num_int_nodes - Vector of number of internal FEM nodes for
20 * "num_proc_in_f" processors.
21 * num_bor_nodes - Vector of number of border FEM nodes for
22 * "num_proc_in_f" processors.
23 * num_ext_nodes - Vector of number of external FEM nodes for
24 * "num_proc_in_f" processors.
25 * num_int_elems - Vector of number of internal FEM elems for
26 * "num_proc_in_f" processors.
27 * num_bor_elems - Vector of number of border FEM elems for
28 * "num_proc_in_f" processors.
29 * num_node_cmaps - Vector of number of nodal communication maps
30 * for "num_proc_in_f" processors.
31 * num_elem_cmaps - Vector of number of elemental communication maps
32 * for "num_proc_in_f" processors.
33 */
34 /*****************************************************************************/
35 /*****************************************************************************/
36 /*****************************************************************************/
37
38 #include <exodusII.h> // for ex_err, etc
39 #include <exodusII_int.h> // for exi_leavedef, EX_FATAL, etc
40
41 #ifndef NC_INT64
42 #define NC_INT64 NC_INT
43 #endif
44
45 /*!
46 * \ingroup ModelDescription
47 * \undoc
48 */
49 int ex_put_loadbal_param_cc(int exoid, const void_int *num_int_nodes, const void_int *num_bor_nodes,
50 const void_int *num_ext_nodes, const void_int *num_int_elems,
51 const void_int *num_bor_elems, const void_int *num_node_cmaps,
52 const void_int *num_elem_cmaps)
53 {
54 int status;
55 int iproc, varid, dimid_npf, dimid[3];
56 int num_proc, num_proc_in_f;
57 int varid_nm[3], varid_em[2];
58 int varid_idx[7] = {0, 0, 0, 0, 0, 0, 0};
59 size_t start[1];
60 char ftype[2];
61 int oldfill;
62
63 #if NC_HAS_HDF5
64 int64_t num_int_elem = 0, num_int_node = 0, num_bor_elem = 0;
65 int64_t num_bor_node = 0, num_ext_node = 0;
66 int64_t num_n_cmaps = 0, num_e_cmaps = 0;
67 #else
68 int num_int_elem = 0, num_int_node = 0, num_bor_elem = 0;
69 int num_bor_node = 0, num_ext_node = 0;
70 int num_n_cmaps = 0, num_e_cmaps = 0;
71 #endif
72
73 int nmstat;
74
75 char errmsg[MAX_ERR_LENGTH];
76
77 int format;
78
79 int index_type = NC_INT;
80 int map_type = NC_INT;
81 int id_type = NC_INT;
82
83 /*-----------------------------Execution begins-----------------------------*/
84 EX_FUNC_ENTER();
85 if (exi_check_valid_file_id(exoid, __func__) == EX_FATAL) {
86 EX_FUNC_LEAVE(EX_FATAL);
87 }
88
89 if (ex_int64_status(exoid) & EX_MAPS_INT64_DB) {
90 map_type = NC_INT64;
91 }
92 if (ex_int64_status(exoid) & EX_IDS_INT64_DB) {
93 id_type = NC_INT64;
94 }
95
96 /* See if using NC_FORMAT_NETCDF4 format... */
97 nc_inq_format(exoid, &format);
98 if ((ex_int64_status(exoid) & EX_BULK_INT64_DB) || (format == NC_FORMAT_NETCDF4)) {
99 index_type = NC_INT64;
100 }
101
102 /* Get the processor information from the file */
103 if (ex_get_init_info(exoid, &num_proc, &num_proc_in_f, ftype) != EX_NOERR) {
104 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Unable to get processor info from file ID %d", exoid);
105 ex_err_fn(exoid, __func__, errmsg, EX_MSG);
106
107 EX_FUNC_LEAVE(EX_FATAL);
108 }
109
110 /*
111 * Get the dimension ID for the number of processors storing
112 * information in this file.
113 */
114 if ((status = nc_inq_dimid(exoid, DIM_NUM_PROCS_F, &dimid_npf)) != NC_NOERR) {
115 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find dimension ID for \"%s\" in file ID %d",
116 DIM_NUM_PROCS_F, exoid);
117 ex_err_fn(exoid, __func__, errmsg, status);
118
119 EX_FUNC_LEAVE(EX_FATAL);
120 }
121
122 /* Put NetCDF file into define mode */
123 if ((status = exi_redef(exoid, __func__)) != NC_NOERR) {
124 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put file id %d into define mode", exoid);
125 ex_err_fn(exoid, __func__, errmsg, status);
126 EX_FUNC_LEAVE(EX_FATAL);
127 }
128
129 /* Set the fill mode */
130 if ((status = nc_set_fill(exoid, NC_NOFILL, &oldfill)) != NC_NOERR) {
131 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put file ID %d into no-fill mode", exoid);
132 ex_err_fn(exoid, __func__, errmsg, status);
133 EX_FUNC_LEAVE(EX_FATAL);
134 }
135
136 /* Output the file version */
137 if ((status = exi_put_nemesis_version(exoid)) < 0) {
138 EX_FUNC_LEAVE(status);
139 }
140
141 /* Output the file type */
142 if (nc_inq_varid(exoid, VAR_FILE_TYPE, &varid) != NC_NOERR) {
143 if ((status = nc_def_var(exoid, VAR_FILE_TYPE, NC_INT, 0, NULL, &varid)) != NC_NOERR) {
144 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define file type in file ID %d", exoid);
145 ex_err_fn(exoid, __func__, errmsg, status);
146
147 /* Leave define mode before returning */
148 exi_leavedef(exoid, __func__);
149
150 EX_FUNC_LEAVE(EX_FATAL);
151 }
152 }
153
154 /* Define the status variables for the nodal vectors */
155 if (nc_inq_varid(exoid, VAR_INT_N_STAT, &varid) != NC_NOERR) {
156 if ((status = nc_def_var(exoid, VAR_INT_N_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
157 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
158 VAR_INT_N_STAT, exoid);
159 ex_err_fn(exoid, __func__, errmsg, status);
160 /* Leave define mode before returning */
161 exi_leavedef(exoid, __func__);
162
163 EX_FUNC_LEAVE(EX_FATAL);
164 }
165 }
166
167 /* Set the dimension for status vectors */
168 if (nc_inq_varid(exoid, VAR_BOR_N_STAT, &varid) != NC_NOERR) {
169 if ((status = nc_def_var(exoid, VAR_BOR_N_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
170 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
171 VAR_BOR_N_STAT, exoid);
172 ex_err_fn(exoid, __func__, errmsg, status);
173 /* Leave define mode before returning */
174 exi_leavedef(exoid, __func__);
175
176 EX_FUNC_LEAVE(EX_FATAL);
177 }
178 }
179
180 if (nc_inq_varid(exoid, VAR_EXT_N_STAT, &varid) != NC_NOERR) {
181 if ((status = nc_def_var(exoid, VAR_EXT_N_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
182 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
183 VAR_EXT_N_STAT, exoid);
184 ex_err_fn(exoid, __func__, errmsg, status);
185 /* Leave define mode before returning */
186 exi_leavedef(exoid, __func__);
187
188 EX_FUNC_LEAVE(EX_FATAL);
189 }
190 }
191
192 /* Define the variable IDs for the elemental status vectors */
193 if (nc_inq_varid(exoid, VAR_INT_E_STAT, &varid) != NC_NOERR) {
194 if ((status = nc_def_var(exoid, VAR_INT_E_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
195 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
196 VAR_INT_E_STAT, exoid);
197 ex_err_fn(exoid, __func__, errmsg, status);
198 /* Leave define mode before returning */
199 exi_leavedef(exoid, __func__);
200
201 EX_FUNC_LEAVE(EX_FATAL);
202 }
203 }
204
205 if (nc_inq_varid(exoid, VAR_BOR_E_STAT, &varid) != NC_NOERR) {
206 if ((status = nc_def_var(exoid, VAR_BOR_E_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
207 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Failed to define variable \"%s\" in file ID %d",
208 VAR_BOR_E_STAT, exoid);
209 ex_err_fn(exoid, __func__, errmsg, status);
210 /* Leave define mode before returning */
211 exi_leavedef(exoid, __func__);
212
213 EX_FUNC_LEAVE(EX_FATAL);
214 }
215 }
216
217 /* Get the variable ID for the nodal status vectors */
218 if ((status = nc_inq_varid(exoid, VAR_INT_N_STAT, &varid_nm[0])) != NC_NOERR) {
219 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
220 VAR_INT_N_STAT, exoid);
221 ex_err_fn(exoid, __func__, errmsg, status);
222 /* Leave define mode before returning */
223 exi_leavedef(exoid, __func__);
224
225 EX_FUNC_LEAVE(EX_FATAL);
226 }
227
228 if ((status = nc_inq_varid(exoid, VAR_BOR_N_STAT, &varid_nm[1])) != NC_NOERR) {
229 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
230 VAR_BOR_N_STAT, exoid);
231 ex_err_fn(exoid, __func__, errmsg, status);
232 /* Leave define mode before returning */
233 exi_leavedef(exoid, __func__);
234
235 EX_FUNC_LEAVE(EX_FATAL);
236 }
237
238 if ((status = nc_inq_varid(exoid, VAR_EXT_N_STAT, &varid_nm[2])) != NC_NOERR) {
239 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
240 VAR_EXT_N_STAT, exoid);
241 ex_err_fn(exoid, __func__, errmsg, status);
242 /* Leave define mode before returning */
243 exi_leavedef(exoid, __func__);
244
245 EX_FUNC_LEAVE(EX_FATAL);
246 }
247
248 /* Get the variable IDs for the elemental status vectors */
249 if ((status = nc_inq_varid(exoid, VAR_INT_E_STAT, &varid_em[0])) != NC_NOERR) {
250 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
251 VAR_INT_E_STAT, exoid);
252 ex_err_fn(exoid, __func__, errmsg, status);
253 /* Leave define mode before returning */
254 exi_leavedef(exoid, __func__);
255
256 EX_FUNC_LEAVE(EX_FATAL);
257 }
258
259 if ((status = nc_inq_varid(exoid, VAR_BOR_E_STAT, &varid_em[1])) != NC_NOERR) {
260 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
261 VAR_BOR_E_STAT, exoid);
262 ex_err_fn(exoid, __func__, errmsg, status);
263 /* Leave define mode before returning */
264 exi_leavedef(exoid, __func__);
265
266 EX_FUNC_LEAVE(EX_FATAL);
267 }
268
269 /* mms: NEW STUFF HERE */
270 /*
271 ** first need to loop through the processors in this
272 ** file and get the counts of the element and cmap lists
273 */
274 if (ex_int64_status(exoid) & EX_BULK_INT64_API) {
275 for (iproc = 0; iproc < num_proc_in_f; iproc++) {
276 num_int_elem += ((int64_t *)num_int_elems)[iproc];
277 num_int_node += ((int64_t *)num_int_nodes)[iproc];
278 num_bor_elem += ((int64_t *)num_bor_elems)[iproc];
279 num_bor_node += ((int64_t *)num_bor_nodes)[iproc];
280 num_ext_node += ((int64_t *)num_ext_nodes)[iproc];
281 num_e_cmaps += ((int64_t *)num_elem_cmaps)[iproc];
282 num_n_cmaps += ((int64_t *)num_node_cmaps)[iproc];
283 }
284 }
285 else {
286 for (iproc = 0; iproc < num_proc_in_f; iproc++) {
287 num_int_elem += ((int *)num_int_elems)[iproc];
288 num_int_node += ((int *)num_int_nodes)[iproc];
289 num_bor_elem += ((int *)num_bor_elems)[iproc];
290 num_bor_node += ((int *)num_bor_nodes)[iproc];
291 num_ext_node += ((int *)num_ext_nodes)[iproc];
292 num_e_cmaps += ((int *)num_elem_cmaps)[iproc];
293 num_n_cmaps += ((int *)num_node_cmaps)[iproc];
294 }
295 }
296
297 /* Define variable for the internal element information */
298 if (num_int_elem > 0) {
299 if ((status = nc_def_dim(exoid, DIM_NUM_INT_ELEMS, num_int_elem, &dimid[0])) != NC_NOERR) {
300 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
301 DIM_NUM_INT_ELEMS, exoid);
302 ex_err_fn(exoid, __func__, errmsg, status);
303 /* Leave define mode before returning */
304 exi_leavedef(exoid, __func__);
305
306 EX_FUNC_LEAVE(EX_FATAL);
307 }
308
309 if ((status = nc_def_var(exoid, VAR_ELEM_MAP_INT, map_type, 1, dimid, &varid)) != NC_NOERR) {
310 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
311 VAR_ELEM_MAP_INT, exoid);
312 ex_err_fn(exoid, __func__, errmsg, status);
313 /* Leave define mode before returning */
314 exi_leavedef(exoid, __func__);
315
316 EX_FUNC_LEAVE(EX_FATAL);
317 }
318 exi_compress_variable(exoid, varid, 1);
319
320 /* and the index variable */
321 if ((status = nc_def_var(exoid, VAR_ELEM_MAP_INT_IDX, index_type, 1, &dimid_npf,
322 &varid_idx[0])) != NC_NOERR) {
323 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
324 VAR_ELEM_MAP_INT_IDX, exoid);
325 ex_err_fn(exoid, __func__, errmsg, status);
326 /* Leave define mode before returning */
327 exi_leavedef(exoid, __func__);
328
329 EX_FUNC_LEAVE(EX_FATAL);
330 }
331 } /* End "if (num_int_elem > 0)" */
332
333 /* Define variable for the border element information */
334 if (num_bor_elem > 0) {
335 if ((status = nc_def_dim(exoid, DIM_NUM_BOR_ELEMS, num_bor_elem, &dimid[0])) != NC_NOERR) {
336 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
337 DIM_NUM_BOR_ELEMS, exoid);
338 ex_err_fn(exoid, __func__, errmsg, status);
339 /* Leave define mode before returning */
340 exi_leavedef(exoid, __func__);
341
342 EX_FUNC_LEAVE(EX_FATAL);
343 }
344
345 if ((status = nc_def_var(exoid, VAR_ELEM_MAP_BOR, map_type, 1, dimid, &varid)) != NC_NOERR) {
346 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
347 VAR_ELEM_MAP_BOR, exoid);
348 ex_err_fn(exoid, __func__, errmsg, status);
349 /* Leave define mode before returning */
350 exi_leavedef(exoid, __func__);
351
352 EX_FUNC_LEAVE(EX_FATAL);
353 }
354 exi_compress_variable(exoid, varid, 1);
355
356 /* and the index variable */
357 if ((status = nc_def_var(exoid, VAR_ELEM_MAP_BOR_IDX, index_type, 1, &dimid_npf,
358 &varid_idx[1])) != NC_NOERR) {
359 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
360 VAR_ELEM_MAP_BOR_IDX, exoid);
361 ex_err_fn(exoid, __func__, errmsg, status);
362 /* Leave define mode before returning */
363 exi_leavedef(exoid, __func__);
364
365 EX_FUNC_LEAVE(EX_FATAL);
366 }
367
368 } /* End "if (num_bor_elem > 0)" */
369
370 if (num_int_node > 0) {
371 /* Define variable for vector of internal FEM node IDs */
372 if ((status = nc_def_dim(exoid, DIM_NUM_INT_NODES, num_int_node, &dimid[0])) != NC_NOERR) {
373 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
374 DIM_NUM_INT_NODES, exoid);
375 ex_err_fn(exoid, __func__, errmsg, status);
376 /* Leave define mode before returning */
377 exi_leavedef(exoid, __func__);
378
379 EX_FUNC_LEAVE(EX_FATAL);
380 }
381
382 if ((status = nc_def_var(exoid, VAR_NODE_MAP_INT, map_type, 1, &dimid[0], &varid)) !=
383 NC_NOERR) {
384 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
385 VAR_NODE_MAP_INT, exoid);
386 ex_err_fn(exoid, __func__, errmsg, status);
387 /* Leave define mode before returning */
388 exi_leavedef(exoid, __func__);
389
390 EX_FUNC_LEAVE(EX_FATAL);
391 }
392 exi_compress_variable(exoid, varid, 1);
393
394 /* and the index variable */
395 if ((status = nc_def_var(exoid, VAR_NODE_MAP_INT_IDX, index_type, 1, &dimid_npf,
396 &varid_idx[2])) != NC_NOERR) {
397 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
398 VAR_NODE_MAP_INT_IDX, exoid);
399 ex_err_fn(exoid, __func__, errmsg, status);
400 /* Leave define mode before returning */
401 exi_leavedef(exoid, __func__);
402
403 EX_FUNC_LEAVE(EX_FATAL);
404 }
405
406 } /* End "if (num_int_node > 0)" */
407
408 if (num_bor_node > 0) {
409 /* Define variable for vector of border FEM node IDs */
410 if ((status = nc_def_dim(exoid, DIM_NUM_BOR_NODES, num_bor_node, &dimid[1])) != NC_NOERR) {
411 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
412 DIM_NUM_BOR_NODES, exoid);
413 ex_err_fn(exoid, __func__, errmsg, status);
414 /* Leave define mode before returning */
415 exi_leavedef(exoid, __func__);
416
417 EX_FUNC_LEAVE(EX_FATAL);
418 }
419
420 if ((status = nc_def_var(exoid, VAR_NODE_MAP_BOR, map_type, 1, &dimid[1], &varid)) !=
421 NC_NOERR) {
422 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
423 VAR_NODE_MAP_BOR, exoid);
424 ex_err_fn(exoid, __func__, errmsg, status);
425 /* Leave define mode before returning */
426 exi_leavedef(exoid, __func__);
427
428 EX_FUNC_LEAVE(EX_FATAL);
429 }
430 exi_compress_variable(exoid, varid, 1);
431
432 /* and the index variable */
433 if ((status = nc_def_var(exoid, VAR_NODE_MAP_BOR_IDX, index_type, 1, &dimid_npf,
434 &varid_idx[3])) != NC_NOERR) {
435 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
436 VAR_NODE_MAP_BOR_IDX, exoid);
437 ex_err_fn(exoid, __func__, errmsg, status);
438 /* Leave define mode before returning */
439 exi_leavedef(exoid, __func__);
440
441 EX_FUNC_LEAVE(EX_FATAL);
442 }
443
444 } /* End "if (num_bor_node > 0)" */
445
446 if (num_ext_node > 0) {
447 /* Define dimension for vector of external FEM node IDs */
448 if ((status = nc_def_dim(exoid, DIM_NUM_EXT_NODES, num_ext_node, &dimid[2])) != NC_NOERR) {
449 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
450 DIM_NUM_EXT_NODES, exoid);
451 ex_err_fn(exoid, __func__, errmsg, status);
452 /* Leave define mode before returning */
453 exi_leavedef(exoid, __func__);
454
455 EX_FUNC_LEAVE(EX_FATAL);
456 }
457
458 if ((status = nc_def_var(exoid, VAR_NODE_MAP_EXT, map_type, 1, &dimid[2], &varid)) !=
459 NC_NOERR) {
460 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
461 VAR_NODE_MAP_EXT, exoid);
462 ex_err_fn(exoid, __func__, errmsg, status);
463 /* Leave define mode before returning */
464 exi_leavedef(exoid, __func__);
465
466 EX_FUNC_LEAVE(EX_FATAL);
467 }
468 exi_compress_variable(exoid, varid, 1);
469
470 /* and the index variable */
471 if ((status = nc_def_var(exoid, VAR_NODE_MAP_EXT_IDX, index_type, 1, &dimid_npf,
472 &varid_idx[4])) != NC_NOERR) {
473 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
474 VAR_NODE_MAP_EXT_IDX, exoid);
475 ex_err_fn(exoid, __func__, errmsg, status);
476 /* Leave define mode before returning */
477 exi_leavedef(exoid, __func__);
478
479 EX_FUNC_LEAVE(EX_FATAL);
480 }
481
482 } /* End "if (num_ext_node > 0)" */
483
484 /* Output the communication map dimensions */
485 if (num_n_cmaps > 0) {
486 if ((status = nc_def_dim(exoid, DIM_NUM_N_CMAPS, num_n_cmaps, &dimid[0])) != NC_NOERR) {
487 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add dimension \"%s\" in file ID %d",
488 DIM_NUM_N_CMAPS, exoid);
489 ex_err_fn(exoid, __func__, errmsg, status);
490 /* Leave define mode before returning */
491 exi_leavedef(exoid, __func__);
492
493 EX_FUNC_LEAVE(EX_FATAL);
494 }
495
496 /* Add variables for communication maps */
497 if ((status = nc_def_var(exoid, VAR_N_COMM_IDS, id_type, 1, dimid, &varid)) != NC_NOERR) {
498 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
499 VAR_N_COMM_IDS, exoid);
500 ex_err_fn(exoid, __func__, errmsg, status);
501 /* Leave define mode before returning */
502 exi_leavedef(exoid, __func__);
503
504 EX_FUNC_LEAVE(EX_FATAL);
505 }
506
507 if ((status = nc_def_var(exoid, VAR_N_COMM_STAT, NC_INT, 1, dimid, &varid)) != NC_NOERR) {
508 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
509 VAR_N_COMM_STAT, exoid);
510 ex_err_fn(exoid, __func__, errmsg, status);
511 /* Leave define mode before returning */
512 exi_leavedef(exoid, __func__);
513
514 EX_FUNC_LEAVE(EX_FATAL);
515 }
516
517 /* and the index variable */
518 if ((status = nc_def_var(exoid, VAR_N_COMM_INFO_IDX, index_type, 1, &dimid_npf,
519 &varid_idx[5])) != NC_NOERR) {
520 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
521 VAR_N_COMM_INFO_IDX, exoid);
522 ex_err_fn(exoid, __func__, errmsg, status);
523 /* Leave define mode before returning */
524 exi_leavedef(exoid, __func__);
525
526 EX_FUNC_LEAVE(EX_FATAL);
527 }
528
529 } /* End "if (num_n_cmaps > 0)" */
530
531 if (num_e_cmaps > 0) {
532 if ((status = nc_def_dim(exoid, DIM_NUM_E_CMAPS, num_e_cmaps, &dimid[0])) != NC_NOERR) {
533 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add dimension \"%s\" in file ID %d",
534 DIM_NUM_E_CMAPS, exoid);
535 ex_err_fn(exoid, __func__, errmsg, status);
536 /* Leave define mode before returning */
537 exi_leavedef(exoid, __func__);
538
539 EX_FUNC_LEAVE(EX_FATAL);
540 }
541
542 /* Add variables for elemental communication maps */
543 if ((status = nc_def_var(exoid, VAR_E_COMM_IDS, id_type, 1, dimid, &varid)) != NC_NOERR) {
544 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
545 VAR_E_COMM_IDS, exoid);
546 ex_err_fn(exoid, __func__, errmsg, status);
547 /* Leave define mode before returning */
548 exi_leavedef(exoid, __func__);
549
550 EX_FUNC_LEAVE(EX_FATAL);
551 }
552
553 if ((status = nc_def_var(exoid, VAR_E_COMM_STAT, NC_INT, 1, dimid, &varid)) != NC_NOERR) {
554 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
555 VAR_E_COMM_STAT, exoid);
556 ex_err_fn(exoid, __func__, errmsg, status);
557 /* Leave define mode before returning */
558 exi_leavedef(exoid, __func__);
559
560 EX_FUNC_LEAVE(EX_FATAL);
561 }
562
563 /* and the index variable */
564 if ((status = nc_def_var(exoid, VAR_E_COMM_INFO_IDX, index_type, 1, &dimid_npf,
565 &varid_idx[6])) != NC_NOERR) {
566 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
567 VAR_E_COMM_INFO_IDX, exoid);
568 ex_err_fn(exoid, __func__, errmsg, status);
569 /* Leave define mode before returning */
570 exi_leavedef(exoid, __func__);
571
572 EX_FUNC_LEAVE(EX_FATAL);
573 }
574
575 } /* End "if (num_e_cmaps > 0)" */
576
577 /* Leave define mode */
578 if (exi_leavedef(exoid, __func__) != EX_NOERR) {
579 EX_FUNC_LEAVE(EX_FATAL);
580 }
581
582 /* need to reset these counters */
583 num_int_elem = 0;
584 num_int_node = 0;
585 num_bor_elem = 0;
586 num_bor_node = 0;
587 num_ext_node = 0;
588 num_n_cmaps = 0;
589 num_e_cmaps = 0;
590
591 /* Update the status vectors */
592 for (iproc = 0; iproc < num_proc_in_f; iproc++) {
593 size_t nin;
594 size_t nbn;
595 size_t nen;
596 size_t nie;
597 size_t nbe;
598 size_t nnc;
599 size_t nec;
600 if (ex_int64_status(exoid) & EX_BULK_INT64_API) {
601 nie = ((int64_t *)num_int_elems)[iproc];
602 nin = ((int64_t *)num_int_nodes)[iproc];
603 nbe = ((int64_t *)num_bor_elems)[iproc];
604 nbn = ((int64_t *)num_bor_nodes)[iproc];
605 nen = ((int64_t *)num_ext_nodes)[iproc];
606 nec = ((int64_t *)num_elem_cmaps)[iproc];
607 nnc = ((int64_t *)num_node_cmaps)[iproc];
608 }
609 else {
610 nie = ((int *)num_int_elems)[iproc];
611 nin = ((int *)num_int_nodes)[iproc];
612 nbe = ((int *)num_bor_elems)[iproc];
613 nbn = ((int *)num_bor_nodes)[iproc];
614 nen = ((int *)num_ext_nodes)[iproc];
615 nec = ((int *)num_elem_cmaps)[iproc];
616 nnc = ((int *)num_node_cmaps)[iproc];
617 }
618
619 start[0] = iproc;
620
621 if (nin > 0) {
622 nmstat = 1;
623 }
624 else {
625 nmstat = 0;
626 }
627
628 if ((status = nc_put_var1_int(exoid, varid_nm[0], start, &nmstat)) != NC_NOERR) {
629 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output status int node map in file ID %d",
630 exoid);
631 ex_err_fn(exoid, __func__, errmsg, status);
632 EX_FUNC_LEAVE(EX_FATAL);
633 }
634
635 if (nbn > 0) {
636 nmstat = 1;
637 }
638 else {
639 nmstat = 0;
640 }
641
642 if ((status = nc_put_var1_int(exoid, varid_nm[1], start, &nmstat)) != NC_NOERR) {
643 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output status bor node map in file ID %d",
644 exoid);
645 ex_err_fn(exoid, __func__, errmsg, status);
646 EX_FUNC_LEAVE(EX_FATAL);
647 }
648
649 if (nen > 0) {
650 nmstat = 1;
651 }
652 else {
653 nmstat = 0;
654 }
655
656 if ((status = nc_put_var1_int(exoid, varid_nm[2], start, &nmstat)) != NC_NOERR) {
657 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output status ext node map in file ID %d",
658 exoid);
659 ex_err_fn(exoid, __func__, errmsg, status);
660 EX_FUNC_LEAVE(EX_FATAL);
661 }
662
663 if (nie > 0) {
664 nmstat = 1;
665 }
666 else {
667 nmstat = 0;
668 }
669
670 if ((status = nc_put_var1_int(exoid, varid_em[0], start, &nmstat)) != NC_NOERR) {
671 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output status int elem map in file ID %d",
672 exoid);
673 ex_err_fn(exoid, __func__, errmsg, status);
674 EX_FUNC_LEAVE(EX_FATAL);
675 }
676
677 if (nbe > 0) {
678 nmstat = 1;
679 }
680 else {
681 nmstat = 0;
682 }
683
684 if ((status = nc_put_var1_int(exoid, varid_em[1], start, &nmstat)) != NC_NOERR) {
685 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output status bor elem map in file ID %d",
686 exoid);
687 ex_err_fn(exoid, __func__, errmsg, status);
688 EX_FUNC_LEAVE(EX_FATAL);
689 }
690
691 /* now fill the index variables */
692 if (varid_idx[0] > 0) {
693 /* increment to the next starting position */
694 num_int_elem += nie;
695 #if NC_HAS_HDF5
696 status = nc_put_var1_longlong(exoid, varid_idx[0], start, (long long *)&num_int_elem);
697 #else
698 status = nc_put_var1_int(exoid, varid_idx[0], start, &num_int_elem);
699 #endif
700 if (status != NC_NOERR) {
701 snprintf(errmsg, MAX_ERR_LENGTH,
702 "ERROR: failed to output internal element map index in file ID %d", exoid);
703 ex_err_fn(exoid, __func__, errmsg, status);
704 EX_FUNC_LEAVE(EX_FATAL);
705 }
706 }
707
708 if (varid_idx[1] > 0) {
709 /* increment to the next starting position */
710 num_bor_elem += nbe;
711 #if NC_HAS_HDF5
712 status = nc_put_var1_longlong(exoid, varid_idx[1], start, (long long *)&num_bor_elem);
713 #else
714 status = nc_put_var1_int(exoid, varid_idx[1], start, &num_bor_elem);
715 #endif
716 if (status != NC_NOERR) {
717 snprintf(errmsg, MAX_ERR_LENGTH,
718 "ERROR: failed to output border element map index in file ID %d", exoid);
719 ex_err_fn(exoid, __func__, errmsg, status);
720 EX_FUNC_LEAVE(EX_FATAL);
721 }
722 }
723
724 if (varid_idx[2] > 0) {
725 /* increment to the next starting position */
726 num_int_node += nin;
727 #if NC_HAS_HDF5
728 status = nc_put_var1_longlong(exoid, varid_idx[2], start, (long long *)&num_int_node);
729 #else
730 status = nc_put_var1_int(exoid, varid_idx[2], start, &num_int_node);
731 #endif
732 if (status != NC_NOERR) {
733 snprintf(errmsg, MAX_ERR_LENGTH,
734 "ERROR: failed to output internal node map index in file ID %d", exoid);
735 ex_err_fn(exoid, __func__, errmsg, status);
736 EX_FUNC_LEAVE(EX_FATAL);
737 }
738 }
739
740 if (varid_idx[3] > 0) {
741 /* increment to the next starting position */
742 num_bor_node += nbn;
743 #if NC_HAS_HDF5
744 status = nc_put_var1_longlong(exoid, varid_idx[3], start, (long long *)&num_bor_node);
745 #else
746 status = nc_put_var1_int(exoid, varid_idx[3], start, &num_bor_node);
747 #endif
748 if (status != NC_NOERR) {
749 snprintf(errmsg, MAX_ERR_LENGTH,
750 "ERROR: failed to output border node map index in file ID %d", exoid);
751 ex_err_fn(exoid, __func__, errmsg, status);
752 EX_FUNC_LEAVE(EX_FATAL);
753 }
754 }
755
756 if (varid_idx[4] > 0) {
757 /* increment to the next starting position */
758 num_ext_node += nen;
759 #if NC_HAS_HDF5
760 status = nc_put_var1_longlong(exoid, varid_idx[4], start, (long long *)&num_ext_node);
761 #else
762 status = nc_put_var1_int(exoid, varid_idx[4], start, &num_ext_node);
763 #endif
764 if (status != NC_NOERR) {
765 snprintf(errmsg, MAX_ERR_LENGTH,
766 "ERROR: failed to output external node map index in file ID %d", exoid);
767 ex_err_fn(exoid, __func__, errmsg, status);
768 EX_FUNC_LEAVE(EX_FATAL);
769 }
770 }
771
772 if (varid_idx[5] > 0) {
773 /* increment to the next starting position */
774 num_n_cmaps += nnc;
775 #if NC_HAS_HDF5
776 status = nc_put_var1_longlong(exoid, varid_idx[5], start, (long long *)&num_n_cmaps);
777 #else
778 status = nc_put_var1_int(exoid, varid_idx[5], start, &num_n_cmaps);
779 #endif
780 if (status != NC_NOERR) {
781 snprintf(errmsg, MAX_ERR_LENGTH,
782 "ERROR: failed to output node communication map index "
783 "in file ID %d",
784 exoid);
785 ex_err_fn(exoid, __func__, errmsg, status);
786 EX_FUNC_LEAVE(EX_FATAL);
787 }
788 }
789
790 if (varid_idx[6] > 0) {
791 /* increment to the next starting position */
792 num_e_cmaps += nec;
793 #if NC_HAS_HDF5
794 status = nc_put_var1_longlong(exoid, varid_idx[6], start, (long long *)&num_e_cmaps);
795 #else
796 status = nc_put_var1_int(exoid, varid_idx[6], start, &num_e_cmaps);
797 #endif
798 if (status != NC_NOERR) {
799 snprintf(errmsg, MAX_ERR_LENGTH,
800 "ERROR: failed to output elem communication map index "
801 "in file ID %d",
802 exoid);
803 ex_err_fn(exoid, __func__, errmsg, status);
804 EX_FUNC_LEAVE(EX_FATAL);
805 }
806 }
807
808 } /* End "for(iproc=0; iproc < num_proc_in_f; iproc++)" */
809 EX_FUNC_LEAVE(EX_NOERR);
810 }