| 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 |
#include "fmt/ostream.h" |
| 9 |
#include "nem_spread.h" // for NemSpread |
| 10 |
#include "ps_pario_const.h" // for PIO_Info, Parallel_IO |
| 11 |
#include "rf_io_const.h" // for ExoFile, Exo_LB_File, etc |
| 12 |
#include <copy_string_cpp.h> |
| 13 |
#include <cstdio> // for stderr |
| 14 |
#include <cstring> // for strlen |
| 15 |
#include <exodusII.h> // for ex_close, ex_open, EX_READ |
| 16 |
|
| 17 |
template int NemSpread<double, int>::check_inp(); |
| 18 |
template int NemSpread<float, int>::check_inp(); |
| 19 |
template int NemSpread<double, int64_t>::check_inp(); |
| 20 |
template int NemSpread<float, int64_t>::check_inp(); |
| 21 |
|
| 22 |
template <typename T, typename INT> int NemSpread<T, INT>::check_inp() |
| 23 |
{ |
| 24 |
int exid; |
| 25 |
int icpu_ws = 0; |
| 26 |
int iio_ws = 0; |
| 27 |
float vers = 0.0; |
| 28 |
|
| 29 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 30 |
/* Check the input and output files */ |
| 31 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 32 |
/* check if the Mesh file was specified */ |
| 33 |
if (ExoFile.empty()) { |
| 34 |
fmt::print(stderr, "{}: fatal - must specify input FEM file.\n", __func__); |
| 35 |
return 0; |
| 36 |
} |
| 37 |
|
| 38 |
/* check for the existence of a readable FEM file */ |
| 39 |
int mode = EX_READ | int64api; |
| 40 |
if ((exid = ex_open(ExoFile.c_str(), mode, &icpu_ws, &iio_ws, &vers)) < 0) { |
| 41 |
fmt::print(stderr, "{}: fatal - unable to open input FEM file, {}.\n", __func__, |
| 42 |
ExoFile.c_str()); |
| 43 |
return 0; |
| 44 |
} |
| 45 |
ex_close(exid); |
| 46 |
|
| 47 |
/* check that there is a load balance file specified */ |
| 48 |
if (Exo_LB_File.empty()) { |
| 49 |
fmt::print(stderr, "{}: fatal - must specify input FEM file.\n", __func__); |
| 50 |
return 0; |
| 51 |
} |
| 52 |
|
| 53 |
/* check for the existence of a readable load balance file */ |
| 54 |
icpu_ws = 0; |
| 55 |
iio_ws = 0; |
| 56 |
if ((exid = ex_open(Exo_LB_File.c_str(), mode, &icpu_ws, &iio_ws, &vers)) < 0) { |
| 57 |
fmt::print(stderr, "{}: fatal - unable to open load balance file, {}.\n", __func__, |
| 58 |
Exo_LB_File.c_str()); |
| 59 |
return 0; |
| 60 |
} |
| 61 |
ex_close(exid); |
| 62 |
|
| 63 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 64 |
/* Check the result spreading specifications */ |
| 65 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 66 |
|
| 67 |
/* check if anything was specified for restart information */ |
| 68 |
if (Restart_Info.Flag < 0) { |
| 69 |
/* default is now to spread results if they exist */ |
| 70 |
Restart_Info.Flag = 1; |
| 71 |
Restart_Info.Num_Times = -1; /* -1 means spread all results */ |
| 72 |
} |
| 73 |
|
| 74 |
/* check to see if there is a separate restart file */ |
| 75 |
if (Restart_Info.Flag > 0) { |
| 76 |
if (Exo_Res_File.empty()) { |
| 77 |
Exo_Res_File = ExoFile; /* if not use the input FEM file */ |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
/* check if space is to be reserved for variables in the parallel files */ |
| 82 |
if (Num_Glob_Var < 0) { |
| 83 |
Num_Glob_Var = 0; |
| 84 |
} |
| 85 |
if (Num_Nod_Var < 0) { |
| 86 |
Num_Nod_Var = 0; |
| 87 |
} |
| 88 |
if (Num_Elem_Var < 0) { |
| 89 |
Num_Elem_Var = 0; |
| 90 |
} |
| 91 |
if (Num_Nset_Var < 0) { |
| 92 |
Num_Nset_Var = 0; |
| 93 |
} |
| 94 |
if (Num_Sset_Var < 0) { |
| 95 |
Num_Sset_Var = 0; |
| 96 |
} |
| 97 |
|
| 98 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 99 |
/* Check the parallel IO specifications */ |
| 100 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 101 |
|
| 102 |
/* default is not to have preceding 0's in the disk names */ |
| 103 |
if (PIO_Info.Zeros < 0) { |
| 104 |
PIO_Info.Zeros = 0; |
| 105 |
} |
| 106 |
/* most systems that we deal with start their files systems with 1 not 0 */ |
| 107 |
if (PIO_Info.PDsk_Add_Fact < 0) { |
| 108 |
PIO_Info.PDsk_Add_Fact = 1; |
| 109 |
} |
| 110 |
|
| 111 |
/* check that there is a list of disks, or a number of raids */ |
| 112 |
if ((PIO_Info.Dsk_List_Cnt <= 0) && (PIO_Info.Num_Dsk_Ctrlrs <= 0)) { |
| 113 |
fmt::print(stderr, |
| 114 |
"{}: fatal - must specify a number of raids, or a disk" |
| 115 |
" list.\n", |
| 116 |
__func__); |
| 117 |
return 0; |
| 118 |
} |
| 119 |
|
| 120 |
if (PIO_Info.Par_Dsk_Root.empty()) { |
| 121 |
fmt::print(stderr, |
| 122 |
"{}: Error - Root directory for parallel files must" |
| 123 |
" be specified.\n", |
| 124 |
__func__); |
| 125 |
return 0; |
| 126 |
} |
| 127 |
|
| 128 |
if (PIO_Info.Par_Dsk_SubDirec.empty()) { |
| 129 |
fmt::print(stderr, |
| 130 |
"{}: Error - Subdirectory for parallel files must" |
| 131 |
" be specified.\n", |
| 132 |
__func__); |
| 133 |
return 0; |
| 134 |
} |
| 135 |
|
| 136 |
return 1; |
| 137 |
} |