[cig-commits] [commit] knepley/upgrade-petsc-interface: Create path (if necessary) for output files. (9c58e45)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Fri Nov 22 14:33:36 PST 2013


Repository : ssh://geoshell/pylith

On branch  : knepley/upgrade-petsc-interface
Link       : https://github.com/geodynamics/pylith/compare/fc9bae9073e01349a5b61ca62497308467621296...9c58e45cd6d5031d89122ae1f646064e9a4e0dbf

>---------------------------------------------------------------

commit 9c58e45cd6d5031d89122ae1f646064e9a4e0dbf
Author: Brad Aagaard <baagaard at usgs.gov>
Date:   Fri Nov 22 14:36:25 2013 -0800

    Create path (if necessary) for output files.


>---------------------------------------------------------------

9c58e45cd6d5031d89122ae1f646064e9a4e0dbf
 pylith/meshio/DataWriter.py        |  6 +++++-
 pylith/meshio/DataWriterHDF5.py    |  2 +-
 pylith/meshio/DataWriterHDF5Ext.py | 10 +---------
 pylith/meshio/DataWriterVTK.py     |  2 +-
 4 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/pylith/meshio/DataWriter.py b/pylith/meshio/DataWriter.py
index 432c51b..aeccb21 100644
--- a/pylith/meshio/DataWriter.py
+++ b/pylith/meshio/DataWriter.py
@@ -51,10 +51,14 @@ class DataWriter(PetscComponent):
     return
 
 
-  def initialize(self, normalizer):
+  def initialize(self, normalizer, filename):
     """
     Initialize writer.
     """
+    import os
+    relpath = os.path.dirname(filename)
+    if not os.path.exists(relpath):
+      os.makedirs(relpath)
     return
 
 
diff --git a/pylith/meshio/DataWriterHDF5.py b/pylith/meshio/DataWriterHDF5.py
index 9d4f9a7..502e5de 100644
--- a/pylith/meshio/DataWriterHDF5.py
+++ b/pylith/meshio/DataWriterHDF5.py
@@ -59,7 +59,7 @@ class DataWriterHDF5(DataWriter, ModuleDataWriterHDF5):
     """
     Initialize writer.
     """
-    DataWriter.initialize(self, normalizer)
+    DataWriter.initialize(self, normalizer, self.filename)
 
     timeScale = normalizer.timeScale()
     
diff --git a/pylith/meshio/DataWriterHDF5Ext.py b/pylith/meshio/DataWriterHDF5Ext.py
index 9e21376..c1c9510 100644
--- a/pylith/meshio/DataWriterHDF5Ext.py
+++ b/pylith/meshio/DataWriterHDF5Ext.py
@@ -61,15 +61,7 @@ class DataWriterHDF5Ext(DataWriter, ModuleDataWriterHDF5Ext):
     """
     Initialize writer.
     """
-    DataWriter.initialize(self, normalizer)
-    return
-
-
-  def initialize(self, normalizer):
-    """
-    Initialize writer.
-    """
-    DataWriter.initialize(self, normalizer)
+    DataWriter.initialize(self, normalizer, self.filename)
     
     timeScale = normalizer.timeScale()
 
diff --git a/pylith/meshio/DataWriterVTK.py b/pylith/meshio/DataWriterVTK.py
index c3348ee..0b33cdc 100644
--- a/pylith/meshio/DataWriterVTK.py
+++ b/pylith/meshio/DataWriterVTK.py
@@ -75,7 +75,7 @@ class DataWriterVTK(DataWriter, ModuleDataWriterVTK):
     """
     Initialize writer.
     """
-    DataWriter.initialize(self, normalizer)
+    DataWriter.initialize(self, normalizer, self.filename)
     
     timeScale = normalizer.timeScale()
     timeConstantN = normalizer.nondimensionalize(self.timeConstant, timeScale)



More information about the CIG-COMMITS mailing list