Changeset 1232 for XIOS/dev/XIOS_DEV_CMIP6/src/node/file.cpp
- Timestamp:
- 07/31/17 17:59:25 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/XIOS_DEV_CMIP6/src/node/file.cpp
r1201 r1232 25 25 : CObjectTemplate<CFile>(), CFileAttributes() 26 26 , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 27 , allDomainEmpty(false), isOpen(false)27 , isOpen(false), read_client(0), checkRead(false), allZoneEmpty(false) 28 28 { 29 29 setVirtualFieldGroup(CFieldGroup::create(getId() + "_virtual_field_group")); … … 34 34 : CObjectTemplate<CFile>(id), CFileAttributes() 35 35 , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 36 , allDomainEmpty(false), isOpen(false)36 , isOpen(false), read_client(0), checkRead(false), allZoneEmpty(false) 37 37 { 38 38 setVirtualFieldGroup(CFieldGroup::create(getId() + "_virtual_field_group")); … … 207 207 208 208 //! Initialize a file in order to write into it 209 void CFile::init File(void)209 void CFile::initWrite(void) 210 210 { 211 211 CContext* context = CContext::getCurrent(); … … 228 228 } 229 229 } 230 isOpen = false; 231 232 allDomainEmpty = true; 230 isOpen = false; 233 231 234 232 // if (!record_offset.isEmpty() && record_offset < 0) … … 243 241 for (it = this->enabledFields.begin(); it != end; it++) 244 242 { 245 CField* field = *it; 246 allDomainEmpty &= !field->grid->doGridHaveDataToWrite(); 243 CField* field = *it; 247 244 std::vector<CAxis*> vecAxis = field->grid->getAxis(); 248 245 for (size_t i = 0; i < vecAxis.size(); ++i) 249 246 setAxis.insert(vecAxis[i]->getAxisOutputName()); 250 // setAxis.insert(vecAxis[i]);251 247 std::vector<CDomain*> vecDomains = field->grid->getDomains(); 252 248 for (size_t i = 0; i < vecDomains.size(); ++i) 253 249 setDomains.insert(vecDomains[i]->getDomainOutputName()); 254 // setDomains.insert(vecDomains[i]);255 250 256 251 field->resetNStep(recordOffset); … … 260 255 261 256 // create sub communicator for file 262 int color = allDomainEmpty ? 0 : 1; 263 MPI_Comm_split(server->intraComm, color, server->intraCommRank, &fileComm); 264 if (allDomainEmpty) MPI_Comm_free(&fileComm); 257 createSubComFile(); 265 258 266 259 // if (time_counter.isEmpty()) time_counter.setValue(time_counter_attr::centered); 267 260 if (time_counter_name.isEmpty()) time_counter_name = "time_counter"; 261 } 262 263 //! Initialize a file in order to write into it 264 void CFile::initRead(void) 265 { 266 if (checkRead) return; 267 createSubComFile(); 268 checkRead = true; 269 } 270 271 /*! 272 Create a sub communicator in which processes participate in reading/opening file 273 */ 274 void CFile::createSubComFile() 275 { 276 CContext* context = CContext::getCurrent(); 277 CContextServer* server = context->server; 278 279 // create sub communicator for file 280 allZoneEmpty = true; 281 std::vector<CField*>::iterator it, end = this->enabledFields.end(); 282 for (it = this->enabledFields.begin(); it != end; it++) 283 { 284 CField* field = *it; 285 bool nullGrid = (0 == field->grid); 286 allZoneEmpty &= nullGrid ? false : !field->grid->doGridHaveDataToWrite(); 287 } 288 289 int color = allZoneEmpty ? 0 : 1; 290 MPI_Comm_split(server->intraComm, color, server->intraCommRank, &fileComm); 291 if (allZoneEmpty) MPI_Comm_free(&fileComm); 268 292 } 269 293 … … 307 331 { 308 332 CTimer::get("Files : open headers").resume(); 309 if (!isOpen) openInReadMode(&(context->server->intraComm)); 333 334 if (!isOpen) openInReadMode(); 335 310 336 CTimer::get("Files : open headers").suspend(); 311 337 } 312 338 //checkSplit(); // Really need for reading? 313 339 } 340 } 341 342 /*! 343 Verify if a process participates in an opening-file communicator 344 \return true if the process doesn't participate in opening file 345 */ 346 bool CFile::isEmptyZone() 347 { 348 return allZoneEmpty; 314 349 } 315 350 … … 376 411 CContextServer* server = context->server; 377 412 378 if (!all DomainEmpty)413 if (!allZoneEmpty) 379 414 { 380 415 StdString filename = getFileOutputName(); … … 558 593 \brief Open an existing NetCDF file in read-only mode 559 594 */ 560 void CFile::openInReadMode( MPI_Comm* comm)595 void CFile::openInReadMode() 561 596 { 562 597 CContext* context = CContext::getCurrent(); 563 598 CContextServer* server = context->server; 564 MPI_Comm readComm = *comm;565 566 if (!all DomainEmpty)599 MPI_Comm readComm = this->fileComm; 600 601 if (!allZoneEmpty) 567 602 { 568 603 StdString filename = getFileOutputName(); … … 632 667 void CFile::close(void) 633 668 { 634 if (!all DomainEmpty)669 if (!allZoneEmpty) 635 670 if (isOpen) 636 671 { … … 639 674 else 640 675 this->data_in->closeFile(); 676 isOpen = false; 641 677 } 642 678 if (fileComm != MPI_COMM_NULL) MPI_Comm_free(&fileComm); … … 905 941 } 906 942 943 void CFile::setReadContextClient(CContextClient* readContextclient) 944 { 945 read_client = readContextclient; 946 } 947 948 CContextClient* CFile::getReadContextClient() 949 { 950 return read_client; 951 } 952 907 953 /*! 908 954 \brief Send a message to create a field on server side
Note: See TracChangeset
for help on using the changeset viewer.