@@ -75,16 +75,11 @@ void Reader ::ReadInputFile(char input_fn[])
7575 microstructure = j[" microstructure" ];
7676 std::snprintf (ms_filename, sizeof (ms_filename), " %s" , microstructure[" filepath" ].get <std::string>().c_str ());
7777 // dataset name handling
78- std::string tmp_str = microstructure[" datasetname" ].get <std::string>();
79- if (tmp_str.empty ()) {
80- throw std::invalid_argument (
81- " datasetname must not be empty and must refer to a valid HDF5 path" );
82- }
83- // Ensure absolute HDF5 path, leeading slash
84- if (tmp_str.front () != ' /' ) {
85- tmp_str.insert (tmp_str.begin (), ' /' );
86- }
87- std::snprintf (ms_datasetname, sizeof (ms_datasetname), " %s" , tmp_str.c_str ());
78+ const auto tmp_str = microstructure[" datasetname" ].get <std::string>();
79+ if (tmp_str.empty ())
80+ throw std::invalid_argument (" datasetname must not be empty and must refer to a valid HDF5 path" );
81+ // Ensure absolute HDF5 path, leading slash
82+ std::snprintf (ms_datasetname, sizeof (ms_datasetname), " %s%s" , tmp_str.front () == ' /' ? " " : " /" , tmp_str.c_str ());
8883 L = microstructure[" L" ].get <vector<double >>();
8984
9085 if (j.contains (" results_prefix" )) {
@@ -100,6 +95,15 @@ void Reader ::ReadInputFile(char input_fn[])
10095 TOL = errorParameters[" tolerance" ].get <double >();
10196 n_it = j[" n_it" ].get <int >();
10297
98+ extrapolate_displacement = j.value (" extrapolate_displacement" , extrapolate_displacement);
99+
100+ if (j.contains (" linesearch_parameters" )) {
101+ ls_max_iter = j[" linesearch_parameters" ].value (" max_iter" , ls_max_iter);
102+ ls_tol = j[" linesearch_parameters" ].value (" tol" , ls_tol);
103+ if (ls_max_iter < 1 || ls_tol <= 0.0 )
104+ throw std::invalid_argument (" linesearch_parameters: max_iter >= 1 and tol > 0 required" );
105+ }
106+
103107 problemType = j[" problem_type" ].get <string>();
104108 method = j[" method" ].get <string>();
105109
@@ -173,7 +177,7 @@ void Reader ::ReadInputFile(char input_fn[])
173177 }
174178
175179 } catch (const std::exception &e) {
176- fprintf (stderr, " ERROR trying to read input file '%s' for FANS\n " , input_fn);
180+ fprintf (stderr, " ERROR trying to read input file '%s' for FANS: %s \n " , input_fn, e. what () );
177181 exit (10 );
178182 }
179183}
0 commit comments