From 278a914a0c62f6d118127b43c44c490bf77b0688 Mon Sep 17 00:00:00 2001 From: Simon Praetorius <simon.praetorius@tu-dresden.de> Date: Mon, 25 Oct 2010 10:30:12 +0000 Subject: [PATCH] VtkWriter boost::iostreams used instead of std::ofstream --- AMDiS/libtool | 44 +++++++++++++++++++++--------------------- AMDiS/src/VtkWriter.cc | 30 +++++++++++++++++++--------- AMDiS/src/VtkWriter.h | 8 ++------ 3 files changed, 45 insertions(+), 37 deletions(-) diff --git a/AMDiS/libtool b/AMDiS/libtool index 5085abd4..008d56e2 100755 --- a/AMDiS/libtool +++ b/AMDiS/libtool @@ -51,32 +51,32 @@ build_old_libs=yes pic_mode=default # Whether or not to optimize for fast installation. -fast_install=needless +fast_install=yes # The host system. host_alias= -host=x86_64-unknown-linux-gnu +host=i686-redhat-linux-gnu host_os=linux-gnu # The build system. build_alias= -build=x86_64-unknown-linux-gnu +build=i686-redhat-linux-gnu build_os=linux-gnu # A sed program that does not truncate output. -SED="/usr/bin/sed" +SED="/bin/sed" # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="$SED -e 1s/^X//" # A grep program that handles long lines. -GREP="/usr/bin/grep" +GREP="/bin/grep" # An ERE matcher. -EGREP="/usr/bin/grep -E" +EGREP="/bin/grep -E" # A literal string matcher. -FGREP="/usr/bin/grep -F" +FGREP="/bin/grep -F" # A BSD- or MS-compatible name lister. NM="/usr/bin/nm -B" @@ -128,7 +128,7 @@ old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$oldlib" old_postuninstall_cmds="" # A C compiler. -LTCC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc" +LTCC="gcc" # LTCC compiler flags. LTCFLAGS="-g -O2" @@ -204,7 +204,7 @@ runpath_var=LD_RUN_PATH shlibpath_var=LD_LIBRARY_PATH # Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=yes +shlibpath_overrides_runpath=no # Format of library name prefix. libname_spec="lib\$name" @@ -233,10 +233,10 @@ finish_eval="" hardcode_into_libs=yes # Compile-time system search path for libraries. -sys_lib_search_path_spec="/usr/lib64/gcc/x86_64-suse-linux/4.1.2 /usr/lib64 /lib64 /fastfs/wir/local/lib /usr/x86_64-suse-linux/lib" +sys_lib_search_path_spec="/usr/lib/openmpi/1.4-gcc/lib /usr/lib /usr/lib/gcc/i386-redhat-linux/4.1.2 /lib" # Run-time system search path for libraries. -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso " +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/mysql /usr/lib/octave-3.0.1 /usr/lib/qt-3.3/lib /usr/lib/qt4/lib /usr/lib/xulrunner-1.9.2 " # Whether dlopen is supported. dlopen_support=unknown @@ -253,13 +253,13 @@ striplib="strip --strip-unneeded" # The linker used to build libraries. -LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64" +LD="/usr/bin/ld" # Commands used to build an old-style archive. old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$oldlib" # A language specific compiler. -CC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc" +CC="gcc" # Is the compiler the GNU compiler? with_gcc=yes @@ -274,7 +274,7 @@ wl="-Wl," pic_flag=" -fPIC -DPIC" # Compiler flag to prevent dynamic linking. -link_static_flag="" +link_static_flag="-static" # Does compiler simultaneously support -c and -o options? compiler_c_o="yes" @@ -8908,13 +8908,13 @@ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### BEGIN LIBTOOL TAG CONFIG: CXX # The linker used to build libraries. -LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64" +LD="/usr/bin/ld" # Commands used to build an old-style archive. old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$oldlib" # A language specific compiler. -CC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicxx" +CC="g++" # Is the compiler the GNU compiler? with_gcc=yes @@ -8929,7 +8929,7 @@ wl="-Wl," pic_flag=" -fPIC -DPIC" # Compiler flag to prevent dynamic linking. -link_static_flag="" +link_static_flag="-static" # Does compiler simultaneously support -c and -o options? compiler_c_o="yes" @@ -9039,17 +9039,17 @@ file_list_spec="" hardcode_action=immediate # The directories searched by this compiler when creating a shared library. -compiler_lib_search_dirs="/usr/lib64 /licsoft/libraries/openmpi/1.2.6/64bit/lib /usr/lib64/gcc/x86_64-suse-linux/4.1.2 /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64 /lib/../lib64 /usr/lib/../lib64 /fastfs/wir/local/lib /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../.." +compiler_lib_search_dirs=". /usr/lib/openmpi/1.4-gcc/lib /usr/lib/openmpi/1.4-gcc/lib /usr/lib/gcc/i386-redhat-linux/4.1.2 /usr/lib/gcc/i386-redhat-linux/4.1.2 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../.." # Dependencies to place before and after the objects being linked to # create a shared library. -predep_objects="/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbeginS.o" -postdep_objects="/usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtendS.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crtn.o" +predep_objects="/usr/lib/crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbeginS.o" +postdep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/crtendS.o /usr/lib/crtn.o" predeps="" -postdeps="-lmpi_cxx -lmpi -lopen-rte -lopen-pal -libverbs -lrt -lnuma -ldl -lnsl -lutil -ldl -lstdc++ -lm -lgcc_s -lpthread -lc -lgcc_s" +postdeps="-lstdc++ -lm -lgcc_s -lc -lgcc_s" # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path="-L/usr/lib64 -L/licsoft/libraries/openmpi/1.2.6/64bit/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/fastfs/wir/local/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../.." +compiler_lib_search_path="-L. -L/usr/lib/openmpi/1.4-gcc/lib -L/usr/lib/openmpi/1.4-gcc/lib -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.." # ### END LIBTOOL TAG CONFIG: CXX diff --git a/AMDiS/src/VtkWriter.cc b/AMDiS/src/VtkWriter.cc index 7b997d58..45a033ed 100644 --- a/AMDiS/src/VtkWriter.cc +++ b/AMDiS/src/VtkWriter.cc @@ -22,8 +22,6 @@ namespace AMDiS { int VtkWriter::writeFile(std::string name) { FUNCNAME("VtkWriter::writeFile()"); - -#ifdef HAVE_BOOST boost::iostreams::filtering_ostream file; switch (compress) { @@ -46,7 +44,7 @@ namespace AMDiS { file.push(boost::iostreams::file_descriptor_sink(name, std::ios::trunc)); writeFileToStream(file); -#else +#if 0 std::ofstream file; file.open(name.c_str()); @@ -63,8 +61,15 @@ namespace AMDiS { void VtkWriter::writeParallelFile(std::string name, int nRanks, std::string fnPrefix, std::string fnPostfix) { - std::ofstream file; - file.open(name.c_str()); + boost::iostreams::filtering_ostream file; + { + //boost::iostreams seems not to truncate the file + std::ofstream swapfile(name.c_str(), std::ios::out | std::ios::trunc); + swapfile.close(); + } + file.push(boost::iostreams::file_descriptor_sink(name, std::ios::trunc)); +// std::ofstream file; +// file.open(name.c_str()); file << "<?xml version=\"1.0\"?>\n"; file << "<VTKFile type=\"PUnstructuredGrid\">\n"; @@ -98,7 +103,7 @@ namespace AMDiS { file << " </PUnstructuredGrid>\n"; file << "</VTKFile>\n"; - file.close(); +// file.close(); } @@ -109,8 +114,15 @@ namespace AMDiS { size_t found = valueFilename.find_last_of("/\\"); paraViewAnimationFrames->push_back(valueFilename.substr(found + 1)); - std::ofstream file; - file.open(animationFilename.c_str()); + boost::iostreams::filtering_ostream file; + { + //boost::iostreams seems not to truncate the file + std::ofstream swapfile(animationFilename.c_str(), std::ios::out | std::ios::trunc); + swapfile.close(); + } + file.push(boost::iostreams::file_descriptor_sink(animationFilename, std::ios::trunc)); +// std::ofstream file; +// file.open(animationFilename.c_str()); file << "<?xml version=\"1.0\"?>\n"; file << "<VTKFile type=\"Collection\" version=\"0.1\" >" << "\n"; @@ -128,7 +140,7 @@ namespace AMDiS { file << "</Collection>\n"; file << "</VTKFile>\n"; - file.close(); +// file.close(); return 0; } diff --git a/AMDiS/src/VtkWriter.h b/AMDiS/src/VtkWriter.h index c7be36da..a4418d09 100644 --- a/AMDiS/src/VtkWriter.h +++ b/AMDiS/src/VtkWriter.h @@ -22,12 +22,10 @@ #ifndef AMDIS_VTKWRITER_H #define AMDIS_VTKWRITER_H -#ifdef HAVE_BOOST #include <boost/iostreams/filtering_stream.hpp> #include <boost/iostreams/device/file_descriptor.hpp> #include <boost/iostreams/filter/gzip.hpp> #include <boost/iostreams/filter/bzip2.hpp> -#endif #include <fstream> #include "BasisFunction.h" @@ -135,7 +133,6 @@ namespace AMDiS { template<typename T> void writeConnectivity_dim2_degree4(T &file); -#ifdef HAVE_BOOST /// Writes a world coordinate to a given file. inline void writeCoord(boost::iostreams::filtering_ostream &file, WorldVector<double> coord) @@ -143,11 +140,10 @@ namespace AMDiS { for (int i = 0; i < Global::getGeo(WORLD); i++) file << " " << std::scientific << coord[i]; for (int i = Global::getGeo(WORLD); i < 3; i++) - file << " 0.0"; + file << " "<<0.0; file << "\n"; } -#endif /// Writes a world coordinate to a given file. inline void writeCoord(std::ofstream &file, WorldVector<double> coord) @@ -155,7 +151,7 @@ namespace AMDiS { for (int i = 0; i < Global::getGeo(WORLD); i++) file << " " << std::scientific << coord[i]; for (int i = Global::getGeo(WORLD); i < 3; i++) - file << " 0.0"; + file << " "<<0.0; file << "\n"; } -- GitLab