/[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 1020 by phornby, Mon Mar 12 10:12:36 2007 UTC revision 1141 by gross, Tue May 15 04:24:51 2007 UTC
# Line 16  Line 16 
16    
17  #include "DataConstant.h"  #include "DataConstant.h"
18  #include "DataException.h"  #include "DataException.h"
19  #include <netcdfcpp.h>  #ifdef USE_NETCDF
20    #include "netcdfcpp.h"
21    #endif
22    
23  using namespace std;  using namespace std;
24    
# Line 362  DataTagged::toString() const Line 364  DataTagged::toString() const
364      tempView.setOffset(i->second);      tempView.setOffset(i->second);
365      temp << tempView.toString() << endl;      temp << tempView.toString() << endl;
366    }    }
367    return temp.str();    return string(temp.str());
368  }  }
369    
370  DataArrayView::ValueType::size_type  DataArrayView::ValueType::size_type
# Line 555  DataTagged::eigenvalues_and_eigenvectors Line 557  DataTagged::eigenvalues_and_eigenvectors
557  }  }
558    
559  void  void
560    DataTagged::setToZero(){
561        DataArrayView::ValueType::size_type n=m_data.size();
562        for (int i=0; i<n ;++i) m_data[i]=0.;
563    }
564    
565    void
566  DataTagged::dump(const std::string fileName) const  DataTagged::dump(const std::string fileName) const
567  {  {
568       #ifdef PASO_MPI
569       throw DataException("Error - DataTagged:: dump is not implemented for MPI yet.")
570       #endif
571       #ifdef USE_NETCDF
572     const int ldims=DataArrayView::maxRank+1;     const int ldims=DataArrayView::maxRank+1;
573     const NcDim* ncdims[ldims];     const NcDim* ncdims[ldims];
574     NcVar *var, *tags_var;     NcVar *var, *tags_var;
# Line 564  DataTagged::dump(const std::string fileN Line 576  DataTagged::dump(const std::string fileN
576     int type=  getFunctionSpace().getTypeCode();     int type=  getFunctionSpace().getTypeCode();
577     int ndims =0;     int ndims =0;
578     long dims[ldims];     long dims[ldims];
579       const double* d_ptr=&(m_data[0]);
580     DataArrayView::ShapeType shape = getPointDataView().getShape();     DataArrayView::ShapeType shape = getPointDataView().getShape();
581    
582     // netCDF error handler     // netCDF error handler
# Line 573  DataTagged::dump(const std::string fileN Line 586  DataTagged::dump(const std::string fileN
586     // check if writing was successful     // check if writing was successful
587     if (!dataFile.is_valid())     if (!dataFile.is_valid())
588          throw DataException("Error - DataTagged:: opening of netCDF file for output failed.");          throw DataException("Error - DataTagged:: opening of netCDF file for output failed.");
589     if (!dataFile.add_att("type","tagged") )     if (!dataFile.add_att("type_id",1) )
590          throw DataException("Error - DataTagged:: appending data type to netCDF file failed.");          throw DataException("Error - DataTagged:: appending data type to netCDF file failed.");
591     if (!dataFile.add_att("rank",rank) )     if (!dataFile.add_att("rank",rank) )
592          throw DataException("Error - DataTagged:: appending rank attribute to netCDF file failed.");          throw DataException("Error - DataTagged:: appending rank attribute to netCDF file failed.");
# Line 630  DataTagged::dump(const std::string fileN Line 643  DataTagged::dump(const std::string fileN
643      free(tags);      free(tags);
644          throw DataException("Error - DataTagged:: appending variable to netCDF file failed.");          throw DataException("Error - DataTagged:: appending variable to netCDF file failed.");
645     }     }
646     if (! (var->put(&m_data[0],dims)) )     if (! (var->put(d_ptr,dims)) )
647     {     {
648      free(tags);      free(tags);
649          throw DataException("Error - DataTagged:: copy data to netCDF buffer failed.");          throw DataException("Error - DataTagged:: copy data to netCDF buffer failed.");
650     }     }
651       #else
652       throw DataException("Error - DataTagged:: dump is not configured with netCDF. Please contact your installation manager.");
653       #endif
654  }  }
   
   
655  }  // end of namespace  }  // end of namespace

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

  ViewVC Help
Powered by ViewVC 1.1.26