Changeset 1136 for XIOS/dev/dev_olga/src/node/file.cpp
- Timestamp:
- 05/17/17 18:30:38 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/node/file.cpp
r1132 r1136 267 267 } 268 268 269 //! Verify state of a file 270 void CFile::checkFile(void) 269 /* 270 Check condition to write into a file 271 For now, we only use the level-2 server to write files (if this mode is activated) 272 or classical server to do this job. 273 */ 274 void CFile::checkWriteFile(void) 271 275 { 272 276 CContext* context = CContext::getCurrent(); 273 277 // Done by classical server or secondary server 274 if (!CXios::usingServer2 || (CXios::usingServer2 && !context->hasClient)) 278 // This condition should be changed soon 279 if (!CXios::usingServer2 || (CXios::usingServer2 && !context->hasClient)) 275 280 { 276 281 if (mode.isEmpty() || mode.getValue() == mode_attr::write) … … 278 283 if (!isOpen) createHeader(); 279 284 checkSync(); 285 } 286 checkSplit(); // REally need this? 287 } 288 } 289 290 /* 291 Check condition to read from a file 292 For now, we only use the level-1 server to write files (if this mode is activated) 293 or classical server to do this job. 294 This function can be used by client for reading metadata 295 */ 296 void CFile::checkReadFile(void) 297 { 298 CContext* context = CContext::getCurrent(); 299 // Done by classical server or secondary server 300 // TODO: This condition should be changed soon. It only works with maximum number of level as 2 301 if (!CXios::usingServer2 || (CXios::usingServer2 && context->hasClient)) 302 { 303 if (!mode.isEmpty() && mode.getValue() == mode_attr::read) 304 { 305 if (!isOpen) openInReadMode(&(context->server->intraComm)); 280 306 } 281 else 282 { 283 if (!isOpen) openInReadMode(); 284 } 285 checkSplit(); 307 //checkSplit(); // Really need for reading? 286 308 } 287 309 } … … 502 524 \brief Open an existing NetCDF file in read-only mode 503 525 */ 504 void CFile::openInReadMode( void)526 void CFile::openInReadMode(MPI_Comm* comm) 505 527 { 506 528 CContext* context = CContext::getCurrent(); 507 529 CContextServer* server = context->server; 530 MPI_Comm readComm = *comm; 508 531 509 532 if (!allDomainEmpty) … … 547 570 { 548 571 int commSize, commRank; 549 MPI_Comm_size( fileComm, &commSize);550 MPI_Comm_rank( fileComm, &commRank);572 MPI_Comm_size(readComm, &commSize); 573 MPI_Comm_rank(readComm, &commRank); 551 574 552 575 if (server->intraCommSize > 1) … … 567 590 568 591 if (isOpen) data_out->closeFile(); 569 if (time_counter_name.isEmpty()) data_in = shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), fileComm, multifile, isCollective));570 else data_in = shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), fileComm, multifile, isCollective, time_counter_name));592 if (time_counter_name.isEmpty()) data_in = shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), readComm, multifile, isCollective)); 593 else data_in = shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), readComm, multifile, isCollective, time_counter_name)); 571 594 isOpen = true; 572 595 } … … 594 617 // Just check file and try to open it 595 618 CContext* context = CContext::getCurrent(); 596 CContextClient* client=context->client;597 //CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client;619 // CContextClient* client=context->client; 620 CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; 598 621 599 622 // It would probably be better to call initFile() somehow 600 MPI_Comm_dup(client->intraComm, &fileComm);623 // MPI_Comm_dup(client->intraComm, &fileComm); 601 624 if (time_counter_name.isEmpty()) time_counter_name = "time_counter"; 602 625 603 check File();626 checkReadFile(); 604 627 605 628 for (int idx = 0; idx < enabledFields.size(); ++idx) … … 883 906 884 907 /*! 908 \brief Send a message to create a field group on server side 909 \param[in] id String identity of field group that will be created on server 910 */ 911 void CFile::sendAddFieldGroup(const string& id, CContextClient* client) 912 { 913 sendAddItem(id, (int)EVENT_ID_ADD_FIELD_GROUP, client); 914 } 915 916 /*! 885 917 \brief Receive a message annoucing the creation of a field on server side 886 918 \param[in] event Received event … … 1057 1089 With these two id, it's easier to make reference to grid where all data should be written. 1058 1090 Remark: This function must be called AFTER all active (enabled) files have been created on the server side 1059 */ void CFile::sendEnabledFields(CContextClient* client) 1091 */ 1092 void CFile::sendEnabledFields(CContextClient* client) 1060 1093 { 1061 1094 size_t size = this->enabledFields.size();
Note: See TracChangeset
for help on using the changeset viewer.