Changeset 605


Ignore:
Timestamp:
06/03/15 15:06:24 (9 years ago)
Author:
rlacroix
Message:

Don't enable NETCDF parallel mode when only one server is used.

Location:
XIOS
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/branchs/xios-1.0/src/output/onetcdf4.cpp

    r501 r605  
    1313         (const StdString & filename, bool exist, const MPI_Comm * comm, bool multifile) 
    1414            : path() 
    15       { 
    16          this->wmpi = (comm != NULL) && !multifile; 
     15            , wmpi(false) 
     16      { 
    1717         this->initialize(filename, exist, comm,multifile); 
    1818      } 
     
    3131         (const StdString & filename, bool exist, const MPI_Comm * comm, bool multifile) 
    3232      { 
     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 
    3343         if (!exist) 
    3444         { 
    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); 
    4149         } 
    4250         else 
    4351         { 
    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); 
    5056         } 
    5157      } 
  • XIOS/trunk/src/output/onetcdf4.cpp

    r528 r605  
    1313 
    1414      CONetCDF4::CONetCDF4 
    15          (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm * comm, bool multifile) 
     15         (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm* comm, bool multifile) 
    1616            : path() 
     17            , wmpi(false) 
    1718            , useClassicFormat(useClassicFormat) 
    1819            , recordOffset(0) 
    1920      { 
    20          this->wmpi = (comm != NULL) && !multifile; 
    2121         this->initialize(filename, append, useClassicFormat, comm,multifile); 
    2222      } 
     
    3333 
    3434      void CONetCDF4::initialize 
    35          (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm * comm, bool multifile) 
     35         (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm* comm, bool multifile) 
    3636      { 
    3737         this->useClassicFormat = useClassicFormat; 
    3838 
    3939         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) 
    4152            mode |= useClassicFormat ? NC_PNETCDF : NC_MPIIO; 
    4253 
     
    4455         if (!append || !std::ifstream(filename.c_str())) 
    4556         { 
    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); 
    5261 
    5362            this->appendMode = false; 
     
    5766         { 
    5867            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); 
    6572 
    6673            this->appendMode = true; 
Note: See TracChangeset for help on using the changeset viewer.