[MOAB-dev] r3188 - in MOAB/trunk: . test/h5file

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Thu Oct 1 16:18:23 CDT 2009


Author: kraftche
Date: 2009-10-01 16:18:23 -0500 (Thu, 01 Oct 2009)
New Revision: 3188

Modified:
   MOAB/trunk/MBCore.cpp
   MOAB/trunk/MBReaderIface.hpp
   MOAB/trunk/ReadABAQUS.cpp
   MOAB/trunk/ReadABAQUS.hpp
   MOAB/trunk/ReadCGM.cpp
   MOAB/trunk/ReadCGM.hpp
   MOAB/trunk/ReadGmsh.cpp
   MOAB/trunk/ReadGmsh.hpp
   MOAB/trunk/ReadHDF5.cpp
   MOAB/trunk/ReadHDF5.hpp
   MOAB/trunk/ReadIDEAS.cpp
   MOAB/trunk/ReadIDEAS.hpp
   MOAB/trunk/ReadMCNP5.cpp
   MOAB/trunk/ReadMCNP5.hpp
   MOAB/trunk/ReadNASTRAN.cpp
   MOAB/trunk/ReadNASTRAN.hpp
   MOAB/trunk/ReadNCDF.cpp
   MOAB/trunk/ReadNCDF.hpp
   MOAB/trunk/ReadSTL.cpp
   MOAB/trunk/ReadSTL.hpp
   MOAB/trunk/ReadSms.cpp
   MOAB/trunk/ReadSms.hpp
   MOAB/trunk/ReadTetGen.cpp
   MOAB/trunk/ReadTetGen.hpp
   MOAB/trunk/ReadVtk.cpp
   MOAB/trunk/ReadVtk.hpp
   MOAB/trunk/Tqdcfr.cpp
   MOAB/trunk/Tqdcfr.hpp
   MOAB/trunk/cub_file_test.cc
   MOAB/trunk/exodus_test.cc
   MOAB/trunk/gmsh_test.cc
   MOAB/trunk/stl_test.cc
   MOAB/trunk/test/h5file/h5sets_test.cpp
Log:
o Move creation of file set out of individual readers and into common
  code in MBCore.

o Move deletion of entities when read fails part way from individual
  readers to common code in MBCore (and implement it properly.)  

o ReadIDEAS: check that the call to open the file succeeds.

o ReadHDF5: fix bug preventing deletion of entities if read fails.

o ReadSMS: fix bug where read entities were never added to file set

o ReadCGM: fix bug where no entities are added to file set,
           remove unnecessary variables (3 copies of file name,
           etc.)
           
o ReadNCDF: remove all logic related to doing special stuff with
            file sets.  All of this belongs in higher-level code
            if we want it at all.  Remove unnecessary variables.


Modified: MOAB/trunk/MBCore.cpp
===================================================================
--- MOAB/trunk/MBCore.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/MBCore.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -421,12 +421,20 @@
 {
   if (num_sets < 0)
     return MB_INDEX_OUT_OF_RANGE;
-   
-  file_set = 0;
   
   MBErrorCode rval = MB_FAILURE;
   const MBReaderWriterSet* set = reader_writer_set();
 
+  
+  MBRange initial_ents;
+  rval = get_entities_by_handle( 0, initial_ents );
+  if (MB_SUCCESS != rval)
+    return rval;
+  
+  rval = create_meshset( MESHSET_SET, file_set ); 
+  if (MB_SUCCESS != rval)
+    return rval;
+
     // otherwise try using the file extension to select a reader
   MBReaderIface* reader = set->get_file_extension_reader( file_name );
   if (reader)
@@ -451,6 +459,18 @@
     }
   }
   
+  MBRange new_ents;
+  get_entities_by_handle( 0, new_ents );
+  new_ents = subtract( new_ents, initial_ents );
+  if (MB_SUCCESS != rval) {
+    delete_entities( new_ents );
+    file_set = 0;
+  }
+  else {
+    new_ents.erase( file_set );
+    rval = add_entities( file_set, new_ents );
+  }
+  
   return rval; 
 }
 

Modified: MOAB/trunk/MBReaderIface.hpp
===================================================================
--- MOAB/trunk/MBReaderIface.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/MBReaderIface.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -49,7 +49,11 @@
      * Method all readers must provide to import a mesh.
      *
      *\param file_name      The file to read.
-     *\param file_set       Output: a new entity set containing all data read from file.
+     *\param file_set       The entity set to which to add all entities read
+     *                      from the file.  If the reader returns anything 
+     *                      other than MB_SUCCESS, it is the responsibility
+     *                      of the caller to delete this set and any contained
+     *                      entities that were read.
      *\param subset_list    An array of tag name and value sets specifying
      *                      the subset of the file to read.  If multiple
      *                      tags are specified, the sets that match all
@@ -60,7 +64,7 @@
      *\author Jason Kraftcheck
      */
     virtual MBErrorCode load_file( const char* file_name,
-                                   MBEntityHandle& file_set,
+                                   MBEntityHandle file_set,
                                    const FileOptions& opts,
                                    const IDTag* subset_list = 0,
                                    int subset_list_length = 0,

Modified: MOAB/trunk/ReadABAQUS.cpp
===================================================================
--- MOAB/trunk/ReadABAQUS.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadABAQUS.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -132,7 +132,7 @@
 
 
 MBErrorCode ReadABAQUS::load_file(const char *abaqus_file_name,
-				  MBEntityHandle& file_set,
+				  MBEntityHandle file_set,
 				  const FileOptions& opts,
 				  const MBReaderIface::IDTag* subset_list,
 				  int subset_list_length,
@@ -145,10 +145,6 @@
 
   bool in_unsupported = false;
 
-  // initialize meshset, etc
-  status = mdbImpl->create_meshset(MESHSET_SET, file_set);
-  MB_RETURN_IF_FAIL;
-
   next_line_type = get_next_line_type();
   while (next_line_type != abq_eof)
     {

Modified: MOAB/trunk/ReadABAQUS.hpp
===================================================================
--- MOAB/trunk/ReadABAQUS.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadABAQUS.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -162,7 +162,7 @@
   
   //! load an ABAQUS file
   MBErrorCode load_file( const char *exodus_file_name,
-                         MBEntityHandle& file_set,
+                         MBEntityHandle file_set,
                          const FileOptions& opts,
                          const MBReaderIface::IDTag* subset_list = 0,
                          int subset_list_length = 0,

Modified: MOAB/trunk/ReadCGM.cpp
===================================================================
--- MOAB/trunk/ReadCGM.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadCGM.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -109,7 +109,7 @@
 
 // copy geometry into mesh database
 MBErrorCode ReadCGM::load_file(const char *cgm_file_name,
-                      MBEntityHandle& file_set,
+                      MBEntitySet,
                       const FileOptions& opts,
                       const MBReaderIface::IDTag* subset_list,
                       int subset_list_length,
@@ -117,16 +117,12 @@
 {
   // blocks_to_load and num_blocks are ignored.
   MBErrorCode rval;
-  file_set = 0;
 
   if (subset_list && subset_list_length) {
     readUtilIface->report_error( "Reading subset of files not supported for CGM data." );
     return MB_UNSUPPORTED_OPERATION;
   }
 
-  std::string filename( cgm_file_name );
-  cgmFile = filename;
-
   int norm_tol, DEFAULT_NORM = 5;
   double faceting_tol, DEFAULT_FACET_TOL = 0.001, len_tol, DEFAULT_LEN_TOL = 0.0;
   bool act_att = true;
@@ -197,7 +193,7 @@
       MBEntityHandle handle;
       rval = mdbImpl->create_meshset( dim == 1 ? MESHSET_ORDERED : MESHSET_SET, handle );
       if (MB_SUCCESS != rval)
-        return MB_FAILURE;
+        return rval;
     
       entmap[dim][ent] = handle;
       
@@ -227,7 +223,7 @@
         MBEntityHandle h = entmap[dim-1][ent];
         rval = mdbImpl->add_parent_child( ci->second, h );
         if (MB_SUCCESS != rval)
-          return MB_FAILURE;
+          return rval;
       }
     }
   }
@@ -291,7 +287,7 @@
     MBEntityHandle h;
     rval = mdbImpl->create_meshset( MESHSET_SET, h );
     if (MB_SUCCESS != rval)
-      return MB_FAILURE;
+      return rval;
     
     char namebuf[NAME_TAG_SIZE];
     memset( namebuf, '\0', NAME_TAG_SIZE );
@@ -565,18 +561,9 @@
       return MB_FAILURE;
   }
   
-  MBRange init_range, loaded_range;
-  rval = mdbImpl->get_entities_by_handle(0, loaded_range);
-  if (MB_FAILURE == rval) return rval;
-  rval = mdbImpl->get_entities_by_handle(0, init_range);
-  loaded_range = subtract( loaded_range, init_range);
-  rval = mdbImpl->add_entities(mCurrentMeshHandle, loaded_range);
-  if (MB_FAILURE == rval) return rval;
-  
   if (file_id_tag)
     readUtilIface->assign_ids( *file_id_tag, loaded_range );
 
-  file_set = mCurrentMeshHandle;
   return MB_SUCCESS;
 }
 

Modified: MOAB/trunk/ReadCGM.hpp
===================================================================
--- MOAB/trunk/ReadCGM.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadCGM.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -56,7 +56,7 @@
     //  * MAX_FACET_EDGE_LENGTH=<real> (default: 0.0)
     //  * CGM_ATTRIBS=<yes|no>         (default: no)
   MBErrorCode load_file( const char *cgm_file_name,
-                         MBEntityHandle& file_set,
+                         MBEntityHandle file_set,
                          const FileOptions& opts,
                          const MBReaderIface::IDTag* subset_list = 0,
                          int subset_list_length = 0,
@@ -97,12 +97,6 @@
     //! interface instance
   MBInterface* mdbImpl;
 
-    //! file name
-  std::string cgmFile;
-
-    //! Meshset Handle for the mesh that is currently being read
-  MBEntityHandle mCurrentMeshHandle;
-
   MBTag geom_tag, id_tag, name_tag, category_tag;
 };
 

Modified: MOAB/trunk/ReadGmsh.cpp
===================================================================
--- MOAB/trunk/ReadGmsh.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadGmsh.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -70,47 +70,23 @@
 
 
 MBErrorCode ReadGmsh::load_file( const char* filename, 
-                                 MBEntityHandle& file_set,
+                                 MBEntityHandle,
                                  const FileOptions& ,
                                  const MBReaderIface::IDTag* subset_list,
                                  int subset_list_length,
                                  const MBTag* file_id_tag )
 {
-  int num_blocks = 0;
-  const int* blocks = 0;
+  int num_material_sets = 0;
+  const int* material_set_list = 0;
   if (subset_list && subset_list_length) {
     if (subset_list_length > 1 && !strcmp( subset_list[0].tag_name, MATERIAL_SET_TAG_NAME) ) {
       readMeshIface->report_error( "GMsh supports subset read only by material ID." );
       return MB_UNSUPPORTED_OPERATION;
     }
-    blocks = subset_list[0].tag_values;
-    num_blocks = subset_list[0].num_tag_values;
+    material_set_list = subset_list[0].tag_values;
+    num_material_sets = subset_list[0].num_tag_values;
   }
 
-  mCurrentMeshHandle = 0;
-  const MBErrorCode result = load_file_impl( filename, blocks, num_blocks, file_id_tag );
-  
-    // If file read has failed, destroy anything that was
-    // created during the read.
-  if (MB_SUCCESS != result && mCurrentMeshHandle)
-  {
-    MBRange entities;
-    mdbImpl->get_entities_by_handle( mCurrentMeshHandle, entities );
-    entities.insert( mCurrentMeshHandle );
-    mdbImpl->delete_entities( entities );
-    mCurrentMeshHandle = 0;
-  }
-  
-  file_set = mCurrentMeshHandle;
-  return result;
-}
-
-
-MBErrorCode ReadGmsh::load_file_impl( const char* filename, 
-                                      const int* material_set_list,
-                                      const int num_material_sets,
-                                      const MBTag* file_id_tag )
-{
   geomSets.clear();
   MBErrorCode result = mdbImpl->tag_get_handle( GLOBAL_ID_TAG_NAME, globalId );
   if (MB_TAG_NOT_FOUND == result)
@@ -169,10 +145,6 @@
   long num_nodes;
   if (!tokens.get_long_ints( 1, &num_nodes ))
     return MB_FILE_WRITE_ERROR;
-
-    // make a meshset for this mesh
-  result = mdbImpl->create_meshset(MESHSET_SET, mCurrentMeshHandle);
-  if (MB_SUCCESS != result) return result;
   
     // allocate nodes
   std::vector<double*> coord_arrays;
@@ -181,12 +153,6 @@
                                            handle, coord_arrays );
   if (MB_SUCCESS != result)
     return result;
-  
-    // put nodes in set of all loaded entities
-  MBRange node_handles( handle, handle + num_nodes - 1 );
-  result = mdbImpl->add_entities( mCurrentMeshHandle, node_handles );
-  if (MB_SUCCESS != result)
-    return result;
 
     // read nodes
   double *x = coord_arrays[0], 
@@ -394,12 +360,6 @@
   if (MB_SUCCESS != result)
     return result;
   
-    // Put newly created elements in set of all entities read from file.
-  MBRange elements( handle, handle + num_elem - 1 );
-  result = mdbImpl->add_entities( mCurrentMeshHandle, elements );
-  if (MB_SUCCESS != result)
-    return result;
-  
     // Copy passed element connectivity into entity sequence data.
   if (type.node_order)
   {
@@ -417,6 +377,7 @@
   if (MB_SUCCESS != result) return result;
 
     // Store element IDs
+  MBRange elements( handle, handle + num_elem - 1 );
   result = mdbImpl->tag_set_data( globalId, elements, &elem_ids[0] );
   if (MB_SUCCESS != result)
     return result;
@@ -539,10 +500,6 @@
       result = mdbImpl->create_meshset( MESHSET_SET, set );
       if (MB_SUCCESS != result)
         return result;
-         
-      result = mdbImpl->add_entities( mCurrentMeshHandle, &set, 1 );
-      if (MB_SUCCESS != result)
-        return result;
      
       result = mdbImpl->tag_set_data( tag_handles[0], &set, 1, &*i );
       if (MB_SUCCESS != result)

Modified: MOAB/trunk/ReadGmsh.hpp
===================================================================
--- MOAB/trunk/ReadGmsh.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadGmsh.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -40,7 +40,7 @@
   static MBReaderIface* factory( MBInterface* );
 
   MBErrorCode load_file( const char *file_name,
-                         MBEntityHandle& file_set,
+                         MBEntityHandle file_set,
                          const FileOptions& opts,
                          const MBReaderIface::IDTag* subset_list = 0,
                          int subset_list_length = 0,
@@ -61,11 +61,6 @@
 
 private:
 
-  MBErrorCode load_file_impl( const char *file_name,
-                              const int* material_set_list,
-                              const int num_material_sets,
-                              const MBTag* file_id_tag );
-  
   MBErrorCode create_elements( const GmshElemType& type,
                                const std::vector<int>& elem_ids,
                                const std::vector<int>& matl_ids,
@@ -86,9 +81,6 @@
 
     //! interface instance
   MBInterface* mdbImpl;
-
-    //! Meshset Handle for the mesh that is currently being read
-  MBEntityHandle mCurrentMeshHandle;
   
   MBTag globalId;
   MBRange geomSets;

Modified: MOAB/trunk/ReadHDF5.cpp
===================================================================
--- MOAB/trunk/ReadHDF5.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadHDF5.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -291,7 +291,7 @@
 }
 
 MBErrorCode ReadHDF5::load_file( const char* filename, 
-                                 MBEntityHandle& file_set, 
+                                 MBEntityHandle file_set, 
                                  const FileOptions& opts,
                                  const MBReaderIface::IDTag* subset_list,
                                  int subset_list_length,
@@ -304,46 +304,26 @@
     return rval;
  
   if (subset_list && subset_list_length) 
-    rval = load_file_partial( file_set, subset_list, subset_list_length, opts );
+    rval = load_file_partial( subset_list, subset_list_length, opts );
   else
-    rval = load_file_impl( file_set, opts );
+    rval = load_file_impl( opts );
     
   if (MB_SUCCESS == rval && file_id_tag)
     rval = store_file_ids( *file_id_tag );
+  
+  if (MB_SUCCESS == rval)
+    rval = read_qa( file_set );
     
   MBErrorCode rval2 = clean_up_read( opts );
   if (rval == MB_SUCCESS && rval2 != MB_SUCCESS)
     rval = rval2;
   
-  if (MB_SUCCESS == rval) {
-    DEBUGOUT("Creating entity set for file contents\n")
-
-    rval = iFace->create_meshset( MESHSET_SET, file_set );
-    if (MB_SUCCESS == rval) {
-      MBRange range;
-      MBRange::iterator hint = range.begin();
-      for (IDMap::iterator j = idMap.begin(); j != idMap.end(); ++j)
-        hint = range.insert( hint, j->value, j->value + j->count - 1);
-      rval = iFace->add_entities( file_set, range );
-    }
-  }
-        
-      // delete everything that was read in if read failed part-way through
-  if (MB_SUCCESS != rval) {
-    MBRange range;
-    range.insert( file_set );
-    for (IDMap::iterator i = idMap.begin(); i != idMap.end(); ++i) 
-      range.insert( i->value, i->value + i->count - 1 );
-    iFace->delete_entities( range );
-  }
-  
   return rval;
 }
   
 
 
-MBErrorCode ReadHDF5::load_file_impl( MBEntityHandle file_set, 
-                                      const FileOptions& opts )
+MBErrorCode ReadHDF5::load_file_impl( const FileOptions& opts )
 {
   MBErrorCode rval;
   mhdf_Status status;
@@ -423,9 +403,7 @@
       return error(rval);
   }
   
-DEBUGOUT("Finishing read.\n");
-  rval = read_qa( file_set );
-  return rval;
+  return MB_SUCCESS;
 }
 
 MBErrorCode ReadHDF5::find_int_tag( const char* name, int& index )
@@ -511,8 +489,7 @@
   return MB_SUCCESS;
 }
 
-MBErrorCode ReadHDF5::load_file_partial( MBEntityHandle file_set, 
-                                         const MBReaderIface::IDTag* subset_list,
+MBErrorCode ReadHDF5::load_file_partial( const MBReaderIface::IDTag* subset_list,
                                          int subset_list_length,
                                          const FileOptions& opts )
 {

Modified: MOAB/trunk/ReadHDF5.hpp
===================================================================
--- MOAB/trunk/ReadHDF5.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadHDF5.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -48,7 +48,7 @@
    * \param export_set_count Length of <code>export_sets</code> array.
    */
   MBErrorCode load_file( const char* filename,
-                         MBEntityHandle& file_set,
+                         MBEntityHandle file_set,
                          const FileOptions& opts,
                          const MBReaderIface::IDTag* subset_list = 0,
                          int subset_list_length = 0,
@@ -63,11 +63,9 @@
 
 protected:
 
-  MBErrorCode load_file_impl( MBEntityHandle file_set,
-                              const FileOptions& opts );
+  MBErrorCode load_file_impl( const FileOptions& opts );
 
-  MBErrorCode load_file_partial( MBEntityHandle file_set, 
-                                 const MBReaderIface::IDTag* subset_list,
+  MBErrorCode load_file_partial( const MBReaderIface::IDTag* subset_list,
                                  int subset_list_length,
                                  const FileOptions& opts );
 

Modified: MOAB/trunk/ReadIDEAS.cpp
===================================================================
--- MOAB/trunk/ReadIDEAS.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadIDEAS.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -35,7 +35,7 @@
 
 
 MBErrorCode ReadIDEAS::load_file(const char* fname, 
-                                 MBEntityHandle& meshset, 
+                                 MBEntityHandle meshset, 
                                  const FileOptions& options,
                                  const MBReaderIface::IDTag* subset_list,
                                  int subset_list_length,
@@ -47,12 +47,13 @@
   }
 
   file.open( fname );
+  if (!file.good()) {
+    readMeshIface->report_error("Failed to open file: %s", fname);
+    return MB_FILE_DOES_NOT_EXIST;
+  }
 
   MBErrorCode rval;
 
-  rval = MBI->create_meshset(MESHSET_SET, mesh_handle);
-  if (MB_SUCCESS != rval) return rval;
-
   char line[10000];
   file.getline(line, 10000);
   std::string s = line;
@@ -81,18 +82,8 @@
         rval = skip_header(); 
       break;
     }
-
-    if (MB_SUCCESS != rval) {
-      file.close();
-      MBRange ents;
-      MBI->get_entities_by_handle( mesh_handle, ents );
-      ents.insert( mesh_handle );
-      MBI->delete_entities( ents );
-      return rval;
-    }
   }
 
-  meshset = mesh_handle;
   file.close();
   return MB_SUCCESS;
 
@@ -169,10 +160,6 @@
 
   MBRange verts;
   verts.insert( first_vertex, first_vertex + num_verts - 1 );
-  rval = MBI->add_entities( mesh_handle, verts );
-  assert( MB_SUCCESS == rval );
-  if (MB_SUCCESS != rval)
-    return rval;
   
   double *x = arrays[0];
   double *y = arrays[1];
@@ -262,9 +249,6 @@
     rval = MBI->tag_set_data(mat_prop_tag,&handle,1,&mat_table);
     assert( MB_SUCCESS == rval);
     
-    rval = MBI->add_entities( mesh_handle, &handle, 1);
-    assert( MB_SUCCESS == rval );
-    
     if (file_id_tag) {
       rval = MBI->tag_set_data( *file_id_tag, &handle, 1, &id );
       ++id;

Modified: MOAB/trunk/ReadIDEAS.hpp
===================================================================
--- MOAB/trunk/ReadIDEAS.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadIDEAS.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -21,7 +21,7 @@
   static MBReaderIface* factory( MBInterface* );
 
   MBErrorCode load_file( const char* fname, 
-			 MBEntityHandle& meshset, 
+			 MBEntityHandle meshset, 
 			 const FileOptions&,
                          const MBReaderIface::IDTag* subset_list = 0,
                          int subset_list_length = 0,
@@ -55,8 +55,5 @@
   
   // MOAB Interface
   MBInterface* MBI;
-  
-  // Handle for the mesh
-  MBEntityHandle mesh_handle;
 
 };

Modified: MOAB/trunk/ReadMCNP5.cpp
===================================================================
--- MOAB/trunk/ReadMCNP5.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadMCNP5.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -69,7 +69,7 @@
 
 // load the file as called by the MBInterface function
 MBErrorCode ReadMCNP5::load_file(const char        *filename, 
-                                 MBEntityHandle    &input_meshset, 
+                                 MBEntityHandle    input_meshset, 
                                  const FileOptions &options,
                                  const MBReaderIface::IDTag* subset_list,
                                  int               subset_list_length,
@@ -133,7 +133,7 @@
 // This actually reads the file. It creates the mesh elements unless
 // the file is being averaged with a pre-existing mesh.
 MBErrorCode ReadMCNP5::load_one_file(const char        *fname,
-                                     MBEntityHandle    &input_meshset,
+                                     MBEntityHandle    input_meshset,
                                      const FileOptions &options,
                                      const bool        average ) {
 
@@ -190,13 +190,10 @@
   // blank line
   file.getline(line, 10000);
 
-  // Everything stored in the file being read will be in the output_meshset.
+  // Everything stored in the file being read will be in the input_meshset.
   // if this is being saved in MOAB, set header tags
-  MBEntityHandle output_meshset;
   if (!average) {
-    result = MBI->create_meshset( MESHSET_SET, output_meshset );
-    if(MB_SUCCESS != result) return result;
-    result = set_header_tags( output_meshset, 
+    result = set_header_tags( input_meshset, 
                               date_and_time,
                               title,
                               nps,
@@ -347,8 +344,6 @@
       
       // add this tally's meshset to the output meshset
       if (debug) std::cout << "not averaging tally" << std::endl;
-      result = MBI->add_entities( output_meshset, &tally_meshset, 1);
-      if(MB_SUCCESS != result) return result;
 
     // average the tally values, then delete stuff that was created
     } else {
@@ -387,10 +382,7 @@
     if(MB_SUCCESS != result) return result;
 
   // If this file is not being averaged, return the output meshset.
-  } else {
-    input_meshset = output_meshset;
-  }
-
+  } 
   file.close();
   return MB_SUCCESS;
 }

Modified: MOAB/trunk/ReadMCNP5.hpp
===================================================================
--- MOAB/trunk/ReadMCNP5.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadMCNP5.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -54,7 +54,7 @@
   static MBReaderIface* factory( MBInterface* );
   
   MBErrorCode load_file( const char*                 fname,
-                         MBEntityHandle              &input_meshset,
+                         MBEntityHandle              input_meshset,
                          const FileOptions           &options,
                          const MBReaderIface::IDTag* subset_list = 0,
                          int                         subset_list_length = 0,
@@ -100,7 +100,7 @@
 
   // reads the meshtal file
   MBErrorCode load_one_file( const char        *fname,
-                             MBEntityHandle    &input_meshset,
+                             MBEntityHandle    input_meshset,
                              const FileOptions &options,
                              const bool        average );
   

Modified: MOAB/trunk/ReadNASTRAN.cpp
===================================================================
--- MOAB/trunk/ReadNASTRAN.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadNASTRAN.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -66,7 +66,7 @@
 
 // load the file as called by the MBInterface function
 MBErrorCode ReadNASTRAN::load_file(const char                  *filename, 
-                                   MBEntityHandle              &file_set, 
+                                   MBEntityHandle              file_set, 
                                    const FileOptions           &options,
                                    const MBReaderIface::IDTag  *subset_list,
                                    int                         subset_list_length,
@@ -84,10 +84,6 @@
   if (debug) std::cout << "begin ReadNASTRAN::load_file" << std::endl;
   MBErrorCode result;
 
-  // create the file set
-  result = MBI->create_meshset(MESHSET_SET, file_set);
-  if(MB_SUCCESS != result) return result;
-
   // create tags
   MBTag id_tag, material_tag;
   result = MBI->tag_create(GLOBAL_ID_TAG_NAME, sizeof(int), MB_TAG_DENSE, 

Modified: MOAB/trunk/ReadNASTRAN.hpp
===================================================================
--- MOAB/trunk/ReadNASTRAN.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadNASTRAN.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -50,7 +50,7 @@
   static MBReaderIface* factory( MBInterface* );
   
   MBErrorCode load_file( const char                  *filename,
-                         MBEntityHandle              &file_set,
+                         MBEntityHandle              file_set,
                          const FileOptions           &options,
                          const MBReaderIface::IDTag  *subset_list = 0,
                          int                         subset_list_length = 0,

Modified: MOAB/trunk/ReadNCDF.cpp
===================================================================
--- MOAB/trunk/ReadNCDF.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadNCDF.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -26,6 +26,7 @@
 #include <assert.h>
 #include <stdio.h>
 #include <cmath>
+#include <memory>
 
 #include "MBCN.hpp"
 #include "MBRange.hpp"
@@ -172,262 +173,9 @@
 {
   std::string iface_name = "MBReadUtilIface";
   mdbImpl->release_interface(iface_name, readMeshIface);
-  if (NULL != ncFile)
-    delete ncFile;
 }
-
-// should this be moved to the core?  This could apply to ANY input
-// file type.  There is no exodus specific code here although the
-// loaded_blocks tag does get used later on and it does save the
-// current mesh handle.  But that could be handled differently.
-MBErrorCode ReadNCDF::check_file_status( std::string& exodus_file_name,
-                                          bool& previously_read) 
-{
-  MBErrorCode status = MB_FAILURE;
-  char mesh_tag_buffer[256] = "";
-
-  // assume that this is the first time reading this file
-  previously_read = false;
-
-  // look for any mesh sets tagged "__mesh" that already exist
-  MBTag mesh_tag=0;
-  if (mdbImpl->tag_get_handle("__mesh", mesh_tag) == MB_SUCCESS)
-  {
-    MBRange mesh_range;
-    mdbImpl->get_entities_by_type_and_tag( 0, MBENTITYSET, &mesh_tag, NULL, 1, mesh_range,
-                                           MBInterface::UNION);
-
-    // see if any of the mesh sets came from this filename
-    MBRange::iterator iter;
-    for (iter = mesh_range.begin(); iter != mesh_range.end(); iter++)
-    {
-      mdbImpl->tag_get_data(mesh_tag, &(*iter), 1, mesh_tag_buffer);
-
-      if (exodus_file_name.empty() || exodus_file_name == mesh_tag_buffer)
-      {
-        // found it, there should only be one.  Set the mesh handle and the flag
-        // indicating that the mesh has been previously read and use the
-        // handle later to determine what blocks need to be read.
-        mCurrentMeshHandle = *iter;
-        previously_read = true;
-
-        if (exodus_file_name.empty())
-          exodus_file_name = mesh_tag_buffer;
-        
-        return MB_SUCCESS;
-      }
-    }
-  }
-
-  // if we get to this point, this mesh has never been seen before; if the
-  // file name is null, that means no file was read
-  if (exodus_file_name.empty())
-    return MB_FILE_DOES_NOT_EXIST;
-
-    // ok, it's a valid name; make sure file exists
-  FILE* infile = NULL;
-  infile = fopen(exodus_file_name.c_str(), "r");
-  if (!infile) 
-    return MB_FILE_DOES_NOT_EXIST;
-  else 
-    fclose(infile);
-
-  // get the handle if it exists otherwise create a new "__mesh" handle
-  if (mdbImpl->tag_get_handle("__mesh", mesh_tag) != MB_SUCCESS)
-  {
-    memset( mesh_tag_buffer, 0, sizeof(mesh_tag_buffer) );
-    if( mdbImpl->tag_create("__mesh", sizeof(mesh_tag_buffer), MB_TAG_SPARSE,
-                            mesh_tag, mesh_tag_buffer) != MB_SUCCESS )
-      return MB_FAILURE;
-  }
-
-  // \bug the offset tags need to be created, but do I need to get them?
-  // get the "__vertex_offset" tag if it exists otherwise create a new one
-  int offset = 0;
-  MBTag tag_handle;
-  if (mdbImpl->tag_get_handle("__vertex_offset", tag_handle) != MB_SUCCESS)
-  {
-    if (mdbImpl->tag_create("__vertex_offset", sizeof(int), MB_TAG_SPARSE,
-                            tag_handle, &offset) != MB_SUCCESS )
-      return MB_FAILURE;
-  }
-
-
-  MBEntityHandle mesh_handle;
-  if( mdbImpl->create_meshset( MESHSET_SET, mesh_handle ) != MB_SUCCESS)
-      return MB_FAILURE;
-
-  MBRange temp_range;
-  MBRange::iterator iter, end_iter;
-  int highest_id = 0;
-  int temp_id= 0;
-
-  MBTag block_offset_tag=0;
   
-  //block offset tag
-  if (mdbImpl->tag_get_handle("__block_id_offset", block_offset_tag) != MB_SUCCESS)
-  {
-    if (mdbImpl->tag_create("__block_id_offset", sizeof(int), MB_TAG_SPARSE,
-                            block_offset_tag, &offset) != MB_SUCCESS )
-      return MB_FAILURE;
 
-    //set the highest id to zero
-    int highest_id = 0;
-    if( mdbImpl->tag_set_data( block_offset_tag, &mesh_handle, 1, &highest_id ) != MB_SUCCESS )
-      return MB_FAILURE;
-
-  }
-  else
-  {
-
-    //get all 'matrerial' meshsets
-    if(mdbImpl->get_entities_by_type_and_tag( 0, MBENTITYSET, &mMaterialSetTag, NULL, 1, temp_range ) != MB_SUCCESS )
-      return MB_FAILURE;
-
-    highest_id = 0;  
-    temp_id = 0;  
-
-    if( !temp_range.empty() )
-    {
-
-      //get the highest id 
-      iter = temp_range.begin();
-      end_iter = temp_range.end();
-  
-      for(; iter != end_iter; iter++)
-      {
-        if(mdbImpl->tag_get_data( mMaterialSetTag, &(*iter), 1, &temp_id) != MB_SUCCESS )
-          return MB_FAILURE;
-       
-        if( temp_id > highest_id )
-          highest_id = temp_id;
-      }
-    }
-
-    //set the highest id
-    if( mdbImpl->tag_set_data( block_offset_tag, &mesh_handle, 1, &highest_id ) != MB_SUCCESS )
-      return MB_FAILURE;
-
-  }
-
-  //sideset offset tag
-  if (mdbImpl->tag_get_handle("__sideset_id_offset", tag_handle) != MB_SUCCESS)
-  {
-    if (mdbImpl->tag_create("__sideset_id_offset", sizeof(int), MB_TAG_SPARSE,
-                            tag_handle, &offset) != MB_SUCCESS )
-      return MB_FAILURE;
-
-    //set the highest id to zero
-    int highest_id = 0;
-    if( mdbImpl->tag_set_data( tag_handle, &mesh_handle, 1, &highest_id ) != MB_SUCCESS )
-      return MB_FAILURE;
-  }
-  else
-  {
-
-    temp_range.clear(); 
-    //get all sideset meshsets
-    if(mdbImpl->get_entities_by_type_and_tag( 0, MBENTITYSET, &mNeumannSetTag, NULL, 1, temp_range ) != MB_SUCCESS )
-      return MB_FAILURE;
-
-    highest_id = 0;  
-    temp_id = 0;  
-
-    if( !temp_range.empty() ) 
-    {
-
-      //get the highest id 
-      iter = temp_range.begin();
-      end_iter = temp_range.end();
-  
-      for(; iter != end_iter; iter++)
-      {
-        if(mdbImpl->tag_get_data( mNeumannSetTag, &(*iter), 1, &temp_id) != MB_SUCCESS )
-          return MB_FAILURE;
-       
-        if( temp_id > highest_id )
-          highest_id = temp_id;
-      }
-    }
-
-    if( mdbImpl->tag_get_handle( "__sideset_id_offset", tag_handle) != MB_SUCCESS )
-      return MB_FAILURE;
-
-    //set the highest id
-    if( mdbImpl->tag_set_data( tag_handle, &mesh_handle, 1, &highest_id ) != MB_SUCCESS )
-      return MB_FAILURE;
-
-  }
-
-  //nodeset offset tag
-  if (mdbImpl->tag_get_handle("__nodeset_id_offset", tag_handle) != MB_SUCCESS)
-  {
-    if (mdbImpl->tag_create("__nodeset_id_offset", sizeof(int), MB_TAG_SPARSE,
-                            tag_handle, &offset) != MB_SUCCESS )
-      return MB_FAILURE;
-
-    //set the highest id to zero
-    int highest_id = 0;
-    if( mdbImpl->tag_set_data( tag_handle, &mesh_handle, 1, &highest_id ) != MB_SUCCESS )
-      return MB_FAILURE;
-  }
-  else
-  {
-
-    temp_range.clear(); 
-    //get all nodeset meshsets
-    if(mdbImpl->get_entities_by_type_and_tag( 0, MBENTITYSET, &mDirichletSetTag, NULL, 1, temp_range ) != MB_SUCCESS )
-      return MB_FAILURE;
-
-    //get the highest id 
-    iter = temp_range.begin();
-    end_iter = temp_range.end();
-  
-    highest_id = 0;  
-    temp_id = 0;  
-
-    if( !temp_range.empty() ) 
-    {
-
-      //get the highest id 
-      iter = temp_range.begin();
-      end_iter = temp_range.end();
-  
-      for(; iter != end_iter; iter++)
-      {
-        if(mdbImpl->tag_get_data( mDirichletSetTag, &(*iter), 1, &temp_id) != MB_SUCCESS )
-          return MB_FAILURE;
-       
-        if( temp_id > highest_id )
-          highest_id = temp_id;
-      }
-    }
-
-    if( mdbImpl->tag_get_handle( "__nodeset_id_offset", tag_handle) != MB_SUCCESS )
-      return MB_FAILURE;
-
-    //set the highest id
-    if( mdbImpl->tag_set_data( tag_handle, &mesh_handle, 1, &highest_id ) != MB_SUCCESS )
-      return MB_FAILURE;
-
-  }
-
-
-  // save the filename on the mesh_tag
-  strncpy( mesh_tag_buffer, exodus_file_name.c_str(), sizeof(mesh_tag_buffer) - 1 );
-  mesh_tag_buffer[sizeof(mesh_tag_buffer)-1] = '\0';
-  status = mdbImpl->tag_set_data(mesh_tag, &mesh_handle, 1, mesh_tag_buffer);
-  if (status != MB_SUCCESS )
-    return MB_FAILURE;
-
-
-  // save this mesh handle as the current one being read
-  mCurrentMeshHandle = mesh_handle;
-
-  return MB_SUCCESS;
-}
-  
-
 MBErrorCode ReadNCDF::read_tag_values(const char* file_name,
                                       const char* tag_name,
                                       const FileOptions& opts,
@@ -440,8 +188,18 @@
     return MB_UNSUPPORTED_OPERATION;
   }
 
+      // open netcdf/exodus file
+  ncFile = new NcFile(file_name);
+  if (NULL == ncFile || !ncFile->is_valid())
+  {
+    readMeshIface->report_error("MBCN:: problem opening Netcdf/Exodus II file %s",file_name);
+    return MB_FILE_DOES_NOT_EXIST;
+  }
+    // delete file when we return from this function
+  std::auto_ptr<NcFile> deleter(ncFile);
+
     // 1. Read the header
-  MBErrorCode rval = read_exodus_header( file_name );
+  MBErrorCode rval = read_exodus_header( );
   if (MB_FAILURE == rval) 
     return rval;
   
@@ -485,7 +243,6 @@
     }
   }
   
-  delete ncFile;
   ncFile = 0;
   return rval;
 }
@@ -493,7 +250,7 @@
 
 
 MBErrorCode ReadNCDF::load_file(const char *exodus_file_name,
-                                MBEntityHandle& file_set,
+                                MBEntityHandle file_set,
                                 const FileOptions& opts,
                                 const MBReaderIface::IDTag* subset_list,
                                 int subset_list_length,
@@ -516,7 +273,6 @@
     num_blocks = subset_list[0].num_tag_values;
   }
   
-  file_set = 0;
     // this function directs the reading of an exoii file, but doesn't do any of
     // the actual work
   
@@ -527,28 +283,30 @@
   if(MB_SUCCESS == rval && !s.empty())
     return update(exodus_file_name, opts); 
 
-    // 0. Check for previously read file.
   reset();
-  bool previously_loaded = false;
-  std::string filename( exodus_file_name );
-  exodusFile = filename;
-  status = check_file_status(filename, previously_loaded);
-  if (MB_SUCCESS != status) 
-    return status;
 
+  // 0. Open the file.
+
+      // open netcdf/exodus file
+  ncFile = new NcFile(exodus_file_name);
+  if (NULL == ncFile || !ncFile->is_valid())
+  {
+    readMeshIface->report_error("MBCN:: problem opening Netcdf/Exodus II file %s",exodus_file_name);
+    return MB_FILE_DOES_NOT_EXIST;
+  }
+    // delete file when we return from this function
+  std::auto_ptr<NcFile> deleter(ncFile);
+
     // 1. Read the header
-  status = read_exodus_header(exodus_file_name);
+  status = read_exodus_header();
   if (MB_FAILURE == status) return status;
   
   status = mdbImpl->get_entities_by_handle(0, initRange);
   if (MB_FAILURE == status) return status;
 
     // 2. Read the nodes unless they've already been read before
-  if (!previously_loaded)
-  {
-    status = read_nodes(file_id_tag);
-    if (MB_FAILURE == status) return status;
-  }
+  status = read_nodes(file_id_tag);
+  if (MB_FAILURE == status) return status;
  
     //3. 
   status = read_block_headers(blocks_to_load, num_blocks);
@@ -571,46 +329,21 @@
   if (MB_FAILURE == status) return status;
 
     // 8. Read qa records
-  if (!previously_loaded)
-  {
-    status = read_qa_records();
-    if (MB_FAILURE == status) return status;
-  }
-
-  
-  MBRange loaded_range;
-  status = mdbImpl->get_entities_by_handle(0, loaded_range);
+  status = read_qa_records(file_set);
   if (MB_FAILURE == status) return status;
-  loaded_range = subtract( loaded_range, initRange);
-  status = mdbImpl->add_entities(mCurrentMeshHandle, loaded_range);
-  if (MB_FAILURE == status) return status;
   
     // what about properties???
 
-  file_set = mCurrentMeshHandle;
-  delete ncFile;
   ncFile = 0;
   return MB_SUCCESS;
 }
 
 
 
-MBErrorCode ReadNCDF::read_exodus_header(const char *exodus_file_name)
+MBErrorCode ReadNCDF::read_exodus_header()
 {
-
-  if (NULL == ncFile) {
-    
-      // open netcdf/exodus file
-    CPU_WORD_SIZE = sizeof(double);  // With ExodusII version 2, all floats
-    IO_WORD_SIZE = sizeof(double);   // should be changed to doubles
-
-    ncFile = new NcFile(exodus_file_name);
-    if (NULL == ncFile || !ncFile->is_valid())
-    {
-      readMeshIface->report_error("MBCN:: problem opening Netcdf/Exodus II file %s",exodus_file_name);
-      return MB_FAILURE;
-    }
-  }
+  CPU_WORD_SIZE = sizeof(double);  // With ExodusII version 2, all floats
+  IO_WORD_SIZE = sizeof(double);   // should be changed to doubles
   
     // get the attributes
 
@@ -677,14 +410,6 @@
   
   vertexOffset = ID_FROM_HANDLE( node_handle ) - MB_START_ID;
 
-  // save the start id in the vertex offset tag.
-  MBTag offset_tag;
-  if (mdbImpl->tag_get_handle("__vertex_offset", offset_tag) != MB_SUCCESS)
-    return MB_FAILURE;
-
-  if( mdbImpl->tag_set_data(offset_tag, &mCurrentMeshHandle, 1, &vertexOffset) != MB_SUCCESS)
-    return MB_FAILURE;
-
   // read in the coordinates
   NcBool status;
   NcVar *coords = ncFile->get_var("coord");
@@ -759,36 +484,19 @@
 
   int exodus_id = 1;
 
-  // if the active_block_id_list is NULL all blocks are active.
+  // if the active_block_id_list is NULL all blocks are active. 
   int temp_num_blocks = num_blocks;
   if (NULL == blocks_to_load || 0 == num_blocks) {
     blocks_to_load = &block_ids[0];
     temp_num_blocks = numberElementBlocks_loading;
   }
-  
-    // if we're only reading active blocks, go through the block list
-    // removing inactive ones and update the list of currently read blocks.
-  std::vector<int> new_blocks;
-  MBErrorCode result = remove_previously_loaded_blocks(blocks_to_load,
-                                                        temp_num_blocks,
-                                                        new_blocks);
-  if (result != MB_SUCCESS)
-    return result;
 
+  std::vector<int> new_blocks(blocks_to_load,blocks_to_load+numberElementBlocks_loading);
 
   std::vector<int>::iterator iter, end_iter;
   iter = block_ids.begin();
   end_iter = block_ids.end();
- 
 
-  //get block offset tag
-  MBTag tag_handle;
-  if (mdbImpl->tag_get_handle("__block_id_offset", tag_handle) != MB_SUCCESS)
-    return MB_FAILURE;
-  int block_offset = 0;
-  if( mdbImpl->tag_get_data( tag_handle, &mCurrentMeshHandle, 1, &block_offset ) != MB_SUCCESS )
-    return MB_FAILURE;
-
     // read header information and initialize header-type block information
   NcDim *temp_dim;
   std::vector<char> temp_string_storage(max_str_length+1);
@@ -818,7 +526,7 @@
 
     //if block is in 'blocks_to_load'----load it!
     if( std::find(new_blocks.begin(), new_blocks.end(), *iter) 
-        != new_blocks.end()) 
+        != block_ids.end()) 
     { 
       block_data.reading_in = true;
     }
@@ -848,64 +556,6 @@
   return false;
 }
 
-MBErrorCode ReadNCDF::remove_previously_loaded_blocks(const int *blocks_to_load,
-                                                        const int num_blocks,
-                                                        std::vector<int> &new_blocks) 
-{
-  // if this mesh has been previously read, also remove the block ids
-  // that were read before.
-
-  //get all the blocks of mCurrentMeshHandle
-  MBRange child_meshsets; 
-  if(mdbImpl->get_entities_by_type(0, MBENTITYSET, child_meshsets ) != MB_SUCCESS )
-    return MB_FAILURE;
-
-  child_meshsets = subtract( child_meshsets, initRange);
-
-  MBTag tag_handle;
-
-  MBRange::iterator iter, end_iter;
- 
-  //get the block id offset 
-  int id_offset = 0;
-  if( mdbImpl->tag_get_handle( "__block_id_offset", tag_handle) != MB_SUCCESS )
-    return MB_FAILURE;
-
-  if( mdbImpl->tag_get_data( tag_handle, &mCurrentMeshHandle, 1, &id_offset) != MB_SUCCESS )
-    return MB_FAILURE;
-
-  //make a vector of currently loaded block
-  std::vector< int > loaded_blocks;
-  iter = child_meshsets.begin(); 
-  end_iter = child_meshsets.end(); 
-  int block_id = 0;
-  for(; iter != end_iter; iter++)
-  {
-    if(mdbImpl->tag_get_data( mMaterialSetTag, &(*iter), 1, &block_id ) != MB_SUCCESS ) 
-      continue;
-
-    //strip the offset
-    loaded_blocks.push_back( block_id /*- id_offset*/ ); 
-  }
-
-
-  // takes already loaded blocks out of 'blocks_to_load'
-  std::copy(blocks_to_load, blocks_to_load+num_blocks, std::back_inserter(new_blocks));
-  std::sort(new_blocks.begin(), new_blocks.end());
-  std::sort(loaded_blocks.begin(), loaded_blocks.end()); 
-  
-  std::vector<int> tmp;
-
-  std::set_difference(new_blocks.begin(), new_blocks.end(),
-                      loaded_blocks.begin(), loaded_blocks.end(),
-                      std::back_inserter(tmp)); 
-
-  new_blocks.swap(tmp);
-    
-  return MB_SUCCESS;
-}
-
-
 MBErrorCode ReadNCDF::read_elements(const MBTag* file_id_tag)
 {
     // read in elements
@@ -920,26 +570,6 @@
     this_it = blocksLoading.begin();
 
 
-  //here we have to offset the block id
-
-  //get the block id offset 
-  MBTag tag_handle;
-  if( mdbImpl->tag_get_handle( "__block_id_offset", tag_handle) != MB_SUCCESS )
-    return MB_FAILURE;
-
-  int id_offset = 0;
-  if( mdbImpl->tag_get_data( tag_handle, &mCurrentMeshHandle, 1, &id_offset) != MB_SUCCESS )
-    return MB_FAILURE;
-
-  //set the id on this block
-
-  //reset vertexOffset 
-  if (mdbImpl->tag_get_handle("__vertex_offset", tag_handle) != MB_SUCCESS)
-    return MB_FAILURE;
-
-  if( mdbImpl->tag_get_data(tag_handle, &mCurrentMeshHandle, 1, &vertexOffset) != MB_SUCCESS)
-    return MB_FAILURE;
-
   std::vector<char> temp_string_storage(max_str_length+1);
   char *temp_string = &temp_string_storage[0];
   NcVar *temp_var;
@@ -1055,7 +685,6 @@
     }
 
     //set the block id with an offset
-    block_id += id_offset;
     if( mdbImpl->tag_set_data( mMaterialSetTag, &ms_handle, 1, &block_id ) != MB_SUCCESS )
       return MB_FAILURE;
     if( mdbImpl->tag_set_data( mGlobalIdTag, &ms_handle, 1, &block_id ) != MB_SUCCESS )
@@ -1164,16 +793,7 @@
     return MB_FAILURE;
   }
 
-    //get the node_id_offset
-  MBTag tag_handle;
-  if( mdbImpl->tag_get_handle( "__nodeset_id_offset", tag_handle ) != MB_SUCCESS )
-    return MB_FAILURE;
 
-  int nodeset_id_offset = 0; 
-  if( mdbImpl->tag_get_data( tag_handle, &mCurrentMeshHandle, 1, &nodeset_id_offset ) != MB_SUCCESS )
-    return MB_FAILURE;
-
-
     // use a vector of ints to read node handles
   std::vector<int> node_handles;
 
@@ -1246,7 +866,7 @@
       if( mdbImpl->tag_get_data( mDirichletSetTag, &(*iter), 1, &nodeset_id ) != MB_SUCCESS )
         continue; 
 
-      if((id_array[i]+nodeset_id_offset) == nodeset_id )
+      if(id_array[i] == nodeset_id )
       {
           //found the meshset
         ns_handle = *iter;
@@ -1297,7 +917,7 @@
         // set a tag signifying dirichlet bc
         // TODO: create this tag another way
 
-      int nodeset_id = id_array[i] + nodeset_id_offset;
+      int nodeset_id = id_array[i];
       if( mdbImpl->tag_set_data(mDirichletSetTag, &ns_handle, 1, &nodeset_id ) != MB_SUCCESS )
         return MB_FAILURE;
       if( mdbImpl->tag_set_data(mGlobalIdTag, &ns_handle, 1, &nodeset_id ) != MB_SUCCESS )
@@ -1366,15 +986,6 @@
   int number_dist_factors_in_set;
 
 
-  //get the sideset_id_offset
-  MBTag tag_handle;
-  if( mdbImpl->tag_get_handle( "__sideset_id_offset", tag_handle ) != MB_SUCCESS )
-    return MB_FAILURE;
-
-  int sideset_id_offset = 0; 
-  if( mdbImpl->tag_get_data( tag_handle, &mCurrentMeshHandle, 1, &sideset_id_offset ) != MB_SUCCESS )
-    return MB_FAILURE;
-
   // Maybe there is already a sidesets meshset here we can append to 
   MBRange child_meshsets;
   if( mdbImpl->get_entities_by_type(0, MBENTITYSET, 
@@ -1446,7 +1057,7 @@
         if( mdbImpl->tag_get_data( mNeumannSetTag, &(*iter), 1, &sideset_id ) != MB_SUCCESS )
           continue; 
 
-        if( (id_array[i] + sideset_id_offset) == sideset_id )
+        if( id_array[i] == sideset_id )
         {
           //found the meshset
           ss_handle = *iter;
@@ -1465,7 +1076,7 @@
           return MB_FAILURE;
         }
 
-        int sideset_id = id_array[i] + sideset_id_offset;
+        int sideset_id = id_array[i];
         if( mdbImpl->tag_set_data(mNeumannSetTag, &ss_handle, 1, &sideset_id ) != MB_SUCCESS)
           return MB_FAILURE;
         if( mdbImpl->tag_set_data(mGlobalIdTag, &ss_handle, 1, &sideset_id ) != MB_SUCCESS)
@@ -1892,7 +1503,7 @@
   return MB_FAILURE;
 }
 
-MBErrorCode ReadNCDF::read_qa_records()
+MBErrorCode ReadNCDF::read_qa_records(MBEntityHandle file_set)
 {
   std::vector<std::string> qa_records;
   read_qa_information( qa_records );
@@ -1908,7 +1519,7 @@
   {
     const void* ptr = &tag_data[0];
     int size = tag_data.size();
-    if( mdbImpl->tag_set_data( mQaRecordTag, &mCurrentMeshHandle, 1, &ptr, &size  ) != MB_SUCCESS ) {
+    if( mdbImpl->tag_set_data( mQaRecordTag, &file_set, 1, &ptr, &size  ) != MB_SUCCESS ) {
       return MB_FAILURE;
     }
   }
@@ -2037,15 +1648,20 @@
   else
     des = "";
 
-  // a. read in the node_num_map and coords from the input exodus file.
-  bool previously_loaded = false;
-  std::string filename( exodus_file_name );
-  ncFile = NULL;
-  rval = check_file_status(filename, previously_loaded);
+
+      // open netcdf/exodus file
+  ncFile = new NcFile(exodus_file_name);
+  if (NULL == ncFile || !ncFile->is_valid())
+  {
+    readMeshIface->report_error("MBCN:: problem opening Netcdf/Exodus II file %s",exodus_file_name);
+    return MB_FILE_DOES_NOT_EXIST;
+  }
+    // delete file when we return from this function
+  std::auto_ptr<NcFile> deleter(ncFile);
+
+  rval = read_exodus_header();
   if (MB_SUCCESS != rval)
     return rval;
-
-  read_exodus_header(exodus_file_name);
   
   //read in the node_num_map .
   std::vector<int> ptr(numberNodes_loading);

Modified: MOAB/trunk/ReadNCDF.hpp
===================================================================
--- MOAB/trunk/ReadNCDF.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadNCDF.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -70,7 +70,7 @@
 
     //! load an ExoII file
   MBErrorCode load_file( const char *exodus_file_name,
-                         MBEntityHandle& file_set,
+                         MBEntityHandle file_set,
                          const FileOptions& opts,
                          const MBReaderIface::IDTag* subset_list = 0,
                          int subset_list_length = 0,
@@ -101,7 +101,7 @@
   void reset();
 
     //! read the header from the ExoII file
-  MBErrorCode read_exodus_header(const char *exodus_file_name);
+  MBErrorCode read_exodus_header();
   
     //! read the nodes
   MBErrorCode read_nodes(const MBTag* file_id_tag);
@@ -141,7 +141,7 @@
  */
 
   //qa record stuff 
-  MBErrorCode read_qa_records();
+  MBErrorCode read_qa_records(MBEntityHandle file_set);
   MBErrorCode read_qa_information( std::vector<std::string> &qa_record_list);
 
   MBErrorCode read_qa_string(char *string,
@@ -157,10 +157,6 @@
 
   MBErrorCode find_side_element_type( const int element_id, ExoIIElementType &type, 
                                        ReadBlockData &block_data, int &df_index, int side_id );
-
-  MBErrorCode remove_previously_loaded_blocks(const int *blocks_to_load,
-                                               const int num_blocks,
-                                               std::vector<int> &new_blocks);
   
  /* MBErrorCode assign_block_ids_to_ssets(MBEntityHandle ss_handle,
                                          MB_MeshSet *ss_mesh_set);
@@ -169,10 +165,6 @@
   //! creates an element with the given connectivity
   MBErrorCode create_sideset_element( const std::vector<MBEntityHandle>&, MBEntityType, MBEntityHandle&);
 
-  //! I think this ought to be moved to MBCore. KGM
-  MBErrorCode check_file_status(std::string& filename,
-                                 bool& previously_read);
-
   int get_number_nodes( MBEntityHandle handle );
 
 

Modified: MOAB/trunk/ReadSTL.cpp
===================================================================
--- MOAB/trunk/ReadSTL.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadSTL.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -72,44 +72,21 @@
   return MB_NOT_IMPLEMENTED;
 }
 
-
+// Generic load function for both ASCII and binary.  Calls
+// pure-virtual function implemented in subclasses to read
+// the data from the file.
 MBErrorCode ReadSTL::load_file( const char* filename,
-                                MBEntityHandle& file_set, 
+                                MBEntityHandle file_set, 
                                 const FileOptions& opts,
                                 const MBReaderIface::IDTag* subset_list,
                                 int subset_list_length,
                                 const MBTag* file_id_tag )
 {
-  mCurrentMeshHandle = 0;
-  const MBErrorCode result = load_file_impl( filename, opts, file_id_tag );
-  
   if (subset_list && subset_list_length) {
     readMeshIface->report_error( "Reading subset of files not supported for STL." );
     return MB_UNSUPPORTED_OPERATION;
   }
-  
-    // If file read has failed, destroy anything that was
-    // created during the read.
-  if (MB_SUCCESS != result && mCurrentMeshHandle)
-  {
-    MBRange entities;
-    mdbImpl->get_entities_by_handle( mCurrentMeshHandle, entities );
-    entities.insert( mCurrentMeshHandle );
-    mdbImpl->delete_entities( entities );
-    mCurrentMeshHandle = 0;
-  }
-  
-  file_set = mCurrentMeshHandle;
-  return result;
-}
 
-// Generic load function for both ASCII and binary.  Calls
-// pure-virtual function implemented in subclasses to read
-// the data from the file.
-MBErrorCode ReadSTL::load_file_impl(const char *filename,
-                                    const FileOptions& opts,
-                                    const MBTag* file_id_tag ) 
-{
   MBErrorCode result;
 
   std::vector<ReadSTL::Triangle> triangles;
@@ -151,10 +128,6 @@
   if (MB_SUCCESS != result)
     return result;
 
-    // make a meshset for this mesh
-  result = mdbImpl->create_meshset(MESHSET_SET, mCurrentMeshHandle);
-  if (MB_SUCCESS != result) return result;
-
     // Create a std::map from position->handle, and such
     // that all positions are specified, and handles are zero.
   std::map<Point,MBEntityHandle> vertex_map;
@@ -175,7 +148,7 @@
 
     // Add vertices to entity set
   MBRange range(handle, handle+vertex_map.size()-1);
-  result = mdbImpl->add_entities(mCurrentMeshHandle, range);
+  result = mdbImpl->add_entities(file_set, range);
   if (MB_SUCCESS != result)
     return result;
   
@@ -211,7 +184,7 @@
 
     // Add triangles to entity set
   MBRange range2(handle, handle+triangles.size()-1);
-  result = mdbImpl->add_entities(mCurrentMeshHandle, range2);
+  result = mdbImpl->add_entities(file_set, range2);
   if (MB_SUCCESS != result)
     return result;
   

Modified: MOAB/trunk/ReadSTL.hpp
===================================================================
--- MOAB/trunk/ReadSTL.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadSTL.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -72,7 +72,7 @@
     //! Generic file loading code for both binary and ASCII readers.
     //! Calls reader-specific read_triangles function to do actual I/O.
   MBErrorCode load_file( const char *file_name,
-                         MBEntityHandle& file_set,
+                         MBEntityHandle file_set,
                          const FileOptions& opts,
                          const MBReaderIface::IDTag* subset_list = 0,
                          int subset_list_length = 0,
@@ -120,16 +120,6 @@
     //! interface instance
   MBInterface* mdbImpl;
 
-private:
-
-    //! Generic file loading code for both binary and ASCII readers.
-    //! Calls reader-specific *_read_triangles function to do actual I/O.
-  MBErrorCode load_file_impl( const char *file_name, 
-                              const FileOptions& opts,
-                              const MBTag* file_id_tag );
-
-    //! Meshset Handle for the mesh that is currently being read
-  MBEntityHandle mCurrentMeshHandle;
 };
 
 #endif

Modified: MOAB/trunk/ReadSms.cpp
===================================================================
--- MOAB/trunk/ReadSms.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadSms.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -73,7 +73,7 @@
 
 
 MBErrorCode ReadSms::load_file( const char* filename, 
-                                MBEntityHandle& file_set,
+                                MBEntityHandle ,
                                 const FileOptions& ,
                                 const MBReaderIface::IDTag* subset_list,
                                 int subset_list_length,
@@ -94,22 +94,9 @@
     return MB_FILE_DOES_NOT_EXIST;
   }
 
-  mCurrentMeshHandle = 0;
   const MBErrorCode result = load_file_impl( file_ptr, file_id_tag );
   fclose( file_ptr );
-  
-    // If file read has failed, destroy anything that was
-    // created during the read.
-  if (MB_SUCCESS != result && mCurrentMeshHandle)
-  {
-    MBRange entities;
-    mdbImpl->get_entities_by_handle( mCurrentMeshHandle, entities );
-    entities.insert( mCurrentMeshHandle );
-    mdbImpl->delete_entities( entities );
-    mCurrentMeshHandle = 0;
-  }
-  
-  file_set = mCurrentMeshHandle;
+
   return result;
 }
 
@@ -347,9 +334,6 @@
     CHECK("Failed to create edge.");
     if (MB_SUCCESS != result) return result;
 
-    result = mdbImpl->add_entities(mCurrentMeshHandle, &new_faces[i], 1);
-    if (MB_SUCCESS != result) return result;
-
     result = mdbImpl->add_entities(this_gent, &new_faces[i], 1);
     CHECK("Failed to add edge to geom set.");
     if (MB_SUCCESS != result) return result;
@@ -476,11 +460,6 @@
                                      &set_dim);
       if (MB_SUCCESS != result) return result;
       
-      result = mdbImpl->add_entities( mCurrentMeshHandle,
-                                      &sets[set_dim][set_id],
-                                      1 );
-      if (MB_SUCCESS != result) return result;
-      
       if (file_id_tag) {
         result = mdbImpl->tag_set_data(*file_id_tag,
                                      &sets[set_dim][set_id], 1,
@@ -534,20 +513,10 @@
                                    MBEntityHandle count,
                                    const MBTag* file_id_tag )
 {
-  if (!count)
+  if (!count || !file_id_tag)
     return MB_FAILURE;
+
   MBRange range;
   range.insert( start, start + count - 1 );
-  
-  MBErrorCode rval = mdbImpl->add_entities( mCurrentMeshHandle, range );
-  if (MB_SUCCESS != rval)
-    return rval;
-  
-  if (file_id_tag) {
-    rval = readMeshIface->assign_ids( *file_id_tag, range, 1 );
-    if (MB_SUCCESS != rval)
-      return rval;
-  }
-  
-  return MB_SUCCESS;
+  return readMeshIface->assign_ids( *file_id_tag, range, 1 );
 }

Modified: MOAB/trunk/ReadSms.hpp
===================================================================
--- MOAB/trunk/ReadSms.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadSms.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -18,7 +18,7 @@
   static MBReaderIface* factory( MBInterface* );
 
   MBErrorCode load_file( const char *file_name,
-                         MBEntityHandle& file_set,
+                         MBEntityHandle file_set,
                          const FileOptions& opts,
                          const MBReaderIface::IDTag* subset_list = 0,
                          int subset_list_length = 0,
@@ -57,9 +57,6 @@
 
     //! interface instance
   MBInterface* mdbImpl;
-
-    //! Meshset Handle for the mesh that is currently being read
-  MBEntityHandle mCurrentMeshHandle;
   
   MBTag globalId, paramCoords, geomDimension;
   

Modified: MOAB/trunk/ReadTetGen.cpp
===================================================================
--- MOAB/trunk/ReadTetGen.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadTetGen.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -74,7 +74,7 @@
 
 
 MBErrorCode ReadTetGen::load_file( const char* file_name_c,
-                                   MBEntityHandle& file_set,
+                                   MBEntityHandle file_set,
                                    const FileOptions& opts,
                                    const MBReaderIface::IDTag* subset_list,
                                    int subset_list_length,
@@ -138,24 +138,24 @@
   MBRange tets, tris, edges;
   std::vector<MBEntityHandle> nodes;
   rval = read_node_file( node_file, &attr_tags[0][0], &attr_idx[0][0], attr_tags[0].size(), nodes );
-  if (MB_SUCCESS == rval && ele_file.is_open())
+  if (MB_SUCCESS == rval)
+    rval = mbIface->add_entities( file_set, &nodes[0], nodes.size() );
+  if (MB_SUCCESS == rval && ele_file.is_open()) {
     rval = read_elem_file( MBTET, ele_file, nodes, tets );
-  if (MB_SUCCESS == rval && face_file.is_open())
+    if (MB_SUCCESS == rval)
+      rval = mbIface->add_entities( file_set, tets );
+  }
+  if (MB_SUCCESS == rval && face_file.is_open()) {
     rval = read_elem_file( MBTRI, face_file, nodes, tris );
-  if (MB_SUCCESS == rval && edge_file.is_open())
+    if (MB_SUCCESS == rval)
+      rval = mbIface->add_entities( file_set, tris );
+  }
+  if (MB_SUCCESS == rval && edge_file.is_open()) {
     rval = read_elem_file( MBEDGE, edge_file, nodes, edges );
+    if (MB_SUCCESS == rval)
+      rval = mbIface->add_entities( file_set, edges );
+  }
 
-  file_set = 0;
-  if (MB_SUCCESS == rval)
-    rval = mbIface->create_meshset( MESHSET_SET, file_set );
-  if (MB_SUCCESS == rval)
-    rval = mbIface->add_entities( file_set, &nodes[0], nodes.size() );
-  if (MB_SUCCESS == rval)
-    rval = mbIface->add_entities( file_set, tets );
-  if (MB_SUCCESS == rval)
-    rval = mbIface->add_entities( file_set, tris );
-  if (MB_SUCCESS == rval)
-    rval = mbIface->add_entities( file_set, edges );
   if (file_id_tag && MB_SUCCESS == rval)
     rval = readTool->assign_ids( *file_id_tag, &nodes[0], nodes.size() );
   if (file_id_tag && MB_SUCCESS == rval)
@@ -165,15 +165,6 @@
   if (file_id_tag && MB_SUCCESS == rval)
     rval = readTool->assign_ids( *file_id_tag, tets );
   
-  if (MB_SUCCESS != rval) {
-    if (file_set) 
-      mbIface->delete_entities( &file_set, 1 );
-    mbIface->delete_entities( tets );
-    mbIface->delete_entities( tris );
-    mbIface->delete_entities( edges );
-    mbIface->delete_entities( &nodes[0], nodes.size() );
-  }
-  
   return rval;  
 }
 

Modified: MOAB/trunk/ReadTetGen.hpp
===================================================================
--- MOAB/trunk/ReadTetGen.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadTetGen.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -37,7 +37,7 @@
 
     //! load a file
   MBErrorCode load_file( const char *file_name,
-                         MBEntityHandle& file_set,
+                         MBEntityHandle file_set,
                          const FileOptions&,
                          const MBReaderIface::IDTag* subset_list = 0,
                          int subset_list_length = 0,

Modified: MOAB/trunk/ReadVtk.cpp
===================================================================
--- MOAB/trunk/ReadVtk.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadVtk.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -82,10 +82,9 @@
 class MBModulator : public std::map<MBHash,MBEntityHandle>
 {
 public:
-  MBModulator( MBInterface* iface, MBEntityHandle fset, std::string tag_name, MBDataType mb_type, size_t size, size_t per_elem )
+  MBModulator( MBInterface* iface, std::string tag_name, MBDataType mb_type, size_t size, size_t per_elem )
     {
     this->mesh = iface;
-    this->file_set = fset;
     std::vector<unsigned char> default_val;
     default_val.resize( size * per_elem );
     this->mesh->tag_create( tag_name.c_str(), size, MB_TAG_SPARSE,
@@ -122,7 +121,6 @@
         {
         this->mesh->create_meshset( MESHSET_SET, mset );
         this->mesh->tag_set_data( this->tag, &mset, 1, tag_data );
-        this->mesh->add_entities( this->file_set, &mset, 1 );
         }
       (*this)[h] = mset;
       return mset;
@@ -132,7 +130,6 @@
 
   MBInterface* mesh;
   MBTag tag;
-  MBEntityHandle file_set;
 };
 #endif // MB_VTK_MATERIAL_SETS
 
@@ -182,14 +179,13 @@
 
 
 MBErrorCode ReadVtk::load_file( const char *filename,
-                                MBEntityHandle& file_set,
+                                MBEntityHandle ,
                                 const FileOptions& opts,
                                 const MBReaderIface::IDTag* subset_list,
                                 int subset_list_length,
                                 const MBTag* file_id_tag) 
 {
   MBErrorCode result;
-  file_set = 0;
 
   int major, minor;
   char vendor_string[257];
@@ -258,10 +254,6 @@
       break;
   }
 
-    // make a meshset for this mesh
-  result = mdbImpl->create_meshset(MESHSET_SET, mCurrentMeshHandle);
-  if (MB_SUCCESS != result) return result;
-
     // Read the mesh
   if (!tokens.match_token( "DATASET" ))
     return MB_FAILURE;
@@ -334,7 +326,6 @@
       return result;
   }
   
-  file_set = mCurrentMeshHandle;
   return MB_SUCCESS;
 }
 
@@ -358,9 +349,7 @@
   y_coord_array_out = arrays[1];
   z_coord_array_out = arrays[2];
   
-    // Add vertices to meshset
-  MBRange vert_range(start_handle_out, start_handle_out+num_verts-1);
-  return mdbImpl->add_entities(mCurrentMeshHandle, vert_range);
+  return MB_SUCCESS;
 }
 
 MBErrorCode ReadVtk::read_vertices( FileTokenizer& tokens,
@@ -407,7 +396,7 @@
   
   MBRange range(start_handle_out, start_handle_out+num_elements-1);
   append_to_this.push_back( range );
-  return mdbImpl->add_entities(mCurrentMeshHandle, range);
+  return MB_SUCCESS;
 }
 
 MBErrorCode ReadVtk::vtk_read_dataset( FileTokenizer& tokens,
@@ -1040,7 +1029,7 @@
   }
 
 #ifdef MB_VTK_MATERIAL_SETS
-  MBModulator materialMap( this->mdbImpl, this->mCurrentMeshHandle, this->mPartitionTagName, mb_type, size, per_elem );
+  MBModulator materialMap( this->mdbImpl, this->mPartitionTagName, mb_type, size, per_elem );
   bool isMaterial =
     size * per_elem <= 4 &&                            // must have int-sized values (MBParallelComm requires it)
     ! this->mPartitionTagName.empty() &&               // must have a non-empty field name...

Modified: MOAB/trunk/ReadVtk.hpp
===================================================================
--- MOAB/trunk/ReadVtk.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/ReadVtk.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -33,7 +33,7 @@
 
     //! load a file
   MBErrorCode load_file( const char *file_name,
-                         MBEntityHandle& file_set,
+                         MBEntityHandle file_set,
                          const FileOptions&,
                          const MBReaderIface::IDTag* subset_list = 0,
                          int subset_list_length = 0,

Modified: MOAB/trunk/Tqdcfr.cpp
===================================================================
--- MOAB/trunk/Tqdcfr.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/Tqdcfr.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -202,14 +202,13 @@
 }
 
 MBErrorCode Tqdcfr::load_file(const char *file_name,
-                              MBEntityHandle& file_set,
+                              MBEntityHandle file_set,
                               const FileOptions& opts,
                               const MBReaderIface::IDTag* subset_list,
                               int subset_list_length,
                               const MBTag* file_id_tag) 
 {
   MBErrorCode result;
-  file_set = mFileSet = 0;
 
   if (subset_list && subset_list_length) {
     readUtilIface->report_error( "Reading subset of files not supported for CUB files." );
@@ -230,16 +229,7 @@
     readUtilIface->report_error("This doesn't appear to be a .cub file.");
     return MB_FAILURE;
   }
-  
-    // create meshset to contain file
-  result = mdbImpl->create_meshset( MESHSET_SET, file_set );
-  if (MB_SUCCESS != result) {
-    readUtilIface->report_error("Problems creating mesh set for file contents.");
-    return result;
-  }
 
-  mFileSet = file_set;
-
     // get "before" entities
   result = mdbImpl->get_entities_by_handle(0, beforeEnts);
   if (MB_SUCCESS != result) {
@@ -396,7 +386,6 @@
     return result;
 
   after_ents = subtract( after_ents, beforeEnts);
-  result = mdbImpl->add_entities(mFileSet, after_ents);
   
   if (file_id_tag)
     readUtilIface->assign_ids( *file_id_tag, after_ents );
@@ -2579,11 +2568,7 @@
 
 MBErrorCode Tqdcfr::create_set( MBEntityHandle& h, unsigned int flags )
 {
-  MBErrorCode rval;
-  if (!mFileSet)
-    return MB_FAILURE;
-  rval = mdbImpl->create_meshset( flags, h );
-  return rval;
+  return mdbImpl->create_meshset( flags, h );
 }
 
 #ifdef TEST_TQDCFR

Modified: MOAB/trunk/Tqdcfr.hpp
===================================================================
--- MOAB/trunk/Tqdcfr.hpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/Tqdcfr.hpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -293,7 +293,7 @@
   
     // read cub file
   MBErrorCode load_file(const char *file_name,
-                        MBEntityHandle& file_set,
+                        MBEntityHandle file_set,
                         const FileOptions& opts,
                         const MBReaderIface::IDTag* subset_list = 0,
                         int subset_list_length = 0,

Modified: MOAB/trunk/cub_file_test.cc
===================================================================
--- MOAB/trunk/cub_file_test.cc	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/cub_file_test.cc	2009-10-01 21:18:23 UTC (rev 3188)
@@ -83,9 +83,7 @@
 static const char ho_file[] = "test/ho_test.cub";
 #endif
 
-void read_file( MBInterface& moab, 
-                const char* input_file,
-                MBEntityHandle* file_set = 0 );
+void read_file( MBInterface& moab, const char* input_file );
 
 
 // Check that adjacent lower-order entities have
@@ -124,8 +122,6 @@
 
 void test_node_sets();
 
-void test_file_set();
-
 void test_tri6 () { test_ho_elements(MBTRI, 6); }
 void test_tri7 () { test_ho_elements(MBTRI, 7); }
 
@@ -156,7 +152,6 @@
   result += RUN_TEST(test_blocks);
   result += RUN_TEST(test_side_sets);
   result += RUN_TEST(test_node_sets);
-  result += RUN_TEST(test_file_set);
   result += RUN_TEST(test_tri6 );
   result += RUN_TEST(test_tri7 );
   result += RUN_TEST(test_quad5);
@@ -173,17 +168,15 @@
   return result;
 }
 
-void read_file( MBInterface& moab, 
-                const char* input_file,
-                MBEntityHandle* file_set )
+void read_file( MBInterface& moab, const char* input_file )
 {
   MBErrorCode rval;
   MBEntityHandle set;
   Tqdcfr reader( &moab );
   FileOptions opts("");
+  rval = moab.create_meshset( MESHSET_SET, set );
+  CHECK_ERR(rval);
   rval = reader.load_file( input_file, set, opts, 0, 0, 0 );
-  if (file_set)
-    *file_set = set;
   CHECK_ERR(rval);
 }
 
@@ -831,21 +824,6 @@
   test_bc_sets( DIRICHLET_SET_TAG_NAME, 2, ids, surfs );
 }
 
-void test_file_set()
-{
-  MBCore mb_impl;
-  MBInterface& mb = mb_impl;
-  MBEntityHandle set;
-  read_file( mb, input_file_1, &set );
-  
-  MBErrorCode rval;
-  MBRange exp, act;
-  rval = mb.get_entities_by_handle( 0, exp ); CHECK_ERR(rval);
-  rval = mb.get_entities_by_handle( set, act ); CHECK_ERR(rval);
-  exp.erase( set );
-  CHECK( exp == act );
-}
-
 static MBEntityHandle find_side( MBInterface& moab, 
                                  MBEntityHandle entity,
                                  int side_dim,
@@ -1044,9 +1022,17 @@
   MBErrorCode rval;
   MBCore mb_impl;
   MBInterface& mb = mb_impl;
+  MBRange file1_ents, file2_ents;
+  read_file( mb, input_file_1 );
+  mb.get_entities_by_handle( 0, file1_ents );
+  read_file( mb, input_file_1 );
+  mb.get_entities_by_handle( 0, file2_ents );
+  file2_ents = subtract( file2_ents, file1_ents );
   MBEntityHandle file1, file2;
-  read_file( mb, input_file_1, &file1);
-  read_file( mb, input_file_1, &file2 );
+  mb.create_meshset( MESHSET_SET, file1 );
+  mb.create_meshset( MESHSET_SET, file2 );
+  mb.add_entities( file1, file1_ents );
+  mb.add_entities( file2, file2_ents );
   
     // first check that we get the same number of verts from 
     // each file and that they are distinct vertices

Modified: MOAB/trunk/exodus_test.cc
===================================================================
--- MOAB/trunk/exodus_test.cc	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/exodus_test.cc	2009-10-01 21:18:23 UTC (rev 3188)
@@ -184,6 +184,8 @@
   MBEntityHandle set;
   ReadNCDF reader( &moab );
   FileOptions opts("");
+  rval = moab.create_meshset( MESHSET_SET, set );
+  CHECK_ERR(rval);
   rval = reader.load_file( input_file, set, opts, 0, 0, 0 );
   CHECK_ERR(rval);
 }
@@ -209,6 +211,10 @@
     remove(tmp_file);
   CHECK_ERR(rval);
   
+  rval = read_mb.create_meshset( MESHSET_SET, set );
+  if (MB_SUCCESS != rval) 
+    remove(tmp_file);
+  CHECK_ERR(rval);
   rval = reader.load_file( tmp_file, set, opts, 0, 0, 0 );
   remove( tmp_file );
   CHECK_ERR(rval);

Modified: MOAB/trunk/gmsh_test.cc
===================================================================
--- MOAB/trunk/gmsh_test.cc	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/gmsh_test.cc	2009-10-01 21:18:23 UTC (rev 3188)
@@ -41,6 +41,7 @@
 {
   MBErrorCode rval;
   MBEntityHandle set;
+  moab.create_meshset( MESHSET_SET, set );
   ReadGmsh reader( &moab );
   FileOptions opts("");
   rval = reader.load_file( input_file, set, opts, 0, 0, 0 );

Modified: MOAB/trunk/stl_test.cc
===================================================================
--- MOAB/trunk/stl_test.cc	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/stl_test.cc	2009-10-01 21:18:23 UTC (rev 3188)
@@ -60,6 +60,7 @@
 {
   MBErrorCode rval;
   MBEntityHandle set;
+  moab.create_meshset( MESHSET_SET, set );
   ReadSTL reader( &moab );
   FileOptions opts(options);
   rval = reader.load_file( input_file, set, opts, 0, 0, 0 );
@@ -77,6 +78,7 @@
   MBErrorCode rval;
   MBEntityHandle set;
   MBCore moab;
+  moab.create_meshset( MESHSET_SET, set );
 
   ReadSTL reader( &moab );
   FileOptions opts_reader("");

Modified: MOAB/trunk/test/h5file/h5sets_test.cpp
===================================================================
--- MOAB/trunk/test/h5file/h5sets_test.cpp	2009-10-01 15:29:26 UTC (rev 3187)
+++ MOAB/trunk/test/h5file/h5sets_test.cpp	2009-10-01 21:18:23 UTC (rev 3188)
@@ -254,7 +254,7 @@
   
   // create a binary tree to a depth of 20 (about 1 million nodes)
   rval = mb.create_meshset( MESHSET_SET, root ); CHECK_ERR(rval);
-  int idx = 0;
+  int idx = 1;
   recursive_build_tree( max_depth, mb, tag, root, 1, idx );
   const int last_idx = idx;
   std::cerr << "Created binary tree containing " << last_idx << " nodes." << std::endl;
@@ -273,14 +273,14 @@
   // get tree root
   rval = mb.tag_get_handle( "GLOBAL_ID", tag ); CHECK_ERR(rval);
   MBRange roots;
-  idx = 0;
+  idx = 1;
   const void* vals[] = {&idx};
   rval = mb.get_entities_by_type_and_tag( 0, MBENTITYSET, &tag, vals, 1, roots );
   CHECK_EQUAL( (MBEntityHandle)1, roots.size() );
   root = roots.front();
   
   // check that tree is as we expect it
-  idx = 0;
+  idx = 1;
   recursive_check_tree( max_depth, mb, tag, root, 1, idx );
   CHECK_EQUAL( last_idx, idx );
 }



More information about the moab-dev mailing list