/[escript]/trunk/escript/src/DataExpanded.cpp
ViewVC logotype

Diff of /trunk/escript/src/DataExpanded.cpp

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

revision 1799 by jfenwick, Wed Sep 17 06:33:18 2008 UTC revision 1800 by ksteube, Thu Sep 18 05:28:20 2008 UTC
# Line 13  Line 13 
13   *   *
14   *******************************************************/   *******************************************************/
15    
16    #include "Data.h"
17  #include "DataExpanded.h"  #include "DataExpanded.h"
18  #include "DataException.h"  #include "DataException.h"
19  #include "DataConstant.h"  #include "DataConstant.h"
# Line 770  DataExpanded::dump(const std::string fil Line 771  DataExpanded::dump(const std::string fil
771     long dims[ldims];     long dims[ldims];
772     const double* d_ptr=&(m_data[0]);     const double* d_ptr=&(m_data[0]);
773     const DataTypes::ShapeType& shape = getShape();     const DataTypes::ShapeType& shape = getShape();
774     int mpi_iam=0, mpi_num=1;     int mpi_iam=getFunctionSpace().getDomain().getMPIRank();
775       int mpi_num=getFunctionSpace().getDomain().getMPISize();
776    #ifdef PASO_MPI
777       MPI_Status status;
778    #endif
779    
780     // netCDF error handler     // netCDF error handler
781     NcError err(NcError::verbose_nonfatal);     NcError err(NcError::verbose_nonfatal);
782     // Create the file.     // Create the file.
783  #ifdef PASO_MPI  #ifdef PASO_MPI
784     MPI_Comm_rank(MPI_COMM_WORLD, &mpi_iam);     if (mpi_iam>0) MPI_Recv(&ndims, 0, MPI_INT, mpi_iam-1, 81801, getFunctionSpace().getDomain().getMPIComm(), &status);
    MPI_Comm_size(MPI_COMM_WORLD, &mpi_num);  
785  #endif  #endif
786     char *newFileName = Escript_MPI_appendRankToFileName(fileName.c_str(), mpi_num, mpi_iam);     char *newFileName = Escript_MPI_appendRankToFileName(fileName.c_str(), mpi_num, mpi_iam);
787     NcFile dataFile(newFileName, NcFile::Replace);     NcFile dataFile(newFileName, NcFile::Replace);
# Line 794  DataExpanded::dump(const std::string fil Line 798  DataExpanded::dump(const std::string fil
798     if ( rank >0 ) {     if ( rank >0 ) {
799         dims[0]=shape[0];         dims[0]=shape[0];
800         if (! (ncdims[0] = dataFile.add_dim("d0",shape[0])) )         if (! (ncdims[0] = dataFile.add_dim("d0",shape[0])) )
801              throw DataException("Error - DataExpanded:: appending ncdimsion 0 to netCDF file failed.");              throw DataException("Error - DataExpanded:: appending ncdimension 0 to netCDF file failed.");
802     }     }
803     if ( rank >1 ) {     if ( rank >1 ) {
804         dims[1]=shape[1];         dims[1]=shape[1];
805         if (! (ncdims[1] = dataFile.add_dim("d1",shape[1])) )         if (! (ncdims[1] = dataFile.add_dim("d1",shape[1])) )
806              throw DataException("Error - DataExpanded:: appending ncdimsion 1 to netCDF file failed.");              throw DataException("Error - DataExpanded:: appending ncdimension 1 to netCDF file failed.");
807     }     }
808     if ( rank >2 ) {     if ( rank >2 ) {
809         dims[2]=shape[2];         dims[2]=shape[2];
810         if (! (ncdims[2] = dataFile.add_dim("d2", shape[2])) )         if (! (ncdims[2] = dataFile.add_dim("d2", shape[2])) )
811              throw DataException("Error - DataExpanded:: appending ncdimsion 2 to netCDF file failed.");              throw DataException("Error - DataExpanded:: appending ncdimension 2 to netCDF file failed.");
812     }     }
813     if ( rank >3 ) {     if ( rank >3 ) {
814         dims[3]=shape[3];         dims[3]=shape[3];
815         if (! (ncdims[3] = dataFile.add_dim("d3", shape[3])) )         if (! (ncdims[3] = dataFile.add_dim("d3", shape[3])) )
816              throw DataException("Error - DataExpanded:: appending ncdimsion 3 to netCDF file failed.");              throw DataException("Error - DataExpanded:: appending ncdimension 3 to netCDF file failed.");
817     }     }
818     dims[rank]=getFunctionSpace().getNumDataPointsPerSample();     dims[rank]=getFunctionSpace().getNumDataPointsPerSample();
819     if (! (ncdims[rank] = dataFile.add_dim("num_data_points_per_sample", dims[rank])) )     if (! (ncdims[rank] = dataFile.add_dim("num_data_points_per_sample", dims[rank])) )
# Line 828  DataExpanded::dump(const std::string fil Line 832  DataExpanded::dump(const std::string fil
832          throw DataException("Error - DataExpanded:: appending variable to netCDF file failed.");          throw DataException("Error - DataExpanded:: appending variable to netCDF file failed.");
833     if (! (var->put(d_ptr,dims)) )     if (! (var->put(d_ptr,dims)) )
834          throw DataException("Error - DataExpanded:: copy data to netCDF buffer failed.");          throw DataException("Error - DataExpanded:: copy data to netCDF buffer failed.");
835    #ifdef PASO_MPI
836       if (mpi_iam<mpi_num-1) MPI_Send(&ndims, 0, MPI_INT, mpi_iam+1, 81801, getFunctionSpace().getDomain().getMPIComm());
837    #endif
838     #else     #else
839     throw DataException("Error - DataExpanded:: dump is not configured with netCDF. Please contact your installation manager.");     throw DataException("Error - DataExpanded:: dump is not configured with netCDF. Please contact your installation manager.");
840     #endif     #endif

Legend:
Removed from v.1799  
changed lines
  Added in v.1800

  ViewVC Help
Powered by ViewVC 1.1.26