[cig-commits] r1306 - trunk/aspect/source/simulator
bangerth at dealii.org
bangerth at dealii.org
Sun Oct 21 17:30:10 PDT 2012
Author: bangerth
Date: 2012-10-21 18:30:09 -0600 (Sun, 21 Oct 2012)
New Revision: 1306
Modified:
trunk/aspect/source/simulator/parameters.cc
Log:
Detect if the output directory does not exist and abort there, rather than waiting till we actually try to write into that directory.
Modified: trunk/aspect/source/simulator/parameters.cc
===================================================================
--- trunk/aspect/source/simulator/parameters.cc 2012-10-22 00:00:18 UTC (rev 1305)
+++ trunk/aspect/source/simulator/parameters.cc 2012-10-22 00:30:09 UTC (rev 1306)
@@ -25,6 +25,7 @@
#include <deal.II/base/parameter_handler.h>
+#include <dirent.h>
namespace aspect
@@ -467,6 +468,23 @@
else if (output_directory[output_directory.size()-1] != '/')
output_directory += "/";
+ // verify that the output directory actually exists. trying to
+ // write to a non-existing output directory will eventually
+ // produce an error but one not easily understood. since
+ // this is no error where a nicely formatted error message
+ // with a backtrace is likely very useful, just print an
+ // error and exit
+ if (opendir(output_directory.c_str()) == NULL)
+ {
+ std::cerr << "\n"
+ << "-----------------------------------------------------------------------------\n"
+ << "The output directory <" << output_directory
+ << "> provided in the input file appears not to exist!\n"
+ << "-----------------------------------------------------------------------------\n"
+ << std::endl;
+ std::exit (1);
+ }
+
surface_pressure = prm.get_double ("Surface pressure");
adiabatic_surface_temperature = prm.get_double ("Adiabatic surface temperature");
pressure_normalization = prm.get("Pressure normalization");
More information about the CIG-COMMITS
mailing list