| 1 |
/* |
| 2 |
* Copyright(C) 1999-2021, 2024 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 |
/* This file contains the source code for the program used to test the |
| 12 |
* Nemesis distribution. |
| 13 |
***************************************************************************** |
| 14 |
* Written By: Gary L. Hennigan (SNL, 1421) |
| 15 |
***************************************************************************** |
| 16 |
* Functions contained in this file: |
| 17 |
* main() - Entry point and main calling program. |
| 18 |
*/ |
| 19 |
/*****************************************************************************/ |
| 20 |
/*****************************************************************************/ |
| 21 |
/*****************************************************************************/ |
| 22 |
#include <exodusII.h> |
| 23 |
#include <stdio.h> |
| 24 |
#include <stdlib.h> |
| 25 |
#include <string.h> |
| 26 |
|
| 27 |
/* Constants for init_global functions */ |
| 28 |
#define NNG 100 |
| 29 |
#define NEG 50 |
| 30 |
#define NEBG 5 |
| 31 |
#define NEBCG 10 |
| 32 |
#define NNSG 2 |
| 33 |
#define NSSG 3 |
| 34 |
|
| 35 |
/* Constants for load-balance functions */ |
| 36 |
#define NPROC 10 |
| 37 |
#define NPROCF NPROC |
| 38 |
#define NINTN 200 |
| 39 |
#define NBORN 10 |
| 40 |
#define NEXTN 5 |
| 41 |
#define NINTE 100 |
| 42 |
#define NBORE 20 |
| 43 |
#define NNCMAP 4 |
| 44 |
#define NECMAP 2 |
| 45 |
|
| 46 |
/* Constants for communication map */ |
| 47 |
#define NCNTCM 20 |
| 48 |
#define ECNTCM 17 |
| 49 |
|
| 50 |
int main(int argc, char **argv) |
| 51 |
{ |
| 52 |
|
| 53 |
/* Local function calls */ |
| 54 |
int ne_test_glbp(int /*fileid*/); |
| 55 |
int ne_test_piinf(int /*fileid*/); |
| 56 |
int ne_test_pinig(int /*fileid*/); |
| 57 |
int ne_test_pelbid(int /*fileid*/); |
| 58 |
int ne_test_pnsp(int /*fileid*/); |
| 59 |
int ne_test_pssp(int /*fileid*/); |
| 60 |
int ne_test_pnm(int /*fileid*/); |
| 61 |
int ne_test_pem(int /*fileid*/); |
| 62 |
int ne_test_pcmp(int /*fileid*/); |
| 63 |
int ne_test_pncm(int /*fileid*/); |
| 64 |
int ne_test_pecm(int /*fileid*/); |
| 65 |
|
| 66 |
int ne_test_giinf(int /*fileid*/); |
| 67 |
int ne_test_ginig(int /*fileid*/); |
| 68 |
int ne_test_gelbid(int /*fileid*/); |
| 69 |
int ne_test_gnsp(int /*fileid*/); |
| 70 |
int ne_test_gssp(int /*fileid*/); |
| 71 |
int ne_test_gnm(int /*fileid*/); |
| 72 |
int ne_test_gem(int /*fileid*/); |
| 73 |
int ne_test_gncm(int /*fileid*/); |
| 74 |
int ne_test_gecm(int /*fileid*/); |
| 75 |
|
| 76 |
int ne_test_plbpc(int /*fileid*/); |
| 77 |
int ne_test_pcmpc(int /*fileid*/); |
| 78 |
|
| 79 |
/* Uninitialized local variables */ |
| 80 |
int ne_file_id; |
| 81 |
float version; |
| 82 |
|
| 83 |
/* Initialized local variables */ |
| 84 |
int mode3 = EX_CLOBBER; |
| 85 |
int mode4 = EX_CLOBBER | EX_NETCDF4 | EX_NOCLASSIC; |
| 86 |
|
| 87 |
char *yo = "main"; |
| 88 |
int io_ws = 0, cpu_ws = 0, t_pass = 0, t_fail = 0; |
| 89 |
|
| 90 |
char *file_name = "ne_test.exo"; |
| 91 |
|
| 92 |
/*---------------------------------------------------------------------------*/ |
| 93 |
/* OUTPUT TEST SECTION */ |
| 94 |
/*---------------------------------------------------------------------------*/ |
| 95 |
|
| 96 |
printf("*********************Output Tests***********************\n"); |
| 97 |
|
| 98 |
/* Create the ExodusII/Nemesis file */ |
| 99 |
printf("creating ExodusII file..."); |
| 100 |
fflush(stdout); |
| 101 |
|
| 102 |
/* Attempt to create a netcdf4-format file; if it fails, then assume |
| 103 |
that the netcdf library does not support that mode and fall back |
| 104 |
to classic netcdf3 format. If that fails, issue an error and |
| 105 |
die. |
| 106 |
*/ |
| 107 |
if ((ne_file_id = ex_create(file_name, mode4, &cpu_ws, &io_ws)) < 0) { |
| 108 |
/* netcdf4 create failed, try netcdf3 */ |
| 109 |
if ((ne_file_id = ex_create(file_name, mode3, &cpu_ws, &io_ws)) < 0) { |
| 110 |
printf("FAILED\n"); |
| 111 |
t_fail++; |
| 112 |
fprintf(stderr, "[%s]: ERROR, unable to create test file \"%s\"!\n", yo, file_name); |
| 113 |
exit(-1); |
| 114 |
} |
| 115 |
} |
| 116 |
printf("successful\n"); |
| 117 |
fflush(stdout); |
| 118 |
t_pass++; |
| 119 |
|
| 120 |
/* Test the output of initial information */ |
| 121 |
printf("testing init info output..."); |
| 122 |
fflush(stdout); |
| 123 |
if (ne_test_piinf(ne_file_id) < 0) { |
| 124 |
printf("FAILED\n"); |
| 125 |
fflush(stdout); |
| 126 |
t_fail++; |
| 127 |
} |
| 128 |
else { |
| 129 |
printf("successful\n"); |
| 130 |
fflush(stdout); |
| 131 |
t_pass++; |
| 132 |
} |
| 133 |
|
| 134 |
/* Test the output of initial global information */ |
| 135 |
printf("testing global init info output..."); |
| 136 |
fflush(stdout); |
| 137 |
if (ne_test_pinig(ne_file_id) < 0) { |
| 138 |
printf("FAILED\n"); |
| 139 |
fflush(stdout); |
| 140 |
t_fail++; |
| 141 |
} |
| 142 |
else { |
| 143 |
printf("successful\n"); |
| 144 |
fflush(stdout); |
| 145 |
t_pass++; |
| 146 |
} |
| 147 |
|
| 148 |
/* Test the output of the global element block IDs */ |
| 149 |
printf("testing global element block ID output..."); |
| 150 |
fflush(stdout); |
| 151 |
if (ne_test_pelbid(ne_file_id) < 0) { |
| 152 |
printf("FAILED\n"); |
| 153 |
fflush(stdout); |
| 154 |
t_fail++; |
| 155 |
} |
| 156 |
else { |
| 157 |
printf("successful\n"); |
| 158 |
fflush(stdout); |
| 159 |
t_pass++; |
| 160 |
} |
| 161 |
|
| 162 |
/* Test the output of the global node-set info */ |
| 163 |
printf("testing global node-set params output..."); |
| 164 |
fflush(stdout); |
| 165 |
if (ne_test_pnsp(ne_file_id) < 0) { |
| 166 |
printf("FAILED\n"); |
| 167 |
fflush(stdout); |
| 168 |
t_fail++; |
| 169 |
} |
| 170 |
else { |
| 171 |
printf("successful\n"); |
| 172 |
fflush(stdout); |
| 173 |
t_pass++; |
| 174 |
} |
| 175 |
|
| 176 |
/* Test the output of the global side-set info */ |
| 177 |
printf("testing global side-set params output..."); |
| 178 |
fflush(stdout); |
| 179 |
if (ne_test_pssp(ne_file_id) < 0) { |
| 180 |
printf("FAILED\n"); |
| 181 |
fflush(stdout); |
| 182 |
t_fail++; |
| 183 |
} |
| 184 |
else { |
| 185 |
printf("successful\n"); |
| 186 |
fflush(stdout); |
| 187 |
t_pass++; |
| 188 |
} |
| 189 |
|
| 190 |
/* Test the output of the concatenated load-balance parameters */ |
| 191 |
printf("testing concatenated load balance info output..."); |
| 192 |
fflush(stdout); |
| 193 |
if (ne_test_plbpc(ne_file_id) < 0) { |
| 194 |
printf("FAILED\n"); |
| 195 |
fflush(stdout); |
| 196 |
} |
| 197 |
else { |
| 198 |
printf("successful\n"); |
| 199 |
fflush(stdout); |
| 200 |
} |
| 201 |
|
| 202 |
/* Test the output of the node map */ |
| 203 |
printf("testing node map output..."); |
| 204 |
fflush(stdout); |
| 205 |
if (ne_test_pnm(ne_file_id) < 0) { |
| 206 |
printf("FAILED\n"); |
| 207 |
fflush(stdout); |
| 208 |
t_fail++; |
| 209 |
} |
| 210 |
else { |
| 211 |
printf("successful\n"); |
| 212 |
fflush(stdout); |
| 213 |
t_pass++; |
| 214 |
} |
| 215 |
|
| 216 |
/* Test the output of the element map */ |
| 217 |
printf("testing element map output..."); |
| 218 |
fflush(stdout); |
| 219 |
if (ne_test_pem(ne_file_id) < 0) { |
| 220 |
printf("FAILED\n"); |
| 221 |
fflush(stdout); |
| 222 |
t_fail++; |
| 223 |
} |
| 224 |
else { |
| 225 |
printf("successful\n"); |
| 226 |
fflush(stdout); |
| 227 |
t_pass++; |
| 228 |
} |
| 229 |
|
| 230 |
/* Test the output of the concatenated communication map params */ |
| 231 |
printf("testing concatenated communication map params output..."); |
| 232 |
fflush(stdout); |
| 233 |
if (ne_test_pcmpc(ne_file_id) < 0) { |
| 234 |
printf("FAILED\n"); |
| 235 |
fflush(stdout); |
| 236 |
t_fail++; |
| 237 |
} |
| 238 |
else { |
| 239 |
printf("successful\n"); |
| 240 |
fflush(stdout); |
| 241 |
t_pass++; |
| 242 |
} |
| 243 |
|
| 244 |
/* Test nodal communication map output */ |
| 245 |
printf("testing nodal communication map output..."); |
| 246 |
fflush(stdout); |
| 247 |
if (ne_test_pncm(ne_file_id) < 0) { |
| 248 |
printf("FAILED\n"); |
| 249 |
fflush(stdout); |
| 250 |
t_fail++; |
| 251 |
} |
| 252 |
else { |
| 253 |
printf("successful\n"); |
| 254 |
fflush(stdout); |
| 255 |
t_pass++; |
| 256 |
} |
| 257 |
|
| 258 |
/* Test elemental communication map output */ |
| 259 |
printf("testing elemental communication map output..."); |
| 260 |
fflush(stdout); |
| 261 |
if (ne_test_pecm(ne_file_id) < 0) { |
| 262 |
printf("FAILED\n"); |
| 263 |
fflush(stdout); |
| 264 |
t_fail++; |
| 265 |
} |
| 266 |
else { |
| 267 |
printf("successful\n"); |
| 268 |
fflush(stdout); |
| 269 |
t_pass++; |
| 270 |
} |
| 271 |
|
| 272 |
/* Close the ExodusII/Nemesis test file */ |
| 273 |
printf("closing ExodusII file..."); |
| 274 |
fflush(stdout); |
| 275 |
if (ex_close(ne_file_id) < 0) { |
| 276 |
printf("FAILED\n"); |
| 277 |
fflush(stdout); |
| 278 |
t_fail++; |
| 279 |
fprintf(stderr, "[%s]: ERROR, unable to close test file \"%s\"!\n", yo, file_name); |
| 280 |
exit(-1); |
| 281 |
} |
| 282 |
printf("successful\n"); |
| 283 |
fflush(stdout); |
| 284 |
t_pass++; |
| 285 |
|
| 286 |
/*---------------------------------------------------------------------------*/ |
| 287 |
/* INPUT TEST SECTION */ |
| 288 |
/*---------------------------------------------------------------------------*/ |
| 289 |
|
| 290 |
printf("**********************Input Tests***********************\n"); |
| 291 |
|
| 292 |
/* Re-open the ExodusII/NemesisI file */ |
| 293 |
printf("reopening ExodusII file..."); |
| 294 |
fflush(stdout); |
| 295 |
if (ex_open(file_name, EX_READ, &cpu_ws, &io_ws, &version) < 0) { |
| 296 |
printf("FAILED\n"); |
| 297 |
fflush(stdout); |
| 298 |
t_fail++; |
| 299 |
} |
| 300 |
else { |
| 301 |
printf("successful\n"); |
| 302 |
fflush(stdout); |
| 303 |
t_pass++; |
| 304 |
} |
| 305 |
|
| 306 |
/* Test read of of the initial information */ |
| 307 |
printf("testing init info input..."); |
| 308 |
fflush(stdout); |
| 309 |
if (ne_test_giinf(ne_file_id) < 0) { |
| 310 |
printf("FAILED\n"); |
| 311 |
fflush(stdout); |
| 312 |
t_fail++; |
| 313 |
} |
| 314 |
else { |
| 315 |
printf("successful\n"); |
| 316 |
fflush(stdout); |
| 317 |
t_pass++; |
| 318 |
} |
| 319 |
|
| 320 |
/* Test read of initial global information */ |
| 321 |
printf("testing global init info input..."); |
| 322 |
fflush(stdout); |
| 323 |
if (ne_test_ginig(ne_file_id) < 0) { |
| 324 |
printf("FAILED\n"); |
| 325 |
fflush(stdout); |
| 326 |
t_fail++; |
| 327 |
} |
| 328 |
else { |
| 329 |
printf("successful\n"); |
| 330 |
fflush(stdout); |
| 331 |
t_pass++; |
| 332 |
} |
| 333 |
|
| 334 |
/* Test read of global element block IDs */ |
| 335 |
printf("testing global element block IDs input..."); |
| 336 |
fflush(stdout); |
| 337 |
if (ne_test_gelbid(ne_file_id) < 0) { |
| 338 |
printf("FAILED\n"); |
| 339 |
fflush(stdout); |
| 340 |
t_fail++; |
| 341 |
} |
| 342 |
else { |
| 343 |
printf("successful\n"); |
| 344 |
fflush(stdout); |
| 345 |
t_pass++; |
| 346 |
} |
| 347 |
|
| 348 |
/* Test read of global node-set params */ |
| 349 |
printf("testing global node-set params input..."); |
| 350 |
fflush(stdout); |
| 351 |
if (ne_test_gnsp(ne_file_id) < 0) { |
| 352 |
printf("FAILED\n"); |
| 353 |
fflush(stdout); |
| 354 |
t_fail++; |
| 355 |
} |
| 356 |
else { |
| 357 |
printf("successful\n"); |
| 358 |
fflush(stdout); |
| 359 |
t_pass++; |
| 360 |
} |
| 361 |
|
| 362 |
/* Test read of global side-set params */ |
| 363 |
printf("testing global side-set params input..."); |
| 364 |
fflush(stdout); |
| 365 |
if (ne_test_gssp(ne_file_id) < 0) { |
| 366 |
printf("FAILED\n"); |
| 367 |
fflush(stdout); |
| 368 |
t_fail++; |
| 369 |
} |
| 370 |
else { |
| 371 |
printf("successful\n"); |
| 372 |
fflush(stdout); |
| 373 |
t_pass++; |
| 374 |
} |
| 375 |
|
| 376 |
/* Test read of load-balance params */ |
| 377 |
printf("testing load-balance params input..."); |
| 378 |
fflush(stdout); |
| 379 |
if (ne_test_glbp(ne_file_id) < 0) { |
| 380 |
printf("FAILED\n"); |
| 381 |
fflush(stdout); |
| 382 |
t_fail++; |
| 383 |
} |
| 384 |
else { |
| 385 |
printf("successful\n"); |
| 386 |
fflush(stdout); |
| 387 |
t_pass++; |
| 388 |
} |
| 389 |
|
| 390 |
/* Test read of the node map */ |
| 391 |
printf("testing node map input..."); |
| 392 |
fflush(stdout); |
| 393 |
if (ne_test_gnm(ne_file_id) < 0) { |
| 394 |
printf("FAILED\n"); |
| 395 |
fflush(stdout); |
| 396 |
t_fail++; |
| 397 |
} |
| 398 |
else { |
| 399 |
printf("successful\n"); |
| 400 |
fflush(stdout); |
| 401 |
t_pass++; |
| 402 |
} |
| 403 |
|
| 404 |
/* Test read of element map */ |
| 405 |
printf("testing element map input..."); |
| 406 |
fflush(stdout); |
| 407 |
if (ne_test_gem(ne_file_id) < 0) { |
| 408 |
printf("FAILED\n"); |
| 409 |
fflush(stdout); |
| 410 |
t_fail++; |
| 411 |
} |
| 412 |
else { |
| 413 |
printf("successful\n"); |
| 414 |
fflush(stdout); |
| 415 |
t_pass++; |
| 416 |
} |
| 417 |
|
| 418 |
/* Test read of nodal communication maps */ |
| 419 |
printf("testing nodal communication map input..."); |
| 420 |
fflush(stdout); |
| 421 |
if (ne_test_gncm(ne_file_id) < 0) { |
| 422 |
printf("FAILED\n"); |
| 423 |
fflush(stdout); |
| 424 |
t_fail++; |
| 425 |
} |
| 426 |
else { |
| 427 |
printf("successful\n"); |
| 428 |
fflush(stdout); |
| 429 |
t_pass++; |
| 430 |
} |
| 431 |
|
| 432 |
/* Test read of elemental communication maps */ |
| 433 |
printf("testing elemental communication map input..."); |
| 434 |
fflush(stdout); |
| 435 |
if (ne_test_gecm(ne_file_id) < 0) { |
| 436 |
printf("FAILED\n"); |
| 437 |
fflush(stdout); |
| 438 |
t_fail++; |
| 439 |
} |
| 440 |
else { |
| 441 |
printf("successful\n"); |
| 442 |
fflush(stdout); |
| 443 |
t_pass++; |
| 444 |
} |
| 445 |
|
| 446 |
/* Close the ExodusII/Nemesis test file */ |
| 447 |
printf("closing ExodusII file..."); |
| 448 |
fflush(stdout); |
| 449 |
if (ex_close(ne_file_id) < 0) { |
| 450 |
printf("FAILED\n"); |
| 451 |
fflush(stdout); |
| 452 |
t_fail++; |
| 453 |
fprintf(stderr, "[%s]: ERROR, unable to close test file \"%s\"!\n", yo, file_name); |
| 454 |
exit(-1); |
| 455 |
} |
| 456 |
printf("successful\n"); |
| 457 |
fflush(stdout); |
| 458 |
t_pass++; |
| 459 |
|
| 460 |
/* Output a test summary */ |
| 461 |
printf("\n"); |
| 462 |
printf("Tests Passed: %d\n", t_pass); |
| 463 |
printf("Tests Failed: %d\n", t_fail); |
| 464 |
|
| 465 |
return 0; |
| 466 |
} |
| 467 |
|
| 468 |
/*****************************************************************************/ |
| 469 |
int ne_test_piinf(int fileid) |
| 470 |
{ |
| 471 |
char ftype[3]; |
| 472 |
|
| 473 |
ex_copy_string(ftype, "s", 3); |
| 474 |
|
| 475 |
return ex_put_init_info(fileid, NPROC, NPROCF, ftype); |
| 476 |
} |
| 477 |
|
| 478 |
/*****************************************************************************/ |
| 479 |
int ne_test_pinig(int fileid) |
| 480 |
{ |
| 481 |
int nng = NNG, neg = NEG, nebg = NEBG, nnsg = NNSG, nssg = NSSG; |
| 482 |
|
| 483 |
return ex_put_init_global(fileid, nng, neg, nebg, nnsg, nssg); |
| 484 |
} |
| 485 |
|
| 486 |
/*****************************************************************************/ |
| 487 |
int ne_test_pelbid(int fileid) |
| 488 |
{ |
| 489 |
int elblk_ids[NEBG], elblk_cnt[NEBG]; |
| 490 |
|
| 491 |
for (int i = 0; i < NEBG; i++) { |
| 492 |
elblk_ids[i] = (i + 1); |
| 493 |
elblk_cnt[i] = NEBCG; |
| 494 |
} |
| 495 |
|
| 496 |
return ex_put_eb_info_global(fileid, elblk_ids, elblk_cnt); |
| 497 |
} |
| 498 |
|
| 499 |
/*****************************************************************************/ |
| 500 |
int ne_test_pnsp(int fileid) |
| 501 |
{ |
| 502 |
int global_ids[NNSG], global_n_cnts[NNSG], global_df_cnts[NNSG]; |
| 503 |
|
| 504 |
for (int i = 0; i < NNSG; i++) { |
| 505 |
global_ids[i] = 2 * (i + 1); |
| 506 |
global_n_cnts[i] = 3 * (i + 1); |
| 507 |
global_df_cnts[i] = 1; |
| 508 |
} |
| 509 |
|
| 510 |
return ex_put_ns_param_global(fileid, global_ids, global_n_cnts, global_df_cnts); |
| 511 |
} |
| 512 |
|
| 513 |
/*****************************************************************************/ |
| 514 |
int ne_test_pssp(int fileid) |
| 515 |
{ |
| 516 |
int global_ids[NSSG], global_el_cnts[NSSG], global_df_cnts[NSSG]; |
| 517 |
|
| 518 |
for (int i = 0; i < NSSG; i++) { |
| 519 |
global_ids[i] = 3 * (i + 1); |
| 520 |
global_el_cnts[i] = 2 * (i + 1); |
| 521 |
global_df_cnts[i] = 1; |
| 522 |
} |
| 523 |
|
| 524 |
return ex_put_ss_param_global(fileid, global_ids, global_el_cnts, global_df_cnts); |
| 525 |
} |
| 526 |
|
| 527 |
/*****************************************************************************/ |
| 528 |
int ne_test_pnm(int fileid) |
| 529 |
{ |
| 530 |
int node_mapi[NINTN], node_mapb[NBORN], node_mape[NEXTN]; |
| 531 |
|
| 532 |
int j1 = 0; |
| 533 |
for (int iproc = 0; iproc < NPROCF; iproc++) { |
| 534 |
for (int j = 0; j < NINTN; node_mapi[j++] = j1++) { |
| 535 |
; |
| 536 |
} |
| 537 |
for (int j = 0; j < NBORN; node_mapb[j++] = j1++) { |
| 538 |
; |
| 539 |
} |
| 540 |
for (int j = 0; j < NEXTN; node_mape[j++] = j1++) { |
| 541 |
; |
| 542 |
} |
| 543 |
j1 = 0; |
| 544 |
int error = ex_put_processor_node_maps(fileid, node_mapi, node_mapb, node_mape, iproc); |
| 545 |
if (error < 0) { |
| 546 |
return error; |
| 547 |
} |
| 548 |
} |
| 549 |
|
| 550 |
return 0; |
| 551 |
} |
| 552 |
|
| 553 |
/*****************************************************************************/ |
| 554 |
int ne_test_pem(int fileid) |
| 555 |
{ |
| 556 |
int elem_mapi[NINTE], elem_mapb[NBORE]; |
| 557 |
|
| 558 |
int j1 = 0; |
| 559 |
for (int iproc = 0; iproc < NPROCF; iproc++) { |
| 560 |
for (int j = 0; j < NINTE; elem_mapi[j++] = j1++) { |
| 561 |
; |
| 562 |
} |
| 563 |
for (int j = 0; j < NBORE; elem_mapb[j++] = j1++) { |
| 564 |
; |
| 565 |
} |
| 566 |
j1 = 0; |
| 567 |
int error = ex_put_processor_elem_maps(fileid, elem_mapi, elem_mapb, iproc); |
| 568 |
if (error < 0) { |
| 569 |
return error; |
| 570 |
} |
| 571 |
} |
| 572 |
|
| 573 |
return 0; |
| 574 |
} |
| 575 |
|
| 576 |
/*****************************************************************************/ |
| 577 |
int ne_test_pcmp(int fileid) |
| 578 |
{ |
| 579 |
int node_map_ids[NNCMAP], node_map_node_cnts[NNCMAP]; |
| 580 |
int elem_map_ids[NECMAP], elem_map_elem_cnts[NECMAP]; |
| 581 |
|
| 582 |
for (int iproc = 0; iproc < NPROCF; iproc++) { |
| 583 |
for (int i = 0; i < NNCMAP; i++) { |
| 584 |
node_map_ids[i] = (i + 1); |
| 585 |
node_map_node_cnts[i] = NCNTCM; |
| 586 |
} |
| 587 |
|
| 588 |
for (int i = 0; i < NECMAP; i++) { |
| 589 |
elem_map_ids[i] = 2 * (i + 1); |
| 590 |
elem_map_elem_cnts[i] = ECNTCM; |
| 591 |
} |
| 592 |
|
| 593 |
int error = ex_put_cmap_params(fileid, node_map_node_cnts, node_map_ids, elem_map_elem_cnts, |
| 594 |
elem_map_ids, iproc); |
| 595 |
if (error < 0) { |
| 596 |
return error; |
| 597 |
} |
| 598 |
} |
| 599 |
|
| 600 |
return 0; |
| 601 |
} |
| 602 |
|
| 603 |
/*****************************************************************************/ |
| 604 |
int ne_test_pncm(int fileid) |
| 605 |
{ |
| 606 |
int node_map_ids[NNCMAP], node_ids[NCNTCM], proc_ids[NCNTCM]; |
| 607 |
|
| 608 |
for (int iproc = 0; iproc < NPROCF; iproc++) { |
| 609 |
for (int i = 0; i < NNCMAP; i++) { |
| 610 |
node_map_ids[i] = (i + 1); |
| 611 |
} |
| 612 |
for (int i = 0; i < NCNTCM; i++) { |
| 613 |
node_ids[i] = 2 * (i + 1); |
| 614 |
proc_ids[i] = 3 * (i + 1); |
| 615 |
} |
| 616 |
|
| 617 |
for (int i = 0; i < NNCMAP; i++) { |
| 618 |
int error = ex_put_node_cmap(fileid, node_map_ids[i], node_ids, proc_ids, iproc); |
| 619 |
if (error < 0) { |
| 620 |
return error; |
| 621 |
} |
| 622 |
} |
| 623 |
} |
| 624 |
|
| 625 |
return 0; |
| 626 |
} |
| 627 |
|
| 628 |
/*****************************************************************************/ |
| 629 |
int ne_test_pecm(int fileid) |
| 630 |
{ |
| 631 |
int elem_map_ids[NECMAP], elem_ids[ECNTCM], side_ids[ECNTCM]; |
| 632 |
int proc_ids[ECNTCM]; |
| 633 |
|
| 634 |
for (int iproc = 0; iproc < NPROCF; iproc++) { |
| 635 |
for (int i = 0; i < NECMAP; i++) { |
| 636 |
elem_map_ids[i] = 2 * (i + 1); |
| 637 |
} |
| 638 |
for (int i = 0; i < ECNTCM; i++) { |
| 639 |
elem_ids[i] = 2 * (i + 1); |
| 640 |
side_ids[i] = 3 * (i + 1); |
| 641 |
proc_ids[i] = 4 * (i + 1); |
| 642 |
} |
| 643 |
|
| 644 |
for (int i = 0; i < NECMAP; i++) { |
| 645 |
int error = ex_put_elem_cmap(fileid, elem_map_ids[i], elem_ids, side_ids, proc_ids, iproc); |
| 646 |
if (error < 0) { |
| 647 |
return error; |
| 648 |
} |
| 649 |
} |
| 650 |
} |
| 651 |
|
| 652 |
return 0; |
| 653 |
} |
| 654 |
|
| 655 |
/*****************************************************************************/ |
| 656 |
int ne_test_giinf(int fileid) |
| 657 |
{ |
| 658 |
int nproc, nprocf; |
| 659 |
char ftype[2]; |
| 660 |
|
| 661 |
int error = ex_get_init_info(fileid, &nproc, &nprocf, ftype); |
| 662 |
if (error < 0) { |
| 663 |
return error; |
| 664 |
} |
| 665 |
|
| 666 |
if (nproc != NPROC) { |
| 667 |
return -1; |
| 668 |
} |
| 669 |
if (nprocf != NPROCF) { |
| 670 |
return -1; |
| 671 |
} |
| 672 |
if (strcmp(ftype, "s") != 0) { |
| 673 |
return -1; |
| 674 |
} |
| 675 |
|
| 676 |
return 0; |
| 677 |
} |
| 678 |
|
| 679 |
/*****************************************************************************/ |
| 680 |
int ne_test_ginig(int fileid) |
| 681 |
{ |
| 682 |
int num_nodes_g, num_elems_g, num_elem_blks_g, num_ns_g, num_ss_g; |
| 683 |
|
| 684 |
int error = ex_get_init_global(fileid, &num_nodes_g, &num_elems_g, &num_elem_blks_g, &num_ns_g, |
| 685 |
&num_ss_g); |
| 686 |
|
| 687 |
if (error < 0) { |
| 688 |
return error; |
| 689 |
} |
| 690 |
|
| 691 |
if (num_nodes_g != NNG) { |
| 692 |
return -1; |
| 693 |
} |
| 694 |
if (num_elems_g != NEG) { |
| 695 |
return -1; |
| 696 |
} |
| 697 |
if (num_elem_blks_g != NEBG) { |
| 698 |
return -1; |
| 699 |
} |
| 700 |
if (num_ns_g != NNSG) { |
| 701 |
return -1; |
| 702 |
} |
| 703 |
if (num_ss_g != NSSG) { |
| 704 |
return -1; |
| 705 |
} |
| 706 |
|
| 707 |
return 0; |
| 708 |
} |
| 709 |
|
| 710 |
/*****************************************************************************/ |
| 711 |
int ne_test_gelbid(int fileid) |
| 712 |
{ |
| 713 |
int el_blk_ids[NEBG], el_blk_cnt[NEBG]; |
| 714 |
|
| 715 |
int error = ex_get_eb_info_global(fileid, el_blk_ids, el_blk_cnt); |
| 716 |
|
| 717 |
if (error < 0) { |
| 718 |
return error; |
| 719 |
} |
| 720 |
|
| 721 |
for (int i = 0; i < NEBG; i++) { |
| 722 |
if (el_blk_ids[i] != (i + 1)) { |
| 723 |
return -1; |
| 724 |
} |
| 725 |
if (el_blk_cnt[i] != NEBCG) { |
| 726 |
return -1; |
| 727 |
} |
| 728 |
} |
| 729 |
|
| 730 |
return 0; |
| 731 |
} |
| 732 |
|
| 733 |
/*****************************************************************************/ |
| 734 |
int ne_test_gnsp(int fileid) |
| 735 |
{ |
| 736 |
int global_ids[NNSG], global_n_cnts[NNSG], global_df_cnts[NNSG]; |
| 737 |
|
| 738 |
int error = ex_get_ns_param_global(fileid, global_ids, global_n_cnts, global_df_cnts); |
| 739 |
|
| 740 |
if (error < 0) { |
| 741 |
return error; |
| 742 |
} |
| 743 |
|
| 744 |
for (int i = 0; i < NNSG; i++) { |
| 745 |
if (global_ids[i] != 2 * (i + 1)) { |
| 746 |
return -1; |
| 747 |
} |
| 748 |
if (global_n_cnts[i] != 3 * (i + 1)) { |
| 749 |
return -1; |
| 750 |
} |
| 751 |
if (global_df_cnts[i] != 1) { |
| 752 |
return -1; |
| 753 |
} |
| 754 |
} |
| 755 |
|
| 756 |
return 0; |
| 757 |
} |
| 758 |
|
| 759 |
/*****************************************************************************/ |
| 760 |
int ne_test_gssp(int fileid) |
| 761 |
{ |
| 762 |
int global_ids[NSSG], global_e_cnts[NSSG], global_df_cnts[NSSG]; |
| 763 |
|
| 764 |
int error = ex_get_ss_param_global(fileid, global_ids, global_e_cnts, global_df_cnts); |
| 765 |
|
| 766 |
if (error < 0) { |
| 767 |
return error; |
| 768 |
} |
| 769 |
|
| 770 |
for (int i = 0; i < NSSG; i++) { |
| 771 |
if (global_ids[i] != 3 * (i + 1)) { |
| 772 |
return -1; |
| 773 |
} |
| 774 |
if (global_e_cnts[i] != 2 * (i + 1)) { |
| 775 |
return -1; |
| 776 |
} |
| 777 |
if (global_df_cnts[i] != 1) { |
| 778 |
return -1; |
| 779 |
} |
| 780 |
} |
| 781 |
|
| 782 |
return 0; |
| 783 |
} |
| 784 |
|
| 785 |
/*****************************************************************************/ |
| 786 |
int ne_test_glbp(int fileid) |
| 787 |
{ |
| 788 |
int nintn, nborn, nextn, ninte, nbore, nncmap, necmap; |
| 789 |
|
| 790 |
for (int iproc = 0; iproc < NPROCF; iproc++) { |
| 791 |
int error = ex_get_loadbal_param(fileid, &nintn, &nborn, &nextn, &ninte, &nbore, &nncmap, |
| 792 |
&necmap, iproc); |
| 793 |
|
| 794 |
if (error < 0) { |
| 795 |
return error; |
| 796 |
} |
| 797 |
|
| 798 |
if (nintn != NINTN) { |
| 799 |
return -1; |
| 800 |
} |
| 801 |
if (nborn != NBORN) { |
| 802 |
return -1; |
| 803 |
} |
| 804 |
if (nextn != NEXTN) { |
| 805 |
return -1; |
| 806 |
} |
| 807 |
if (ninte != NINTE) { |
| 808 |
return -1; |
| 809 |
} |
| 810 |
if (nbore != NBORE) { |
| 811 |
return -1; |
| 812 |
} |
| 813 |
if (nncmap != NNCMAP) { |
| 814 |
return -1; |
| 815 |
} |
| 816 |
if (necmap != NECMAP) { |
| 817 |
return -1; |
| 818 |
} |
| 819 |
} |
| 820 |
|
| 821 |
return 0; |
| 822 |
} |
| 823 |
|
| 824 |
/*****************************************************************************/ |
| 825 |
int ne_test_gnm(int fileid) |
| 826 |
{ |
| 827 |
int node_mapi[NINTN], node_mapb[NBORN], node_mape[NEXTN]; |
| 828 |
|
| 829 |
int j1 = 0; |
| 830 |
for (int iproc = 0; iproc < NPROCF; iproc++) { |
| 831 |
int error = ex_get_processor_node_maps(fileid, node_mapi, node_mapb, node_mape, iproc); |
| 832 |
|
| 833 |
if (error < 0) { |
| 834 |
return error; |
| 835 |
} |
| 836 |
|
| 837 |
for (int j = 0; j < NINTN; j++) { |
| 838 |
if (node_mapi[j] != j1++) { |
| 839 |
return -1; |
| 840 |
} |
| 841 |
} |
| 842 |
for (int j = 0; j < NBORN; j++) { |
| 843 |
if (node_mapb[j] != j1++) { |
| 844 |
return -1; |
| 845 |
} |
| 846 |
} |
| 847 |
for (int j = 0; j < NEXTN; j++) { |
| 848 |
if (node_mape[j] != j1++) { |
| 849 |
return -1; |
| 850 |
} |
| 851 |
} |
| 852 |
|
| 853 |
j1 = 0; |
| 854 |
} |
| 855 |
|
| 856 |
return 0; |
| 857 |
} |
| 858 |
|
| 859 |
/*****************************************************************************/ |
| 860 |
int ne_test_gem(int fileid) |
| 861 |
{ |
| 862 |
int j1 = 0; |
| 863 |
int elem_mapi[NINTE], elem_mapb[NBORE]; |
| 864 |
|
| 865 |
for (int iproc = 0; iproc < NPROCF; iproc++) { |
| 866 |
|
| 867 |
int error = ex_get_processor_elem_maps(fileid, elem_mapi, elem_mapb, iproc); |
| 868 |
|
| 869 |
if (error < 0) { |
| 870 |
return error; |
| 871 |
} |
| 872 |
|
| 873 |
for (int j = 0; j < NINTE; j++) { |
| 874 |
if (elem_mapi[j] != j1++) { |
| 875 |
return -1; |
| 876 |
} |
| 877 |
} |
| 878 |
for (int j = 0; j < NBORE; j++) { |
| 879 |
if (elem_mapb[j] != j1++) { |
| 880 |
return -1; |
| 881 |
} |
| 882 |
} |
| 883 |
j1 = 0; |
| 884 |
} |
| 885 |
|
| 886 |
return 0; |
| 887 |
} |
| 888 |
|
| 889 |
/*****************************************************************************/ |
| 890 |
int ne_test_gncm(int fileid) |
| 891 |
{ |
| 892 |
int node_map_ids[NNCMAP], node_map_cnts[NNCMAP]; |
| 893 |
int node_ids[NCNTCM], proc_ids[NCNTCM]; |
| 894 |
|
| 895 |
for (int iproc = 0; iproc < NPROCF; iproc++) { |
| 896 |
|
| 897 |
int error = ex_get_cmap_params(fileid, node_map_ids, node_map_cnts, NULL, NULL, iproc); |
| 898 |
|
| 899 |
if (error < 0) { |
| 900 |
return error; |
| 901 |
} |
| 902 |
|
| 903 |
for (int i = 0; i < NNCMAP; i++) { |
| 904 |
error = ex_get_node_cmap(fileid, node_map_ids[i], node_ids, proc_ids, iproc); |
| 905 |
|
| 906 |
if (error < 0) { |
| 907 |
return error; |
| 908 |
} |
| 909 |
|
| 910 |
for (int j = 0; j < NCNTCM; j++) { |
| 911 |
if (node_ids[j] != 2 * (j + 1)) { |
| 912 |
return -1; |
| 913 |
} |
| 914 |
if (proc_ids[j] != 3 * (j + 1)) { |
| 915 |
return -1; |
| 916 |
} |
| 917 |
} |
| 918 |
} |
| 919 |
} |
| 920 |
|
| 921 |
return 0; |
| 922 |
} |
| 923 |
|
| 924 |
/*****************************************************************************/ |
| 925 |
int ne_test_gecm(int fileid) |
| 926 |
{ |
| 927 |
int elem_ids[ECNTCM], elem_map_cnts[NECMAP], proc_ids[ECNTCM]; |
| 928 |
int side_ids[ECNTCM], elem_map_ids[NECMAP]; |
| 929 |
|
| 930 |
for (int iproc = 0; iproc < NPROCF; iproc++) { |
| 931 |
|
| 932 |
int error = ex_get_cmap_params(fileid, NULL, NULL, elem_map_ids, elem_map_cnts, iproc); |
| 933 |
|
| 934 |
if (error < 0) { |
| 935 |
return error; |
| 936 |
} |
| 937 |
|
| 938 |
for (int i = 0; i < NECMAP; i++) { |
| 939 |
error = ex_get_elem_cmap(fileid, elem_map_ids[i], elem_ids, side_ids, proc_ids, iproc); |
| 940 |
|
| 941 |
if (error < 0) { |
| 942 |
return error; |
| 943 |
} |
| 944 |
|
| 945 |
for (int j = 0; j < ECNTCM; j++) { |
| 946 |
if (elem_ids[j] != 2 * (j + 1)) { |
| 947 |
return -1; |
| 948 |
} |
| 949 |
if (side_ids[j] != 3 * (j + 1)) { |
| 950 |
return -1; |
| 951 |
} |
| 952 |
if (proc_ids[j] != 4 * (j + 1)) { |
| 953 |
return -1; |
| 954 |
} |
| 955 |
} |
| 956 |
} |
| 957 |
} |
| 958 |
|
| 959 |
return 0; |
| 960 |
} |
| 961 |
|
| 962 |
/*****************************************************************************/ |
| 963 |
int ne_test_plbpc(int fileid) |
| 964 |
{ |
| 965 |
int num_int_nodes[NPROCF], num_bor_nodes[NPROCF], num_ext_nodes[NPROCF]; |
| 966 |
int num_int_elems[NPROCF], num_bor_elems[NPROCF]; |
| 967 |
int num_node_cmaps[NPROCF], num_elem_cmaps[NPROCF]; |
| 968 |
|
| 969 |
/* Set up the vectors */ |
| 970 |
for (int iproc = 0; iproc < NPROCF; iproc++) { |
| 971 |
num_int_nodes[iproc] = NINTN; |
| 972 |
num_bor_nodes[iproc] = NBORN; |
| 973 |
num_ext_nodes[iproc] = NEXTN; |
| 974 |
|
| 975 |
num_int_elems[iproc] = NINTE; |
| 976 |
num_bor_elems[iproc] = NBORE; |
| 977 |
|
| 978 |
num_node_cmaps[iproc] = NNCMAP; |
| 979 |
num_elem_cmaps[iproc] = NECMAP; |
| 980 |
} |
| 981 |
|
| 982 |
return ex_put_loadbal_param_cc(fileid, num_int_nodes, num_bor_nodes, num_ext_nodes, num_int_elems, |
| 983 |
num_bor_elems, num_node_cmaps, num_elem_cmaps); |
| 984 |
} |
| 985 |
|
| 986 |
/*****************************************************************************/ |
| 987 |
int ne_test_pcmpc(int fileid) |
| 988 |
{ |
| 989 |
int nmap_ids[NNCMAP * NPROCF], nmap_n_cnts[NNCMAP * NPROCF]; |
| 990 |
int nmap_proc_ptr[NPROCF + 1]; |
| 991 |
int emap_ids[NECMAP * NPROCF], emap_e_cnts[NECMAP * NPROCF]; |
| 992 |
int emap_proc_ptr[NPROCF + 1]; |
| 993 |
|
| 994 |
nmap_proc_ptr[0] = 0; |
| 995 |
emap_proc_ptr[0] = 0; |
| 996 |
int n_cntr = 0; |
| 997 |
int e_cntr = 0; |
| 998 |
for (int iproc = 0; iproc < NPROCF; iproc++) { |
| 999 |
|
| 1000 |
for (int j = 0; j < NNCMAP; j++) { |
| 1001 |
nmap_ids[n_cntr] = (j + 1); |
| 1002 |
nmap_n_cnts[n_cntr++] = NCNTCM; |
| 1003 |
} |
| 1004 |
|
| 1005 |
for (int j = 0; j < NECMAP; j++) { |
| 1006 |
emap_ids[e_cntr] = 2 * (j + 1); |
| 1007 |
emap_e_cnts[e_cntr++] = ECNTCM; |
| 1008 |
} |
| 1009 |
|
| 1010 |
nmap_proc_ptr[iproc + 1] = nmap_proc_ptr[iproc] + NNCMAP; |
| 1011 |
emap_proc_ptr[iproc + 1] = emap_proc_ptr[iproc] + NECMAP; |
| 1012 |
} |
| 1013 |
|
| 1014 |
return ex_put_cmap_params_cc(fileid, nmap_ids, nmap_n_cnts, nmap_proc_ptr, emap_ids, emap_e_cnts, |
| 1015 |
emap_proc_ptr); |
| 1016 |
} |