From 64c019a501c509de81cabc6b579417ac75897073 Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Sun, 29 Mar 2015 20:18:35 +0200
Subject: [PATCH] [Cleanup] Allow subdirectories in restart template

---
 src/sand-wedge.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/sand-wedge.cc b/src/sand-wedge.cc
index 6f7dff09..0e71cefc 100644
--- a/src/sand-wedge.cc
+++ b/src/sand-wedge.cc
@@ -213,6 +213,9 @@ int main(int argc, char *argv[]) {
     auto const firstRestart = parset.get<size_t>("restarts.first");
     auto const restartSpacing = parset.get<size_t>("restarts.spacing");
     auto const restartTemplate = parset.get<std::string>("restarts.template");
+    auto const restartDirectory =
+        boost::filesystem::path(restartTemplate).parent_path();
+
     if (firstRestart != 0)
       DataIO::loadData(programState,
                        str(boost::format(restartTemplate) % firstRestart));
@@ -282,9 +285,12 @@ int main(int argc, char *argv[]) {
       specialVelocityWriter.write(velocity);
       specialDisplacementWriter.write(displacement);
 
-      if (programState.timeStep % restartSpacing == 0)
+      if (programState.timeStep % restartSpacing == 0) {
+        if (!boost::filesystem::is_directory(restartDirectory))
+          boost::filesystem::create_directories(restartDirectory);
         DataIO::writeData(programState, str(boost::format(restartTemplate) %
                                             programState.timeStep));
+      }
 
       if (parset.get<bool>("io.writeVTK")) {
         ScalarVector stress;
-- 
GitLab