[cig-commits] r11180 - in short/3D/PyLith/trunk: examples/3d/tet4 libsrc/meshio modulesrc/meshio pylith/meshio
brad at geodynamics.org
brad at geodynamics.org
Mon Feb 18 15:28:41 PST 2008
Author: brad
Date: 2008-02-18 15:28:37 -0800 (Mon, 18 Feb 2008)
New Revision: 11180
Modified:
short/3D/PyLith/trunk/examples/3d/tet4/pylithapp.cfg
short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.hh
short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.icc
short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.cc
short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.hh
short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src
short/3D/PyLith/trunk/pylith/meshio/MeshIOLagrit.py
Log:
Added flag for switching between 32-bit and 64-bit Fortran record header lengths in LaGriT pset files.
Modified: short/3D/PyLith/trunk/examples/3d/tet4/pylithapp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/3d/tet4/pylithapp.cfg 2008-02-18 03:53:42 UTC (rev 11179)
+++ short/3D/PyLith/trunk/examples/3d/tet4/pylithapp.cfg 2008-02-18 23:28:37 UTC (rev 11180)
@@ -11,6 +11,7 @@
petsc = 1
solverlinear = 1
meshiolagrit = 1
+psetfile = 1
implicitelasticity = 1
faultcohesivekin = 1
fiatsimplex = 1
@@ -34,6 +35,10 @@
# uncomment the following line
#flip_endian = True
+# If using version of LaGriT compiled on a 64-bit Linux machine with
+# 64-bit Fortran record headers, then uncomment the following line.
+#record_header_32bit = False
+
# ----------------------------------------------------------------------
# materials
# ----------------------------------------------------------------------
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.cc 2008-02-18 03:53:42 UTC (rev 11179)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.cc 2008-02-18 23:28:37 UTC (rev 11180)
@@ -31,7 +31,8 @@
pylith::meshio::MeshIOLagrit::MeshIOLagrit(void) :
_filenameGmv(""),
_filenamePset(""),
- _flipEndian(false)
+ _flipEndian(false),
+ _isRecordHeader32Bit(true)
{ // constructor
} // constructor
@@ -81,7 +82,8 @@
PsetFileAscii filein(_filenamePset.c_str());
filein.read(&groups);
} else {
- PsetFileBinary filein(_filenamePset.c_str(), _flipEndian);
+ PsetFileBinary filein(_filenamePset.c_str(),
+ _flipEndian, _isRecordHeader32Bit);
filein.read(&groups);
} // if/else
GroupPtType type = VERTEX;
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.hh 2008-02-18 03:53:42 UTC (rev 11179)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.hh 2008-02-18 23:28:37 UTC (rev 11180)
@@ -86,6 +86,19 @@
*/
bool flipEndian(void) const;
+ /** Set Fortran record header size flag.
+ *
+ * @param flag True if Fortran record header size is 32-bit, false if 64-bit.
+ */
+ void isRecordHeader32Bit(const bool flag);
+
+ /** Get Fortran record header size flag.
+ *
+ * @param returns True if Fortran record header size is 32-bit,
+ * false if 64-bit.
+ */
+ bool isRecordHeader32Bit(void) const;
+
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
@@ -129,10 +142,11 @@
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
- std::string _filenameGmv; ///< Name of GMV file
- std::string _filenamePset; ///< Name of PSET file
- bool _writeAscii; ///< True if writing ASCII, false if writing binary
- bool _flipEndian; ///< True if need to change endian when reading/writing
+ std::string _filenameGmv; ///< Name of GMV file.
+ std::string _filenamePset; ///< Name of PSET file.
+ bool _writeAscii; ///< True if writing ASCII, false if writing binary.
+ bool _flipEndian; ///< True if need to change endian when reading/writing.
+ bool _isRecordHeader32Bit; ///< True if Fortran record header is 32-bit.
}; // MeshIOLagrit
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.icc 2008-02-18 03:53:42 UTC (rev 11179)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.icc 2008-02-18 23:28:37 UTC (rev 11180)
@@ -70,6 +70,20 @@
return _flipEndian;
}
+// Set Fortran record header size flag.
+inline
+void
+pylith::meshio::MeshIOLagrit::isRecordHeader32Bit(const bool flag) {
+ _isRecordHeader32Bit = flag;
+}
+
+// Get Fortran record header size flag.
+inline
+bool
+pylith::meshio::MeshIOLagrit::isRecordHeader32Bit(void) const {
+ return _isRecordHeader32Bit;
+}
+
#endif
// End of file
Modified: short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.cc 2008-02-18 03:53:42 UTC (rev 11179)
+++ short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.cc 2008-02-18 23:28:37 UTC (rev 11180)
@@ -30,9 +30,11 @@
// ----------------------------------------------------------------------
// Constructor with name of Pset file.
pylith::meshio::PsetFileBinary::PsetFileBinary(const char* filename,
- const bool flipEndian) :
+ const bool flipEndian,
+ const bool isRecordHeader32Bit) :
PsetFile(filename),
- _flipEndian(flipEndian)
+ _flipEndian(flipEndian),
+ _recordHeaderSize(isRecordHeader32Bit ? 4 : 8)
{ // constructor
} // constructor
@@ -72,7 +74,7 @@
BinaryIO::swapByteOrder((char*) &numGroups, 1, sizeof(int));
assert(numGroups >= 0);
groups->resize(numGroups);
- std::string extra = BinaryIO::readString(fin, 8);
+ std::string extra = BinaryIO::readString(fin, 2*_recordHeaderSize);
// Read groups
info << journal::at(__HERE__)
@@ -119,7 +121,7 @@
void
pylith::meshio::PsetFileBinary::_readHeader(std::ifstream& fin)
{ // _readHeader
- std::string extra = BinaryIO::readString(fin, 4); // Read superfluous 4 bytes
+ std::string extra = BinaryIO::readString(fin, _recordHeaderSize);
std::string header = BinaryIO::readString(fin, strlen(_HEADER));
std::string headerE = _HEADER;
@@ -158,17 +160,17 @@
int size = 0;
fin.read((char*) &size, sizeof(int));
- std::string extra = BinaryIO::readString(fin, 8);
if (_flipEndian)
BinaryIO::swapByteOrder((char*) &size, 1, sizeof(size));
assert(size >= 0);
+ std::string extra = BinaryIO::readString(fin, 2*_recordHeaderSize);
info << journal::at(__HERE__)
<< "Reading point set '" << group->name << "' with " << size
<< " points." << journal::endl;
group->points.resize(size);
fin.read((char*) &group->points[0], size*sizeof(int));
- extra = BinaryIO::readString(fin, 8);
+ extra = BinaryIO::readString(fin, 2*_recordHeaderSize);
if (_flipEndian)
BinaryIO::swapByteOrder((char*) &group->points[0], size, sizeof(int));
Modified: short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.hh 2008-02-18 03:53:42 UTC (rev 11179)
+++ short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.hh 2008-02-18 23:28:37 UTC (rev 11180)
@@ -34,9 +34,11 @@
*
* @param filename Name of Pset file
* @param flipEndian Flip endian type when reading/writing.
+ * @param isRecordHeader32Bit True if Fortran record header size is 32-bit.
*/
PsetFileBinary(const char* name,
- const bool flipEndian);
+ const bool flipEndian,
+ const bool isRecordHeader32Bit);
/// Default destructor
~PsetFileBinary(void);
@@ -96,8 +98,10 @@
/** Header in binary Pset file */
static const char* _HEADER;
- bool _flipEndian; ///< True if need to change endian when reading/writing
+ int _recordHeaderSize; ///< Size of Fortran record header in bytes.
+ bool _flipEndian; ///< True if need to change endian when reading/writing.
+
}; // PsetFileInBinary
#endif // pylith_meshio_psetfilebinary
Modified: short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src 2008-02-18 03:53:42 UTC (rev 11179)
+++ short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src 2008-02-18 23:28:37 UTC (rev 11180)
@@ -552,6 +552,50 @@
return MeshIOLagrit_flipEndian_get(self.thisptr)
+ property isRecordHeader32Bit:
+ def __set__(self, flag):
+ """Set Fortran record header size flag."""
+ # create shim for method 'isRecordHeader32Bit'
+ #embed{ void MeshIOLagrit_isRecordHeader32Bit_set(void* objVptr, int flag)
+ try {
+ assert(0 != objVptr);
+ ((pylith::meshio::MeshIOLagrit*) objVptr)->isRecordHeader32Bit(flag);
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (const ALE::Exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.msg().c_str()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ #}embed
+ MeshIOLagrit_isRecordHeader32Bit_set(self.thisptr, flag)
+
+ def __get__(self):
+ """Get Fortran record header size flag."""
+ # create shim for method 'isRecordHeader32Bit'
+ #embed{ int MeshIOLagrit_isRecordHeader32Bit_get(void* objVptr)
+ int result = 0;
+ try {
+ assert(0 != objVptr);
+ result = ((pylith::meshio::MeshIOLagrit*) objVptr)->isRecordHeader32Bit();
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (const ALE::Exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.msg().c_str()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ return result;
+ #}embed
+ return MeshIOLagrit_isRecordHeader32Bit_get(self.thisptr)
+
+
# ----------------------------------------------------------------------
cdef void OutputManager_destructor(void* obj):
"""
Modified: short/3D/PyLith/trunk/pylith/meshio/MeshIOLagrit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/MeshIOLagrit.py 2008-02-18 03:53:42 UTC (rev 11179)
+++ short/3D/PyLith/trunk/pylith/meshio/MeshIOLagrit.py 2008-02-18 23:28:37 UTC (rev 11180)
@@ -41,6 +41,7 @@
## @li \b filename_gmv Name of mesh GMV file.
## @li \b filename_pset Name of mesh PSET file.
## @li \b flip_endian Flip endian type when reading/writing binary files.
+ ## @li \b record_header_32bit Fortran record header is 32-bit.
##
## \b Facilities
## @li coordsys Coordinate system associated with mesh.
@@ -57,6 +58,9 @@
flipEndian.meta['tip'] = "Flip endian type when reading/writing binary " \
"files."
+ isRecordHeader32Bit = pyre.inventory.bool("record_header_32bit", default=True)
+ isRecordHeader32Bit.meta['tip'] = "Fortran record header is 32-bit."
+
from spatialdata.geocoords.CSCart import CSCart
coordsys = pyre.inventory.facility("coordsys", family="coordsys",
factory=CSCart)
@@ -84,6 +88,7 @@
self.filenamePset = self.inventory.filenamePset
self.coordsys = self.inventory.coordsys
self.flipEndian = self.inventory.flipEndian
+ self.isRecordHeader32Bit = self.inventory.isRecordHeader32Bit
return
@@ -99,6 +104,7 @@
self.cppHandle.filenameGmv = self.filenameGmv
self.cppHandle.filenamePset = self.filenamePset
self.cppHandle.flipEndian = self.flipEndian
+ self.cppHandle.isRecordHeader32Bit = self.isRecordHeader32Bit
return
More information about the cig-commits
mailing list