Ignore:
Timestamp:
11/27/15 09:55:05 (9 years ago)
Author:
rlacroix
Message:

Append mode

Location:
XIOS/branchs/xios-1.0/src/output
Files:
3 edited

Legend:

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

    r713 r798  
    937937                                     this->getTimeStamp()); 
    938938 
    939            SuperClassWriter::addDimension("axis_nbounds", 2); 
     939           if (!appendMode) 
     940             SuperClassWriter::addDimension("axis_nbounds", 2); 
    940941         } 
    941942         catch (CNetCdfException& e) 
  • XIOS/branchs/xios-1.0/src/output/onetcdf4.cpp

    r607 r798  
    1111 
    1212      CONetCDF4::CONetCDF4 
    13          (const StdString & filename, bool exist, const MPI_Comm * comm, bool multifile) 
     13         (const StdString & filename, bool append, const MPI_Comm * comm, bool multifile) 
    1414            : path() 
    1515            , wmpi(false) 
    1616      { 
    17          this->initialize(filename, exist, comm,multifile); 
     17         this->initialize(filename, append, comm,multifile); 
    1818      } 
    1919 
     
    2929 
    3030      void CONetCDF4::initialize 
    31          (const StdString & filename, bool exist, const MPI_Comm * comm, bool multifile) 
     31         (const StdString & filename, bool append, const MPI_Comm * comm, bool multifile) 
    3232      { 
    3333         // Don't use parallel mode if there is only one process 
     
    4141         wmpi = comm && !multifile; 
    4242 
    43          if (!exist) 
     43         // If the file does not exist, we always create it 
     44         if (!append || !std::ifstream(filename.c_str())) 
    4445         { 
    4546            if (wmpi) 
     
    4748            else 
    4849               CNetCdfInterface::create(filename, NC_NETCDF4, this->ncidp); 
     50 
     51            this->appendMode = false; 
     52            this->recordOffset = 0; 
    4953         } 
    5054         else 
    5155         { 
    5256            if (wmpi) 
    53                CNetCdfInterface::openPar(filename, NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, this->ncidp); 
     57               CNetCdfInterface::openPar(filename, NC_NETCDF4|NC_MPIIO|NC_WRITE, *comm, MPI_INFO_NULL, this->ncidp); 
    5458            else 
    55                CNetCdfInterface::open(filename, NC_NETCDF4, this->ncidp); 
     59               CNetCdfInterface::open(filename, NC_NETCDF4|NC_WRITE, this->ncidp); 
     60 
     61            this->appendMode = true; 
     62            // Find out how many temporal records have been written already to the file we are opening 
     63            int ncUnlimitedDimId; 
     64            CNetCdfInterface::inqUnLimDim(this->ncidp, ncUnlimitedDimId); 
     65            if (ncUnlimitedDimId != -1) 
     66               CNetCdfInterface::inqDimLen(this->ncidp, ncUnlimitedDimId, this->recordOffset); 
     67            else 
     68               this->recordOffset = 0; 
    5669         } 
    5770      } 
     
    429442         if (iddims.begin()->compare(this->getUnlimitedDimensionName()) == 0) 
    430443         { 
    431             sstart.push_back(record); 
     444            sstart.push_back(record + recordOffset); 
    432445            scount.push_back(1); 
    433446            if ((start == NULL) && 
  • XIOS/branchs/xios-1.0/src/output/onetcdf4.hpp

    r606 r798  
    2626 
    2727            /// Constructeurs /// 
    28             CONetCDF4(const StdString & filename, bool exist, const MPI_Comm * comm = NULL, bool multifile=true); 
     28            CONetCDF4(const StdString & filename, bool append, const MPI_Comm * comm = NULL, bool multifile=true); 
    2929 
    3030            CONetCDF4(const CONetCDF4 & onetcdf4);       // Not implemented. 
     
    3333 
    3434            /// Initialisation /// 
    35             void initialize(const StdString & filename, bool exist, const MPI_Comm * comm, bool multifile); 
     35            void initialize(const StdString & filename, bool append, const MPI_Comm * comm, bool multifile); 
    3636            void close(void) ; 
    3737            void sync(void) ; 
     
    116116            int ncidp; 
    117117            bool wmpi; 
     118            /*! Number of records already written when opening an existing file. 
     119             *  always 0 when creating a new file */ 
     120            size_t recordOffset; 
    118121            map<int,size_t> timeAxis ; 
    119122      }; // class CONetCDF4 
Note: See TracChangeset for help on using the changeset viewer.