12 |
*******************************************************/ |
*******************************************************/ |
13 |
|
|
14 |
|
|
15 |
|
#include "Data.h" |
16 |
#include "DataTagged.h" |
#include "DataTagged.h" |
17 |
#include "esysUtils/esys_malloc.h" |
#include "esysUtils/esys_malloc.h" |
18 |
|
|
21 |
#ifdef USE_NETCDF |
#ifdef USE_NETCDF |
22 |
#include <netcdfcpp.h> |
#include <netcdfcpp.h> |
23 |
#endif |
#endif |
24 |
|
#ifdef PASO_MPI |
25 |
|
#include <mpi.h> |
26 |
|
#endif |
27 |
#include "DataMaths.h" |
#include "DataMaths.h" |
28 |
|
|
29 |
using namespace std; |
using namespace std; |
891 |
void |
void |
892 |
DataTagged::dump(const std::string fileName) const |
DataTagged::dump(const std::string fileName) const |
893 |
{ |
{ |
|
#ifdef PASO_MPI |
|
|
throw DataException("Error - DataTagged:: dump is not implemented for MPI yet."); |
|
|
#endif |
|
894 |
#ifdef USE_NETCDF |
#ifdef USE_NETCDF |
895 |
const int ldims=DataTypes::maxRank+1; |
const int ldims=DataTypes::maxRank+1; |
896 |
const NcDim* ncdims[ldims]; |
const NcDim* ncdims[ldims]; |
901 |
long dims[ldims]; |
long dims[ldims]; |
902 |
const double* d_ptr=&(m_data[0]); |
const double* d_ptr=&(m_data[0]); |
903 |
DataTypes::ShapeType shape = getShape(); |
DataTypes::ShapeType shape = getShape(); |
904 |
|
int mpi_iam=getFunctionSpace().getDomain().getMPIRank(); |
905 |
|
int mpi_num=getFunctionSpace().getDomain().getMPISize(); |
906 |
|
#ifdef PASO_MPI |
907 |
|
MPI_Status status; |
908 |
|
#endif |
909 |
|
|
910 |
|
#ifdef PASO_MPI |
911 |
|
/* Serialize NetCDF I/O */ |
912 |
|
if (mpi_iam>0) MPI_Recv(&ndims, 0, MPI_INT, mpi_iam-1, 81803, MPI_COMM_WORLD, &status); |
913 |
|
#endif |
914 |
|
|
915 |
// netCDF error handler |
// netCDF error handler |
916 |
NcError err(NcError::verbose_nonfatal); |
NcError err(NcError::verbose_nonfatal); |
917 |
// Create the file. |
// Create the file. |
918 |
NcFile dataFile(fileName.c_str(), NcFile::Replace); |
char *newFileName = Escript_MPI_appendRankToFileName(fileName.c_str(), mpi_num, mpi_iam); |
919 |
|
NcFile dataFile(newFileName, NcFile::Replace); |
920 |
// check if writing was successful |
// check if writing was successful |
921 |
if (!dataFile.is_valid()) |
if (!dataFile.is_valid()) |
922 |
throw DataException("Error - DataTagged:: opening of netCDF file for output failed."); |
throw DataException("Error - DataTagged:: opening of netCDF file for output failed."); |
982 |
esysUtils::free(tags); |
esysUtils::free(tags); |
983 |
throw DataException("Error - DataTagged:: copy data to netCDF buffer failed."); |
throw DataException("Error - DataTagged:: copy data to netCDF buffer failed."); |
984 |
} |
} |
985 |
|
#ifdef PASO_MPI |
986 |
|
if (mpi_iam<mpi_num-1) MPI_Send(&ndims, 0, MPI_INT, mpi_iam+1, 81803, MPI_COMM_WORLD); |
987 |
|
#endif |
988 |
#else |
#else |
989 |
throw DataException("Error - DataTagged:: dump is not configured with netCDF. Please contact your installation manager."); |
throw DataException("Error - DataTagged:: dump is not configured with netCDF. Please contact your installation manager."); |
990 |
#endif |
#endif |