/[escript]/branches/diaplayground/finley/src/CPPAdapter/MeshAdapter.cpp
ViewVC logotype

Diff of /branches/diaplayground/finley/src/CPPAdapter/MeshAdapter.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4436 by caltinay, Fri May 31 07:09:03 2013 UTC revision 4437 by caltinay, Tue Jun 4 05:37:18 2013 UTC
# Line 129  void MeshAdapter::dump(const string& fil Line 129  void MeshAdapter::dump(const string& fil
129      NcVar *ids;      NcVar *ids;
130      int *int_ptr;      int *int_ptr;
131      Finley_Mesh *mesh = m_finleyMesh.get();      Finley_Mesh *mesh = m_finleyMesh.get();
     Finley_TagMap* tag_map;  
132      int num_Tags = 0;      int num_Tags = 0;
133      int mpi_size                         = mesh->MPIInfo->size;      int mpi_size                         = mesh->MPIInfo->size;
134      int mpi_rank                         = mesh->MPIInfo->rank;      int mpi_rank                         = mesh->MPIInfo->rank;
# Line 157  void MeshAdapter::dump(const string& fil Line 156  void MeshAdapter::dump(const string& fil
156                                                       mpi_size, mpi_rank);                                                       mpi_size, mpi_rank);
157    
158      // Figure out how much storage is required for tags      // Figure out how much storage is required for tags
159      tag_map = mesh->TagMap;      num_Tags = mesh->tagMap.size();
     num_Tags = 0;  
     while (tag_map) {  
         num_Tags++;  
         tag_map=tag_map->next;  
     }  
160    
161      // NetCDF error handler      // NetCDF error handler
162      NcError err(NcError::verbose_nonfatal);      NcError err(NcError::verbose_nonfatal);
# Line 470  void MeshAdapter::dump(const string& fil Line 464  void MeshAdapter::dump(const string& fil
464          vector<int> Tags_keys;          vector<int> Tags_keys;
465    
466          // Copy tag data into temp arrays          // Copy tag data into temp arrays
467          tag_map = mesh->TagMap;          TagMap::const_iterator it;
468          while (tag_map) {          for (it=mesh->tagMap.begin(); it!=mesh->tagMap.end(); it++) {
469              Tags_keys.push_back(tag_map->tag_key);              Tags_keys.push_back(it->second);
             tag_map=tag_map->next;  
470          }          }
471    
472          // Tags_keys          // Tags_keys
# Line 487  void MeshAdapter::dump(const string& fil Line 480  void MeshAdapter::dump(const string& fil
480          // This is an array of strings, it should be stored as an array but          // This is an array of strings, it should be stored as an array but
481          // instead I have hacked in one attribute per string because the NetCDF          // instead I have hacked in one attribute per string because the NetCDF
482          // manual doesn't tell how to do an array of strings          // manual doesn't tell how to do an array of strings
         tag_map = mesh->TagMap;  
483          int i = 0;          int i = 0;
484          while (tag_map) {          for (it=mesh->tagMap.begin(); it!=mesh->tagMap.end(); it++, i++) {
485              stringstream tagnamestream;              stringstream tagnamestream;
486              tagnamestream << "Tags_name_" << i;              tagnamestream << "Tags_name_" << i;
487              const string tagname = tagnamestream.str();              const string tagname = tagnamestream.str();
488              if (!dataFile.add_att(tagname.c_str(), tag_map->name) )              if (!dataFile.add_att(tagname.c_str(), it->first.c_str()))
489                  throw FinleyAdapterException(msgPrefix+"add_att(Tags_names_XX)");                  throw FinleyAdapterException(msgPrefix+"add_att(Tags_names_X)");
             tag_map=tag_map->next;  
             i++;  
490          }          }
491      }      }
492    
# Line 2089  string MeshAdapter::showTagNames() const Line 2079  string MeshAdapter::showTagNames() const
2079  {  {
2080      stringstream temp;      stringstream temp;
2081      Finley_Mesh* mesh=m_finleyMesh.get();      Finley_Mesh* mesh=m_finleyMesh.get();
2082      Finley_TagMap* tag_map=mesh->TagMap;      TagMap::const_iterator it = mesh->tagMap.begin();
2083      while (tag_map) {      while (it != mesh->tagMap.end()) {
2084          temp << tag_map->name;          temp << it->first;
2085          tag_map=tag_map->next;          ++it;
2086          if (tag_map) temp << ", ";          if (it != mesh->tagMap.end())
2087                temp << ", ";
2088      }      }
2089      return temp.str();      return temp.str();
2090  }  }

Legend:
Removed from v.4436  
changed lines
  Added in v.4437

  ViewVC Help
Powered by ViewVC 1.1.26