/[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 1455 by phornby, Thu Feb 28 17:19:44 2008 UTC revision 1628 by phornby, Fri Jul 11 13:12:46 2008 UTC
# Line 14  Line 14 
14   *******************************************************/   *******************************************************/
15    
16  #include "DataTagged.h"  #include "DataTagged.h"
17    #include "esysUtils/esys_malloc.h"
18    
19  #include "DataConstant.h"  #include "DataConstant.h"
20  #include "DataException.h"  #include "DataException.h"
# Line 620  DataTagged::dump(const std::string fileN Line 621  DataTagged::dump(const std::string fileN
621     DataTagged::DataMapType::const_iterator thisLookupEnd=thisLookup.end();     DataTagged::DataMapType::const_iterator thisLookupEnd=thisLookup.end();
622     int ntags=1;     int ntags=1;
623     for (i=thisLookup.begin();i!=thisLookupEnd;i++) ntags++;     for (i=thisLookup.begin();i!=thisLookupEnd;i++) ntags++;
624     int* tags =(int*) malloc(ntags*sizeof(int));     int* tags =(int*) esysUtils::malloc(ntags*sizeof(int));
625     int c=1;     int c=1;
626     tags[0]=-1;     tags[0]=-1;
627     for (i=thisLookup.begin();i!=thisLookupEnd;i++) tags[c++]=i->first;     for (i=thisLookup.begin();i!=thisLookupEnd;i++) tags[c++]=i->first;
628     dims[rank]=ntags;     dims[rank]=ntags;
629     if (! (ncdims[rank] = dataFile.add_dim("num_tags", dims[rank])) )     if (! (ncdims[rank] = dataFile.add_dim("num_tags", dims[rank])) )
630     {     {
631         free(tags);         esysUtils::free(tags);
632             throw DataException("Error - DataTagged:: appending num_tags to netCDF file failed.");             throw DataException("Error - DataTagged:: appending num_tags to netCDF file failed.");
633     }     }
634     if (! ( tags_var = dataFile.add_var("tags", ncInt, ncdims[rank])) )     if (! ( tags_var = dataFile.add_var("tags", ncInt, ncdims[rank])) )
635     {     {
636      free(tags);      esysUtils::free(tags);
637          throw DataException("Error - DataTagged:: appending tags to netCDF file failed.");          throw DataException("Error - DataTagged:: appending tags to netCDF file failed.");
638     }     }
639     if (! (tags_var->put(tags,dims[rank])) )     if (! (tags_var->put(tags,dims[rank])) )
640     {     {
641      free(tags);      esysUtils::free(tags);
642          throw DataException("Error - DataTagged:: copy tags to netCDF buffer failed.");          throw DataException("Error - DataTagged:: copy tags to netCDF buffer failed.");
643     }     }
644     if (! ( var = dataFile.add_var("data", ncDouble, ndims, ncdims)) )     if (! ( var = dataFile.add_var("data", ncDouble, ndims, ncdims)) )
645     {     {
646      free(tags);      esysUtils::free(tags);
647          throw DataException("Error - DataTagged:: appending variable to netCDF file failed.");          throw DataException("Error - DataTagged:: appending variable to netCDF file failed.");
648     }     }
649     if (! (var->put(d_ptr,dims)) )     if (! (var->put(d_ptr,dims)) )
650     {     {
651      free(tags);      esysUtils::free(tags);
652          throw DataException("Error - DataTagged:: copy data to netCDF buffer failed.");          throw DataException("Error - DataTagged:: copy data to netCDF buffer failed.");
653     }     }
654     #else     #else

Legend:
Removed from v.1455  
changed lines
  Added in v.1628

  ViewVC Help
Powered by ViewVC 1.1.26