/[escript]/branches/lapack2681/escript/src/DataConstant.cpp
ViewVC logotype

Diff of /branches/lapack2681/escript/src/DataConstant.cpp

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

revision 854 by gross, Thu Sep 21 05:29:42 2006 UTC revision 950 by gross, Tue Feb 6 07:01:11 2007 UTC
# Line 17  Line 17 
17    
18  #include <iostream>  #include <iostream>
19  #include <boost/python/extract.hpp>  #include <boost/python/extract.hpp>
20    #include <netcdfcpp.h>
21    
22  using namespace std;  using namespace std;
23    
# Line 263  DataConstant::eigenvalues_and_eigenvecto Line 264  DataConstant::eigenvalues_and_eigenvecto
264    DataArrayView::eigenvalues_and_eigenvectors(thisView,0,evView,0,VView,tol);    DataArrayView::eigenvalues_and_eigenvectors(thisView,0,evView,0,VView,tol);
265  }  }
266    
267    void
268    DataConstant::dump(const std::string fileName) const
269    {
270       #ifdef PASO_MPI
271       throw DataException("Error - DataConstant:: dump is not implemented for MPI yet.")
272       #endif
273       const NcDim* ncdims[DataArrayView::maxRank];
274       NcVar* var;
275       int rank = getPointDataView().getRank();
276       int type=  getFunctionSpace().getTypeCode();
277       int ndims =0;
278       long dims[DataArrayView::maxRank];
279       DataArrayView::ShapeType shape = getPointDataView().getShape();
280      
281       // netCDF error handler
282       NcError err(NcError::verbose_nonfatal);
283       // Create the file.
284       NcFile dataFile(fileName.c_str(), NcFile::Replace);
285       // check if writing was successful
286       if (!dataFile.is_valid())
287        throw DataException("Error - DataConstant:: opening of netCDF file for output failed.");
288       if (!dataFile.add_att("type","constant") )
289        throw DataException("Error - DataConstant:: appending data type to netCDF file failed.");
290       if (!dataFile.add_att("rank",rank) )
291        throw DataException("Error - DataConstant:: appending rank attribute to netCDF file failed.");
292       if (!dataFile.add_att("function_space_type",type))
293        throw DataException("Error - DataConstant:: appending function space attribute to netCDF file failed.");
294    
295       if (rank == 0) {
296          if( ! (ncdims[0] = dataFile.add_dim("l", 1)) )
297            throw DataException("Error - DataConstant:: appending ncdimsion 0 to netCDF file failed.");
298          dims[0]=1,
299          ndims=1;
300       } else {
301           ndims=rank;
302           dims[0]=shape[0];
303           if (! (ncdims[0] = dataFile.add_dim("d0",shape[0])) )
304            throw DataException("Error - DataConstant:: appending ncdimsion 0 to netCDF file failed.");
305           if ( rank >1 ) {
306               dims[1]=shape[1];
307               if (! (ncdims[1] = dataFile.add_dim("d1",shape[1])) )
308            throw DataException("Error - DataConstant:: appending ncdimsion 1 to netCDF file failed.");
309           }
310           if ( rank >2 ) {
311               dims[2]=shape[2];
312               if (! (ncdims[2] = dataFile.add_dim("d2", shape[2])) )
313            throw DataException("Error - DataConstant:: appending ncdimsion 2 to netCDF file failed.");
314           }
315           if ( rank >3 ) {
316               dims[3]=shape[3];
317               if (! (ncdims[3] = dataFile.add_dim("d3", shape[3])) )
318            throw DataException("Error - DataConstant:: appending ncdimsion 3 to netCDF file failed.");
319           }
320       }
321       if (! ( var = dataFile.add_var("data", ncDouble, ndims, ncdims)) )
322        throw DataException("Error - DataConstant:: appending variable to netCDF file failed.");
323       if (! (var->put(&m_data[0],dims)) )
324        throw DataException("Error - DataConstant:: copy data to netCDF buffer failed.");
325    }
326    
327  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.854  
changed lines
  Added in v.950

  ViewVC Help
Powered by ViewVC 1.1.26