Changeset 321 for XIOS/trunk
- Timestamp:
- 02/23/12 14:57:50 (12 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/data_output.cpp
r286 r321 42 42 { 43 43 this->writeFile_(file); 44 } 45 46 void CDataOutput::syncFile(void) 47 { 48 this->syncFile_(); 44 49 } 45 50 -
XIOS/trunk/src/data_output.hpp
r286 r321 25 25 /// Ecriture /// 26 26 void writeFile (const boost::shared_ptr<tree::CFile> file); 27 void syncFile (void); 27 28 void closeFile (void); 28 29 void writeField (const boost::shared_ptr<tree::CField> field); … … 45 46 virtual void writeFile_ (const boost::shared_ptr<tree::CFile> file) = 0; 46 47 virtual void closeFile_ (void) = 0; 48 virtual void syncFile_ (void) = 0; 47 49 virtual void writeField_ (const boost::shared_ptr<tree::CField> field) = 0; 48 50 virtual void writeFieldData_ (const boost::shared_ptr<tree::CField> field) = 0; -
XIOS/trunk/src/date.cpp
r316 r321 194 194 //---------------------------------------------------------------- 195 195 196 StdString CDate::getStryyyymmdd(void) const 197 { 198 std::streamsize s ; 199 char c ; 200 201 ostringstream oss ; 202 203 s = oss.width (4); c = oss.fill ('0') ; oss << year ; 204 s = oss.width (2); c = oss.fill ('0') ; oss << month; 205 s = oss.width (2); c = oss.fill ('0') ; oss << day ; 206 207 return oss.str(); 208 } 209 196 210 StdString CDate::toString(void) const 197 211 { -
XIOS/trunk/src/date.hpp
r219 r321 57 57 /// Autres /// 58 58 StdString toString(void) const; 59 StdString getStryyyymmdd(void) const; 59 60 60 61 public : /* static */ -
XIOS/trunk/src/node/context.cpp
r314 r321 544 544 for (it=enabledFiles.begin(); it != enabledFiles.end(); it++) 545 545 { 546 /* shared_ptr<CFile> file = *it; 547 StdString filename = (!file->name.isEmpty()) ? file->name.getValue() : file->getId(); 548 StdOStringStream oss; 549 if (! output_dir.isEmpty()) oss << output_dir.getValue(); 550 oss << filename; 551 if (!file->name_suffix.isEmpty()) oss << file->name_suffix.getValue(); 552 553 bool multifile=true ; 554 if (!file->type.isEmpty()) 555 { 556 StdString str=file->type.getValue() ; 557 if (str.compare("one_file")==0) multifile=false ; 558 else if (str.compare("multi_file")==0) multifile=true ; 559 else ERROR("void Context::createDataOutput(void)", 560 "incorrect file <type> attribut : must be <multi_file> or <one_file>, " 561 <<"having : <"<<str<<">") ; 562 } 563 if (multifile) 564 { 565 if (server->intraCommSize > 1) oss << "_" << server->intraCommRank; 566 } 567 oss << ".nc"; 568 569 shared_ptr<io::CDataOutput> dout(new T(oss.str(), false,server->intraComm,multifile)); 570 */ 571 (*it)->createHeader(); 546 (*it)->initFile(); 572 547 } 573 548 } -
XIOS/trunk/src/node/field.cpp
r314 r321 176 176 } 177 177 178 this->incrementNStep();179 178 *last_Write_srv = writeDate; 180 179 writeField() ; … … 184 183 void CField::writeField(void) 185 184 { 186 if (! grid->domain->isEmpty() || getRelFile()->type.getValue()=="one_file") 185 if (! grid->domain->isEmpty() || getRelFile()->type.getValue()=="one_file") 186 { 187 getRelFile()->checkFile(); 188 this->incrementNStep(); 187 189 getRelFile()->getDataOutput()->writeFieldData(CObjectFactory::GetObject<CField>(this)); 190 } 188 191 } 189 192 //---------------------------------------------------------------- … … 222 225 { 223 226 this->nstep++; 227 } 228 229 void CField::resetNStep(void) 230 { 231 this->nstep=0; 224 232 } 225 233 -
XIOS/trunk/src/node/field.hpp
r310 r321 88 88 void setRelFile(const boost::shared_ptr<CFile> _file); 89 89 void incrementNStep(void); 90 void resetNStep() ; 90 91 91 92 template <StdSize N> bool updateData(const ARRAY(double, N) data); -
XIOS/trunk/src/node/file.cpp
r318 r321 141 141 return false ; 142 142 } 143 143 144 void CFile::initFile(void) 145 { 146 shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 147 date::CDate& currentDate=context->calendar->getCurrentDate() ; 148 149 if (! sync_freq.isEmpty()) syncFreq = date::CDuration::FromString(sync_freq.getValue()); 150 if (! split_freq.isEmpty()) splitFreq = date::CDuration::FromString(split_freq.getValue()); 151 if (! output_freq.isEmpty()) outputFreq = date::CDuration::FromString(output_freq.getValue()); 152 lastSync=new date::CDate(currentDate) ; 153 lastSplit=new date::CDate(currentDate) ; 154 isOpen=false ; 155 } 156 157 void CFile::checkFile(void) 158 { 159 if (!isOpen) createHeader() ; 160 checkSync() ; 161 checkSplit() ; 162 } 163 164 165 bool CFile::checkSync(void) 166 { 167 shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 168 date::CDate& currentDate=context->calendar->getCurrentDate() ; 169 if (! sync_freq.isEmpty()) 170 { 171 if (*lastSync+syncFreq < currentDate) 172 { 173 *lastSync=currentDate ; 174 data_out->syncFile() ; 175 return true ; 176 } 177 } 178 return false ; 179 } 180 181 182 bool CFile::checkSplit(void) 183 { 184 shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 185 date::CDate& currentDate=context->calendar->getCurrentDate() ; 186 if (! split_freq.isEmpty()) 187 { 188 if (*lastSplit+splitFreq < currentDate) 189 { 190 *lastSplit=currentDate-outputFreq ; 191 192 std::vector<boost::shared_ptr<CField> >::iterator it, end = this->enabledFields.end(); 193 for (it = this->enabledFields.begin() ;it != end; it++) (*it)->resetNStep() ; 194 createHeader() ; 195 return true ; 196 } 197 } 198 return false ; 199 } 200 144 201 void CFile::createHeader(void) 145 202 { 146 203 shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 147 148 if (! sync_freq.isEmpty()) syncFreq = date::CDuration::FromString(sync_freq.getValue()); 149 lastSync=new date::CDate(context->calendar->getCurrentDate()) ; 204 date::CDate& currentDate=context->calendar->getCurrentDate() ; 150 205 151 206 std::vector<boost::shared_ptr<CField> >::iterator it, end = this->enabledFields.end(); … … 168 223 oss << filename; 169 224 if (!name_suffix.isEmpty()) oss << name_suffix.getValue(); 170 225 // if (!split_freq.isEmpty()) oss<<"-["<<currentDate.toString()<<"]" ; 226 if (!split_freq.isEmpty()) oss<<"_"<<lastSplit->getStryyyymmdd()<<"-"<< (*lastSplit+(splitFreq-1*date::Second)).getStryyyymmdd(); 171 227 bool multifile=true ; 172 228 if (!type.isEmpty()) … … 187 243 oss << ".nc"; 188 244 245 if (isOpen) data_out->closeFile() ; 246 189 247 data_out=shared_ptr<io::CDataOutput>(new io::CNc4DataOutput(oss.str(), false,server->intraComm,multifile)); 248 isOpen=true ; 190 249 191 250 data_out->writeFile(CObjectFactory::GetObject<CFile>(this)); … … 208 267 void CFile::close(void) 209 268 { 269 delete lastSync ; 270 delete lastSplit ; 210 271 if (!AllDomainEmpty || type.getValue()=="one_file") 211 this->data_out->closeFile(); 212 delete lastSync ; 272 if (isOpen) 273 { 274 this->data_out->closeFile(); 275 } 213 276 } 214 277 //---------------------------------------------------------------- -
XIOS/trunk/src/node/file.hpp
r318 r321 104 104 static bool dispatchEvent(CEventServer& event) ; 105 105 bool isSyncTime(void) ; 106 bool checkSplit(void) ; 107 bool checkSync(void) ; 108 void checkFile(void) ; 109 void initFile(void) ; 106 110 date::CDate* lastSync ; 111 date::CDate* lastSplit ; 107 112 date::CDuration syncFreq ; 113 date::CDuration splitFreq ; 114 date::CDuration outputFreq ; 108 115 int nbDomain ; 116 bool isOpen ; 109 117 private : 110 118 -
XIOS/trunk/src/output/nc4_data_output.cpp
r318 r321 433 433 else singleDomain=false ; 434 434 } 435 436 void CNc4DataOutput::syncFile_ (void) 437 { 438 SuperClassWriter::sync() ; 439 } 435 440 436 441 void CNc4DataOutput::closeFile_ (void) … … 460 465 { 461 466 shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 462 if (field->getRelFile()->isSyncTime()) SuperClassWriter::sync() ;467 // if (field->getRelFile()->isSyncTime()) SuperClassWriter::sync() ; 463 468 464 469 boost::shared_ptr<CGrid> grid = field->grid ; -
XIOS/trunk/src/output/nc4_data_output.hpp
r318 r321 47 47 virtual void writeFile_ (const boost::shared_ptr<tree::CFile> file); 48 48 virtual void closeFile_ (void); 49 virtual void syncFile_ (void); 49 50 virtual void writeTimeAxis_ (const boost::shared_ptr<tree::CField> field, 50 51 const boost::shared_ptr<date::CCalendar> cal);
Note: See TracChangeset
for help on using the changeset viewer.