/[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 1811 by ksteube, Thu Sep 25 23:11:13 2008 UTC revision 1827 by ksteube, Thu Oct 2 04:28:07 2008 UTC
# Line 12  Line 12 
12  *******************************************************/  *******************************************************/
13    
14    
15    #include "Data.h"
16  #include "DataConstant.h"  #include "DataConstant.h"
17  #include "DataException.h"  #include "DataException.h"
18  #include "esysUtils/EsysAssert.h"  #include "esysUtils/EsysAssert.h"
# Line 21  Line 22 
22  #ifdef USE_NETCDF  #ifdef USE_NETCDF
23  #include <netcdfcpp.h>  #include <netcdfcpp.h>
24  #endif  #endif
25    #ifdef PASO_MPI
26    #include <mpi.h>
27    #endif
28    
29  #include <boost/python/extract.hpp>  #include <boost/python/extract.hpp>
30  #include "DataMaths.h"  #include "DataMaths.h"
# Line 292  DataConstant::setToZero() Line 296  DataConstant::setToZero()
296  void  void
297  DataConstant::dump(const std::string fileName) const  DataConstant::dump(const std::string fileName) const
298  {  {
    #ifdef PASO_MPI  
    throw DataException("Error - DataConstant:: dump is not implemented for MPI yet.");  
    #endif  
299     #ifdef USE_NETCDF     #ifdef USE_NETCDF
300     const NcDim* ncdims[DataTypes::maxRank];     const NcDim* ncdims[DataTypes::maxRank];
301     NcVar* var;     NcVar* var;
# Line 304  DataConstant::dump(const std::string fil Line 305  DataConstant::dump(const std::string fil
305     long dims[DataTypes::maxRank];     long dims[DataTypes::maxRank];
306     const double* d_ptr=&(m_data[0]);     const double* d_ptr=&(m_data[0]);
307     DataTypes::ShapeType shape = getShape();     DataTypes::ShapeType shape = getShape();
308       int mpi_iam=getFunctionSpace().getDomain().getMPIRank();
309       int mpi_num=getFunctionSpace().getDomain().getMPISize();
310    #ifdef PASO_MPI
311       MPI_Status status;
312    #endif
313    
314    #ifdef PASO_MPI
315       /* Serialize NetCDF I/O */
316       if (mpi_iam>0) MPI_Recv(&ndims, 0, MPI_INT, mpi_iam-1, 81802, MPI_COMM_WORLD, &status);
317    #endif
318    
319     // netCDF error handler     // netCDF error handler
320     NcError err(NcError::verbose_nonfatal);     NcError err(NcError::verbose_nonfatal);
321     // Create the file.     // Create the file.
322     NcFile dataFile(fileName.c_str(), NcFile::Replace);     char *newFileName = Escript_MPI_appendRankToFileName(fileName.c_str(), mpi_num, mpi_iam);
323       NcFile dataFile(newFileName, NcFile::Replace);
324     // check if writing was successful     // check if writing was successful
325     if (!dataFile.is_valid())     if (!dataFile.is_valid())
326      throw DataException("Error - DataConstant:: opening of netCDF file for output failed.");      throw DataException("Error - DataConstant:: opening of netCDF file for output failed.");
# Line 350  DataConstant::dump(const std::string fil Line 362  DataConstant::dump(const std::string fil
362      throw DataException("Error - DataConstant:: appending variable to netCDF file failed.");      throw DataException("Error - DataConstant:: appending variable to netCDF file failed.");
363     if (! (var->put(d_ptr,dims)) )     if (! (var->put(d_ptr,dims)) )
364           throw DataException("Error - DataConstant:: copy data to netCDF buffer failed.");           throw DataException("Error - DataConstant:: copy data to netCDF buffer failed.");
365    #ifdef PASO_MPI
366       if (mpi_iam<mpi_num-1) MPI_Send(&ndims, 0, MPI_INT, mpi_iam+1, 81802, MPI_COMM_WORLD);
367    #endif
368     #else     #else
369     throw DataException("Error - DataConstant:: dump is not configured with netCDF. Please contact your installation manager.");     throw DataException("Error - DataConstant:: dump is not configured with netCDF. Please contact your installation manager.");
370     #endif     #endif

Legend:
Removed from v.1811  
changed lines
  Added in v.1827

  ViewVC Help
Powered by ViewVC 1.1.26