[cig-commits] r18522 - short/3D/PyLith/trunk/libsrc/pylith/meshio
brad at geodynamics.org
brad at geodynamics.org
Wed Jun 1 09:54:34 PDT 2011
Author: brad
Date: 2011-06-01 09:54:34 -0700 (Wed, 01 Jun 2011)
New Revision: 18522
Modified:
short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5.cc
short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5Ext.cc
Log:
Fixed some more HDF5 (PETSc viewer) related memory leaks.
Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5.cc 2011-06-01 14:37:32 UTC (rev 18521)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5.cc 2011-06-01 16:54:34 UTC (rev 18522)
@@ -86,6 +86,8 @@
try {
PetscErrorCode err = 0;
+
+ deallocate();
const std::string& filename = _hdf5Filename();
Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5Ext.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5Ext.cc 2011-06-01 14:37:32 UTC (rev 18521)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5Ext.cc 2011-06-01 16:54:34 UTC (rev 18522)
@@ -53,11 +53,10 @@
const typename dataset_type::const_iterator& dEnd = _datasets.end();
for (typename dataset_type::iterator d_iter=_datasets.begin();
d_iter != dEnd;
- ++d_iter)
- if (d_iter->second.viewer) {
- PetscErrorCode err = PetscViewerDestroy(&d_iter->second.viewer);
- CHECK_PETSC_ERROR(err);
- } // if
+ ++d_iter) {
+ PetscErrorCode err = PetscViewerDestroy(&d_iter->second.viewer);
+ CHECK_PETSC_ERROR(err);
+ } // for
} // deallocate
// ----------------------------------------------------------------------
@@ -137,8 +136,6 @@
assert(coordinatesVector);
const std::string& filenameVertices = _datasetFilename("vertices");
- err = PetscViewerBinaryCreate(sieveMesh->comm(), &binaryViewer);
- CHECK_PETSC_ERROR(err);
err = PetscViewerBinaryOpen(sieveMesh->comm(), filenameVertices.c_str(),
FILE_MODE_WRITE,
&binaryViewer);
@@ -147,7 +144,6 @@
CHECK_PETSC_ERROR(err);
err = VecView(coordinatesVector, binaryViewer); CHECK_PETSC_ERROR(err);
err = PetscViewerDestroy(&binaryViewer); CHECK_PETSC_ERROR(err);
- binaryViewer = 0;
// Create external dataset for coordinates
if (!rank) {
@@ -216,8 +212,6 @@
"cells");CHECK_PETSC_ERROR(err);
const std::string& filenameCells = _datasetFilename("cells");
- err = PetscViewerBinaryCreate(sieveMesh->comm(), &binaryViewer);
- CHECK_PETSC_ERROR(err);
err = PetscViewerBinaryOpen(sieveMesh->comm(), filenameCells.c_str(),
FILE_MODE_WRITE,
&binaryViewer);
@@ -228,7 +222,6 @@
err = VecDestroy(&elemVec); CHECK_PETSC_ERROR(err);
err = PetscFree(tmpVertices); CHECK_PETSC_ERROR(err);
err = PetscViewerDestroy(&binaryViewer); CHECK_PETSC_ERROR(err);
- binaryViewer = 0;
// Create external dataset for cells
if (!rank) {
@@ -316,8 +309,6 @@
if (_datasets.find(field.label()) != _datasets.end()) {
binaryViewer = _datasets[field.label()].viewer;
} else {
- err = PetscViewerBinaryCreate(sieveMesh->comm(), &binaryViewer);
- CHECK_PETSC_ERROR(err);
err = PetscViewerBinaryOpen(sieveMesh->comm(),
_datasetFilename(field.label()).c_str(),
FILE_MODE_WRITE, &binaryViewer);
@@ -331,6 +322,7 @@
createdExternalDataset = true;
} // else
+ assert(binaryViewer);
err = VecView(vector, binaryViewer);
CHECK_PETSC_ERROR(err);
@@ -453,8 +445,6 @@
if (_datasets.find(field.label()) != _datasets.end()) {
binaryViewer = _datasets[field.label()].viewer;
} else {
- err = PetscViewerBinaryCreate(sieveMesh->comm(), &binaryViewer);
- CHECK_PETSC_ERROR(err);
err = PetscViewerBinaryOpen(sieveMesh->comm(),
_datasetFilename(field.label()).c_str(),
FILE_MODE_WRITE, &binaryViewer);
@@ -468,6 +458,7 @@
createdExternalDataset = true;
} // else
+ assert(binaryViewer);
err = VecView(vector, binaryViewer);
CHECK_PETSC_ERROR(err);
More information about the CIG-COMMITS
mailing list