Ignore:
Timestamp:
05/17/17 18:30:38 (7 years ago)
Author:
mhnguyen
Message:

Reading for two-level server

+) Update reading with the changes of grid distribution
+) Correct a minor bug on modification grid mask
+) Do some code cleaning

Test
+) On Curie
+) Work in both mode: classical and two-level
+) Push some *.nc for test_remap

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/node/file.cpp

    r1132 r1136  
    267267    } 
    268268 
    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) 
    271275    { 
    272276      CContext* context = CContext::getCurrent(); 
    273277      // 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))           
    275280      { 
    276281        if (mode.isEmpty() || mode.getValue() == mode_attr::write) 
     
    278283          if (!isOpen) createHeader(); 
    279284          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)); 
    280306        } 
    281         else 
    282         { 
    283           if (!isOpen) openInReadMode(); 
    284         } 
    285         checkSplit(); 
     307        //checkSplit(); // Really need for reading? 
    286308      } 
    287309    } 
     
    502524  \brief Open an existing NetCDF file in read-only mode 
    503525  */ 
    504   void CFile::openInReadMode(void) 
     526  void CFile::openInReadMode(MPI_Comm* comm) 
    505527  { 
    506528    CContext* context = CContext::getCurrent(); 
    507529    CContextServer* server = context->server; 
     530    MPI_Comm readComm = *comm; 
    508531 
    509532    if (!allDomainEmpty) 
     
    547570      { 
    548571        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); 
    551574 
    552575        if (server->intraCommSize > 1) 
     
    567590 
    568591      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)); 
    571594      isOpen = true; 
    572595    } 
     
    594617     // Just check file and try to open it 
    595618     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; 
    598621 
    599622     // It would probably be better to call initFile() somehow 
    600      MPI_Comm_dup(client->intraComm, &fileComm); 
     623     // MPI_Comm_dup(client->intraComm, &fileComm); 
    601624     if (time_counter_name.isEmpty()) time_counter_name = "time_counter"; 
    602625 
    603      checkFile(); 
     626     checkReadFile(); 
    604627 
    605628     for (int idx = 0; idx < enabledFields.size(); ++idx) 
     
    883906 
    884907   /*! 
     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   /*! 
    885917   \brief Receive a message annoucing the creation of a field on server side 
    886918   \param[in] event Received event 
     
    10571089   With these two id, it's easier to make reference to grid where all data should be written. 
    10581090   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) 
    10601093   { 
    10611094     size_t size = this->enabledFields.size(); 
Note: See TracChangeset for help on using the changeset viewer.