/[escript]/trunk/escript/src/DataTagged.cpp
ViewVC logotype

Diff of /trunk/escript/src/DataTagged.cpp

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

revision 1019 by gross, Tue Feb 20 02:49:08 2007 UTC revision 1020 by phornby, Mon Mar 12 10:12:36 2007 UTC
# Line 605  DataTagged::dump(const std::string fileN Line 605  DataTagged::dump(const std::string fileN
605     DataTagged::DataMapType::const_iterator thisLookupEnd=thisLookup.end();     DataTagged::DataMapType::const_iterator thisLookupEnd=thisLookup.end();
606     int ntags=1;     int ntags=1;
607     for (i=thisLookup.begin();i!=thisLookupEnd;i++) ntags++;     for (i=thisLookup.begin();i!=thisLookupEnd;i++) ntags++;
608     int tags[ntags], c=1;     int* tags =(int*) malloc(ntags*sizeof(int));
609       int c=1;
610     tags[0]=-1;     tags[0]=-1;
611     for (i=thisLookup.begin();i!=thisLookupEnd;i++) tags[c++]=i->first;     for (i=thisLookup.begin();i!=thisLookupEnd;i++) tags[c++]=i->first;
612     dims[rank]=ntags;     dims[rank]=ntags;
613     if (! (ncdims[rank] = dataFile.add_dim("num_tags", dims[rank])) )     if (! (ncdims[rank] = dataFile.add_dim("num_tags", dims[rank])) )
614              throw DataException("Error - DataTagged:: appending num_tags to netCDF file failed.");     {
615           free(tags);
616               throw DataException("Error - DataTagged:: appending num_tags to netCDF file failed.");
617       }
618     if (! ( tags_var = dataFile.add_var("tags", ncInt, ncdims[rank])) )     if (! ( tags_var = dataFile.add_var("tags", ncInt, ncdims[rank])) )
619       {
620        free(tags);
621          throw DataException("Error - DataTagged:: appending tags to netCDF file failed.");          throw DataException("Error - DataTagged:: appending tags to netCDF file failed.");
622       }
623     if (! (tags_var->put(tags,dims[rank])) )     if (! (tags_var->put(tags,dims[rank])) )
624       {
625        free(tags);
626          throw DataException("Error - DataTagged:: copy tags to netCDF buffer failed.");          throw DataException("Error - DataTagged:: copy tags to netCDF buffer failed.");
627       }
628     if (! ( var = dataFile.add_var("data", ncDouble, ndims, ncdims)) )     if (! ( var = dataFile.add_var("data", ncDouble, ndims, ncdims)) )
629       {
630        free(tags);
631          throw DataException("Error - DataTagged:: appending variable to netCDF file failed.");          throw DataException("Error - DataTagged:: appending variable to netCDF file failed.");
632       }
633     if (! (var->put(&m_data[0],dims)) )     if (! (var->put(&m_data[0],dims)) )
634       {
635        free(tags);
636          throw DataException("Error - DataTagged:: copy data to netCDF buffer failed.");          throw DataException("Error - DataTagged:: copy data to netCDF buffer failed.");
637       }
638  }  }
639    
640    

Legend:
Removed from v.1019  
changed lines
  Added in v.1020

  ViewVC Help
Powered by ViewVC 1.1.26