Changeset 1136 for XIOS


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

Location:
XIOS/dev/dev_olga
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/bld.cfg

    r1133 r1136  
    3434bld::target xios_server.exe  
    3535bld::target test_regular.exe 
    36 bld::target test_xios2_cmip6.exe 
     36#bld::target test_xios2_cmip6.exe 
    3737#bld::target test_new_features.exe test_unstruct_complete.exe  
     38bld::target test_remap.exe 
    3839bld::target test_complete.exe 
    3940bld::target test_client.exe 
     41bld::target test_unstruct_complete.exe 
     42bld::target test_unstructured.exe 
    4043bld::exe_dep 
    4144 
  • XIOS/dev/dev_olga/inputs/REMAP/iodef.xml

    r978 r1136  
    2020      <field id="dst_field_2D_clone" field_ref="src_field_2D_clone" domain_ref="dst_domain"/> 
    2121    </field_group> 
    22     <field_group id="read_fields" operation="instant"> 
    23 <!--       <field id="tmp_field_0" domain_ref="src_domain_regular_read"/> 
     22    <field_group id="read_fields" operation="instant" enabled="FALSE"> 
     23      <field id="tmp_field_0" domain_ref="src_domain_regular_read" enabled="true"/> 
    2424      <field id="tmp_field_clone" field_ref="tmp_field_0"/> 
    2525      <field id="tmp_field_1" grid_ref="src_grid_curvilinear_read" /> 
     
    2727      <field id="dst_field_regular" field_ref="tmp_field_2" grid_ref="dst_grid_regular"/>       
    2828      <field id="dst_field_regular_pole_0" field_ref="tmp_field_0" domain_ref="dst_domain_regular_pole"/> 
    29       <field id="dst_field_regular_pole_1" field_ref="tmp_field_clone" domain_ref="dst_domain_regular_pole"/> --> 
     29      <field id="dst_field_regular_pole_1" field_ref="tmp_field_clone" domain_ref="dst_domain_regular_pole"/> 
    3030    </field_group>  
    3131   </field_definition> 
     
    5252     </file_group> 
    5353     <file_group id="read_files" > 
    54 <!--        <file id="output_src_regular" name="output_src_regular" mode="read" > 
     54       <file id="output_src_regular" name="output_src_regular" mode="read" > 
    5555          <field id="src_field_regular" name="field" grid_ref="src_grid_regular_read" operation="instant"/> 
    5656       </file> 
    57        <file id="output_src_curvilinear" name="output_src_curvilinear" mode="read" > 
     57<!--        <file id="output_src_curvilinear" name="output_src_curvilinear" mode="read" > 
    5858          <field id="src_field_curvilinear" name="field_A" grid_ref="src_grid_curvilinear_read" operation="instant"/> 
    5959       </file> 
     
    170170  <context id="xios"> 
    171171      <variable_definition> 
     172         <variable_group id="server"> 
     173            <variable id="using_server2" type="bool">true</variable> 
     174            <variable id="ratio_server2" type="int">50</variable> 
     175         </variable_group> 
     176 
    172177        <variable_group id="buffer"> 
    173178            <variable id="optimal_buffer_size" type="string">performance</variable> 
  • XIOS/dev/dev_olga/src/node/field.cpp

    r1129 r1136  
    125125 
    126126    CContext* context = CContext::getCurrent(); 
    127 //    CContextClient* client = context->client; 
    128     // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    129     // int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
    130     // for (int i = 0; i < nbSrvPools; ++i) 
    131     // { 
    132127      CContextClient* client = (!context->hasServer) ? context->client : this->file->getContextClient(); 
    133128 
     
    261256    {             
    262257      CArray<int,1>& storeClient = grid->storeIndex_client; 
    263       // for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 
    264       // { 
    265       //   // sizeData += it->second.numElements(); 
    266       //   data_srv.insert(std::make_pair(it->first, CArray<double,1>(it->second.numElements()))); 
    267       // } 
    268  
    269       // for (map<int, CArray<size_t, 1> >::iterator it = grid->outLocalIndexStoreOnClient.begin(); it != grid->outLocalIndexStoreOnClient.end(); ++it) 
    270       // { 
    271       //   // sizeData += it->second.numElements(); 
    272       //   data_srv.insert(std::make_pair(it->first, CArray<double,1>(it->second.numElements()))); 
    273       // } 
    274  
    275       // Gather all data from different clients 
    276       // recvDataSrv.resize(sizeData); 
     258 
     259      // Gather all data from different clients       
    277260      recvDataSrv.resize(storeClient.numElements()); 
    278261      recvFoperationSrv = boost::shared_ptr<func::CFunctor>(new func::CInstant(recvDataSrv)); 
    279262    } 
    280263 
    281     CArray<double,1> recv_data_tmp(recvDataSrv.numElements()); 
    282     // sizeData = 0; 
     264    CArray<double,1> recv_data_tmp(recvDataSrv.numElements());     
    283265    const CDate& currDate = context->getCalendar()->getCurrentDate(); 
    284266    const CDate opeDate   = last_operation_srv +freq_op + freq_operation_srv - freq_op; 
     
    286268    if (opeDate <= currDate) 
    287269    { 
    288        for (map<int, CArray<size_t, 1> >::iterator it = grid->outLocalIndexStoreOnClient.begin(); it != grid->outLocalIndexStoreOnClient.end(); ++it) 
     270      for (map<int, CArray<size_t, 1> >::iterator it = grid->outLocalIndexStoreOnClient.begin(); it != grid->outLocalIndexStoreOnClient.end(); ++it) 
    289271      { 
    290272        CArray<double,1> tmp; 
     
    294276        { 
    295277          recv_data_tmp(indexTmp(idx)) = tmp(idx); 
    296         } 
    297         // recv_data_tmp(Range(sizeData,sizeData+it->second.numElements()-1)) = tmp;   
    298         // sizeData += it->second.numElements();       
    299       } 
    300  
    301       // for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 
    302       // {         
    303       //   CArray<double,1> tmp; 
    304       //   CArray<size_t,1>& indexTmp = it->second; 
    305       //   *(rankBuffers[it->first]) >> tmp; 
    306       //   for (int idx = 0; idx < indexTmp.numElements(); ++idx) 
    307       //   { 
    308       //     recv_data_tmp(indexTmp(idx)) = tmp(idx); 
    309       //   } 
    310       //   // recv_data_tmp(Range(sizeData,sizeData+it->second.numElements()-1)) = tmp;   
    311       //   // sizeData += it->second.numElements();       
    312       // } 
     278        }       
     279      } 
    313280    } 
    314281 
     
    328295      (*recvFoperationSrv)(data); 
    329296      last_operation_srv = currDate; 
    330 //        sendUpdateData(fieldData); 
    331         // Redirecting data to the correct secondary server 
    332         //int fileIdx = std::find(context->enabledFiles.begin(), context->enabledFiles.end(), this->file) - context->enabledFiles.begin(); 
    333         //int srvId = fileIdx % context->clientPrimServer.size(); 
    334         //sendUpdateData(fieldData, context->clientPrimServer[srvId]); 
    335297    } 
    336298 
     
    416378      if (grid->doGridHaveDataToWrite() || getRelFile()->type == CFile::type_attr::one_file) 
    417379      { 
    418         getRelFile()->checkFile(); 
     380        getRelFile()->checkWriteFile(); 
    419381        this->incrementNStep(); 
    420382        getRelFile()->getDataOutput()->writeFieldData(CField::get(this)); 
     
    479441  { 
    480442    CContext* context = CContext::getCurrent(); 
    481     CContextClient* client = context->client; 
     443    CContextClient* client = context->client;     
    482444 
    483445    CEventClient event(getType(), EVENT_ID_READ_DATA_READY); 
     
    486448    bool hasData = readField(); 
    487449 
    488     map<int, CArray<double,1> >::iterator it; 
    489 //    for (it = data_srv.begin(); it != data_srv.end(); it++) 
    490 //    { 
    491 //      msgs.push_back(CMessage()); 
    492 //      CMessage& msg = msgs.back(); 
    493 //      msg << getId(); 
    494 //      if (hasData) 
    495 //        msg << getNStep() - 1 << it->second; 
    496 //      else 
    497 //        msg << int(-1); 
    498 //      event.push(it->first, grid->nbSenders[it->first], msg); 
    499 //    } 
    500 //    client->sendEvent(event); 
     450     
    501451    if (!grid->doGridHaveDataDistributed()) 
    502452    { 
    503453       if (client->isServerLeader()) 
    504454       { 
    505           if (!data_srv.empty()) 
    506           { 
    507             it = data_srv.begin(); 
     455          if (0 != recvDataSrv.numElements()) 
     456          {             
    508457            const std::list<int>& ranks = client->getRanksServerLeader(); 
    509458            for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     
    513462              msg << getId(); 
    514463              if (hasData) 
    515                 msg << getNStep() - 1 << it->second; 
     464                msg << getNStep() - 1 << recvDataSrv; 
    516465              else 
    517466                msg << int(-1); 
     
    519468            } 
    520469          } 
     470 
    521471          client->sendEvent(event); 
    522472       } 
    523473       else 
    524474       { 
    525           // if (!data_srv.empty()) 
    526           // { 
    527           //   it = data_srv.begin(); 
    528           //   const std::list<int>& ranks = client->getRanksServerNotLeader(); 
    529           //   for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    530           //   { 
    531           //     msgs.push_back(CMessage()); 
    532           //     CMessage& msg = msgs.back(); 
    533           //     msg << getId(); 
    534           //     if (hasData) 
    535           //       msg << getNStep() - 1 << it->second; 
    536           //     else 
    537           //       msg << int(-1); 
    538           //     event.push(*itRank, 1, msg); 
    539           //   } 
    540           // } 
    541475          client->sendEvent(event); 
    542476       } 
     
    544478    else 
    545479    { 
    546       for (it = data_srv.begin(); it != data_srv.end(); it++) 
     480      for (map<int, CArray<size_t, 1> >::iterator it = grid->outLocalIndexStoreOnClient.begin();  
     481                                                  it != grid->outLocalIndexStoreOnClient.end(); ++it) 
    547482      { 
     483        CArray<size_t,1>& indexTmp = it->second; 
     484        CArray<double,1> tmp(indexTmp.numElements()); 
     485        for (int idx = 0; idx < indexTmp.numElements(); ++idx) 
     486        { 
     487          tmp(idx) = recvDataSrv(indexTmp(idx)); 
     488        }  
     489 
    548490        msgs.push_back(CMessage()); 
    549491        CMessage& msg = msgs.back(); 
    550492        msg << getId(); 
    551493        if (hasData) 
    552           msg << getNStep() - 1 << it->second; 
     494          msg << getNStep() - 1 << tmp; 
    553495        else 
    554496          msg << int(-1); 
    555         event.push(it->first, grid->nbSenders[0][it->first], msg); 
     497        event.push(it->first, grid->nbReadSenders[0][it->first], msg); 
    556498      } 
    557499      client->sendEvent(event); 
     
    561503  bool CField::readField(void) 
    562504  { 
     505    grid->computeWrittenIndex(); 
    563506    if (!getRelFile()->allDomainEmpty) 
    564507    { 
    565508      if (grid->doGridHaveDataToWrite() || getRelFile()->type == CFile::type_attr::one_file) 
    566509      { 
    567         if (data_srv.empty()) 
    568         { 
    569           for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 
    570             data_srv.insert(std::make_pair(it->first, CArray<double,1>(it->second.numElements()))); 
     510        if (0 == recvDataSrv.numElements()) 
     511        {             
     512          CArray<int,1>& storeClient = grid->storeIndex_client;           
     513          recvDataSrv.resize(storeClient.numElements());           
    571514        } 
    572515 
    573         getRelFile()->checkFile(); 
     516        getRelFile()->checkReadFile(); 
    574517        if (!nstepMax) 
    575518        { 
     
    578521 
    579522        this->incrementNStep(); 
    580  
    581  
    582523 
    583524        if (getNStep() > nstepMax && (getRelFile()->cyclic.isEmpty() || !getRelFile()->cyclic) ) 
     
    14261367   void CField::scaleFactorAddOffset(double scaleFactor, double addOffset) 
    14271368   { 
    1428      map<int, CArray<double,1> >::iterator it; 
    1429      for (it = data_srv.begin(); it != data_srv.end(); it++) it->second = (it->second - addOffset) / scaleFactor; 
     1369     // map<int, CArray<double,1> >::iterator it; 
     1370     // for (it = data_srv.begin(); it != data_srv.end(); it++) it->second = (it->second - addOffset) / scaleFactor; 
     1371     recvDataSrv = (recvDataSrv - addOffset) / scaleFactor; 
    14301372   } 
    14311373 
    14321374   void CField::invertScaleFactorAddOffset(double scaleFactor, double addOffset) 
    14331375   { 
    1434      map<int, CArray<double,1> >::iterator it; 
    1435      for (it = data_srv.begin(); it != data_srv.end(); it++) it->second = it->second * scaleFactor + addOffset; 
    1436    } 
    1437  
    1438    void CField::outputField(CArray<double,3>& fieldOut) 
    1439    { 
    1440       map<int, CArray<double,1> >::iterator it; 
    1441       for (it = data_srv.begin(); it != data_srv.end(); it++) 
    1442       { 
    1443         grid->outputField(it->first, it->second, fieldOut.dataFirst()); 
    1444       } 
    1445    } 
    1446  
    1447    void CField::outputField(CArray<double,2>& fieldOut) 
    1448    { 
    1449       map<int, CArray<double,1> >::iterator it; 
    1450       for(it=data_srv.begin();it!=data_srv.end();it++) 
    1451       { 
    1452          grid->outputField(it->first, it->second, fieldOut.dataFirst()); 
    1453       } 
     1376     // map<int, CArray<double,1> >::iterator it; 
     1377     // for (it = data_srv.begin(); it != data_srv.end(); it++) it->second = it->second * scaleFactor + addOffset; 
     1378     recvDataSrv = recvDataSrv * scaleFactor + addOffset; 
    14541379   } 
    14551380 
    14561381   void CField::outputField(CArray<double,1>& fieldOut) 
    1457    { 
    1458       map<int, CArray<double,1> >::iterator it;       
    1459       
     1382   {  
    14601383      CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient; 
    14611384      CArray<size_t,1>& outIndexServer = grid->localIndexToWriteOnServer; 
     
    14641387        fieldOut(outIndexServer(idx)) = recvDataSrv(outIndexClient(idx)); 
    14651388      } 
    1466  
     1389   } 
     1390 
     1391   void CField::inputField(CArray<double,1>& fieldIn) 
     1392   { 
     1393      // map<int, CArray<double,1> >::iterator it; 
    14671394      // for (it = data_srv.begin(); it != data_srv.end(); it++) 
    14681395      // { 
    1469       //    grid->outputField(it->first, it->second, fieldOut.dataFirst()); 
     1396      //    grid->inputField(it->first, fieldOut.dataFirst(), it->second); 
    14701397      // } 
    1471     // grid->outputField(recvDataSrv, fieldOut); 
    1472    } 
    1473  
    1474    void CField::inputField(CArray<double,3>& fieldOut) 
    1475    { 
    1476       map<int, CArray<double,1> >::iterator it; 
    1477       for (it = data_srv.begin(); it != data_srv.end(); it++) 
     1398      CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient; 
     1399      CArray<size_t,1>& outIndexServer = grid->localIndexToWriteOnServer; 
     1400      for (size_t idx = 0; idx < outIndexServer.numElements(); ++idx) 
    14781401      { 
    1479         grid->inputField(it->first, fieldOut.dataFirst(), it->second); 
    1480       } 
    1481    } 
    1482  
    1483    void CField::inputField(CArray<double,2>& fieldOut) 
    1484    { 
    1485       map<int, CArray<double,1> >::iterator it; 
    1486       for(it = data_srv.begin(); it != data_srv.end(); it++) 
    1487       { 
    1488          grid->inputField(it->first, fieldOut.dataFirst(), it->second); 
    1489       } 
    1490    } 
    1491  
    1492    void CField::inputField(CArray<double,1>& fieldOut) 
    1493    { 
    1494       map<int, CArray<double,1> >::iterator it; 
    1495       for (it = data_srv.begin(); it != data_srv.end(); it++) 
    1496       { 
    1497          grid->inputField(it->first, fieldOut.dataFirst(), it->second); 
    1498       } 
     1402        recvDataSrv(outIndexClient(idx)) = fieldIn(outIndexServer(idx)); 
     1403      } 
     1404 
    14991405   } 
    15001406 
     
    16031509   { 
    16041510      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE); 
    1605     // CContext* context = CContext::getCurrent(); 
    1606  
    1607     // if (!context->hasServer) 
    1608     // { 
    1609     //    CContextClient* client = context->client; 
    1610  
    1611     //    CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE); 
    1612     //    if (client->isServerLeader()) 
    1613     //    { 
    1614     //      CMessage msg; 
    1615     //      msg << this->getId(); 
    1616     //      msg << id; 
    1617     //      const std::list<int>& ranks = client->getRanksServerLeader(); 
    1618     //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1619     //        event.push(*itRank,1,msg); 
    1620     //      client->sendEvent(event); 
    1621     //    } 
    1622     //    else client->sendEvent(event); 
    1623     // } 
    16241511   } 
    16251512 
     
    16271514   { 
    16281515      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE, client); 
    1629     // CContext* context = CContext::getCurrent(); 
    1630  
    1631     // if (!context->hasServer) 
    1632     // { 
    1633     //    CContextClient* client = context->client; 
    1634  
    1635     //    CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE); 
    1636     //    if (client->isServerLeader()) 
    1637     //    { 
    1638     //      CMessage msg; 
    1639     //      msg << this->getId(); 
    1640     //      msg << id; 
    1641     //      const std::list<int>& ranks = client->getRanksServerLeader(); 
    1642     //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1643     //        event.push(*itRank,1,msg); 
    1644     //      client->sendEvent(event); 
    1645     //    } 
    1646     //    else client->sendEvent(event); 
    1647     // } 
    16481516   } 
    16491517 
     
    16511519   { 
    16521520      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE_GROUP); 
    1653     // CContext* context = CContext::getCurrent(); 
    1654     // if (!context->hasServer) 
    1655     // { 
    1656     //    CContextClient* client = context->client; 
    1657  
    1658     //    CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP); 
    1659     //    if (client->isServerLeader()) 
    1660     //    { 
    1661     //      CMessage msg; 
    1662     //      msg << this->getId(); 
    1663     //      msg << id; 
    1664     //      const std::list<int>& ranks = client->getRanksServerLeader(); 
    1665     //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1666     //        event.push(*itRank,1,msg); 
    1667     //      client->sendEvent(event); 
    1668     //    } 
    1669     //    else client->sendEvent(event); 
    1670     // } 
    16711521   } 
    16721522 
  • XIOS/dev/dev_olga/src/node/field.hpp

    r1129 r1136  
    157157        static void recvReadDataReady(CEventServer& event); 
    158158        void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers); 
    159         void outputField(CArray<double,3>& fieldOut); 
    160         void outputField(CArray<double,2>& fieldOut); 
    161159        void outputField(CArray<double,1>& fieldOut); 
    162         void inputField(CArray<double,3>& fieldOut); 
    163         void inputField(CArray<double,2>& fieldOut); 
    164160        void inputField(CArray<double,1>& fieldOut); 
    165161        void outputCompressedField(CArray<double, 1>& fieldOut); 
  • 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(); 
  • XIOS/dev/dev_olga/src/node/file.hpp

    r1132 r1136  
    8787         bool checkSplit(void); 
    8888         bool checkSync(void); 
    89          void checkFile(void); 
     89         void checkWriteFile(void); 
     90         void checkReadFile(void); 
    9091         void initFile(void); 
    9192 
     
    9697 
    9798         void createHeader(void); 
    98          void openInReadMode(void); 
     99         void openInReadMode(MPI_Comm* readComm = NULL); 
    99100         void close(void); 
    100101         void readAttributesOfEnabledFieldsInReadMode(); 
     
    128129         void sendAddField(const string& id, CContextClient* client); 
    129130         void sendAddFieldGroup(const string& id = ""); 
     131         void sendAddFieldGroup(const string& id, CContextClient* client); 
    130132         void sendAddAllVariables();                        // to be removed (?) 
    131133         void sendAddAllVariables(CContextClient* client); 
  • XIOS/dev/dev_olga/src/node/grid.cpp

    r1132 r1136  
    409409      using namespace std; 
    410410      std::vector<CDomain*> domainP = this->getDomains(); 
    411       std::vector<CAxis*> axisP = this->getAxis(); 
     411      std::vector<CAxis*> axisP = this->getAxis();       
    412412      int dim = domainP.size() * 2 + axisP.size(); 
    413413 
     
    442442   {       
    443443      std::vector<CDomain*> domainP = this->getDomains(); 
    444       std::vector<CAxis*> axisP = this->getAxis(); 
     444      std::vector<CAxis*> axisP = this->getAxis();             
    445445      int dim = domainP.size() * 2 + axisP.size(); 
    446446 
     
    591591     { 
    592592       CContextClient* client = (context->hasServer) ? (context->hasClient ? context->clientPrimServer[p] : context->client) : context->client; 
    593        // CContextClient* client = (context->hasServer) ? context->clientPrimServer[i] : context->client; 
    594        // CContextServer* server = (context->hasServer) ? context->server : 0 ; 
    595        // int rank = (server && !client) ? server->intraCommRank : client->clientRank; 
    596593       int rank = client->clientRank; 
    597594 
    598        // First of all, compute distribution on client side 
    599        // if (0 != serverDistribution_) 
    600        // { 
    601        //   // clientDistribution_ = new CDistributionClient(rank, this, serverDistribution_->getGlobalLocalIndex()); 
    602        //   clientDistribution_ = new CDistributionClient(rank, this); 
    603        //   storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 
    604        //   // storeIndex_client.resize(serverDistribution_->getGridSize()); 
    605        //   int nbStoreIndex = storeIndex_client.numElements(); 
    606        //   for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = idx; 
    607        // } 
    608        // else 
    609        // { 
    610595         clientDistribution_ = new CDistributionClient(rank, this); 
    611596         // Get local data index on client 
     
    665650   } 
    666651 
     652   /*! 
     653     Compute the connected clients and index to send to these clients. 
     654     Each client can connect to a pool of other clients, each of which can have a piece of information of a grid 
     655 
     656   */ 
    667657   void CGrid::computeConnectedClients() 
    668658   { 
    669659     CContext* context = CContext::getCurrent(); 
    670      // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    671660     int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
    672661     connectedServerRank_.resize(nbSrvPools); 
     
    747736   { 
    748737     CContext* context = CContext::getCurrent(); 
    749 //     CContextClient* client = context->client; 
    750      // CContextClient* client = (context->hasServer) ? context->clientPrimServer : context->client; 
    751       
    752  
    753      // // First of all, compute distribution on client side 
    754      // if (0 != serverDistribution_) 
    755      //   clientDistribution_ = new CDistributionClient(client->clientRank, this, serverDistribution_->getGlobalLocalIndex()); 
    756      // else 
    757      //   clientDistribution_ = new CDistributionClient(client->clientRank, this); 
    758  
    759      // // Get local data index on client 
    760      // int tmp = clientDistribution_->getLocalDataIndexOnClient().size(); 
    761      // storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 
    762      // int nbStoreIndex = storeIndex_client.numElements(); 
    763      // for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 
    764      // isDataDistributed_= clientDistribution_->isDataDistributed(); 
    765  
    766  
    767      // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    768  
    769738     computeClientIndex(); 
    770739     if (context->hasClient) 
     
    772741       computeConnectedClients(); 
    773742     } 
    774  
    775      // connectedServerRank_.clear(); 
    776  
    777      // if (!doGridHaveDataDistributed()) 
    778      // { 
    779      //    if (client->isServerLeader()) 
    780      //    { 
    781      //      size_t ssize = clientDistribution_->getLocalDataIndexOnClient().size(); 
    782      //      const std::list<int>& ranks = client->getRanksServerLeader(); 
    783      //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    784      //      { 
    785      //        connectedServerRank_.push_back(*itRank); 
    786      //        connectedDataSize_[*itRank] = ssize; 
    787      //      } 
    788      //    } 
    789      //    return; 
    790      // } 
    791  
    792      // // Compute mapping between client and server 
    793      // std::vector<boost::unordered_map<size_t,std::vector<int> > > indexServerOnElement; 
    794      // CServerDistributionDescription serverDistributionDescription(globalDim_, client->serverSize); 
    795      // serverDistributionDescription.computeServerGlobalByElement(indexServerOnElement, 
    796      //                                                            client->clientRank, 
    797      //                                                            client->clientSize, 
    798      //                                                            axis_domain_order, 
    799      //                                                            positionDimensionDistributed_); 
    800      // computeIndexByElement(indexServerOnElement, globalIndexOnServer_); 
    801  
    802      // const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = clientDistribution_->getGlobalLocalDataSendToServer(); 
    803      // CDistributionClient::GlobalLocalDataMap::const_iterator iteGlobalLocalIndexMap = globalLocalIndexSendToServer.end(), itGlobalLocalIndexMap; 
    804      // CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 
    805      // itGlobalMap  = itbGlobalMap = globalIndexOnServer_.begin(); 
    806      // iteGlobalMap = globalIndexOnServer_.end(); 
    807  
    808      // for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
    809      // { 
    810      //   int serverRank = itGlobalMap->first; 
    811      //   int indexSize = itGlobalMap->second.size(); 
    812      //   const std::vector<size_t>& indexVec = itGlobalMap->second; 
    813      //   for (int idx = 0; idx < indexSize; ++idx) 
    814      //   { 
    815      //      itGlobalLocalIndexMap = globalLocalIndexSendToServer.find(indexVec[idx]); 
    816      //      if (iteGlobalLocalIndexMap != itGlobalLocalIndexMap) 
    817      //      { 
    818      //         if (connectedDataSize_.end() == connectedDataSize_.find(serverRank)) 
    819      //           connectedDataSize_[serverRank] = 1; 
    820      //         else 
    821      //           ++connectedDataSize_[serverRank]; 
    822      //      } 
    823      //   } 
    824      // } 
    825  
    826      // for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) { 
    827      //   connectedServerRank_.push_back(itGlobalMap->first); 
    828      // } 
    829  
    830      // nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    831743   } 
    832744 
     
    950862 
    951863       nbIndexOnServer = 0; 
    952 //       for (it = itb; it != ite; ++it) 
    953864       for (size_t j = 0; j < globalIndexElementOnServerMap.size(); ++j) 
    954865       { 
     
    15851496    nbSrvPools = 1; 
    15861497    // connectedServerRank_.resize(nbSrvPools); 
    1587     // nbSenders.resize(nbSrvPools); 
     1498    nbReadSenders.resize(nbSrvPools); 
    15881499    for (int p = 0; p < nbSrvPools; ++p) 
    15891500    { 
    15901501      CContextServer* server = (!context->hasClient) ? context->server : context->serverPrimServer[p]; 
    15911502      CContextClient* client = (!context->hasClient) ? context->client : context->clientPrimServer[p]; 
     1503       
    15921504//      CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer[p]; 
    15931505//      CContextClient* client = (context->hasServer) ? context->client : context->clientPrimServer[p]; 
     
    16991611        std::vector<CDomain*> domainList = getDomains(); 
    17001612        std::vector<CAxis*> axisList = getAxis(); 
    1701         std::vector<int> nBegin(ssize), nSize(ssize), nGlob(ssize), nBeginGlobal(ssize);         
     1613        int dimSize = 2 * domainList.size() + axisList.size(); 
     1614        std::vector<int> nBegin(dimSize), nSize(dimSize), nGlob(dimSize), nBeginGlobal(dimSize);         
    17021615        for (int i = 0; i < numElement; ++i) 
    17031616        {           
     
    17261639          else // scalar 
    17271640          {  
    1728             nBegin[indexMap[i]] = 0; 
    1729             nSize[indexMap[i]]  = 1; 
    1730             nBeginGlobal[indexMap[i]] = 0;               
    1731             nGlob[indexMap[i]] = 1; 
    1732  
    1733             ++scalarId; 
    17341641          } 
    17351642        } 
     
    17821689        totalNumberWrittenIndexes_ = numberWrittenIndexes_; 
    17831690 
    1784       // nbSenders[p] = CClientServerMappingDistributed::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, ranks); 
     1691      nbReadSenders[p] = CClientServerMappingDistributed::computeConnectedClients(context->client->serverSize, context->client->clientSize, context->client->intraComm, ranks); 
    17851692    } 
    17861693  } 
  • XIOS/dev/dev_olga/src/node/grid.hpp

    r1129 r1136  
    223223         map<int, CArray<int, 1> > storeIndex_toSrv; 
    224224         map<int, CArray<int, 1> > storeIndex_fromSrv; 
    225          std::vector<map<int,int> > nbSenders; 
     225         std::vector<map<int,int> > nbSenders, nbReadSenders; 
    226226 
    227227         map<int, CArray<size_t, 1> > outIndexFromClient, compressedOutIndexFromClient, outGlobalIndexFromClient; 
  • XIOS/dev/dev_olga/src/test/test_remap.f90

    r1025 r1136  
    176176  ! ALLOCATE(tmp_field_2(src_tmp_ni*src_tmp_nj)) 
    177177 
    178   DO ts=1,5 
     178  DO ts=1,1 
    179179    CALL xios_recv_field("src_field_regular", tmp_field_0) 
    180180    ! CALL xios_recv_field("src_field_curvilinear", tmp_field_1) 
     
    184184    CALL xios_send_field("src_field_2D_clone",src_field_2D) 
    185185    CALL xios_send_field("src_field_3D",src_field_3D) 
    186     CALL xios_send_field("src_field_4D",src_field_4D) 
    187     CALL xios_send_field("src_field_3D_pression",src_field_pression) 
     186    ! CALL xios_send_field("src_field_4D",src_field_4D) 
     187    ! CALL xios_send_field("src_field_3D_pression",src_field_pression) 
    188188    CALL xios_send_field("tmp_field_0",tmp_field_0) 
    189189    ! CALL xios_send_field("tmp_field_1",tmp_field_1) 
Note: See TracChangeset for help on using the changeset viewer.