]> git.treefish.org Git - phys/latlib.git/commitdiff
Let outdir be created from rank 0.
authorAlexander Schmidt <alex@treefish.org>
Wed, 4 Dec 2013 11:07:06 +0000 (12:07 +0100)
committerAlexander Schmidt <alex@treefish.org>
Wed, 4 Dec 2013 11:07:06 +0000 (12:07 +0100)
CMakeLists.txt
writeout.cpp

index 761a585acfaa4b06e0af0f33a6b27982f3833c7a..0521c1fa7e7d73326bac7db15540ac0cb8537a3d 100644 (file)
@@ -7,7 +7,7 @@ project(latlib)
 
 cmake_minimum_required(VERSION 2.8)
 
-find_package(Boost 1.49 COMPONENTS iostreams REQUIRED)
+find_package(Boost 1.49 COMPONENTS filesystem iostreams REQUIRED)
 include_directories(${Boost_INCLUDE_DIRS}) 
 
 add_library(lat_configcache configcache.cpp)
@@ -19,6 +19,7 @@ target_link_libraries(lat_hypercache lat_configcache lat_writeout)
 add_library(lat_neigh neigh.cpp)
 
 add_library(lat_writeout writeout.cpp)
+target_link_libraries(lat_writeout ${Boost_LIBRARIES})
 
 add_library(lat_paraq paraq.cpp)
 
index af67fb5fc913dfa9032aea8df877578e646007b4..e10a9d446da6e4db3e0109a0628239b4ceaa54bc 100644 (file)
@@ -11,6 +11,8 @@
 #include <errno.h>
 #include <unistd.h>
 
+#include <boost/filesystem.hpp>
+
 using namespace std;
 
 string writeout::tstamp(const long& timestamp)
@@ -53,7 +55,14 @@ writeout::writeout(const string& wdir, const string& _signature,
     sprintf(cRank, "%d", rank);
     fulldir = wdir + "/" + tstamp(timestamp) + "_" + signature + ".tmp";
 
-    mkdir(fulldir.c_str(), 0775);
+    if (rank==0)
+      mkdir(fulldir.c_str(), 0775);
+    else {
+      while ( ! ( boost::filesystem::exists(fulldir) && boost::filesystem::is_directory(fulldir) ) ) {
+       cerr << "WRITOUT: Waiting for rank 0 to create out directory." << endl << flush;
+       sleep(1);
+      }
+    }
 
     logf.open( (fulldir + "/rank" + cRank + ".log").c_str() );