/[escript]/trunk/weipa/src/DataVar.cpp
ViewVC logotype

Diff of /trunk/weipa/src/DataVar.cpp

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

revision 3092 by caltinay, Fri Aug 13 07:55:03 2010 UTC revision 3128 by caltinay, Wed Sep 1 03:54:09 2010 UTC
# Line 630  string DataVar::getTensorDef() const Line 630  string DataVar::getTensorDef() const
630  // The corresponding mesh must have been written already and made known  // The corresponding mesh must have been written already and made known
631  // to this variable by a call to setMesh().  // to this variable by a call to setMesh().
632  //  //
633  bool DataVar::writeToSilo(DBfile* dbfile, const string& siloPath)  bool DataVar::writeToSilo(DBfile* dbfile, const string& siloPath,
634                              const string& units)
635  {  {
636  #if USE_SILO  #if USE_SILO
637      if (!initialized)      if (!initialized)
# Line 649  bool DataVar::writeToSilo(DBfile* dbfile Line 650  bool DataVar::writeToSilo(DBfile* dbfile
650    
651      char* siloMesh = const_cast<char*>(siloMeshName.c_str());      char* siloMesh = const_cast<char*>(siloMeshName.c_str());
652      int dcenter = (centering == NODE_CENTERED ? DB_NODECENT : DB_ZONECENT);      int dcenter = (centering == NODE_CENTERED ? DB_NODECENT : DB_ZONECENT);
653        DBoptlist* optList = DBMakeOptlist(2);
654        if (units.length()>0) {
655            DBAddOption(optList, DBOPT_UNITS, (void*)units.c_str());
656        }
657    
658      if (rank == 0) {      if (rank == 0) {
659          ret = DBPutUcdvar1(dbfile, varName.c_str(), siloMesh, dataArray[0],          ret = DBPutUcdvar1(dbfile, varName.c_str(), siloMesh, dataArray[0],
660                  numSamples, NULL, 0, DB_FLOAT, dcenter, NULL);                  numSamples, NULL, 0, DB_FLOAT, dcenter, optList);
661      }      }
662      else if (rank == 1) {      else if (rank == 1) {
663          const string comps[3] = {          const string comps[3] = {
# Line 664  bool DataVar::writeToSilo(DBfile* dbfile Line 669  bool DataVar::writeToSilo(DBfile* dbfile
669    
670          ret = DBPutUcdvar(dbfile, varName.c_str(), siloMesh, shape[0],          ret = DBPutUcdvar(dbfile, varName.c_str(), siloMesh, shape[0],
671                  (char**)varnames, &dataArray[0], numSamples, NULL,                  (char**)varnames, &dataArray[0], numSamples, NULL,
672                  0, DB_FLOAT, dcenter, NULL);                  0, DB_FLOAT, dcenter, optList);
673      }      }
674      else {      else {
675          string tensorDir = varName+string("_comps/");          string tensorDir = varName+string("_comps/");
676          ret = DBMkdir(dbfile, tensorDir.c_str());          ret = DBMkdir(dbfile, tensorDir.c_str());
677          if (ret == 0) {          if (ret == 0) {
678              int one = 1;              int one = 1;
             DBoptlist* optList = DBMakeOptlist(1);  
679              DBAddOption(optList, DBOPT_HIDE_FROM_GUI, &one);              DBAddOption(optList, DBOPT_HIDE_FROM_GUI, &one);
680    
681              for (int i=0; i<shape[1]; i++) {              for (int i=0; i<shape[1]; i++) {
# Line 685  bool DataVar::writeToSilo(DBfile* dbfile Line 689  bool DataVar::writeToSilo(DBfile* dbfile
689                  }                  }
690                  if (ret != 0) break;                  if (ret != 0) break;
691              }              }
             DBFreeOptlist(optList);  
692          } // ret==0          } // ret==0
693      } // rank      } // rank
694    
695        DBFreeOptlist(optList);
696      DBSetDir(dbfile, "/");      DBSetDir(dbfile, "/");
697      return (ret == 0);      return (ret == 0);
698    

Legend:
Removed from v.3092  
changed lines
  Added in v.3128

  ViewVC Help
Powered by ViewVC 1.1.26