[MOAB-dev] r1916 - in MOAB/trunk: . m4 parallel tools/iMesh tools/mbcoupler

tautges at mcs.anl.gov tautges at mcs.anl.gov
Mon Jun 23 12:01:28 CDT 2008


Author: tautges
Date: 2008-06-23 12:01:28 -0500 (Mon, 23 Jun 2008)
New Revision: 1916

Added:
   MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp
Modified:
   MOAB/trunk/configure.in
   MOAB/trunk/m4/compiler.m4
   MOAB/trunk/parallel/MBParallelComm.cpp
   MOAB/trunk/parallel/Makefile.am
   MOAB/trunk/parallel/ReadParallel.cpp
   MOAB/trunk/parallel/ReadParallel.hpp
   MOAB/trunk/tools/iMesh/Makefile.am
   MOAB/trunk/tools/mbcoupler/Makefile.am
Log:
MBCoupler: adding application mbcoupler_test to test coupling

parallel/MBParallelComm: partial fixes for when we have multiple partitions
active at the same time, each with their own MBParallelComm (at least
that's how I'm thinking it'll be done so far...)

parallel/Makefile.am: removing some unneeded commented-out lines

parallel/ReadParallel: adding capability to read multiple files as
part of a parallel read (needed for coupling)


Modified: MOAB/trunk/configure.in
===================================================================
--- MOAB/trunk/configure.in	2008-06-20 18:33:15 UTC (rev 1915)
+++ MOAB/trunk/configure.in	2008-06-23 17:01:28 UTC (rev 1916)
@@ -12,7 +12,6 @@
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
 AC_DISABLE_SHARED
-AC_PROG_FC
 AC_PROG_LIBTOOL
 
 AC_CHECK_PROG([ZCAT],[gunzip],[gunzip -c],[])
@@ -841,6 +840,7 @@
 
 AC_MSG_RESULT([C:   $CC $CFLAGS])
 AC_MSG_RESULT([C++: $CXX $CXXFLAGS])
+AC_MSG_RESULT([Fortran: $FC $FCFLAGS])
 
 
 if test "x$GRAPHVIZ_MISSING" = "xyes"; then

Modified: MOAB/trunk/m4/compiler.m4
===================================================================
--- MOAB/trunk/m4/compiler.m4	2008-06-20 18:33:15 UTC (rev 1915)
+++ MOAB/trunk/m4/compiler.m4	2008-06-23 17:01:28 UTC (rev 1916)
@@ -37,10 +37,14 @@
   xno)
     CC_LIST="cc gcc cl egcs pgcc"
     CXX_LIST="CC aCC cxx xlC_r xlC c++ g++ pgCC gpp cc++ cl FCC KCC RCC"
+    FC_LIST="gfortran ifort pgf90"
+    F77_LIST="gfortran ifort pgf77"
     ;;
   xyes)
     CC_LIST="mpicc mpcc"
     CXX_LIST="mpiCC mpCC mpicxx"
+    FC_LIST="mpif90"
+    F77_LIST="mpif77"
     ;;
   x*)
     if test -z "$CC";then
@@ -63,6 +67,26 @@
     else
       CXX_LIST="$CXX"
     fi
+    if test -z "$FC";then
+      for prog in mpif90; do
+        if test -x ${WITH_MPI}/bin/$prog; then
+          FC="${WITH_MPI}/bin/$prog"
+          FC_LIST="$prog"
+        fi
+      done
+    else
+      FC_LIST="$FC"
+    fi
+    if test -z "$F77";then
+      for prog in mpif77; do
+        if test -x ${WITH_MPI}/bin/$prog; then
+          F77="${WITH_MPI}/bin/$prog"
+          F77_LIST="$prog"
+        fi
+      done
+    else
+      F77_LIST="$F77"
+    fi
     WITH_MPI=yes
     ;;
 esac
@@ -70,6 +94,8 @@
 AC_PROG_CPP
 AC_PROG_CXX( [$CXX_LIST] )
 AC_PROG_CXXCPP
+AC_PROG_FC( [$FC_LIST] )
+AC_PROG_F77( [$F77_LIST] )
 
 # Try to determine compiler-specific flags.  This must be done
 # before setting up libtool so that it can override libtool settings.
@@ -89,9 +115,13 @@
                [enable_debug=$enableval], [enable_debug=] )  
 AC_ARG_ENABLE( optimize, AC_HELP_STRING([--enable-optimize],[Compile optimized (-O2)]),
                [enable_cxx_optimize=$enableval
-                enable_cc_optimize=$enableval], 
+                enable_cc_optimize=$enableval
+		enable_fc_optimize=$enableval
+		], 
                [enable_cxx_optimize=
-                enable_cc_optimize=] )
+                enable_cc_optimize=
+		enable_fc_optimize=
+		] )
 
 # Do enable_optimize by default, unless user has specified
 # custom CXXFLAGS or CFLAGS
@@ -106,12 +136,18 @@
       enable_cc_optimize=yes
     fi
   fi
+  if test "x$enable_fc_optimize" = "x"; then
+    if test "x$USER_FCFLAGS" = "x"; then
+      enable_fc_optimize=yes
+    fi
+  fi
 fi
 
 # Choose compiler flags from CLI args
 if test "xyes" = "x$enable_debug"; then
   CXXFLAGS="$CXXFLAGS -g"
-  CFLAGS="$CLFAGS -g"
+  CFLAGS="$CFLAGS -g"
+  FCFLAGS="$FCFLAGS -g"
 fi
 if test "xyes" = "x$enable_cxx_optimize"; then
   CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
@@ -119,6 +155,9 @@
 if test "xyes" = "x$enable_cc_optimize"; then
   CFLAGS="$CFLAGS -O2 -DNDEBUG"
 fi
+if test "xyes" = "x$enable_fc_optimize"; then
+  FCFLAGS="$FCFLAGS -O2 -DNDEBUG"
+fi
 
   # Check for 32/64 bit.
   # This requires SNL_CXX_FLAGS and SNL_CC_FLAGS to have been called first

Modified: MOAB/trunk/parallel/MBParallelComm.cpp
===================================================================
--- MOAB/trunk/parallel/MBParallelComm.cpp	2008-06-20 18:33:15 UTC (rev 1915)
+++ MOAB/trunk/parallel/MBParallelComm.cpp	2008-06-23 17:01:28 UTC (rev 1916)
@@ -167,6 +167,7 @@
   MBRange entities[4];
   int local_num_elements[4];
   MBErrorCode result;
+  std::vector<unsigned char> pstatus;
   for (int dim = 0; dim <= dimension; dim++) {
     if (dim == 0 || !largest_dim_only || dim == dimension) {
       result = mbImpl->get_entities_by_dimension(this_set, dim, entities[dim]); 
@@ -174,10 +175,15 @@
     }
 
       // need to filter out non-locally-owned entities!!!
+    pstatus.resize(entities[dim].size());
+    result = mbImpl->tag_get_data(pstatus_tag(), entities[dim], &pstatus[0]);
+    RRA("Failed to get pstatus in assign_global_ids.");
+    
     MBRange dum_range;
-    for (MBRange::iterator rit = entities[dim].begin(); rit != entities[dim].end(); rit++)
-      if (mbImpl->handle_utils().rank_from_handle(*rit) != 
-          (unsigned int) mbImpl->proc_rank()) 
+    MBRange::iterator rit;
+    unsigned int i;
+    for (rit = entities[dim].begin(); rit != entities[dim].end(); rit++, i++)
+      if (pstatus[i] & PSTATUS_NOT_OWNED)
         dum_range.insert(*rit);
     entities[dim] = entities[dim].subtract(dum_range);
     
@@ -3074,7 +3080,7 @@
       }
       for (unsigned int j = 0; j < MAX_SHARING_PROCS; j++) {
           // if to_proc shares this entity, skip it
-        if (sharing_procs[j] == to_proc) break;
+        if (-1 != to_proc && sharing_procs[j] == to_proc) break;
           // if we get here, no more sharing procs, and it's not shared
           // with to_proc, so add to list
         else if (sharing_procs[j] == -1) 

Modified: MOAB/trunk/parallel/Makefile.am
===================================================================
--- MOAB/trunk/parallel/Makefile.am	2008-06-20 18:33:15 UTC (rev 1915)
+++ MOAB/trunk/parallel/Makefile.am	2008-06-23 17:01:28 UTC (rev 1916)
@@ -19,7 +19,7 @@
 MOAB_PARALLEL_SRCS =
 MOAB_PARALLEL_HDRS =
 MOAB_PARALLEL_TEST = 
-if USE_MPI
+if PARALLEL
   MOAB_PARALLEL_SRCS += \
      MBParallelComm.cpp \
      MBProcConfig.cpp \
@@ -56,10 +56,6 @@
 
 # Tests and such
 
-#moab_test_SOURCES = MBTest.cpp
-#moab_test_LDADD = $(top_builddir)/libMOAB.la
-#moab_test_DEPENDENCIES = test/mb_big_test.g test/cell1.gen test/cell2.gen $(top_builddir)/libMOAB.la
-
 check_PROGRAMS = $(MOAB_PARALLEL_TEST)
 TESTS = $(MOAB_PARALLEL_TEST)
 pcomm_unit_SOURCES = pcomm_unit.cpp

Modified: MOAB/trunk/parallel/ReadParallel.cpp
===================================================================
--- MOAB/trunk/parallel/ReadParallel.cpp	2008-06-20 18:33:15 UTC (rev 1915)
+++ MOAB/trunk/parallel/ReadParallel.cpp	2008-06-23 17:01:28 UTC (rev 1916)
@@ -33,7 +33,15 @@
   "PARALLEL EXCHANGE_GHOSTS"
 };
 
-MBErrorCode ReadParallel::load_file(const char *file_name,
+ReadParallel::ReadParallel(MBInterface* impl, 
+                           MBParallelComm *pc) 
+    : mbImpl(impl), myPcomm(pc) 
+{
+  if (!myPcomm) myPcomm = new MBParallelComm(mbImpl);
+}
+
+MBErrorCode ReadParallel::load_file(const char **file_names,
+                                    const int num_files,
                                     MBEntityHandle& file_set,
                                     const FileOptions &opts,
                                     const int* material_set_list,
@@ -126,7 +134,7 @@
     // now that we've parsed all the parallel options, make an instruction
     // queue
   std::vector<int> pa_vec;
-  bool is_reader = (mbImpl->proc_rank() == reader_rank);
+  bool is_reader = (reader_rank == (int) myPcomm->proc_config().proc_rank());
   
   switch (parallel_mode) {
     case POPT_BCAST:
@@ -173,14 +181,16 @@
   if (-1 != ghost_dim) pa_vec.push_back(PA_EXCHANGE_GHOSTS);
   
   
-  return load_file(file_name, file_set, parallel_mode, partition_tag_name,
+  return load_file(file_names, num_files, file_set, parallel_mode, 
+                   partition_tag_name,
                    partition_tag_vals, distrib, pa_vec, material_set_list,
                    num_material_sets, opts, reader_rank, cputime, 
                    resolve_dim, shared_dim,
                    ghost_dim, bridge_dim, num_layers);
 }
     
-MBErrorCode ReadParallel::load_file(const char *file_name,
+MBErrorCode ReadParallel::load_file(const char **file_names,
+                                    const int num_files,
                                     MBEntityHandle& file_set,
                                     int parallel_mode, 
                                     std::string &partition_tag_name, 
@@ -199,7 +209,9 @@
                                     const int num_layers) 
 {
   MBErrorCode result = MB_SUCCESS;
-  MBParallelComm pcom( mbImpl);
+  if (myPcomm == NULL)
+    myPcomm = new MBParallelComm(mbImpl);
+
   MBRange entities; 
   MBTag file_set_tag = 0;
   int other_sets;
@@ -213,7 +225,7 @@
   double stime = 0.0;
   if (cputime) stime = MPI_Wtime();
   std::vector<int>::iterator vit;
-  int i;
+  int i, j;
   act_times[0] = MPI_Wtime();
   
   for (i = 1, vit = pa_vec.begin();
@@ -223,36 +235,39 @@
     switch (*vit) {
 //==================
       case PA_READ:
-        if (debug)
-          std::cout << "Reading file " << file_name << std::endl;
+        for (j = 0; j < num_files; j++) {
+          if (debug)
+            std::cout << "Reading file " << file_names[j] << std::endl;
             
-        reader = impl->reader_writer_set()->
-          get_file_extension_reader( file_name );
-        if (reader)
-        { 
-          tmp_result = reader->load_file( file_name, file_set, opts, 
-                                          material_set_list, num_material_sets );
-          delete reader;
-        }
-        else
-        {  
-            // Try all the readers
-          for (iter = impl->reader_writer_set()->begin(); 
-               iter != impl->reader_writer_set()->end(); ++iter)
-          {
-            reader = iter->make_reader( mbImpl );
-            if (NULL != reader)
+          reader = impl->reader_writer_set()->
+            get_file_extension_reader( file_names[j] );
+          if (reader)
+          { 
+            tmp_result = reader->load_file( file_names[j], file_set, opts, 
+                                            material_set_list, num_material_sets );
+            delete reader;
+          }
+          else
+          {  
+              // Try all the readers
+            for (iter = impl->reader_writer_set()->begin(); 
+                 iter != impl->reader_writer_set()->end(); ++iter)
             {
-              tmp_result = reader->load_file( file_name, file_set, opts, 
-                                              material_set_list, num_material_sets );
-              delete reader;
-              if (MB_SUCCESS == tmp_result)
-                break;
+              reader = iter->make_reader( mbImpl );
+              if (NULL != reader)
+              {
+                tmp_result = reader->load_file( file_names[j], file_set, opts, 
+                                                material_set_list, num_material_sets );
+                delete reader;
+                if (MB_SUCCESS == tmp_result)
+                  break;
+              }
             }
           }
+
+          if (MB_SUCCESS != tmp_result) break;
         }
-        if (MB_SUCCESS != tmp_result) break;
-
+        
           // mark the file set
         other_sets = 0;
         tmp_result = mbImpl->tag_create("__file_set", sizeof(int), 
@@ -314,8 +329,8 @@
         if (debug)
           std::cout << "Broadcasting mesh." << std::endl;
 
-        if (mbImpl->proc_size() > 1)
-          tmp_result = pcom.broadcast_entities( reader_rank, entities );
+        if (myPcomm->proc_config().proc_size() > 1)
+          tmp_result = myPcomm->broadcast_entities( reader_rank, entities );
 
         if (debug) {
           std::cerr << "Bcast done; entities:" << std::endl;
@@ -339,7 +354,7 @@
         if (debug)
           std::cout << "Checking global ids." << std::endl;
 
-        tmp_result = pcom.check_global_ids(file_set, 0, 1, true, false);
+        tmp_result = myPcomm->check_global_ids(file_set, 0, 1, true, false);
         break;
         
 //==================
@@ -347,7 +362,7 @@
         if (debug)
           std::cout << "Resolving shared entities." << std::endl;
 
-        tmp_result = pcom.resolve_shared_ents(resolve_dim, shared_dim);
+        tmp_result = myPcomm->resolve_shared_ents(resolve_dim, shared_dim);
         break;
         
 //==================
@@ -355,8 +370,8 @@
         if (debug)
           std::cout << "Exchanging ghost entities." << std::endl;
 
-        tmp_result = pcom.exchange_ghost_cells(ghost_dim, bridge_dim, 
-                                               num_layers, true);
+        tmp_result = myPcomm->exchange_ghost_cells(ghost_dim, bridge_dim, 
+                                                   num_layers, true);
         break;
         
 //==================
@@ -365,7 +380,7 @@
     }
 
     if (MB_SUCCESS != tmp_result &&
-        (*vit != PA_BROADCAST || mbImpl->proc_size() != 1)) {
+        (*vit != PA_BROADCAST || myPcomm->proc_config().proc_size() != 1)) {
       result = tmp_result;
       std::ostringstream ostr;
       ostr << "Failed in step " << ParallelActionsNames[*vit] << std::endl;
@@ -377,7 +392,7 @@
     if (cputime) act_times[i] = MPI_Wtime();
   }
 
-  if (cputime && 0 == mbImpl->proc_rank()) {
+  if (cputime && 0 == myPcomm->proc_config().proc_rank()) {
     std::cout << "Read times: ";
     for (i = 1, vit = pa_vec.begin();
          vit != pa_vec.end(); vit++, i++) 
@@ -409,8 +424,8 @@
                                                 partition_sets);
   RR("Failed to get sets with partition-type tag.");
 
-  int proc_sz = mbImpl->proc_size();
-  int proc_rk = mbImpl->proc_rank();
+  int proc_sz = myPcomm->proc_config().proc_size();
+  int proc_rk = myPcomm->proc_config().proc_rank();
 
   if (!ptag_vals.empty()) {
       // values input, get sets with those values
@@ -466,7 +481,7 @@
         // agree with this partition
       MBRange tagged_sets;
       int *proc_rk_ptr = &proc_rk;
-      result = mbImpl->get_entities_by_type_and_tag(0, MBENTITYSET, &ptag, 
+      result = mbImpl->get_entities_by_type_and_tag(file_set, MBENTITYSET, &ptag, 
                                                     (const void* const*)&proc_rk_ptr, 1,
                                                     tagged_sets); RR(" ");
       if (!tagged_sets.empty() && tagged_sets != partition_sets) {
@@ -557,7 +572,7 @@
         pset_vals.end()) return MB_SUCCESS;
   }
     
-  std::fill(pset_vals.begin(), pset_vals.end(), mbImpl->proc_rank());
+  std::fill(pset_vals.begin(), pset_vals.end(), myPcomm->proc_config().proc_rank());
   result = mbImpl->tag_set_data(partition_set_tag, partition_sets, 
                                 &pset_vals[0]);
   RR("Couldn't set partition set tag value.");

Modified: MOAB/trunk/parallel/ReadParallel.hpp
===================================================================
--- MOAB/trunk/parallel/ReadParallel.hpp	2008-06-20 18:33:15 UTC (rev 1915)
+++ MOAB/trunk/parallel/ReadParallel.hpp	2008-06-23 17:01:28 UTC (rev 1916)
@@ -7,6 +7,7 @@
 #include <string>
 
 class MBReadUtilIface;
+class MBParallelComm;
 
 class ReadParallel : public MBReaderIface
 {
@@ -22,8 +23,16 @@
                         const int* material_set_list,
                         const int num_material_sets );
   
+    //! load multiple files
+  MBErrorCode load_file(const char **file_names,
+                        const int num_files,
+                        MBEntityHandle& file_set,
+                        const FileOptions &opts,
+                        const int* material_set_list,
+                        const int num_material_sets );
+  
     //! Constructor
-  ReadParallel(MBInterface* impl = NULL) {mbImpl = impl;};
+  ReadParallel(MBInterface* impl = NULL, MBParallelComm *pc = NULL);
 
    //! Destructor
   virtual ~ReadParallel() {}
@@ -31,9 +40,8 @@
 protected:
 
 private:
-  MBInterface *mbImpl;
-  
-  MBErrorCode load_file(const char *file_name,
+  MBErrorCode load_file(const char **file_names,
+                        const int num_files,
                         MBEntityHandle& file_set,
                         int parallel_mode, 
                         std::string &partition_tag_name, 
@@ -58,6 +66,21 @@
   
   MBErrorCode delete_nonlocal_entities(MBRange &partition_sets,
                                        MBEntityHandle file_set);
+
+  MBInterface *mbImpl;
+
+    // each reader can keep track of its own pcomm
+  MBParallelComm *myPcomm;
 };
 
+inline MBErrorCode ReadParallel::load_file(const char *file_name,
+                                           MBEntityHandle& file_set,
+                                           const FileOptions &opts,
+                                           const int* material_set_list,
+                                           const int num_material_sets ) 
+{
+  return load_file(&file_name, 1, file_set, opts, 
+                   material_set_list, num_material_sets);
+}
+  
 #endif

Modified: MOAB/trunk/tools/iMesh/Makefile.am
===================================================================
--- MOAB/trunk/tools/iMesh/Makefile.am	2008-06-20 18:33:15 UTC (rev 1915)
+++ MOAB/trunk/tools/iMesh/Makefile.am	2008-06-23 17:01:28 UTC (rev 1916)
@@ -34,9 +34,14 @@
   libiMesh_la_SOURCES += iMeshP_MOAB.cpp
   libiMesh_la_include_HEADERS += iMeshP.h iMeshP_f.h iMeshP_protos.h
   INCLUDES += -I$(top_srcdir)/parallel
+
   check_PROGRAMS += partest
   partest_SOURCES = partest.cpp
   partest_DEPENDENCIES = libiMesh.la $(top_builddir)/libMOAB.la 
+
+  check_PROGRAMS += ftest
+  ftest_SOURCES = ftest.F
+  ftest_DEPENDENCIES = libiMesh.la $(top_builddir)/libMOAB.la 
 endif
 
 lib_LTLIBRARIES = libiMesh.la

Modified: MOAB/trunk/tools/mbcoupler/Makefile.am
===================================================================
--- MOAB/trunk/tools/mbcoupler/Makefile.am	2008-06-20 18:33:15 UTC (rev 1915)
+++ MOAB/trunk/tools/mbcoupler/Makefile.am	2008-06-23 17:01:28 UTC (rev 1916)
@@ -39,3 +39,11 @@
 findpt_test_SOURCES = findpt_test.cpp
 findpt_test_LDADD = libmbcoupler.la $(top_builddir)/libMOAB.la
 
+if PARALLEL
+  TESTS += mbcoupler_test
+  check_PROGRAMS += mbcoupler_test
+  mbcoupler_test_SOURCES = mbcoupler_test.cpp
+  mbcoupler_test_LDADD = libmbcoupler.la $(top_builddir)/libMOAB.la
+  INCLUDES += -I$(srcdir)/parallel
+endif
+

Added: MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp
===================================================================
--- MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp	                        (rev 0)
+++ MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp	2008-06-23 17:01:28 UTC (rev 1916)
@@ -0,0 +1,119 @@
+#include "MBParallelComm.hpp"
+#include "MBCore.hpp"
+#include "FileOptions.hpp"
+#include "ReadParallel.hpp"
+#include "mpi.h"
+#include <iostream>
+#include <sstream>
+#include <assert.h>
+
+#define RRA(a) if (MB_SUCCESS != result) {\
+      std::string tmp_str; mbImpl->get_last_error(tmp_str);\
+      tmp_str.append("\n"); tmp_str.append(a);\
+      dynamic_cast<MBCore*>(mbImpl)->get_error_handler()->set_last_error(tmp_str.c_str()); \
+      return result;}
+
+MBErrorCode get_file_options(int argc, char **argv, 
+                             std::vector<const char *> &filenames,
+                             std::string &opts);
+
+int main(int argc, char **argv) 
+{
+    // need to init MPI first, to tell how many procs and rank
+  int err = MPI_Init(&argc, &argv);
+
+  if (argc < 3) {
+    std::cerr << "Usage: ";
+    std::cerr << argv[0] << " <nfiles> <fname1> ... <fnamen> [tag_name] [tag_val] [distrib] [with_ghosts]" << std::endl;
+    std::cerr << "nfiles        : number of mesh files" << std::endl;
+    std::cerr << "fname1..fnamen: mesh files" << std::endl;
+    std::cerr << "tag_name      : name of tag used to define partitions [MATERIAL_SET]" << std::endl;
+    std::cerr << "tag_val       : tag values denoting partition sets [--]" << std::endl;
+    std::cerr << "distrib       : if non-zero, distribute the partition sets with tag_val round-robin" << std::endl;
+    std::cerr << "with_ghosts   : if non-zero, after initializing in parallel, also exchange one layer of ghost elements" << std::endl;
+
+    err = MPI_Finalize();
+    
+    return 1;
+  }
+  
+  int nprocs, rank;
+  err = MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+  err = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+    // start time
+  double stime, rtime, setime, dtime, ltime;
+  if (0 == rank) stime = MPI_Wtime();
+
+    // create MOAB instance based on that
+  MBInterface *mbImpl = new MBCore(rank, nprocs);
+  if (NULL == mbImpl) return 1;
+  
+  MBErrorCode result = MB_SUCCESS;
+
+  std::vector<const char *> filenames;
+  std::string opts;
+  result = get_file_options(argc, argv, filenames, opts);
+  
+
+    // read in mesh(es)
+  ReadParallel rp(mbImpl);
+  MBEntityHandle file_set = 0;
+  result = rp.load_file(&filenames[0], filenames.size(), file_set, 
+                        FileOptions(opts.c_str()), NULL, 0);
+
+  err = MPI_Finalize();
+  
+  if (MB_SUCCESS == result) {
+    std::cout << "Success." << std::endl;
+    return 0;
+  }
+  else {
+    std::string tmp_str;
+    std::cout << "Failure; message:" << std::endl;
+    std::cout << mbImpl->get_last_error(tmp_str) << std::endl;
+    return 1;
+  }
+}
+
+MBErrorCode get_file_options(int argc, char **argv, 
+                             std::vector<const char *> &filenames,
+                             std::string &opts) 
+{
+  int npos = 1;
+  int nfiles = atoi(argv[npos++]);
+  
+    // get mesh filenames
+  filenames.resize(nfiles);
+  for (int i = 0; i < nfiles; i++) filenames[i] = argv[npos++];
+  
+    // get partition information
+  const char *tag_name = "MATERIAL_SET";
+  int tag_val = -1;
+  int distrib = 1;
+  int with_ghosts = 0;
+  if (npos < argc) tag_name = argv[npos++];
+  if (npos < argc) tag_val = strtol(argv[npos++], NULL, 0);
+  if (npos < argc) distrib = strtol(argv[npos++], NULL, 0);
+  if (npos < argc) with_ghosts = strtol(argv[npos++], NULL, 0);
+
+  std::ostringstream options;
+  options << "PARALLEL=BCAST_DELETE;PARTITION=" << tag_name;
+  
+  if (-1 != tag_val)
+    options << ";PARTITION_VAL=" << tag_val;
+
+  if (1 == distrib)
+    options << ";PARTITION_DISTRIBUTE";
+
+  options << ";PARALLEL_RESOLVE_SHARED_ENTS";
+
+  if (1 == with_ghosts)
+    options << ";PARALLEL_GHOSTS=3.0.1";
+
+  options << ";CPUTIME";
+    
+  opts = options.str();
+
+  return MB_SUCCESS;
+}




More information about the moab-dev mailing list