From 4e04364c980bbd0a676a3a4180120977ba2e92a7 Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Tue, 23 Nov 2010 14:16:41 +0000
Subject: [PATCH] Fixed bug for parallel reading macro files with periodic
 boundary conditions.

---
 AMDiS/libtool            | 44 ++++++++++++++++++++--------------------
 AMDiS/src/ElInfo3d.cc    | 34 ++++++++++++++++---------------
 AMDiS/src/MacroReader.cc | 12 +++++++++--
 AMDiS/src/MatrixVector.h |  4 +++-
 AMDiS/src/Mesh.cc        | 19 +++++++++--------
 AMDiS/src/Mesh.h         |  5 +++++
 AMDiS/src/Traverse.cc    |  3 +++
 7 files changed, 71 insertions(+), 50 deletions(-)

diff --git a/AMDiS/libtool b/AMDiS/libtool
index d38e55be..5085abd4 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=yes
+fast_install=needless
 
 # The host system.
 host_alias=
-host=i686-redhat-linux-gnu
+host=x86_64-unknown-linux-gnu
 host_os=linux-gnu
 
 # The build system.
 build_alias=
-build=i686-redhat-linux-gnu
+build=x86_64-unknown-linux-gnu
 build_os=linux-gnu
 
 # A sed program that does not truncate output.
-SED="/bin/sed"
+SED="/usr/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="/bin/grep"
+GREP="/usr/bin/grep"
 
 # An ERE matcher.
-EGREP="/bin/grep -E"
+EGREP="/usr/bin/grep -E"
 
 # A literal string matcher.
-FGREP="/bin/grep -F"
+FGREP="/usr/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="gcc"
+LTCC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc"
 
 # 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=no
+shlibpath_overrides_runpath=yes
 
 # 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="/u/witkowski/local/lib /u/witkowski/local/intel/mkl/10.0.1.014/lib/32 /usr/lib/gcc/i386-redhat-linux/4.1.2 /usr/lib /lib"
+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"
 
 # Run-time system search path for libraries.
-sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/mysql /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib /usr/lib/qt4/lib /usr/lib/xulrunner-1.9.2 "
+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 "
 
 # Whether dlopen is supported.
 dlopen_support=unknown
@@ -253,13 +253,13 @@ striplib="strip --strip-unneeded"
 
 
 # The linker used to build libraries.
-LD="/usr/bin/ld"
+LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64"
 
 # Commands used to build an old-style archive.
 old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$oldlib"
 
 # A language specific compiler.
-CC="gcc"
+CC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc"
 
 # 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="-static"
+link_static_flag=""
 
 # 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/bin/ld"
+LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64"
 
 # Commands used to build an old-style archive.
 old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$oldlib"
 
 # A language specific compiler.
-CC="g++"
+CC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicxx"
 
 # 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="-static"
+link_static_flag=""
 
 # 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="/u/witkowski/local/lib /u/witkowski/local/intel/mkl/10.0.1.014/lib/32 /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/../../.."
+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/../../.."
 
 # Dependencies to place before and after the objects being linked to
 # create a shared library.
-predep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../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/gcc/i386-redhat-linux/4.1.2/../../../crtn.o"
+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"
 predeps=""
-postdeps="-lstdc++ -lm -lgcc_s -lc -lgcc_s"
+postdeps="-lmpi_cxx -lmpi -lopen-rte -lopen-pal -libverbs -lrt -lnuma -ldl -lnsl -lutil -ldl -lstdc++ -lm -lgcc_s -lpthread -lc -lgcc_s"
 
 # The library search path used internally by the compiler when linking
 # a shared library.
-compiler_lib_search_path="-L/u/witkowski/local/lib -L/u/witkowski/local/intel/mkl/10.0.1.014/lib/32 -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/../../.."
+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/../../.."
 
 # ### END LIBTOOL TAG CONFIG: CXX
diff --git a/AMDiS/src/ElInfo3d.cc b/AMDiS/src/ElInfo3d.cc
index 25cceb93..b67dd40a 100644
--- a/AMDiS/src/ElInfo3d.cc
+++ b/AMDiS/src/ElInfo3d.cc
@@ -162,11 +162,14 @@ namespace AMDiS {
   void ElInfo3d::fillMacroInfo(const MacroElement * mel)
   {
     FUNCNAME("ElInfo3d::fillMacroInfo()");
+
+    TEST_EXIT_DBG(mel)("No macro element given!\n");
+
     Element *nb;
     MacroElement *mnb;
     Flag fill_opp_coords;
 
-    macroElement = const_cast<MacroElement*>( mel);
+    macroElement = const_cast<MacroElement*>(mel);
     element = const_cast<Element*>(mel->getElement());
     parent = NULL;
     level = 0;
@@ -176,10 +179,9 @@ namespace AMDiS {
 
     if (fillFlag.isSet(Mesh::FILL_COORDS) || 
 	fillFlag.isSet(Mesh::FILL_DET) ||
-	fillFlag.isSet(Mesh::FILL_GRD_LAMBDA)) {
+	fillFlag.isSet(Mesh::FILL_GRD_LAMBDA))
       for (int i = 0; i < vertices; i++)
 	coord[i] = mel->coord[i];
-    }
 
     int neighbours = mesh->getGeo(NEIGH);
 
@@ -188,19 +190,19 @@ namespace AMDiS {
 
       fill_opp_coords.setFlags(fillFlag & Mesh::FILL_OPP_COORDS);
       for (int i = 0; i < neighbours; i++) {
-	if ((mnb = const_cast<MacroElement*>( mel->getNeighbour(i)))) {
-	  neighbour[i] = const_cast<Element*>( mel->getNeighbour(i)->getElement());
-	  nb = const_cast<Element*>( neighbour[i]);
+	if ((mnb = const_cast<MacroElement*>(mel->getNeighbour(i)))) {
+	  neighbour[i] = const_cast<Element*>(mel->getNeighbour(i)->getElement());
+	  nb = const_cast<Element*>(neighbour[i]);
 	  int k;
 	  k = oppVertex[i] = mel->getOppVertex(i);
 
 	  if (nb->getChild(0) && (k < 2)) {   /*make nb nearest element.*/
 	    if (k == 1) {
-	      neighbour[i]      = const_cast<Element*>( nb->getChild(0));
-	      nb = const_cast<Element*>( neighbour[i]);
+	      neighbour[i] = const_cast<Element*>(nb->getChild(0));
+	      nb = const_cast<Element*>(neighbour[i]);
 	    } else {
-	      neighbour[i]      = const_cast<Element*>( nb->getChild(1));
-	      nb = const_cast<Element*>( neighbour[i]);
+	      neighbour[i] = const_cast<Element*>(nb->getChild(1));
+	      nb = const_cast<Element*>(neighbour[i]);
 	    }
 	    k = oppVertex[i] = 3;
 	    if (fill_opp_coords.isAnySet()) {
@@ -495,7 +497,7 @@ namespace AMDiS {
 
     TEST_EXIT_DBG(el_old->getChild(0))("missing child?\n"); 
 
-    element = const_cast<Element*>( el_old->getChild(ichild));
+    element = const_cast<Element*>(el_old->getChild(ichild));
     macroElement = elInfoOld->macroElement;
     fillFlag = fillFlag_local;
     parent  = el_old;
@@ -546,7 +548,7 @@ namespace AMDiS {
       
       /*    if (nb = el_old->child[ochild])   old version  */
       if (el_old->getChild(0)  &&  
-	  (nb = const_cast<Element*>( el_old->getChild(ochild)))) {
+	  (nb = const_cast<Element*>(el_old->getChild(ochild)))) {
 	
 	if (nb->getChild(0)) {         /* go down one level for direct neighbour */
 	  if (fill_opp_coords.isAnySet()) {
@@ -558,7 +560,7 @@ namespace AMDiS {
 		oppCoord[0][j] = (elInfoOld->coord[ochild][j] + elInfoOld->coord[k][j]) / 2;
 	    }
 	  }
-	  (*neigh_local)[0] = const_cast<Element*>( nb->getChild(1));
+	  (*neigh_local)[0] = const_cast<Element*>(nb->getChild(1));
 	  oppVertex[0] = 3;
 	} else {
 	  if (fill_opp_coords.isAnySet())
@@ -577,12 +579,12 @@ namespace AMDiS {
       /*----- nb[1],nb[2] are childs of old neighbours nb_old[cv[i]] ----------*/
       
       for (int i = 1; i < 3; i++) {
-	if ((nb = const_cast<Element*>( (*neigh_old)[cv[i]]))) {
+	if ((nb = const_cast<Element*>((*neigh_old)[cv[i]]))) {
 	  TEST_EXIT_DBG(nb->getChild(0))("nonconforming triangulation\n");
 	  
 	  int k;
 	  for (k = 0; k < 2; k++) { /* look at both childs of old neighbour */
-	    nbk = const_cast<Element*>( nb->getChild(k));
+	    nbk = const_cast<Element*>(nb->getChild(k));
 	    if (nbk->getDOF(0) == el_old->getDOF(ichild)) {
 	      /* opp. vertex */
 	      dof = const_cast<int*>(nb->getDOF(elInfoOld->oppVertex[cv[i]])); 
@@ -625,7 +627,7 @@ namespace AMDiS {
 	  // periodic ?
 	  if (k == 2 || ov == -1) {
 	    for (k = 0; k < 2; k++) {  /* look at both childs of old neighbour */
-	      nbk = const_cast<Element*>( nb->getChild(k));
+	      nbk = const_cast<Element*>(nb->getChild(k));
 	      if (nbk->getDOF(0) == el_old->getDOF(ichild) ||
 		  mesh->associated(nbk->getDOF(0, 0), el_old->getDOF(ichild, 0))) {
 		/* opp. vertex */
diff --git a/AMDiS/src/MacroReader.cc b/AMDiS/src/MacroReader.cc
index 7b2d4331..e768087a 100644
--- a/AMDiS/src/MacroReader.cc
+++ b/AMDiS/src/MacroReader.cc
@@ -24,7 +24,7 @@ namespace AMDiS {
 				    std::string periodicFile,
 				    int check)
   {
-    FUNCNAME("Mesh::readMacro()");
+    FUNCNAME("MacroReader::readMacro()");
 
     TEST_EXIT(filename != "")("no file specified; filename NULL pointer\n");  
 
@@ -124,6 +124,14 @@ namespace AMDiS {
 	ElementData *ld1 = element1->getElementData();
 	ElementData *ld2 = element2->getElementData();
 
+	TEST_EXIT_DBG(ld1)
+	  ("Should not happen: no element data pointer in macro element %d!\n",
+	   element1->getIndex());
+
+	TEST_EXIT_DBG(ld2)
+	  ("Should not happen: no element data pointer in macro element %d!\n",
+	   element2->getIndex());
+
 	LeafDataPeriodic *ldp1 = 
 	  dynamic_cast<LeafDataPeriodic*>(ld1->getElementData(PERIODIC));
 	LeafDataPeriodic *ldp2 = 
@@ -1172,7 +1180,7 @@ namespace AMDiS {
     Flag fill_flag;
     int error_detected = 0;
 
-    MSG("checking mesh\n");
+    MSG("Checking mesh ...\n");
 
     fill_flag = Mesh::CALL_EVERY_EL_PREORDER | Mesh::FILL_NEIGH | Mesh::FILL_BOUND;
 
diff --git a/AMDiS/src/MatrixVector.h b/AMDiS/src/MatrixVector.h
index 785a54fc..521e5ca1 100644
--- a/AMDiS/src/MatrixVector.h
+++ b/AMDiS/src/MatrixVector.h
@@ -81,7 +81,9 @@ namespace AMDiS {
     /// Assignement operator
     inline const Vector<T>& operator=(const Vector<T>& rhs) 
     {
-      TEST_EXIT_DBG(rhs.size == size)("invalid size\n");
+      TEST_EXIT_DBG(rhs.size == size)
+	("Invalid sizes %d != %d!\n", rhs.size, size);
+
       T *rhsIt, *thisIt;
       for (rhsIt = rhs.begin(), thisIt = this->begin();
 	   rhsIt != rhs.end();
diff --git a/AMDiS/src/Mesh.cc b/AMDiS/src/Mesh.cc
index 6ee53d80..95dd4d4e 100644
--- a/AMDiS/src/Mesh.cc
+++ b/AMDiS/src/Mesh.cc
@@ -614,12 +614,12 @@ namespace AMDiS {
     TEST_EXIT_DBG(elementPrototype)("no element prototype\n");
 
     Element *el = parent ? parent->clone() : elementPrototype->clone();
-  
+
     if (!parent && elementDataPrototype)
       el->setElementData(elementDataPrototype->clone()); 
     else
       el->setElementData(NULL); // must be done in ElementData::refineElementData()
-    
+
     return el;
   }
 
@@ -747,7 +747,7 @@ namespace AMDiS {
 	    *(g_sp) = s;
 	  
 	  if (dim == 3) 
-	    MSG("outside finest level on el %d: s=%.3e\n", el->getIndex(), s);
+	    MSG("Outside finest level on el %d: s = %.3e\n", el->getIndex(), s);
 
 	  return false;  /* ??? */
 	} else {
@@ -1148,13 +1148,13 @@ namespace AMDiS {
 
 #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
       if (checkParallelMacroFile(macroFilename, periodicFilename, check)) {
-	std::string newPeriodicFilename = "";
-	if (periodicFilename != "")
-	  newPeriodicFilename = periodicFilename + ".tmp";
+ 	std::string newPeriodicFilename = "";
+ 	if (periodicFilename != "")
+ 	  newPeriodicFilename = periodicFilename + ".tmp";
 
-	macroFileInfo = 
-	  MacroReader::readMacro(macroFilename + ".tmp", this, 
-				 newPeriodicFilename, check);
+ 	macroFileInfo = 
+ 	  MacroReader::readMacro(macroFilename + ".tmp", this, 
+ 				 newPeriodicFilename, check);
       } else {
 	macroFileInfo = 
 	  MacroReader::readMacro(macroFilename, this, periodicFilename, check);
@@ -1193,6 +1193,7 @@ namespace AMDiS {
     // === Create a temporary mesh and load the macro file to it. ===
     
     Mesh testMesh(name, dim);
+    testMesh.setElementDataPrototype(new LeafDataEstimatableVec(new LeafDataCoarsenableVec));
     DOFAdmin *localAdmin = new DOFAdmin(&testMesh, admin[0]->getName());
     localAdmin->setNumberOfDOFs(admin[0]->getNumberOfDOFs());
     testMesh.addDOFAdmin(localAdmin);
diff --git a/AMDiS/src/Mesh.h b/AMDiS/src/Mesh.h
index b7445eab..4338c29b 100644
--- a/AMDiS/src/Mesh.h
+++ b/AMDiS/src/Mesh.h
@@ -240,6 +240,11 @@ namespace AMDiS {
       return macroElements[i]; 
     }
 
+    std::deque<MacroElement*>& getMacroElements()
+    {
+      return macroElements;
+    }
+
     /// Returns an iterator to the end of \ref macroElements
     inline std::deque<MacroElement*>::iterator endOfMacroElements() 
     {
diff --git a/AMDiS/src/Traverse.cc b/AMDiS/src/Traverse.cc
index 0e188b7a..a67c3afc 100644
--- a/AMDiS/src/Traverse.cc
+++ b/AMDiS/src/Traverse.cc
@@ -26,6 +26,9 @@ namespace AMDiS {
     traverse_level = level;
     traverse_fill_flag = fill_flag; 
 
+    TEST_EXIT_DBG(mesh)("No mesh!\n");
+    TEST_EXIT_DBG(traverse_mesh->getMacroElements().size() > 0)("Mesh is empty!\n");
+
     if (stack_size < 1)
       enlargeTraverseStack();
 
-- 
GitLab