48 #include <Zoltan2_config.h>
50 #include <Teuchos_ParameterList.hpp>
51 #include <Teuchos_DefaultComm.hpp>
64 {
"debug_output_file",
"temp.txt",
"5"},
65 {
"timer_output_file",
"timerInfo.txt",
"10.3"},
66 {
"memory_output_file",
"memory.txt",
"3.33"}
70 #ifdef HAVE_ZOLTAN2_PULP
77 {
"error_check_level",
"basic_assertions",
"invalid_assertion_request"},
78 {
"debug_level",
"basic_status",
"invalid_status"},
79 {
"timer_type",
"no_timers",
"invalid_timers"},
80 {
"debug_output_stream",
"std::cout",
"invalid_stream"},
81 {
"timer_output_stream",
"/dev/null",
"invalid_stream"},
82 {
"memory_output_stream",
"std::cerr",
"invalid_stream"},
83 {
"debug_procs",
"all",
"not_a_valid_list_of_any_type"},
84 {
"mj_parts",
"2,3,4",
"not_a_valid_list_of_any_type"},
85 {
"memory_procs",
"2-10",
"not_a_valid_list_of_any_type"},
86 {
"order_method",
"rcm",
"invalid_method"},
87 {
"order_method_type",
"local",
"invalid_method_type"},
88 {
"order_package",
"amd",
"invalid_package"},
89 {
"partitioning_objective",
"balance_object_weight",
"invalid_objective"},
90 {
"partitioning_approach",
"repartition",
"invalid_approach"},
91 {
"objects_to_partition",
"graph_vertices",
"invalid_objects"},
92 {
"model",
"graph",
"invalid_model"},
93 {
"algorithm",
"rcb",
"invalid_algorithm"},
94 {
"symmetrize_input",
"transpose",
"invalid_option"},
95 {
"symmetrize_input",
"transpose",
"invalid_option"},
96 {
"mj_concurrent_part_count",
"0",
"invalid_value"},
97 {
"mj_recursion_depth",
"0",
"invalid_value"},
98 {
"mapping_type",
"0",
"invalid_value"},
99 {
"imbalance_tolerance",
"1.1",
"invalid_option"},
100 {
"mj_minimum_migration_imbalance",
"1.1",
"invalid_option"},
101 #ifdef HAVE_ZOLTAN2_PULP
102 {
"pulp_vert_imbalance",
"1.1",
"invalid_option"},
103 {
"pulp_edge_imbalance",
"1.1",
"invalid_option"},
104 #endif // HAVE_ZOLTAN2_PULP
105 {
"scotch_imbalance_ratio",
"1.1",
"invalid_option"},
106 {
"compute_metrics",
"false",
"invalid_bool_setting"},
107 {
"rectilinear",
"false",
"invalid_bool_setting"},
108 {
"subset_graph",
"false",
"invalid_bool_setting"},
109 {
"mj_enable_rcb",
"true",
"invalid_bool_setting"},
110 {
"mj_keep_part_boxes",
"true",
"invalid_bool_setting"},
111 {
"num_global_parts",
"1",
"invalid_value"},
112 {
"num_local_parts",
"0",
"invalid_value"},
113 {
"mj_premigration_option",
"1",
"invalid_value"},
114 {
"mj_migration_option",
"2",
"invalid_value"},
117 template <
typename T>
121 Teuchos::ParameterList validParameters;
122 pl.set(paramName, badValue);
123 std::cout << std::endl;
124 std::cout << paramName <<
" = " << badValue << std::endl;
129 pl.validateParametersAndSetDefaults(validParameters);
131 catch(std::exception &e){
132 std::cout <<
"Correctly generated an error:" << std::endl;
133 std::cout << e.what() << std::endl;
138 std::cerr <<
"Bad parameter value was not detected in parameter list." << std::endl;
151 Teuchos::ParameterList valid(
"valid parameter list");
154 typedef Teuchos::AnyNumberParameterEntryValidator validator_t;
155 Teuchos::RCP<const validator_t> anyNumVal = Teuchos::rcp(
new validator_t);
160 std::cout <<
"set good default value" << std::endl;
162 std::string parameterName(
"parameterName");
164 valid.set(parameterName, 5.0,
"parameterDoc", anyNumVal);
166 catch (std::exception &e) {
167 std::cout <<
"FAIL error setting good default value "
168 << e.what() << std::endl;
172 double dd = valid.getEntry(parameterName).getValue<
double>(&dd);
173 std::cout <<
"good default value <double> = " << dd << std::endl;
177 Teuchos::ParameterList user(
"user");
180 std::cout <<
"test good user value" << std::endl;
181 user.set(parameterName,
"0.123");
183 user.validateParametersAndSetDefaults(valid);
185 catch (std::exception &e) {
186 std::cout <<
"FAIL " << e.what() << std::endl;
190 dd = user.getEntry(parameterName).getValue<
double>(&dd);
191 std::cout <<
"good user value <double> = " << dd << std::endl;
194 std::cout <<
"test bogus user value" << std::endl;
200 user.set(parameterName,
"bogus");
202 catch(std::exception &e) {
204 std::cout <<
"Parameter list correctly rejected bogus user value."
210 std::cout <<
"FAIL parameter list accepted a bogus user value"
217 std::cout <<
"set bogus default value" << std::endl;
219 std::string parameterNameToo(
"parameterNameToo");
222 valid.set(parameterNameToo,
"bogus",
"parameterDoc", anyNumVal);
224 catch (std::exception &e) {
226 std::cout <<
"Parameter list correctly rejected bogus default value."
232 std::cout <<
"FAIL parameter list accepted a bogus default value"
237 std::cout <<
"PASS" << std::endl;
243 int main(
int narg,
char *arg[])
245 Tpetra::ScopeGuard tscope(&narg, &arg);
246 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
248 int rank = comm->getRank();
257 if( tempTest != 0 ) {
263 Teuchos::ParameterList validParameters;
264 Teuchos::ParameterList myParams(
"testParameterList");
266 for (
int i=0; i <
NUMSTR; i++){
270 for (
int i=0; i <
NUMFN; i++){
274 Teuchos::ParameterList origParams(myParams);
281 myParams.validateParametersAndSetDefaults(validParameters);
284 catch(std::exception &e){
285 std::cerr <<
"Validate parameters generated an error:" << std::endl;
286 std::cerr << e.what() << std::endl;
287 std::cerr <<
"FAIL" << std::endl;
291 std::cout << std::endl;
292 std::cout <<
"Parameters after validation: " << std::endl;
293 std::cout << myParams << std::endl;
296 for (
int i=0; i <
NUMSTR; i++){
297 Teuchos::ParameterList badParams(origParams);
299 testInvalidValue<string>(badParams,
strParams[i][0], strParams[i][2]);
301 std::cout <<
"FAIL" << std::endl;
306 for (
int i=0; i <
NUMFN; i++){
307 Teuchos::ParameterList badParams(origParams);
308 std::istringstream iss(
fnParams[i][2]);
312 testInvalidValue<double>(badParams,
fnParams[i][0], badVal);
314 std::cout <<
"FAIL" << std::endl;
322 std::cout << std::endl;
323 std::cout <<
"Parameter documentation:" << std::endl;
326 std::cout <<
"PASS" << std::endl;
void createValidatorList(const Teuchos::ParameterList &plIn, Teuchos::ParameterList &plOut)
Create a list by adding validators to the users parameter list.
static void convertStringToInt(Teuchos::ParameterList ¶ms)
Convert parameters of type Teuchos::StringToIntegralParameterEntryValidator<int> to integer...
int main(int narg, char *arg[])
void printListDocumentation(const Teuchos::ParameterList &pl, std::ostream &os, std::string listNames)
static string fnParams[NUMFN][3]
static const std::string fail
Defines the Environment class.
int testInvalidValue(Teuchos::ParameterList &pl, string paramName, T badValue)
static string strParams[NUMSTR][3]