Changeset 736


Ignore:
Timestamp:
10/14/15 13:58:26 (6 years ago)
Author:
rlacroix
Message:

Fix the opening of NetCDF-4 input files in parallel.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/io/inetcdf4.cpp

    r686 r736  
    77{ 
    88  CINetCDF4::CINetCDF4(const StdString& filename, const MPI_Comm* comm /*= NULL*/, bool multifile /*= true*/) 
    9     : mpi(comm != NULL && !multifile) 
    10   { 
    11     if (comm != NULL) 
    12     { 
    13       if (!multifile) CNetCdfInterface::openPar(filename, NC_NOWRITE, *comm, MPI_INFO_NULL, this->ncidp); 
    14       else CNetCdfInterface::open(filename, NC_NOWRITE, this->ncidp); 
    15     } 
    16       else CNetCdfInterface::open(filename, NC_NOWRITE, this->ncidp); 
     9  { 
     10    // Don't use parallel mode if there is only one process 
     11    if (comm) 
     12    { 
     13      int commSize = 0; 
     14      MPI_Comm_size(*comm, &commSize); 
     15      if (commSize <= 1) 
     16        comm = NULL; 
     17    } 
     18    mpi = comm && !multifile; 
     19 
     20    // The file format will be detected automatically by NetCDF, it is safe to always set NC_MPIIO 
     21    // even if Parallel NetCDF ends up being used. 
     22    if (mpi) 
     23      CNetCdfInterface::openPar(filename, NC_NOWRITE | NC_MPIIO, *comm, MPI_INFO_NULL, this->ncidp); 
     24    else 
     25      CNetCdfInterface::open(filename, NC_NOWRITE, this->ncidp); 
    1726  } 
    1827 
Note: See TracChangeset for help on using the changeset viewer.