[MOAB-dev] r4933 - MOAB/trunk/src/parallel

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Thu Jun 2 16:45:27 CDT 2011


Author: kraftche
Date: 2011-06-02 16:45:26 -0500 (Thu, 02 Jun 2011)
New Revision: 4933

Modified:
   MOAB/trunk/src/parallel/ParallelComm.cpp
Log:
Fix accidental change to global/mesh value for tag when entity handle vector is empty

Modified: MOAB/trunk/src/parallel/ParallelComm.cpp
===================================================================
--- MOAB/trunk/src/parallel/ParallelComm.cpp	2011-06-02 21:45:00 UTC (rev 4932)
+++ MOAB/trunk/src/parallel/ParallelComm.cpp	2011-06-02 21:45:26 UTC (rev 4933)
@@ -3090,33 +3090,35 @@
       RRA("Failed to get local handles for tag vals.");
     }
 
-    if (tag_size == MB_VARIABLE_LENGTH) {
-        // Be careful of alignment here.  If the integers are aligned
-        // in the buffer, we can use them directly.  Otherwise we must
-        // copy them.
-      std::vector<int> var_lengths(num_ents);
-      UNPACK_INTS(buff_ptr, &var_lengths[0], num_ents);
-      UPC(sizeof(int) * num_ents, " void");
-      
-        // get pointers into buffer for each tag value
-      var_len_vals.resize(num_ents);
-      for (std::vector<EntityHandle>::size_type j = 0; 
-           j < (std::vector<EntityHandle>::size_type) num_ents; ++j) {
-        var_len_vals[j] = buff_ptr;
-        buff_ptr += var_lengths[j];
-        UPC(var_lengths[j], " void");
+    if (!dum_ents.empty()) {
+      if (tag_size == MB_VARIABLE_LENGTH) {
+          // Be careful of alignment here.  If the integers are aligned
+          // in the buffer, we can use them directly.  Otherwise we must
+          // copy them.
+        std::vector<int> var_lengths(num_ents);
+        UNPACK_INTS(buff_ptr, &var_lengths[0], num_ents);
+        UPC(sizeof(int) * num_ents, " void");
+
+          // get pointers into buffer for each tag value
+        var_len_vals.resize(num_ents);
+        for (std::vector<EntityHandle>::size_type j = 0; 
+             j < (std::vector<EntityHandle>::size_type) num_ents; ++j) {
+          var_len_vals[j] = buff_ptr;
+          buff_ptr += var_lengths[j];
+          UPC(var_lengths[j], " void");
+        }
+        result = mbImpl->tag_set_data( tag_handle, &dum_ents[0], num_ents,
+                                       &var_len_vals[0], &var_lengths[0]);
+        RRA("Trouble setting tag data when unpacking variable-length tag.");
       }
-      result = mbImpl->tag_set_data( tag_handle, &dum_ents[0], num_ents,
-                                     &var_len_vals[0], &var_lengths[0]);
-      RRA("Trouble setting tag data when unpacking variable-length tag.");
+      else {
+        result = mbImpl->tag_set_data(tag_handle, &dum_ents[0],
+                                      num_ents, buff_ptr);
+        RRA("Trouble setting range-based tag data when unpacking tag.");


More information about the moab-dev mailing list