Changeset 528 for XIOS/trunk/src/output
- Timestamp:
- 12/03/14 17:54:33 (10 years ago)
- Location:
- XIOS/trunk/src/output
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/output/onetcdf4.cpp
r517 r528 1 #include <fstream> 2 1 3 #include "onetcdf4.hpp" 2 4 #include "group_template.hpp" … … 11 13 12 14 CONetCDF4::CONetCDF4 13 (const StdString & filename, bool exist, bool useClassicFormat, const MPI_Comm * comm, bool multifile)15 (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm * comm, bool multifile) 14 16 : path() 15 17 , useClassicFormat(useClassicFormat) 18 , recordOffset(0) 16 19 { 17 20 this->wmpi = (comm != NULL) && !multifile; 18 this->initialize(filename, exist, useClassicFormat, comm,multifile);21 this->initialize(filename, append, useClassicFormat, comm,multifile); 19 22 } 20 23 … … 30 33 31 34 void CONetCDF4::initialize 32 (const StdString & filename, bool exist, bool useClassicFormat, const MPI_Comm * comm, bool multifile)35 (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm * comm, bool multifile) 33 36 { 34 37 this->useClassicFormat = useClassicFormat; … … 38 41 mode |= useClassicFormat ? NC_PNETCDF : NC_MPIIO; 39 42 40 if (!exist) 43 // If the file does not exist, we always create it 44 if (!append || !std::ifstream(filename.c_str())) 41 45 { 42 46 if (comm != NULL) … … 46 50 } 47 51 else CNetCdfInterface::create(filename, mode, this->ncidp); 52 53 this->appendMode = false; 54 this->recordOffset = 0; 48 55 } 49 56 else 50 57 { 58 mode |= NC_WRITE; 51 59 if (comm != NULL) 52 60 { … … 55 63 } 56 64 else CNetCdfInterface::open(filename, mode, this->ncidp); 65 66 this->appendMode = true; 67 // Find out how many temporal records have been written already to the file we are opening 68 int ncUnlimitedDimId; 69 CNetCdfInterface::inqUnLimDim(this->ncidp, ncUnlimitedDimId); 70 if (ncUnlimitedDimId != -1) 71 CNetCdfInterface::inqDimLen(this->ncidp, ncUnlimitedDimId, this->recordOffset); 72 else 73 this->recordOffset = 0; 57 74 } 58 75 … … 424 441 if (iddims.begin()->compare(this->getUnlimitedDimensionName()) == 0) 425 442 { 426 sstart.push_back(record );443 sstart.push_back(record + recordOffset); 427 444 scount.push_back(1); 428 445 if ((start == NULL) && -
XIOS/trunk/src/output/onetcdf4.hpp
r517 r528 26 26 27 27 /// Constructeurs /// 28 CONetCDF4(const StdString & filename, bool exist, bool useClassicFormat = false,28 CONetCDF4(const StdString & filename, bool append, bool useClassicFormat = false, 29 29 const MPI_Comm * comm = NULL, bool multifile = true); 30 30 … … 34 34 35 35 /// Initialisation /// 36 void initialize(const StdString & filename, bool exist, bool useClassicFormat,36 void initialize(const StdString & filename, bool append, bool useClassicFormat, 37 37 const MPI_Comm * comm, bool multifile); 38 38 void close(void) ; … … 118 118 int ncidp; 119 119 bool wmpi; 120 /*! Number of records already written when opening an existing file. 121 * always 0 when creating a new file */ 122 size_t recordOffset; 120 123 map<int,size_t> timeAxis ; 121 124 }; // class CONetCDF4
Note: See TracChangeset
for help on using the changeset viewer.