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

Append mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/branchs/xios-1.0/src/node/file.cpp

    r692 r798  
    311311         oss << ".nc"; 
    312312 
     313        bool append = !this->append.isEmpty() && this->append.getValue(); 
     314 
    313315         if (isOpen) data_out->closeFile() ; 
    314316         bool isCollective=true ; 
     
    324326           } 
    325327         } 
    326          data_out=shared_ptr<CDataOutput>(new CNc4DataOutput(oss.str(), false, fileComm, multifile, isCollective)); 
    327          isOpen=true ; 
    328  
    329          data_out->writeFile(CFile::get(this)); 
    330          std::vector<CField*>::iterator it, end = this->enabledFields.end(); 
    331          for (it = this->enabledFields.begin() ;it != end; it++) 
    332          { 
     328        data_out = shared_ptr<CDataOutput>(new CNc4DataOutput(oss.str(), append, fileComm, multifile, isCollective)); 
     329        isOpen = true; 
     330 
     331        data_out->writeFile(CFile::get(this)); 
     332 
     333        // Do not recreate the file structure if opening an existing file 
     334        if (!data_out->IsInAppendMode()) 
     335        { 
     336          std::vector<CField*>::iterator it, end = this->enabledFields.end(); 
     337          for (it = this->enabledFields.begin(); it != end; it++) 
     338          { 
    333339            CField* field = *it; 
    334340            this->data_out->writeFieldGrid(field); 
    335          } 
    336          this->data_out->writeTimeDimension(); 
    337           
    338          for (it = this->enabledFields.begin() ;it != end; it++) 
    339          { 
     341          } 
     342          this->data_out->writeTimeDimension(); 
     343 
     344          for (it = this->enabledFields.begin(); it != end; it++) 
     345          { 
    340346            CField* field = *it; 
    341347            this->data_out->writeField(field); 
    342          } 
    343           
    344          vector<CVariable*> listVars = getAllVariables() ; 
    345          for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) this-> data_out-> writeAttribute(*it) ; 
    346           
    347          this->data_out->definition_end(); 
     348          } 
     349 
     350          vector<CVariable*> listVars = getAllVariables() ; 
     351          for (vector<CVariable*>::iterator it = listVars.begin(); it != listVars.end(); it++) 
     352            this->data_out->writeAttribute(*it); 
     353 
     354          this->data_out->definition_end(); 
     355        } 
    348356      } 
    349357   } 
Note: See TracChangeset for help on using the changeset viewer.