Changeset 605
- Timestamp:
- 06/03/15 15:06:24 (9 years ago)
- Location:
- XIOS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/branchs/xios-1.0/src/output/onetcdf4.cpp
r501 r605 13 13 (const StdString & filename, bool exist, const MPI_Comm * comm, bool multifile) 14 14 : path() 15 {16 this->wmpi = (comm != NULL) && !multifile;15 , wmpi(false) 16 { 17 17 this->initialize(filename, exist, comm,multifile); 18 18 } … … 31 31 (const StdString & filename, bool exist, const MPI_Comm * comm, bool multifile) 32 32 { 33 // Don't use parallel mode if there is only one process 34 if (comm) 35 { 36 int commSize = 0; 37 MPI_Comm_size(*comm, &commSize); 38 if (commSize <= 1) 39 comm = NULL; 40 } 41 wmpi = comm && !multifile; 42 33 43 if (!exist) 34 44 { 35 if (comm != NULL) 36 { 37 if (!multifile) (CNetCdfInterface::createPar(filename, NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, (this->ncidp))); 38 else (CNetCdfInterface::create(filename, NC_NETCDF4, this->ncidp)); 39 } 40 else (CNetCdfInterface::create(filename, NC_NETCDF4, this->ncidp)); 45 if (wmpi) 46 CNetCdfInterface::createPar(filename, NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, this->ncidp); 47 else 48 CNetCdfInterface::create(filename, NC_NETCDF4, this->ncidp); 41 49 } 42 50 else 43 51 { 44 if (comm != NULL) 45 { 46 if (!multifile) (CNetCdfInterface::openPar(filename, NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, this->ncidp)); 47 else (CNetCdfInterface::open(filename, NC_NETCDF4, this->ncidp)); 48 } 49 else (CNetCdfInterface::open(filename, NC_NETCDF4, this->ncidp)); 52 if (wmpi) 53 CNetCdfInterface::openPar(filename, NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, this->ncidp); 54 else 55 CNetCdfInterface::open(filename, NC_NETCDF4, this->ncidp); 50 56 } 51 57 } -
XIOS/trunk/src/output/onetcdf4.cpp
r528 r605 13 13 14 14 CONetCDF4::CONetCDF4 15 (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm 15 (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm* comm, bool multifile) 16 16 : path() 17 , wmpi(false) 17 18 , useClassicFormat(useClassicFormat) 18 19 , recordOffset(0) 19 20 { 20 this->wmpi = (comm != NULL) && !multifile;21 21 this->initialize(filename, append, useClassicFormat, comm,multifile); 22 22 } … … 33 33 34 34 void CONetCDF4::initialize 35 (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm 35 (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm* comm, bool multifile) 36 36 { 37 37 this->useClassicFormat = useClassicFormat; 38 38 39 39 int mode = useClassicFormat ? 0 : NC_NETCDF4; 40 if (!multifile) 40 41 // Don't use parallel mode if there is only one process 42 if (comm) 43 { 44 int commSize = 0; 45 MPI_Comm_size(*comm, &commSize); 46 if (commSize <= 1) 47 comm = NULL; 48 } 49 wmpi = comm && !multifile; 50 51 if (wmpi) 41 52 mode |= useClassicFormat ? NC_PNETCDF : NC_MPIIO; 42 53 … … 44 55 if (!append || !std::ifstream(filename.c_str())) 45 56 { 46 if (comm != NULL) 47 { 48 if (!multifile) CNetCdfInterface::createPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp); 49 else CNetCdfInterface::create(filename, mode, this->ncidp); 50 } 51 else CNetCdfInterface::create(filename, mode, this->ncidp); 57 if (wmpi) 58 CNetCdfInterface::createPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp); 59 else 60 CNetCdfInterface::create(filename, mode, this->ncidp); 52 61 53 62 this->appendMode = false; … … 57 66 { 58 67 mode |= NC_WRITE; 59 if (comm != NULL) 60 { 61 if (!multifile) CNetCdfInterface::openPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp); 62 else CNetCdfInterface::open(filename, mode, this->ncidp); 63 } 64 else CNetCdfInterface::open(filename, mode, this->ncidp); 68 if (wmpi) 69 CNetCdfInterface::openPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp); 70 else 71 CNetCdfInterface::open(filename, mode, this->ncidp); 65 72 66 73 this->appendMode = true;
Note: See TracChangeset
for help on using the changeset viewer.