Skip to content

Commit

Permalink
fix for usgs#303
Browse files Browse the repository at this point in the history
  • Loading branch information
jtwhite79 committed Jul 19, 2024
1 parent 050f1c4 commit b07a526
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 26 deletions.
9 changes: 8 additions & 1 deletion benchmarks/basic_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,14 @@ def sweep_bin_test():
#def fail_test():
# raise Exception("fail please")

def invest():
pst = pyemu.Pst(os.path.join("PESTPPTest","PestPilotPointTest.pst"))




if __name__ == "__main__":
invest()
#run()
#mf6_v5_ies_test()
#prep_ends()
Expand Down Expand Up @@ -1529,7 +1536,7 @@ def sweep_bin_test():
#shutil.copy2(os.path.join("..","exe","windows","x64","Debug","pestpp-ies.exe"),os.path.join("..","bin","win","pestpp-ies.exe"))
#tplins1_test()

fr_timeout_test()
#fr_timeout_test()
#mf6_v5_ies_test()
#mf6_v5_sen_test()

Expand Down
9 changes: 8 additions & 1 deletion src/libs/pestpp_common/Pest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,14 @@ int Pest::process_ctl_file(ifstream& fin, string _pst_filename, ofstream& f_rec)
{
convert_ip(tokens[0], num_tpl_file);
if (tokens.size() >= 5) {
convert_ip(tokens[4], control_info.numcom);
try {
convert_ip(tokens[4], control_info.numcom);
}
catch (...)
{
cout << "WARNING: error parsing '" << tokens[4] <<"' to numcom option...continuing" << endl;
control_info.numcom = 0;
}
}
else {
control_info.numcom = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/programs/gsa/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ int main(int argc, char* argv[])
}
catch (PestError e)
{
cerr << "Error prococessing control file: " << ctl_file << endl << endl;
frec << "Error processing control file: " << ctl_file << endl << endl;
frec << e.what() << endl << endl;
cerr << "Error prococessing control file: " << ctl_file << endl << endl;
cerr << e.what() << endl << endl;
throw(e);
}
Expand Down
10 changes: 7 additions & 3 deletions src/programs/pest++/pest++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ int main(int argc, char* argv[])
ctl_file = file_manager.build_filename("pst");
yam_agent.process_ctl_file(ctl_file);
}
catch (PestError e)
catch (exception &e)
{
frec << "Error processing control file: " << ctl_file << endl << endl;
frec << e.what() << endl << endl;
cerr << "Error prococessing control file: " << ctl_file << endl << endl;
cerr << e.what() << endl << endl;
throw(e);
Expand Down Expand Up @@ -203,9 +205,11 @@ int main(int argc, char* argv[])
performance_log.log_event("finished processing control file");
#ifndef _DEBUG
}
catch (PestError e)
catch (exception &e)
{
cerr << "Error prococessing control file: " << filename << endl << endl;
fout_rec << "Error processing control file: " << filename << endl << endl;
fout_rec << e.what() << endl << endl;
cerr << "Error processing control file: " << filename << endl << endl;
cerr << e.what() << endl << endl;
throw(e);
}
Expand Down
12 changes: 7 additions & 5 deletions src/programs/pestpp-da/pestpp-da.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ int main(int argc, char* argv[])
yam_agent.process_ctl_file(ctl_file);

}
catch (PestError e)
catch (exception &e)
{
frec << "Error processing control file: " << ctl_file << endl << endl;
frec << e.what() << endl << endl;
cerr << "Error processing control file: " << ctl_file << endl << endl;
cerr << e.what() << endl << endl;
throw(e);
Expand Down Expand Up @@ -197,13 +199,13 @@ int main(int argc, char* argv[])
pest_scenario.assign_da_cycles(fout_rec);
performance_log.log_event("finished processing control file");
}
catch (PestError e)
catch (exception &e)
{
cerr << "Error prococessing control file: " << filename << endl << endl;
cerr << "Error processing control file: " << filename << endl << endl;
cerr << e.what() << endl << endl;
fout_rec << "Error prococessing control file: " << filename << endl << endl;
fout_rec << "Error processing control file: " << filename << endl << endl;
fout_rec << e.what() << endl << endl;
fout_rec.close();

throw(e);
}
pest_scenario.check_inputs(fout_rec);
Expand Down
19 changes: 16 additions & 3 deletions src/programs/pestpp-ies/pestpp-ies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ int main(int argc, char* argv[])
yam_agent.process_ctl_file(ctl_file);

}
catch (PestError e) {
catch (exception &e) {
frec << "Error processing control file: " << ctl_file << endl << endl;
frec << e.what() << endl << endl;
cerr << "Error processing control file: " << ctl_file << endl << endl;
cerr << e.what() << endl << endl;
throw (e);
Expand Down Expand Up @@ -154,8 +156,18 @@ int main(int argc, char* argv[])
Pest pest_scenario;
//try {
performance_log.log_event("starting to process control file");
pest_scenario.process_ctl_file(file_manager.open_ifile_ext("pst"), file_manager.build_filename("pst"),
fout_rec);
try {
pest_scenario.process_ctl_file(file_manager.open_ifile_ext("pst"), file_manager.build_filename("pst"),
fout_rec);
}
catch (exception &e)
{
fout_rec << "Error processing control file: " << file_manager.build_filename("pst") << endl << endl;
fout_rec << e.what() << endl << endl;
cerr << "Error processing control file: " << file_manager.build_filename("pst") << endl << endl;
cerr << e.what() << endl << endl;
throw(e);
}
file_manager.close_file("pst");
performance_log.log_event("finished processing control file");
/*}
Expand Down Expand Up @@ -308,6 +320,7 @@ int main(int argc, char* argv[])
catch (exception &e)
{
cout << "Error condition prevents further execution: " << endl << e.what() << endl;

//cout << "press enter to continue" << endl;
//char buf[256];
//OperSys::gets_s(buf, sizeof(buf));
Expand Down
10 changes: 6 additions & 4 deletions src/programs/pestpp-mou/pestpp-mou.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ int main(int argc, char* argv[])
}
catch (PestError e)
{
frec << "Error processing control file: " << ctl_file << endl << endl;
frec << e.what() << endl << endl;
cerr << "Error processing control file: " << ctl_file << endl << endl;
cerr << e.what() << endl << endl;
throw(e);
Expand Down Expand Up @@ -180,13 +182,13 @@ int main(int argc, char* argv[])
file_manager.close_file("pst");
performance_log.log_event("finished processing control file");
}
catch (PestError e)
catch (exception &e)
{
cerr << "Error prococessing control file: " << filename << endl << endl;
cerr << "Error processing control file: " << filename << endl << endl;
cerr << e.what() << endl << endl;
fout_rec << "Error prococessing control file: " << filename << endl << endl;
fout_rec << "Error processing control file: " << filename << endl << endl;
fout_rec << e.what() << endl << endl;
fout_rec.close();

throw(e);
}
pest_scenario.check_inputs(fout_rec);
Expand Down
6 changes: 4 additions & 2 deletions src/programs/pestpp-opt/pestpp-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ int main(int argc, char* argv[])
}
catch (PestError e)
{
frec << "Error processing control file: " << ctl_file << endl << endl;
frec << e.what() << endl << endl;
cerr << "Error prococessing control file: " << ctl_file << endl << endl;
cerr << e.what() << endl << endl;
throw(e);
Expand Down Expand Up @@ -168,9 +170,9 @@ int main(int argc, char* argv[])
performance_log.log_event("finished processing control file");
#ifndef _DEBUG
}
catch (PestError e)
catch (exception &e)
{
cerr << "Error prococessing control file: " << filename << endl << endl;
cerr << "Error processing control file: " << filename << endl << endl;
cerr << e.what() << endl << endl;
throw(e);
}
Expand Down
10 changes: 6 additions & 4 deletions src/programs/pestpp-sqp/pestpp-sqp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ int main(int argc, char* argv[])
yam_agent.process_ctl_file(ctl_file);

}
catch (PestError e)
catch (exception &e)
{
frec << "Error processing control file: " << ctl_file << endl << endl;
frec << e.what() << endl << endl;
cerr << "Error processing control file: " << ctl_file << endl << endl;
cerr << e.what() << endl << endl;
throw(e);
Expand Down Expand Up @@ -170,11 +172,11 @@ int main(int argc, char* argv[])
file_manager.close_file("pst");
performance_log.log_event("finished processing control file");
}
catch (PestError e)
catch (exception &e)
{
cerr << "Error prococessing control file: " << cmdline.ctl_file_name << endl << endl;
cerr << "Error processing control file: " << cmdline.ctl_file_name << endl << endl;
cerr << e.what() << endl << endl;
fout_rec << "Error prococessing control file: " << cmdline.ctl_file_name << endl << endl;
fout_rec << "Error processing control file: " << cmdline.ctl_file_name << endl << endl;
fout_rec << e.what() << endl << endl;
fout_rec.close();
throw(e);
Expand Down
6 changes: 4 additions & 2 deletions src/programs/sweep/sweep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,10 @@ int main(int argc, char* argv[])
yam_agent.process_ctl_file(ctl_file);

}
catch (PestError e)
catch (exception &e)
{
frec << "Error processing control file: " << ctl_file << endl << endl;
frec << e.what() << endl << endl;
cerr << "Error prococessing control file: " << ctl_file << endl << endl;
cerr << e.what() << endl << endl;
throw(e);
Expand Down Expand Up @@ -567,7 +569,7 @@ int main(int argc, char* argv[])
file_manager.close_file("pst");
performance_log.log_event("finished processing control file");
}
catch (PestError e)
catch (exception &e)
{
cerr << "Error processing control file: " << filename << endl << endl;
cerr << e.what() << endl << endl;
Expand Down

0 comments on commit b07a526

Please sign in to comment.