Changeset 1027


Ignore:
Timestamp:
01/11/17 16:50:27 (7 years ago)
Author:
oabramkina
Message:

Minor modifications in the merged version of dev.

Location:
XIOS/dev/dev_olga/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/io/nc4_data_output.cpp

    r1025 r1027  
    10431043      { 
    10441044        CContext* context = CContext::getCurrent(); 
    1045         CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer; 
    1046  
    1047         if (axis->IsWritten(this->filename)) return; 
    1048         axis->checkAttributes(); 
    1049  
    1050         int local_size_write  = axis->getLocalWriteSize(); 
    1051         int global_size_write = axis->getGlobalWriteSize(); 
    1052         int start_write = axis->getStartWriteIndex(); 
    1053         int count_write = axis->getCountWriteIndex(); 
    1054  
    1055         if ((0 == local_size_write) && (MULTI_FILE == SuperClass::type)) return; 
    1056  
    1057         std::vector<StdString> dims; 
    1058         StdString axisid = axis->getAxisOutputName(); 
    1059         if (isWrittenAxis(axisid)) return ; 
    1060         else setWrittenAxis(axisid); 
    1061  
    1062         try 
     1045 
     1046        int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     1047        for (int i = 0; i < nbSrvPools; ++i) 
    10631048        { 
    1064           SuperClassWriter::addDimension(axisid, global_size_write); 
    1065           if (axis->hasValue) 
     1049          CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer[i]; 
     1050 
     1051          if (axis->IsWritten(this->filename)) return; 
     1052          axis->checkAttributes(); 
     1053 
     1054          int local_size_write  = axis->getLocalWriteSize(); 
     1055          int global_size_write = axis->getGlobalWriteSize(); 
     1056          int start_write = axis->getStartWriteIndex(); 
     1057          int count_write = axis->getCountWriteIndex(); 
     1058 
     1059          if ((0 == local_size_write) && (MULTI_FILE == SuperClass::type)) return; 
     1060 
     1061          std::vector<StdString> dims; 
     1062          StdString axisid = axis->getAxisOutputName(); 
     1063          if (isWrittenAxis(axisid)) return ; 
     1064          else setWrittenAxis(axisid); 
     1065 
     1066          try 
    10661067          { 
    1067             dims.push_back(axisid); 
    1068             SuperClassWriter::addVariable(axisid, NC_FLOAT, dims); 
    1069  
    1070             if (!axis->name.isEmpty()) 
    1071               SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid); 
    1072  
    1073             if (!axis->standard_name.isEmpty()) 
    1074               SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid); 
    1075  
    1076             if (!axis->long_name.isEmpty()) 
    1077               SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid); 
    1078  
    1079             if (!axis->unit.isEmpty()) 
    1080               SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid); 
    1081  
    1082             if (!axis->positive.isEmpty()) 
     1068            SuperClassWriter::addDimension(axisid, global_size_write); 
     1069            if (axis->hasValue) 
    10831070            { 
    1084               SuperClassWriter::addAttribute("axis", string("Z"), &axisid); 
    1085               SuperClassWriter::addAttribute("positive", 
    1086                                              (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"), 
    1087                                              &axisid); 
    1088             } 
    1089  
    1090             StdString axisBoundsId = axisid + "_bounds"; 
    1091             if (!axis->bounds.isEmpty()) 
    1092             { 
    1093               dims.push_back("axis_nbounds"); 
    1094               SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims); 
    1095               SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); 
    1096             } 
    1097  
    1098             SuperClassWriter::definition_end(); 
    1099  
    1100             switch (SuperClass::type) 
    1101             { 
    1102               case MULTI_FILE: 
     1071              dims.push_back(axisid); 
     1072              SuperClassWriter::addVariable(axisid, NC_FLOAT, dims); 
     1073 
     1074              if (!axis->name.isEmpty()) 
     1075                SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid); 
     1076 
     1077              if (!axis->standard_name.isEmpty()) 
     1078                SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid); 
     1079 
     1080              if (!axis->long_name.isEmpty()) 
     1081                SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid); 
     1082 
     1083              if (!axis->unit.isEmpty()) 
     1084                SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid); 
     1085 
     1086              if (!axis->positive.isEmpty()) 
    11031087              { 
    1104                 CArray<double,1> axis_value(local_size_write); 
    1105                 for (int i = 0; i < local_size_write; i++) axis_value(i) = axis->value(i); 
    1106                 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 
    1107  
    1108                 if (!axis->bounds.isEmpty()) 
    1109                   SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0); 
    1110  
    1111                 SuperClassWriter::definition_start(); 
    1112  
    1113                 break; 
     1088                SuperClassWriter::addAttribute("axis", string("Z"), &axisid); 
     1089                SuperClassWriter::addAttribute("positive", 
     1090                                               (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"), 
     1091                                               &axisid); 
    11141092              } 
    1115               case ONE_FILE: 
     1093 
     1094              StdString axisBoundsId = axisid + "_bounds"; 
     1095              if (!axis->bounds.isEmpty()) 
    11161096              { 
    1117                 CArray<double,1> axis_value(count_write); 
    1118                 axis_value = axis->value; 
    1119  
    1120                 std::vector<StdSize> start(1), startBounds(2) ; 
    1121                 std::vector<StdSize> count(1), countBounds(2) ; 
    1122                 start[0] = startBounds[0] = start_write; 
    1123                 count[0] = countBounds[0] = count_write; 
    1124                 startBounds[1] = 0; 
    1125                 countBounds[1] = 2; 
    1126                 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 
    1127  
    1128                 if (!axis->bounds.isEmpty()) 
    1129                   SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 
    1130  
    1131                 SuperClassWriter::definition_start(); 
    1132  
    1133                 break; 
     1097                dims.push_back("axis_nbounds"); 
     1098                SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims); 
     1099                SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); 
    11341100              } 
    1135               default : 
    1136                 ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", 
    1137                       << "[ type = " << SuperClass::type << "]" 
    1138                       << " not implemented yet !"); 
     1101 
     1102              SuperClassWriter::definition_end(); 
     1103 
     1104              switch (SuperClass::type) 
     1105              { 
     1106                case MULTI_FILE: 
     1107                { 
     1108                  CArray<double,1> axis_value(local_size_write); 
     1109                  for (int i = 0; i < local_size_write; i++) axis_value(i) = axis->value(i); 
     1110                  SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 
     1111 
     1112                  if (!axis->bounds.isEmpty()) 
     1113                    SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0); 
     1114 
     1115                  SuperClassWriter::definition_start(); 
     1116 
     1117                  break; 
     1118                } 
     1119                case ONE_FILE: 
     1120                { 
     1121                  CArray<double,1> axis_value(count_write); 
     1122                  axis_value = axis->value; 
     1123 
     1124                  std::vector<StdSize> start(1), startBounds(2) ; 
     1125                  std::vector<StdSize> count(1), countBounds(2) ; 
     1126                  start[0] = startBounds[0] = start_write; 
     1127                  count[0] = countBounds[0] = count_write; 
     1128                  startBounds[1] = 0; 
     1129                  countBounds[1] = 2; 
     1130                  SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 
     1131 
     1132                  if (!axis->bounds.isEmpty()) 
     1133                    SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 
     1134 
     1135                  SuperClassWriter::definition_start(); 
     1136 
     1137                  break; 
     1138                } 
     1139                default : 
     1140                  ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", 
     1141                        << "[ type = " << SuperClass::type << "]" 
     1142                        << " not implemented yet !"); 
     1143              } 
    11391144            } 
    11401145          } 
    1141         } 
    1142         catch (CNetCdfException& e) 
    1143         { 
    1144           StdString msg("On writing the axis : "); 
    1145           msg.append(axisid); msg.append("\n"); 
    1146           msg.append("In the context : "); 
    1147           CContext* context = CContext::getCurrent() ; 
    1148           msg.append(context->getId()); msg.append("\n"); 
    1149           msg.append(e.what()); 
    1150           ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", << msg); 
    1151         } 
    1152         axis->addRelFile(this->filename); 
     1146          catch (CNetCdfException& e) 
     1147          { 
     1148            StdString msg("On writing the axis : "); 
     1149            msg.append(axisid); msg.append("\n"); 
     1150            msg.append("In the context : "); 
     1151            CContext* context = CContext::getCurrent() ; 
     1152            msg.append(context->getId()); msg.append("\n"); 
     1153            msg.append(e.what()); 
     1154            ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", << msg); 
     1155          } 
     1156      } // loop over nbSrvPools 
     1157      axis->addRelFile(this->filename); 
    11531158     } 
    11541159 
  • XIOS/dev/dev_olga/src/node/axis.cpp

    r1025 r1027  
    453453  { 
    454454    CContext* context = CContext::getCurrent(); 
    455     CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    456     int nbServer = client->serverSize; 
    457     int range, clientSize = client->clientSize; 
    458     int rank = client->clientRank; 
    459  
    460     // size_t ni = this->n.getValue(); 
    461     // size_t ibegin = this->begin.getValue(); 
    462     // size_t zoom_end = global_zoom_begin+global_zoom_n-1; 
    463     // size_t nZoomCount = 0; 
    464     size_t nbIndex = index.numElements(); 
    465     for (size_t idx = 0; idx < nbIndex; ++idx) 
    466     { 
    467       globalLocalIndexMap_[index(idx)] = idx; 
    468       // size_t globalIndex = index(idx); 
    469       // if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nZoomCount; 
    470     } 
    471  
    472     // CArray<size_t,1> globalIndexAxis(nbIndex); 
    473     // std::vector<size_t> globalAxisZoom(nZoomCount); 
    474     // nZoomCount = 0; 
    475     // for (size_t idx = 0; idx < nbIndex; ++idx) 
    476     // { 
    477     //   size_t globalIndex = index(idx); 
    478     //   globalIndexAxis(idx) = globalIndex; 
    479     //   if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 
    480     //   { 
    481     //     globalAxisZoom[nZoomCount] = globalIndex; 
    482     //     ++nZoomCount; 
    483     //   } 
    484     // } 
    485  
    486     // std::set<int> writtenInd; 
    487     // if (isCompressible_) 
    488     // { 
    489     //   for (int idx = 0; idx < data_index.numElements(); ++idx) 
    490     //   { 
    491     //     int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 
    492  
    493     //     if (ind >= 0 && ind < ni && mask(ind)) 
    494     //     { 
    495     //       ind += ibegin; 
    496     //       if (ind >= global_zoom_begin && ind <= zoom_end) 
    497     //         writtenInd.insert(ind); 
    498     //     } 
    499     //   } 
    500     // } 
    501  
    502     CServerDistributionDescription serverDescriptionGlobal(globalDim, nbServer, distType); 
    503     int distributedDimensionOnServer = serverDescriptionGlobal.getDimensionDistributed(); 
    504     CClientServerMapping::GlobalIndexMap globalIndexAxisOnServer; 
    505     if (distributedDimensionOnServer == orderPositionInGrid) // So we have distributed axis on client side and also on server side* 
    506     { 
    507       std::vector<int> nGlobAxis(1); 
    508       nGlobAxis[0] = n_glo.getValue(); 
    509  
    510       size_t globalSizeIndex = 1, indexBegin, indexEnd; 
    511       for (int i = 0; i < nGlobAxis.size(); ++i) globalSizeIndex *= nGlobAxis[i]; 
    512       indexBegin = 0; 
    513       if (globalSizeIndex <= clientSize) 
    514       { 
    515         indexBegin = rank%globalSizeIndex; 
    516         indexEnd = indexBegin; 
     455    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     456    for (int i = 0; i < nbSrvPools; ++i) 
     457    { 
     458      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 
     459      int nbServer = client->serverSize; 
     460      int range, clientSize = client->clientSize; 
     461      int rank = client->clientRank; 
     462 
     463      // size_t ni = this->n.getValue(); 
     464      // size_t ibegin = this->begin.getValue(); 
     465      // size_t zoom_end = global_zoom_begin+global_zoom_n-1; 
     466      // size_t nZoomCount = 0; 
     467      size_t nbIndex = index.numElements(); 
     468      for (size_t idx = 0; idx < nbIndex; ++idx) 
     469      { 
     470        globalLocalIndexMap_[index(idx)] = idx; 
     471        // size_t globalIndex = index(idx); 
     472        // if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nZoomCount; 
     473      } 
     474 
     475      // CArray<size_t,1> globalIndexAxis(nbIndex); 
     476      // std::vector<size_t> globalAxisZoom(nZoomCount); 
     477      // nZoomCount = 0; 
     478      // for (size_t idx = 0; idx < nbIndex; ++idx) 
     479      // { 
     480      //   size_t globalIndex = index(idx); 
     481      //   globalIndexAxis(idx) = globalIndex; 
     482      //   if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 
     483      //   { 
     484      //     globalAxisZoom[nZoomCount] = globalIndex; 
     485      //     ++nZoomCount; 
     486      //   } 
     487      // } 
     488 
     489      // std::set<int> writtenInd; 
     490      // if (isCompressible_) 
     491      // { 
     492      //   for (int idx = 0; idx < data_index.numElements(); ++idx) 
     493      //   { 
     494      //     int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 
     495 
     496      //     if (ind >= 0 && ind < ni && mask(ind)) 
     497      //     { 
     498      //       ind += ibegin; 
     499      //       if (ind >= global_zoom_begin && ind <= zoom_end) 
     500      //         writtenInd.insert(ind); 
     501      //     } 
     502      //   } 
     503      // } 
     504 
     505      CServerDistributionDescription serverDescriptionGlobal(globalDim, nbServer, distType); 
     506      int distributedDimensionOnServer = serverDescriptionGlobal.getDimensionDistributed(); 
     507      CClientServerMapping::GlobalIndexMap globalIndexAxisOnServer; 
     508      if (distributedDimensionOnServer == orderPositionInGrid) // So we have distributed axis on client side and also on server side* 
     509      { 
     510        std::vector<int> nGlobAxis(1); 
     511        nGlobAxis[0] = n_glo.getValue(); 
     512 
     513        size_t globalSizeIndex = 1, indexBegin, indexEnd; 
     514        for (int i = 0; i < nGlobAxis.size(); ++i) globalSizeIndex *= nGlobAxis[i]; 
     515        indexBegin = 0; 
     516        if (globalSizeIndex <= clientSize) 
     517        { 
     518          indexBegin = rank%globalSizeIndex; 
     519          indexEnd = indexBegin; 
     520        } 
     521        else 
     522        { 
     523          for (int i = 0; i < clientSize; ++i) 
     524          { 
     525            range = globalSizeIndex / clientSize; 
     526            if (i < (globalSizeIndex%clientSize)) ++range; 
     527            if (i == client->clientRank) break; 
     528            indexBegin += range; 
     529          } 
     530          indexEnd = indexBegin + range - 1; 
     531        } 
     532 
     533        CArray<size_t,1> globalIndex(index.numElements()); 
     534        for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 
     535          globalIndex(idx) = index(idx); 
     536 
     537        CServerDistributionDescription serverDescription(nGlobAxis, nbServer); 
     538        serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 
     539        CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 
     540        clientServerMap->computeServerIndexMapping(globalIndex); 
     541        globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 
     542        delete clientServerMap; 
    517543      } 
    518544      else 
    519545      { 
    520         for (int i = 0; i < clientSize; ++i) 
    521         { 
    522           range = globalSizeIndex / clientSize; 
    523           if (i < (globalSizeIndex%clientSize)) ++range; 
    524           if (i == client->clientRank) break; 
    525           indexBegin += range; 
    526         } 
    527         indexEnd = indexBegin + range - 1; 
    528       } 
    529  
    530       CArray<size_t,1> globalIndex(index.numElements()); 
    531       for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 
    532         globalIndex(idx) = index(idx); 
    533  
    534       CServerDistributionDescription serverDescription(nGlobAxis, nbServer); 
    535       serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 
    536       CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 
    537       clientServerMap->computeServerIndexMapping(globalIndex); 
    538       globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 
    539       delete clientServerMap; 
    540     } 
    541     else 
    542     { 
    543       std::vector<size_t> globalIndexServer(n_glo.getValue()); 
    544       for (size_t idx = 0; idx < n_glo.getValue(); ++idx) 
    545       { 
    546         globalIndexServer[idx] = idx; 
    547       } 
    548  
    549       for (int idx = 0; idx < nbServer; ++idx) 
    550       { 
    551         globalIndexAxisOnServer[idx] = globalIndexServer; 
    552       } 
    553     } 
    554  
    555     indSrv_.swap(globalIndexAxisOnServer); 
    556  
    557     // CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexAxisOnServer.begin(), 
    558     //                                                      ite = globalIndexAxisOnServer.end(); 
    559     CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_.begin(), 
    560                                                          ite = indSrv_.end(); 
    561     // std::vector<size_t>::const_iterator itbVec = (globalAxisZoom).begin(), 
    562     //                                     iteVec = (globalAxisZoom).end(); 
    563     // indSrv_.clear(); 
    564     // indWrittenSrv_.clear(); 
    565     // for (; it != ite; ++it) 
    566     // { 
    567     //   int rank = it->first; 
    568     //   const std::vector<size_t>& globalIndexTmp = it->second; 
    569     //   int nb = globalIndexTmp.size(); 
    570  
    571     //   for (int i = 0; i < nb; ++i) 
    572     //   { 
    573     //     if (std::binary_search(itbVec, iteVec, globalIndexTmp[i])) 
    574     //     { 
    575     //       indSrv_[rank].push_back(globalIndexTmp[i]); 
    576     //     } 
    577  
    578     //     if (writtenInd.count(globalIndexTmp[i])) 
    579     //     { 
    580     //       indWrittenSrv_[rank].push_back(globalIndexTmp[i]); 
    581     //     } 
    582     //   } 
    583     // } 
    584  
    585     connectedServerRank_.clear(); 
    586     for (it = indSrv_.begin(); it != ite; ++it) { 
    587       connectedServerRank_.push_back(it->first); 
    588     } 
    589  
    590     // if (!indSrv_.empty()) 
    591     // { 
    592     //   std::map<int, vector<size_t> >::const_iterator itIndSrv  = indSrv_.begin(), 
    593     //                                                  iteIndSrv = indSrv_.end(); 
    594     //   connectedServerRank_.clear(); 
    595     //   for (; itIndSrv != iteIndSrv; ++itIndSrv) 
    596     //     connectedServerRank_.push_back(itIndSrv->first); 
    597     // } 
    598     nbConnectedClients_ = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
     546        std::vector<size_t> globalIndexServer(n_glo.getValue()); 
     547        for (size_t idx = 0; idx < n_glo.getValue(); ++idx) 
     548        { 
     549          globalIndexServer[idx] = idx; 
     550        } 
     551 
     552        for (int idx = 0; idx < nbServer; ++idx) 
     553        { 
     554          globalIndexAxisOnServer[idx] = globalIndexServer; 
     555        } 
     556      } 
     557 
     558      indSrv_.swap(globalIndexAxisOnServer); 
     559 
     560      // CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexAxisOnServer.begin(), 
     561      //                                                      ite = globalIndexAxisOnServer.end(); 
     562      CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_.begin(), 
     563                                                           ite = indSrv_.end(); 
     564      // std::vector<size_t>::const_iterator itbVec = (globalAxisZoom).begin(), 
     565      //                                     iteVec = (globalAxisZoom).end(); 
     566      // indSrv_.clear(); 
     567      // indWrittenSrv_.clear(); 
     568      // for (; it != ite; ++it) 
     569      // { 
     570      //   int rank = it->first; 
     571      //   const std::vector<size_t>& globalIndexTmp = it->second; 
     572      //   int nb = globalIndexTmp.size(); 
     573 
     574      //   for (int i = 0; i < nb; ++i) 
     575      //   { 
     576      //     if (std::binary_search(itbVec, iteVec, globalIndexTmp[i])) 
     577      //     { 
     578      //       indSrv_[rank].push_back(globalIndexTmp[i]); 
     579      //     } 
     580 
     581      //     if (writtenInd.count(globalIndexTmp[i])) 
     582      //     { 
     583      //       indWrittenSrv_[rank].push_back(globalIndexTmp[i]); 
     584      //     } 
     585      //   } 
     586      // } 
     587 
     588      connectedServerRank_.clear(); 
     589      for (it = indSrv_.begin(); it != ite; ++it) { 
     590        connectedServerRank_.push_back(it->first); 
     591      } 
     592 
     593      // if (!indSrv_.empty()) 
     594      // { 
     595      //   std::map<int, vector<size_t> >::const_iterator itIndSrv  = indSrv_.begin(), 
     596      //                                                  iteIndSrv = indSrv_.end(); 
     597      //   connectedServerRank_.clear(); 
     598      //   for (; itIndSrv != iteIndSrv; ++itIndSrv) 
     599      //     connectedServerRank_.push_back(itIndSrv->first); 
     600      // } 
     601      nbConnectedClients_ = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
     602    } 
    599603  } 
    600604 
     
    744748  { 
    745749    CContext* context = CContext::getCurrent(); 
    746     CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
     750    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    747751     
    748     CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES); 
    749     size_t nbIndex = index.numElements(); 
    750     size_t nbDataIndex = 0; 
    751  
    752     for (int idx = 0; idx < data_index.numElements(); ++idx) 
    753     {       
    754       int ind = data_index(idx); 
    755       if (ind >= 0 && ind < nbIndex) ++nbDataIndex; 
    756     } 
    757  
    758     CArray<int,1> dataIndex(nbDataIndex); 
    759     nbDataIndex = 0; 
    760     for (int idx = 0; idx < data_index.numElements(); ++idx) 
    761     {       
    762       int ind = data_index(idx); 
    763       if (ind >= 0 && ind < nbIndex) 
    764       { 
    765         dataIndex(nbDataIndex) = ind; 
    766         ++nbDataIndex; 
    767       }  
    768     } 
    769  
    770     if (client->isServerLeader()) 
    771     {  
    772       std::list<CMessage> msgs; 
    773  
    774       const std::list<int>& ranks = client->getRanksServerLeader(); 
    775       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    776       { 
    777         msgs.push_back(CMessage()); 
    778         CMessage& msg = msgs.back(); 
    779         msg << this->getId(); 
    780         msg << index.getValue() << dataIndex << zoom_index.getValue() << mask.getValue(); 
    781         msg << hasValue; 
    782         if (hasValue) msg << value.getValue(); 
    783  
    784         msg << hasBounds_; 
    785         if (hasBounds_) msg << bounds.getValue(); 
    786          
    787         event.push(*itRank, 1, msg); 
    788       } 
    789       client->sendEvent(event); 
    790     } 
    791     else client->sendEvent(event); 
     752    for (int i = 0; i < nbSrvPools; ++i) 
     753    { 
     754      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 
     755 
     756      CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES); 
     757      size_t nbIndex = index.numElements(); 
     758      size_t nbDataIndex = 0; 
     759 
     760      for (int idx = 0; idx < data_index.numElements(); ++idx) 
     761      { 
     762        int ind = data_index(idx); 
     763        if (ind >= 0 && ind < nbIndex) ++nbDataIndex; 
     764      } 
     765 
     766      CArray<int,1> dataIndex(nbDataIndex); 
     767      nbDataIndex = 0; 
     768      for (int idx = 0; idx < data_index.numElements(); ++idx) 
     769      { 
     770        int ind = data_index(idx); 
     771        if (ind >= 0 && ind < nbIndex) 
     772        { 
     773          dataIndex(nbDataIndex) = ind; 
     774          ++nbDataIndex; 
     775        } 
     776      } 
     777 
     778      if (client->isServerLeader()) 
     779      { 
     780        std::list<CMessage> msgs; 
     781 
     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          msgs.push_back(CMessage()); 
     786          CMessage& msg = msgs.back(); 
     787          msg << this->getId(); 
     788          msg << index.getValue() << dataIndex << zoom_index.getValue() << mask.getValue(); 
     789          msg << hasValue; 
     790          if (hasValue) msg << value.getValue(); 
     791 
     792          msg << hasBounds_; 
     793          if (hasBounds_) msg << bounds.getValue(); 
     794 
     795          event.push(*itRank, 1, msg); 
     796        } 
     797        client->sendEvent(event); 
     798      } 
     799      else client->sendEvent(event); 
     800    } 
    792801  } 
    793802 
     
    845854    int ns, n, i, j, ind, nv, idx; 
    846855    CContext* context = CContext::getCurrent(); 
    847     CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    848  
    849     CEventClient eventData(getType(), EVENT_ID_DISTRIBUTED_ATTRIBUTES); 
    850      
    851     list<CMessage> listData; 
    852     list<CArray<int,1> > list_indi, list_dataInd, list_zoomInd;     
    853     list<CArray<bool,1> > list_mask; 
    854     list<CArray<double,1> > list_val; 
    855     list<CArray<double,2> > list_bounds; 
    856  
    857     int nbIndex = index.numElements(); 
    858     CArray<int,1> dataIndex(nbIndex); 
    859     dataIndex = -1; 
    860     for (int idx = 0; idx < data_index.numElements(); ++idx) 
    861     { 
    862       if (0 <= data_index(idx) && data_index(idx) < nbIndex) 
    863         dataIndex(idx) = data_index(idx); 
    864     } 
    865  
    866     boost::unordered_map<int, std::vector<size_t> >::const_iterator it, iteMap; 
    867     iteMap = indSrv_.end(); 
    868     for (int k = 0; k < connectedServerRank_.size(); ++k) 
    869     { 
    870       int nbData = 0; 
    871       int rank = connectedServerRank_[k]; 
    872       int nbSendingClient = nbConnectedClients_[rank]; 
    873       it = indSrv_.find(rank); 
    874       if (iteMap != it) 
    875         nbData = it->second.size(); 
    876  
    877       list_indi.push_back(CArray<int,1>(nbData)); 
    878       list_dataInd.push_back(CArray<int,1>(nbData)); 
    879       list_zoomInd.push_back(CArray<int,1>(nbData)); 
    880       list_mask.push_back(CArray<bool,1>(nbData)); 
    881  
    882  
    883       if (hasValue) 
    884         list_val.push_back(CArray<double,1>(nbData)); 
    885  
    886       if (hasBounds_) 
    887       { 
    888         list_bounds.push_back(CArray<double,2>(2,nbData)); 
    889       } 
    890  
    891       CArray<int,1>& indi = list_indi.back(); 
    892       CArray<int,1>& dataIndi = list_dataInd.back(); 
    893       CArray<int,1>& zoomIndi = list_zoomInd.back(); 
    894       CArray<bool,1>& maskIndi = list_mask.back();       
    895  
    896       for (n = 0; n < nbData; ++n) 
    897       { 
    898         idx = static_cast<int>(it->second[n]); 
    899         indi(n) = idx; 
    900  
    901         ind = globalLocalIndexMap_[idx]; 
    902         dataIndi(n) = dataIndex(ind); 
    903         maskIndi(n) = mask(ind); 
    904         zoomIndi(n) = zoom_index(ind);         
     856    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     857 
     858    for (int i = 0; i < nbSrvPools; ++i) 
     859    { 
     860      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 
     861 
     862      CEventClient eventData(getType(), EVENT_ID_DISTRIBUTED_ATTRIBUTES); 
     863 
     864      list<CMessage> listData; 
     865      list<CArray<int,1> > list_indi, list_dataInd, list_zoomInd; 
     866      list<CArray<bool,1> > list_mask; 
     867      list<CArray<double,1> > list_val; 
     868      list<CArray<double,2> > list_bounds; 
     869 
     870      int nbIndex = index.numElements(); 
     871      CArray<int,1> dataIndex(nbIndex); 
     872      dataIndex = -1; 
     873      for (int inx = 0; inx < data_index.numElements(); ++inx) 
     874      { 
     875        if (0 <= data_index(inx) && data_index(inx) < nbIndex) 
     876          dataIndex(inx) = data_index(inx); 
     877      } 
     878 
     879      boost::unordered_map<int, std::vector<size_t> >::const_iterator it, iteMap; 
     880      iteMap = indSrv_.end(); 
     881      for (int k = 0; k < connectedServerRank_.size(); ++k) 
     882      { 
     883        int nbData = 0; 
     884        int rank = connectedServerRank_[k]; 
     885        int nbSendingClient = nbConnectedClients_[rank]; 
     886        it = indSrv_.find(rank); 
     887        if (iteMap != it) 
     888          nbData = it->second.size(); 
     889 
     890        list_indi.push_back(CArray<int,1>(nbData)); 
     891        list_dataInd.push_back(CArray<int,1>(nbData)); 
     892        list_zoomInd.push_back(CArray<int,1>(nbData)); 
     893        list_mask.push_back(CArray<bool,1>(nbData)); 
     894 
    905895 
    906896        if (hasValue) 
    907         { 
    908           CArray<double,1>& val = list_val.back(); 
    909           val(n) = value(ind); 
    910         } 
     897          list_val.push_back(CArray<double,1>(nbData)); 
    911898 
    912899        if (hasBounds_) 
    913900        { 
    914           CArray<double,2>& boundsVal = list_bounds.back(); 
    915           boundsVal(0, n) = bounds(0,n); 
    916           boundsVal(1, n) = bounds(1,n); 
    917         } 
    918       } 
    919  
    920       listData.push_back(CMessage()); 
    921       listData.back() << this->getId()   
    922                       << list_indi.back() << list_dataInd.back() << list_zoomInd.back() << list_mask.back() 
    923                       << hasValue; 
    924       if (hasValue) 
    925         listData.back() << list_val.back(); 
    926       listData.back() << hasBounds_; 
    927       if (hasBounds_) 
    928         listData.back() << list_bounds.back(); 
    929  
    930       eventData.push(rank, nbConnectedClients_[rank], listData.back()); 
    931     } 
    932  
    933     client->sendEvent(eventData); 
     901          list_bounds.push_back(CArray<double,2>(2,nbData)); 
     902        } 
     903 
     904        CArray<int,1>& indi = list_indi.back(); 
     905        CArray<int,1>& dataIndi = list_dataInd.back(); 
     906        CArray<int,1>& zoomIndi = list_zoomInd.back(); 
     907        CArray<bool,1>& maskIndi = list_mask.back(); 
     908 
     909        for (n = 0; n < nbData; ++n) 
     910        { 
     911          idx = static_cast<int>(it->second[n]); 
     912          indi(n) = idx; 
     913 
     914          ind = globalLocalIndexMap_[idx]; 
     915          dataIndi(n) = dataIndex(ind); 
     916          maskIndi(n) = mask(ind); 
     917          zoomIndi(n) = zoom_index(ind); 
     918 
     919          if (hasValue) 
     920          { 
     921            CArray<double,1>& val = list_val.back(); 
     922            val(n) = value(ind); 
     923          } 
     924 
     925          if (hasBounds_) 
     926          { 
     927            CArray<double,2>& boundsVal = list_bounds.back(); 
     928            boundsVal(0, n) = bounds(0,n); 
     929            boundsVal(1, n) = bounds(1,n); 
     930          } 
     931        } 
     932 
     933        listData.push_back(CMessage()); 
     934        listData.back() << this->getId() 
     935                        << list_indi.back() << list_dataInd.back() << list_zoomInd.back() << list_mask.back() 
     936                        << hasValue; 
     937        if (hasValue) 
     938          listData.back() << list_val.back(); 
     939        listData.back() << hasBounds_; 
     940        if (hasBounds_) 
     941          listData.back() << list_bounds.back(); 
     942 
     943        eventData.push(rank, nbConnectedClients_[rank], listData.back()); 
     944      } 
     945 
     946      client->sendEvent(eventData); 
     947    } 
    934948  } 
    935949 
     
    11141128  //   *buffer >> axisId; 
    11151129  //   get(axisId)->recvServerAttribut(*buffer); 
    1116     { 
    1117       CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] 
    1118     } 
    11191130 
    11201131  //   CContext* context = CContext::getCurrent(); 
  • XIOS/dev/dev_olga/src/node/context.cpp

    r1025 r1027  
    519519   void CContext::sendPostProcessingGlobalAttributes() 
    520520   { 
    521          // Use correct context client to send message 
    522      CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client; 
    523      CEventClient event(getType(),EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES); 
    524  
    525      if (contextClientTmp->isServerLeader()) 
    526      { 
    527        CMessage msg; 
    528        msg<<this->getIdServer(); 
    529        const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
    530        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    531          event.push(*itRank,1,msg); 
    532        contextClientTmp->sendEvent(event); 
    533      } 
    534      else contextClientTmp->sendEvent(event); 
     521      // Use correct context client to send message 
     522     int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1; 
     523     for (int i = 0; i < nbSrvPools; ++i) 
     524     { 
     525       CContextClient* contextClientTmp = (0 != clientPrimServer.size()) ? clientPrimServer[i] : client; 
     526       CEventClient event(getType(),EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES); 
     527 
     528       if (contextClientTmp->isServerLeader()) 
     529       { 
     530         CMessage msg; 
     531         msg<<this->getIdServer(); 
     532         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
     533         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     534           event.push(*itRank,1,msg); 
     535         contextClientTmp->sendEvent(event); 
     536       } 
     537       else contextClientTmp->sendEvent(event); 
     538     } 
    535539   } 
    536540 
     
    10281032   { 
    10291033      // Use correct context client to send message 
    1030      CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client; 
    1031      CEventClient event(getType(),EVENT_ID_PROCESS_GRID_ENABLED_FIELDS); 
    1032  
    1033      if (contextClientTmp->isServerLeader()) 
    1034      { 
    1035        CMessage msg; 
    1036        msg<<this->getIdServer(); 
    1037        const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
    1038        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1039          event.push(*itRank,1,msg); 
    1040        contextClientTmp->sendEvent(event); 
    1041      } 
    1042      else contextClientTmp->sendEvent(event); 
     1034     int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1; 
     1035     for (int i = 0; i < nbSrvPools; ++i) 
     1036     { 
     1037       CContextClient* contextClientTmp = (0 != clientPrimServer.size()) ? clientPrimServer[i] : client; 
     1038       CEventClient event(getType(),EVENT_ID_PROCESS_GRID_ENABLED_FIELDS); 
     1039 
     1040       if (contextClientTmp->isServerLeader()) 
     1041       { 
     1042         CMessage msg; 
     1043         msg<<this->getIdServer(); 
     1044         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
     1045         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     1046           event.push(*itRank,1,msg); 
     1047         contextClientTmp->sendEvent(event); 
     1048       } 
     1049       else contextClientTmp->sendEvent(event); 
     1050     } 
    10431051   } 
    10441052 
  • XIOS/dev/dev_olga/src/node/domain.cpp

    r1025 r1027  
    14951495  { 
    14961496    CContext* context=CContext::getCurrent() ; 
    1497     CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    1498     int nbServer=client->serverSize; 
    1499     int rank = client->clientRank; 
    1500     bool doComputeGlobalIndexServer = true; 
    1501  
    1502     int i,j,i_ind,j_ind, nbIndex, nbIndexZoom; 
    1503     int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 
    1504     int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; 
    1505  
    1506     // Precompute number of index 
    1507     int globalIndexCountZoom = 0; 
    1508     nbIndex = i_index.numElements(); 
    1509     // for (i = 0; i < nbIndex; ++i) 
    1510     // { 
    1511     //   i_ind=i_index(i); 
    1512     //   j_ind=j_index(i); 
    1513  
    1514     //   if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1515     //   { 
    1516     //     ++globalIndexCountZoom; 
    1517     //   } 
    1518     // } 
    1519  
    1520     // int globalIndexWrittenCount = 0; 
    1521     // if (isCompressible_) 
    1522     // { 
    1523     //   for (i = 0; i < data_i_index.numElements(); ++i) 
    1524     //   { 
    1525     //     i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 
    1526     //                                                 data_ibegin, data_jbegin, data_dim, ni, 
    1527     //                                                 j_ind); 
    1528     //     if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 
    1529     //     { 
    1530     //       i_ind += ibegin; 
    1531     //       j_ind += jbegin; 
    1532     //       if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1533     //         ++globalIndexWrittenCount; 
    1534     //     } 
    1535     //   } 
    1536     // } 
    1537  
    1538     // Fill in index 
    1539      
    1540     CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); 
    1541     CArray<size_t,1> globalIndexDomain(nbIndex); 
    1542     size_t globalIndex; 
    1543     int globalIndexCount = 0; 
    1544      
    1545  
    1546     for (i = 0; i < nbIndex; ++i) 
    1547     { 
    1548       i_ind=i_index(i); 
    1549       j_ind=j_index(i); 
    1550       globalIndex = i_ind + j_ind * ni_glo; 
    1551       globalIndexDomain(globalIndexCount) = globalIndex; 
    1552       globalLocalIndexMap_[globalIndex] = i; 
    1553       ++globalIndexCount; 
    1554     } 
    1555  
    1556     nbIndexZoom = zoom_i_index.numElements(); 
    1557     CArray<size_t,1> globalIndexDomainZoom(nbIndexZoom); 
    1558     globalIndexCountZoom = 0; 
    1559     for (i = 0; i < nbIndexZoom; ++i) 
    1560     { 
    1561       i_ind=zoom_i_index(i); 
    1562       j_ind=zoom_j_index(i); 
    1563       globalIndex = i_ind + j_ind * ni_glo; 
    1564       globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
    1565  
    1566       ++globalIndexCountZoom; 
    1567       // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     1497    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     1498    for (int i = 0; i < nbSrvPools; ++i) 
     1499    { 
     1500      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 
     1501      int nbServer=client->serverSize; 
     1502      int rank = client->clientRank; 
     1503      bool doComputeGlobalIndexServer = true; 
     1504 
     1505      int i,j,i_ind,j_ind, nbIndex, nbIndexZoom; 
     1506      int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 
     1507      int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; 
     1508 
     1509      // Precompute number of index 
     1510      int globalIndexCountZoom = 0; 
     1511      nbIndex = i_index.numElements(); 
     1512      // for (i = 0; i < nbIndex; ++i) 
    15681513      // { 
    1569       //   globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
    1570       //   localIndexDomainZoom(globalIndexCountZoom) = i; 
    1571       //   ++globalIndexCountZoom; 
     1514      //   i_ind=i_index(i); 
     1515      //   j_ind=j_index(i); 
     1516 
     1517      //   if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     1518      //   { 
     1519      //     ++globalIndexCountZoom; 
     1520      //   } 
    15721521      // } 
    1573     } 
    1574  
    1575     // CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); 
    1576     // if (isCompressible_) 
    1577     // { 
    1578     //   globalIndexWrittenCount = 0; 
    1579     //   for (i = 0; i < data_i_index.numElements(); ++i) 
    1580     //   { 
    1581     //     i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 
    1582     //                                                 data_ibegin, data_jbegin, data_dim, ni, 
    1583     //                                                 j_ind); 
    1584     //     if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 
    1585     //     { 
    1586     //       i_ind += ibegin; 
    1587     //       j_ind += jbegin; 
    1588     //       if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1589     //       { 
    1590     //         globalIndexWrittenDomain(globalIndexWrittenCount) = i_ind + j_ind * ni_glo; 
    1591     //         ++globalIndexWrittenCount; 
    1592     //       } 
    1593     //     } 
    1594     //   } 
    1595     // } 
    1596  
    1597     size_t globalSizeIndex = 1, indexBegin, indexEnd; 
    1598     int range, clientSize = client->clientSize; 
    1599     std::vector<int> nGlobDomain(2); 
    1600     nGlobDomain[0] = this->ni_glo; 
    1601     nGlobDomain[1] = this->nj_glo; 
    1602     for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 
    1603     indexBegin = 0; 
    1604     if (globalSizeIndex <= clientSize) 
    1605     { 
    1606       indexBegin = rank%globalSizeIndex; 
    1607       indexEnd = indexBegin; 
    1608     } 
    1609     else 
    1610     { 
    1611       for (int i = 0; i < clientSize; ++i) 
    1612       { 
    1613         range = globalSizeIndex / clientSize; 
    1614         if (i < (globalSizeIndex%clientSize)) ++range; 
    1615         if (i == client->clientRank) break; 
    1616         indexBegin += range; 
    1617       } 
    1618       indexEnd = indexBegin + range - 1; 
    1619     } 
    1620  
    1621     CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 
    1622     if (isUnstructed_) serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); 
    1623     else serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1); 
    1624  
    1625     CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), 
    1626                                                                                 client->intraComm); 
    1627     clientServerMap->computeServerIndexMapping(globalIndexDomain); 
    1628     CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 
    1629  
    1630     CClientServerMapping::GlobalIndexMap::const_iterator it  = globalIndexDomainOnServer.begin(), 
    1631                                                          ite = globalIndexDomainOnServer.end(); 
    1632     // typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
    1633     // std::vector<int>::iterator itVec; 
    1634      
    1635     // indSrv_.clear(); 
    1636     // indWrittenSrv_.clear(); 
    1637     // for (; it != ite; ++it) 
    1638     // { 
    1639     //   int rank = it->first; 
    1640     //   int indexSize = it->second.size(); 
    1641     //   std::vector<int> permutIndex(indexSize); 
    1642     //   XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 
    1643     //   XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(it->second, permutIndex); 
    1644     //   BinarySearch binSearch(it->second); 
    1645     //   int nb = globalIndexDomainZoom.numElements(); 
    1646     //   for (int i = 0; i < nb; ++i) 
    1647     //   { 
    1648     //     if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexDomainZoom(i), itVec)) 
    1649     //     { 
    1650     //       indSrv_[rank].push_back(localIndexDomainZoom(i)); 
    1651     //     } 
    1652     //   } 
    1653     //   for (int i = 0; i < globalIndexWrittenDomain.numElements(); ++i) 
    1654     //   { 
    1655     //     if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexWrittenDomain(i), itVec)) 
    1656     //     { 
    1657     //       indWrittenSrv_[rank].push_back(globalIndexWrittenDomain(i)); 
    1658     //     } 
    1659     //   } 
    1660     // } 
    1661  
    1662     connectedServerRank_.clear(); 
    1663     for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { 
    1664       connectedServerRank_.push_back(it->first); 
    1665     } 
    1666  
    1667     indSrv_.swap(globalIndexDomainOnServer); 
    1668     nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    1669  
    1670     clientServerMap->computeServerIndexMapping(globalIndexDomainZoom); 
    1671     CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); 
    1672     indZoomSrv_.swap(globalIndexDomainZoomOnServer); 
    1673     std::vector<int> connectedServerZoomRank(indZoomSrv_.size()); 
    1674     for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 
    1675       connectedServerZoomRank.push_back(it->first); 
    1676     nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank);        
    1677  
    1678     delete clientServerMap; 
     1522 
     1523      // int globalIndexWrittenCount = 0; 
     1524      // if (isCompressible_) 
     1525      // { 
     1526      //   for (i = 0; i < data_i_index.numElements(); ++i) 
     1527      //   { 
     1528      //     i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 
     1529      //                                                 data_ibegin, data_jbegin, data_dim, ni, 
     1530      //                                                 j_ind); 
     1531      //     if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 
     1532      //     { 
     1533      //       i_ind += ibegin; 
     1534      //       j_ind += jbegin; 
     1535      //       if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     1536      //         ++globalIndexWrittenCount; 
     1537      //     } 
     1538      //   } 
     1539      // } 
     1540 
     1541      // Fill in index 
     1542 
     1543      CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); 
     1544      CArray<size_t,1> globalIndexDomain(nbIndex); 
     1545      size_t globalIndex; 
     1546      int globalIndexCount = 0; 
     1547 
     1548 
     1549      for (i = 0; i < nbIndex; ++i) 
     1550      { 
     1551        i_ind=i_index(i); 
     1552        j_ind=j_index(i); 
     1553        globalIndex = i_ind + j_ind * ni_glo; 
     1554        globalIndexDomain(globalIndexCount) = globalIndex; 
     1555        globalLocalIndexMap_[globalIndex] = i; 
     1556        ++globalIndexCount; 
     1557      } 
     1558 
     1559      nbIndexZoom = zoom_i_index.numElements(); 
     1560      CArray<size_t,1> globalIndexDomainZoom(nbIndexZoom); 
     1561      globalIndexCountZoom = 0; 
     1562      for (i = 0; i < nbIndexZoom; ++i) 
     1563      { 
     1564        i_ind=zoom_i_index(i); 
     1565        j_ind=zoom_j_index(i); 
     1566        globalIndex = i_ind + j_ind * ni_glo; 
     1567        globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
     1568 
     1569        ++globalIndexCountZoom; 
     1570        // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     1571        // { 
     1572        //   globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
     1573        //   localIndexDomainZoom(globalIndexCountZoom) = i; 
     1574        //   ++globalIndexCountZoom; 
     1575        // } 
     1576      } 
     1577 
     1578      // CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); 
     1579      // if (isCompressible_) 
     1580      // { 
     1581      //   globalIndexWrittenCount = 0; 
     1582      //   for (i = 0; i < data_i_index.numElements(); ++i) 
     1583      //   { 
     1584      //     i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 
     1585      //                                                 data_ibegin, data_jbegin, data_dim, ni, 
     1586      //                                                 j_ind); 
     1587      //     if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 
     1588      //     { 
     1589      //       i_ind += ibegin; 
     1590      //       j_ind += jbegin; 
     1591      //       if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     1592      //       { 
     1593      //         globalIndexWrittenDomain(globalIndexWrittenCount) = i_ind + j_ind * ni_glo; 
     1594      //         ++globalIndexWrittenCount; 
     1595      //       } 
     1596      //     } 
     1597      //   } 
     1598      // } 
     1599 
     1600      size_t globalSizeIndex = 1, indexBegin, indexEnd; 
     1601      int range, clientSize = client->clientSize; 
     1602      std::vector<int> nGlobDomain(2); 
     1603      nGlobDomain[0] = this->ni_glo; 
     1604      nGlobDomain[1] = this->nj_glo; 
     1605      for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 
     1606      indexBegin = 0; 
     1607      if (globalSizeIndex <= clientSize) 
     1608      { 
     1609        indexBegin = rank%globalSizeIndex; 
     1610        indexEnd = indexBegin; 
     1611      } 
     1612      else 
     1613      { 
     1614        for (int i = 0; i < clientSize; ++i) 
     1615        { 
     1616          range = globalSizeIndex / clientSize; 
     1617          if (i < (globalSizeIndex%clientSize)) ++range; 
     1618          if (i == client->clientRank) break; 
     1619          indexBegin += range; 
     1620        } 
     1621        indexEnd = indexBegin + range - 1; 
     1622      } 
     1623 
     1624      CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 
     1625      if (isUnstructed_) serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); 
     1626      else serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1); 
     1627 
     1628      CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), 
     1629                                                                                  client->intraComm); 
     1630      clientServerMap->computeServerIndexMapping(globalIndexDomain); 
     1631      CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 
     1632 
     1633      CClientServerMapping::GlobalIndexMap::const_iterator it  = globalIndexDomainOnServer.begin(), 
     1634                                                           ite = globalIndexDomainOnServer.end(); 
     1635      // typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
     1636      // std::vector<int>::iterator itVec; 
     1637 
     1638      // indSrv_.clear(); 
     1639      // indWrittenSrv_.clear(); 
     1640      // for (; it != ite; ++it) 
     1641      // { 
     1642      //   int rank = it->first; 
     1643      //   int indexSize = it->second.size(); 
     1644      //   std::vector<int> permutIndex(indexSize); 
     1645      //   XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 
     1646      //   XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(it->second, permutIndex); 
     1647      //   BinarySearch binSearch(it->second); 
     1648      //   int nb = globalIndexDomainZoom.numElements(); 
     1649      //   for (int i = 0; i < nb; ++i) 
     1650      //   { 
     1651      //     if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexDomainZoom(i), itVec)) 
     1652      //     { 
     1653      //       indSrv_[rank].push_back(localIndexDomainZoom(i)); 
     1654      //     } 
     1655      //   } 
     1656      //   for (int i = 0; i < globalIndexWrittenDomain.numElements(); ++i) 
     1657      //   { 
     1658      //     if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexWrittenDomain(i), itVec)) 
     1659      //     { 
     1660      //       indWrittenSrv_[rank].push_back(globalIndexWrittenDomain(i)); 
     1661      //     } 
     1662      //   } 
     1663      // } 
     1664 
     1665      connectedServerRank_.clear(); 
     1666      for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { 
     1667        connectedServerRank_.push_back(it->first); 
     1668      } 
     1669 
     1670      indSrv_.swap(globalIndexDomainOnServer); 
     1671      nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
     1672 
     1673      clientServerMap->computeServerIndexMapping(globalIndexDomainZoom); 
     1674      CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); 
     1675      indZoomSrv_.swap(globalIndexDomainZoomOnServer); 
     1676      std::vector<int> connectedServerZoomRank(indZoomSrv_.size()); 
     1677      for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 
     1678        connectedServerZoomRank.push_back(it->first); 
     1679      nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank); 
     1680 
     1681      delete clientServerMap; 
     1682    } 
    16791683  } 
    16801684 
     
    17061710    int ns, n, i, j, ind, nv, idx; 
    17071711    CContext* context = CContext::getCurrent(); 
    1708     CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    1709  
    1710     CEventClient eventIndex(getType(), EVENT_ID_INDEX); 
    1711  
    1712     list<CMessage> list_msgsIndex; 
    1713     list<CArray<int,1> > list_indZoom, list_writtenInd, list_indGlob; 
    1714  
    1715     boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex, itZoom, iteZoom; 
    1716     iteIndex = indSrv_.end(); iteZoom = indZoomSrv_.end(); 
    1717     for (int k = 0; k < connectedServerRank_.size(); ++k) 
    1718     { 
    1719       int nbIndGlob = 0; 
    1720       int rank = connectedServerRank_[k]; 
    1721       itIndex = indSrv_.find(rank); 
    1722       if (iteIndex != itIndex) 
    1723         nbIndGlob = itIndex->second.size(); 
    1724       int nbIndZoom = 0; 
    1725       itZoom = indZoomSrv_.find(rank); 
    1726       if (iteZoom != itZoom) 
    1727         nbIndZoom = itZoom->second.size();  
    1728  
    1729       list_indGlob.push_back(CArray<int,1>(nbIndGlob)); 
    1730       list_indZoom.push_back(CArray<int,1>(nbIndZoom)); 
    1731  
    1732       CArray<int,1>& indZoom = list_indZoom.back(); 
    1733       CArray<int,1>& indGlob = list_indGlob.back();       
    1734       for (n = 0; n < nbIndGlob; ++n) 
    1735       { 
    1736         indGlob(n) = static_cast<int>(itIndex->second[n]);         
    1737       } 
    1738  
    1739       for (n = 0; n < nbIndZoom; ++n) 
    1740       { 
    1741         indZoom(n) = static_cast<int>(itZoom->second[n]);         
    1742       } 
    1743  
    1744       list_msgsIndex.push_back(CMessage()); 
    1745       list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 
    1746       list_msgsIndex.back() << isCurvilinear; 
    1747       list_msgsIndex.back() << list_indGlob.back() << list_indZoom.back(); //list_indi.back() << list_indj.back(); 
    1748  
    1749       // if (isCompressible_) 
    1750       // { 
    1751       //   std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 
    1752       //   list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 
    1753       //   CArray<int,1>& writtenInd = list_writtenInd.back(); 
    1754  
    1755       //   for (n = 0; n < writtenInd.numElements(); ++n) 
    1756       //     writtenInd(n) = writtenIndSrc[n]; 
    1757  
    1758       //   list_msgsIndex.back() << writtenInd; 
    1759       // } 
    1760  
    1761       eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 
    1762     } 
    1763  
    1764     client->sendEvent(eventIndex); 
     1712    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     1713    for (int i = 0; i < nbSrvPools; ++i) 
     1714    { 
     1715      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 
     1716 
     1717      CEventClient eventIndex(getType(), EVENT_ID_INDEX); 
     1718 
     1719      list<CMessage> list_msgsIndex; 
     1720      list<CArray<int,1> > list_indZoom, list_writtenInd, list_indGlob; 
     1721 
     1722      boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex, itZoom, iteZoom; 
     1723      iteIndex = indSrv_.end(); iteZoom = indZoomSrv_.end(); 
     1724      for (int k = 0; k < connectedServerRank_.size(); ++k) 
     1725      { 
     1726        int nbIndGlob = 0; 
     1727        int rank = connectedServerRank_[k]; 
     1728        itIndex = indSrv_.find(rank); 
     1729        if (iteIndex != itIndex) 
     1730          nbIndGlob = itIndex->second.size(); 
     1731        int nbIndZoom = 0; 
     1732        itZoom = indZoomSrv_.find(rank); 
     1733        if (iteZoom != itZoom) 
     1734          nbIndZoom = itZoom->second.size(); 
     1735 
     1736        list_indGlob.push_back(CArray<int,1>(nbIndGlob)); 
     1737        list_indZoom.push_back(CArray<int,1>(nbIndZoom)); 
     1738 
     1739        CArray<int,1>& indZoom = list_indZoom.back(); 
     1740        CArray<int,1>& indGlob = list_indGlob.back(); 
     1741        for (n = 0; n < nbIndGlob; ++n) 
     1742        { 
     1743          indGlob(n) = static_cast<int>(itIndex->second[n]); 
     1744        } 
     1745 
     1746        for (n = 0; n < nbIndZoom; ++n) 
     1747        { 
     1748          indZoom(n) = static_cast<int>(itZoom->second[n]); 
     1749        } 
     1750 
     1751        list_msgsIndex.push_back(CMessage()); 
     1752        list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 
     1753        list_msgsIndex.back() << isCurvilinear; 
     1754        list_msgsIndex.back() << list_indGlob.back() << list_indZoom.back(); //list_indi.back() << list_indj.back(); 
     1755 
     1756        // if (isCompressible_) 
     1757        // { 
     1758        //   std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 
     1759        //   list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 
     1760        //   CArray<int,1>& writtenInd = list_writtenInd.back(); 
     1761 
     1762        //   for (n = 0; n < writtenInd.numElements(); ++n) 
     1763        //     writtenInd(n) = writtenIndSrc[n]; 
     1764 
     1765        //   list_msgsIndex.back() << writtenInd; 
     1766        // } 
     1767 
     1768        eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 
     1769      } 
     1770 
     1771      client->sendEvent(eventIndex); 
     1772    } 
    17651773  } 
    17661774 
     
    17721780    int ns, n, i, j, ind, nv, idx; 
    17731781    CContext* context = CContext::getCurrent(); 
    1774     CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    1775  
    1776     // send area for each connected server 
    1777     CEventClient eventMask(getType(), EVENT_ID_MASK); 
    1778  
    1779     list<CMessage> list_msgsMask; 
    1780     list<CArray<bool,1> > list_mask; 
    1781  
    1782     boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    1783     iteMap = indSrv_.end(); 
    1784     for (int k = 0; k < connectedServerRank_.size(); ++k) 
    1785     { 
    1786       int nbData = 0; 
    1787       int rank = connectedServerRank_[k]; 
    1788       it = indSrv_.find(rank); 
    1789       if (iteMap != it) 
    1790         nbData = it->second.size(); 
    1791       list_mask.push_back(CArray<bool,1>(nbData)); 
    1792  
    1793       const std::vector<size_t>& temp = it->second; 
    1794       for (n = 0; n < nbData; ++n) 
    1795       { 
    1796         idx = static_cast<int>(it->second[n]); 
    1797         list_mask.back()(n) = mask_1d(globalLocalIndexMap_[idx]);           
    1798       } 
    1799  
    1800       list_msgsMask.push_back(CMessage()); 
    1801       list_msgsMask.back() << this->getId() << list_mask.back(); 
    1802       eventMask.push(rank, nbConnectedClients_[rank], list_msgsMask.back()); 
    1803     } 
    1804     client->sendEvent(eventMask); 
     1782    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     1783    for (int i = 0; i < nbSrvPools; ++i) 
     1784    { 
     1785      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 
     1786 
     1787      // send area for each connected server 
     1788      CEventClient eventMask(getType(), EVENT_ID_MASK); 
     1789 
     1790      list<CMessage> list_msgsMask; 
     1791      list<CArray<bool,1> > list_mask; 
     1792 
     1793      boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
     1794      iteMap = indSrv_.end(); 
     1795      for (int k = 0; k < connectedServerRank_.size(); ++k) 
     1796      { 
     1797        int nbData = 0; 
     1798        int rank = connectedServerRank_[k]; 
     1799        it = indSrv_.find(rank); 
     1800        if (iteMap != it) 
     1801          nbData = it->second.size(); 
     1802        list_mask.push_back(CArray<bool,1>(nbData)); 
     1803 
     1804        const std::vector<size_t>& temp = it->second; 
     1805        for (n = 0; n < nbData; ++n) 
     1806        { 
     1807          idx = static_cast<int>(it->second[n]); 
     1808          list_mask.back()(n) = mask_1d(globalLocalIndexMap_[idx]); 
     1809        } 
     1810 
     1811        list_msgsMask.push_back(CMessage()); 
     1812        list_msgsMask.back() << this->getId() << list_mask.back(); 
     1813        eventMask.push(rank, nbConnectedClients_[rank], list_msgsMask.back()); 
     1814      } 
     1815      client->sendEvent(eventMask); 
     1816    } 
    18051817  } 
    18061818 
     
    18141826    int ns, n, i, j, ind, nv, idx; 
    18151827    CContext* context = CContext::getCurrent(); 
    1816     CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    1817  
    1818     // send area for each connected server 
    1819     CEventClient eventArea(getType(), EVENT_ID_AREA); 
    1820  
    1821     list<CMessage> list_msgsArea; 
    1822     list<CArray<double,1> > list_area; 
    1823  
    1824     boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    1825     iteMap = indSrv_.end(); 
    1826     for (int k = 0; k < connectedServerRank_.size(); ++k) 
    1827     { 
    1828       int nbData = 0; 
    1829       int rank = connectedServerRank_[k]; 
    1830       it = indSrv_.find(rank); 
    1831       if (iteMap != it) 
    1832         nbData = it->second.size(); 
    1833       list_area.push_back(CArray<double,1>(nbData)); 
    1834  
    1835       const std::vector<size_t>& temp = it->second; 
    1836       for (n = 0; n < nbData; ++n) 
    1837       { 
    1838         idx = static_cast<int>(it->second[n]); 
    1839         list_area.back()(n) = areavalue(globalLocalIndexMap_[idx]);  
    1840       } 
    1841  
    1842       list_msgsArea.push_back(CMessage()); 
    1843       list_msgsArea.back() << this->getId() << hasArea; 
    1844       list_msgsArea.back() << list_area.back(); 
    1845       eventArea.push(rank, nbConnectedClients_[rank], list_msgsArea.back()); 
    1846     } 
    1847     client->sendEvent(eventArea); 
     1828    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     1829    for (int i = 0; i < nbSrvPools; ++i) 
     1830    { 
     1831      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 
     1832 
     1833      // send area for each connected server 
     1834      CEventClient eventArea(getType(), EVENT_ID_AREA); 
     1835 
     1836      list<CMessage> list_msgsArea; 
     1837      list<CArray<double,1> > list_area; 
     1838 
     1839      boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
     1840      iteMap = indSrv_.end(); 
     1841      for (int k = 0; k < connectedServerRank_.size(); ++k) 
     1842      { 
     1843        int nbData = 0; 
     1844        int rank = connectedServerRank_[k]; 
     1845        it = indSrv_.find(rank); 
     1846        if (iteMap != it) 
     1847          nbData = it->second.size(); 
     1848        list_area.push_back(CArray<double,1>(nbData)); 
     1849 
     1850        const std::vector<size_t>& temp = it->second; 
     1851        for (n = 0; n < nbData; ++n) 
     1852        { 
     1853          idx = static_cast<int>(it->second[n]); 
     1854          list_area.back()(n) = areavalue(globalLocalIndexMap_[idx]); 
     1855        } 
     1856 
     1857        list_msgsArea.push_back(CMessage()); 
     1858        list_msgsArea.back() << this->getId() << hasArea; 
     1859        list_msgsArea.back() << list_area.back(); 
     1860        eventArea.push(rank, nbConnectedClients_[rank], list_msgsArea.back()); 
     1861      } 
     1862      client->sendEvent(eventArea); 
     1863    } 
    18481864  } 
    18491865 
     
    18591875    int ns, n, i, j, ind, nv, idx; 
    18601876    CContext* context = CContext::getCurrent(); 
    1861     CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    1862  
    1863     // send lon lat for each connected server 
    1864     CEventClient eventLon(getType(), EVENT_ID_LON); 
    1865     CEventClient eventLat(getType(), EVENT_ID_LAT); 
    1866  
    1867     list<CMessage> list_msgsLon, list_msgsLat; 
    1868     list<CArray<double,1> > list_lon, list_lat; 
    1869     list<CArray<double,2> > list_boundslon, list_boundslat; 
    1870  
    1871     boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    1872     iteMap = indSrv_.end(); 
    1873     for (int k = 0; k < connectedServerRank_.size(); ++k) 
    1874     { 
    1875       int nbData = 0; 
    1876       int rank = connectedServerRank_[k]; 
    1877       it = indSrv_.find(rank); 
    1878       if (iteMap != it) 
    1879         nbData = it->second.size(); 
    1880  
    1881       list_lon.push_back(CArray<double,1>(nbData)); 
    1882       list_lat.push_back(CArray<double,1>(nbData)); 
    1883  
    1884       if (hasBounds) 
    1885       { 
    1886         list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); 
    1887         list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 
    1888       } 
    1889  
    1890       CArray<double,1>& lon = list_lon.back(); 
    1891       CArray<double,1>& lat = list_lat.back(); 
    1892       const std::vector<size_t>& temp = it->second; 
    1893       for (n = 0; n < nbData; ++n) 
    1894       { 
    1895         idx = static_cast<int>(it->second[n]); 
    1896         int localInd = globalLocalIndexMap_[idx]; 
    1897         lon(n) = lonvalue(localInd); 
    1898         lat(n) = latvalue(localInd); 
     1877    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     1878    for (int i = 0; i < nbSrvPools; ++i) 
     1879    { 
     1880      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 
     1881 
     1882      // send lon lat for each connected server 
     1883      CEventClient eventLon(getType(), EVENT_ID_LON); 
     1884      CEventClient eventLat(getType(), EVENT_ID_LAT); 
     1885 
     1886      list<CMessage> list_msgsLon, list_msgsLat; 
     1887      list<CArray<double,1> > list_lon, list_lat; 
     1888      list<CArray<double,2> > list_boundslon, list_boundslat; 
     1889 
     1890      boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
     1891      iteMap = indSrv_.end(); 
     1892      for (int k = 0; k < connectedServerRank_.size(); ++k) 
     1893      { 
     1894        int nbData = 0; 
     1895        int rank = connectedServerRank_[k]; 
     1896        it = indSrv_.find(rank); 
     1897        if (iteMap != it) 
     1898          nbData = it->second.size(); 
     1899 
     1900        list_lon.push_back(CArray<double,1>(nbData)); 
     1901        list_lat.push_back(CArray<double,1>(nbData)); 
    18991902 
    19001903        if (hasBounds) 
    19011904        { 
    1902           CArray<double,2>& boundslon = list_boundslon.back(); 
    1903           CArray<double,2>& boundslat = list_boundslat.back(); 
    1904  
    1905           for (nv = 0; nv < nvertex; ++nv) 
     1905          list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); 
     1906          list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 
     1907        } 
     1908 
     1909        CArray<double,1>& lon = list_lon.back(); 
     1910        CArray<double,1>& lat = list_lat.back(); 
     1911        const std::vector<size_t>& temp = it->second; 
     1912        for (n = 0; n < nbData; ++n) 
     1913        { 
     1914          idx = static_cast<int>(it->second[n]); 
     1915          int localInd = globalLocalIndexMap_[idx]; 
     1916          lon(n) = lonvalue(localInd); 
     1917          lat(n) = latvalue(localInd); 
     1918 
     1919          if (hasBounds) 
    19061920          { 
    1907             boundslon(nv, n) = bounds_lonvalue(nv, localInd); 
    1908             boundslat(nv, n) = bounds_latvalue(nv, localInd); 
     1921            CArray<double,2>& boundslon = list_boundslon.back(); 
     1922            CArray<double,2>& boundslat = list_boundslat.back(); 
     1923 
     1924            for (nv = 0; nv < nvertex; ++nv) 
     1925            { 
     1926              boundslon(nv, n) = bounds_lonvalue(nv, localInd); 
     1927              boundslat(nv, n) = bounds_latvalue(nv, localInd); 
     1928            } 
    19091929          } 
    19101930        } 
    1911       } 
    1912  
    1913       list_msgsLon.push_back(CMessage()); 
    1914       list_msgsLat.push_back(CMessage()); 
    1915  
    1916       list_msgsLon.back() << this->getId() << hasLonLat << list_lon.back() << hasBounds; 
    1917       list_msgsLat.back() << this->getId() << hasLonLat << list_lat.back() << hasBounds; 
    1918  
    1919       if (hasBounds) 
    1920       { 
    1921         list_msgsLon.back() << list_boundslon.back(); 
    1922         list_msgsLat.back() << list_boundslat.back(); 
    1923       } 
    1924  
    1925       eventLon.push(rank, nbConnectedClients_[rank], list_msgsLon.back()); 
    1926       eventLat.push(rank, nbConnectedClients_[rank], list_msgsLat.back()); 
    1927     } 
    1928  
    1929     client->sendEvent(eventLon); 
    1930     client->sendEvent(eventLat); 
     1931 
     1932        list_msgsLon.push_back(CMessage()); 
     1933        list_msgsLat.push_back(CMessage()); 
     1934 
     1935        list_msgsLon.back() << this->getId() << hasLonLat << list_lon.back() << hasBounds; 
     1936        list_msgsLat.back() << this->getId() << hasLonLat << list_lat.back() << hasBounds; 
     1937 
     1938        if (hasBounds) 
     1939        { 
     1940          list_msgsLon.back() << list_boundslon.back(); 
     1941          list_msgsLat.back() << list_boundslat.back(); 
     1942        } 
     1943 
     1944        eventLon.push(rank, nbConnectedClients_[rank], list_msgsLon.back()); 
     1945        eventLat.push(rank, nbConnectedClients_[rank], list_msgsLat.back()); 
     1946      } 
     1947 
     1948      client->sendEvent(eventLon); 
     1949      client->sendEvent(eventLat); 
     1950    } 
    19311951  } 
    19321952 
     
    19401960    int ns, n, i, j, ind, nv, idx; 
    19411961    CContext* context = CContext::getCurrent(); 
    1942     CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    1943  
    1944     // send area for each connected server 
    1945     CEventClient eventDataIndex(getType(), EVENT_ID_DATA_INDEX); 
    1946  
    1947     list<CMessage> list_msgsDataIndex; 
    1948     list<CArray<int,1> > list_data_i_index, list_data_j_index; 
    1949  
    1950     int nbIndex = i_index.numElements(); 
    1951     CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 
    1952     dataIIndex = -1; dataJIndex = -1, ind = 0; 
    1953     for (idx = 0; idx < data_i_index.numElements(); ++idx) 
    1954     { 
    1955       if ((0 <= data_i_index(idx)) && (data_i_index(idx) < ni) && (ind < nbIndex)) 
    1956       { 
    1957         dataIIndex(ind) = data_i_index(idx); 
    1958         dataJIndex(ind) = data_j_index(idx); 
    1959         ++ind; 
    1960       } 
    1961     } 
    1962  
    1963     boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    1964     iteMap = indSrv_.end(); 
    1965     for (int k = 0; k < connectedServerRank_.size(); ++k) 
    1966     { 
    1967       int nbData = 0; 
    1968       int rank = connectedServerRank_[k]; 
    1969       it = indSrv_.find(rank); 
    1970       if (iteMap != it) 
    1971         nbData = it->second.size(); 
    1972       list_data_i_index.push_back(CArray<int,1>(nbData)); 
    1973       list_data_j_index.push_back(CArray<int,1>(nbData)); 
    1974  
    1975       const std::vector<size_t>& temp = it->second; 
    1976       for (n = 0; n < nbData; ++n) 
    1977       { 
    1978         idx = static_cast<int>(it->second[n]); 
    1979         i = globalLocalIndexMap_[idx]; 
    1980         list_data_i_index.back()(n) = dataIIndex(i); 
    1981         list_data_j_index.back()(n) = dataJIndex(i);           
    1982       } 
    1983  
    1984       list_msgsDataIndex.push_back(CMessage()); 
    1985       list_msgsDataIndex.back() << this->getId(); 
    1986       list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 
    1987       eventDataIndex.push(rank, nbConnectedClients_[rank], list_msgsDataIndex.back()); 
    1988     } 
    1989     client->sendEvent(eventDataIndex); 
     1962    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     1963    for (int i = 0; i < nbSrvPools; ++i) 
     1964    { 
     1965      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 
     1966 
     1967      // send area for each connected server 
     1968      CEventClient eventDataIndex(getType(), EVENT_ID_DATA_INDEX); 
     1969 
     1970      list<CMessage> list_msgsDataIndex; 
     1971      list<CArray<int,1> > list_data_i_index, list_data_j_index; 
     1972 
     1973      int nbIndex = i_index.numElements(); 
     1974      CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 
     1975      dataIIndex = -1; dataJIndex = -1, ind = 0; 
     1976      for (idx = 0; idx < data_i_index.numElements(); ++idx) 
     1977      { 
     1978        if ((0 <= data_i_index(idx)) && (data_i_index(idx) < ni) && (ind < nbIndex)) 
     1979        { 
     1980          dataIIndex(ind) = data_i_index(idx); 
     1981          dataJIndex(ind) = data_j_index(idx); 
     1982          ++ind; 
     1983        } 
     1984      } 
     1985 
     1986      boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
     1987      iteMap = indSrv_.end(); 
     1988      for (int k = 0; k < connectedServerRank_.size(); ++k) 
     1989      { 
     1990        int nbData = 0; 
     1991        int rank = connectedServerRank_[k]; 
     1992        it = indSrv_.find(rank); 
     1993        if (iteMap != it) 
     1994          nbData = it->second.size(); 
     1995        list_data_i_index.push_back(CArray<int,1>(nbData)); 
     1996        list_data_j_index.push_back(CArray<int,1>(nbData)); 
     1997 
     1998        const std::vector<size_t>& temp = it->second; 
     1999        for (n = 0; n < nbData; ++n) 
     2000        { 
     2001          idx = static_cast<int>(it->second[n]); 
     2002          i = globalLocalIndexMap_[idx]; 
     2003          list_data_i_index.back()(n) = dataIIndex(i); 
     2004          list_data_j_index.back()(n) = dataJIndex(i); 
     2005        } 
     2006 
     2007        list_msgsDataIndex.push_back(CMessage()); 
     2008        list_msgsDataIndex.back() << this->getId(); 
     2009        list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 
     2010        eventDataIndex.push(rank, nbConnectedClients_[rank], list_msgsDataIndex.back()); 
     2011      } 
     2012      client->sendEvent(eventDataIndex); 
     2013    } 
    19902014  } 
    19912015   
  • XIOS/dev/dev_olga/src/node/field.cpp

    r1025 r1027  
    991991     { 
    992992        if (!instantDataFilter) 
    993           instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid)); 
     993          instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid)); 
    994994 
    995995             // If the field data is to be read by the client or/and written to a file 
     
    10061006     { 
    10071007       if (!instantDataFilter) 
    1008           instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid)); 
     1008         instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid)); 
    10091009 
    10101010             // If the field data is to be read by the client or/and written to a file 
  • XIOS/dev/dev_olga/src/node/grid.cpp

    r1023 r1027  
    273273   { 
    274274     CContext* context = CContext::getCurrent(); 
    275      CContextClient* client= context->hasServer ? context->clientPrimServer : context->client; 
    276  
    277275     int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     276 
    278277     for (int i = 0; i < nbSrvPools; ++i) 
    279278     { 
    280                  if (isScalarGrid()) 
    281                  { 
    282                    // if (context->hasClient && !context->hasServer) 
    283                         if (context->hasClient) 
    284                           if (this->isChecked && doSendingIndex && !isIndexSent) { sendIndexScalarGrid(); this->isIndexSent = true; } 
    285  
    286                    if (this->isChecked) return; 
    287                    // if (context->hasClient && !context->hasServer) 
    288                    if (context->hasClient) 
    289                    { 
    290                           this->computeIndexScalarGrid(); 
    291                    } 
    292  
    293 //         this->isChecked = true; 
     279       CContextClient* client= context->hasServer ? context->clientPrimServer[i] : context->client; 
     280       if (isScalarGrid()) 
     281       { 
     282         // if (context->hasClient && !context->hasServer) 
     283        if (context->hasClient) 
     284          if (this->isChecked && doSendingIndex && !isIndexSent) { sendIndexScalarGrid(); this->isIndexSent = true; } 
     285 
     286         if (this->isChecked) return; 
     287         // if (context->hasClient && !context->hasServer) 
     288         if (context->hasClient) 
     289         { 
     290          this->computeIndexScalarGrid(); 
     291         } 
     292 
     293  //         this->isChecked = true; 
     294           if (!(this->hasTransform() && !this->isTransformed())) 
     295            this->isChecked = true; 
     296         return; 
     297       } 
     298 
     299       // if (context->hasClient && !context->hasServer) 
     300      // if (context->hasClient) 
     301      //   if (doSendingIndex && !isIndexSent) 
     302        { 
     303        if (context->hasClient) 
     304        { 
     305          if (this->isChecked && doSendingIndex && !isIndexSent) 
     306            {sendIndex(); this->isIndexSent = true;} 
     307        } 
     308 
     309        if (this->isChecked) return; 
     310        this->checkAttributesAfterTransformation(); 
     311        this->checkMask(); 
     312        this->computeIndex(); 
     313    //       this->isChecked = true; 
    294314         if (!(this->hasTransform() && !this->isTransformed())) 
    295315          this->isChecked = true; 
    296                    return; 
    297                  } 
    298  
    299                  // if (context->hasClient && !context->hasServer) 
    300                 // if (context->hasClient) 
    301                 //   if (doSendingIndex && !isIndexSent)  
    302                   { 
    303                         if (context->hasClient)  
    304                         { 
    305                           if (this->isChecked && doSendingIndex && !isIndexSent)  
    306                             {sendIndex(); this->isIndexSent = true;} 
    307                         } 
    308  
    309                         if (this->isChecked) return; 
    310                         this->checkAttributesAfterTransformation(); 
    311                         this->checkMask(); 
    312                         this->computeIndex();      
    313         //       this->isChecked = true; 
    314                    if (!(this->hasTransform() && !this->isTransformed())) 
    315                     this->isChecked = true; 
    316  
    317                    if (!(this->hasTransform() && (!this->isGenerated()))) 
    318                     this->isChecked = true; 
    319                          
    320  
    321                   } 
    322  
    323                 //  if (this->isChecked) return; 
    324  
    325                 //  // if (context->hasClient && !context->hasServer) 
    326                 // // if (context->hasClient) 
    327                 //  { 
    328                 //     this->checkAttributesAfterTransformation(); 
    329                 //     this->checkMask(); 
    330                 //     this->computeIndex(); 
    331                 //  } 
    332                 //  this->isChecked = true; 
    333      } 
     316 
     317         if (!(this->hasTransform() && (!this->isGenerated()))) 
     318          this->isChecked = true; 
     319 
     320 
     321        } 
     322 
     323      //  if (this->isChecked) return; 
     324 
     325      //  // if (context->hasClient && !context->hasServer) 
     326      // // if (context->hasClient) 
     327      //  { 
     328      //     this->checkAttributesAfterTransformation(); 
     329      //     this->checkMask(); 
     330      //     this->computeIndex(); 
     331      //  } 
     332      //  this->isChecked = true; 
     333      } 
    334334   } 
    335335 
     
    521521     CContext* context = CContext::getCurrent(); 
    522522 
    523      CContextClient* client = (context->hasServer) ? context->clientPrimServer : context->client; 
    524      CContextServer* server = (context->hasServer) ? context->server : 0 ; 
    525      int rank = (server && !client) ? server->intraCommRank : client->clientRank; 
    526  
    527      // First of all, compute distribution on client side 
    528      if (0 != serverDistribution_) 
    529        clientDistribution_ = new CDistributionClient(rank, this, serverDistribution_->getGlobalLocalIndex()); 
    530      else 
    531        clientDistribution_ = new CDistributionClient(rank, this); 
    532  
    533      // Get local data index on client      
    534      storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 
    535      int nbStoreIndex = storeIndex_client.numElements(); 
    536      for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 
    537      isDataDistributed_= clientDistribution_->isDataDistributed(); 
     523     int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     524     for (int i = 0; i < nbSrvPools; ++i) 
     525     { 
     526       CContextClient* client = (context->hasServer) ? context->clientPrimServer[i] : context->client; 
     527       CContextServer* server = (context->hasServer) ? context->server : 0 ; 
     528       int rank = (server && !client) ? server->intraCommRank : client->clientRank; 
     529 
     530       // First of all, compute distribution on client side 
     531       if (0 != serverDistribution_) 
     532         clientDistribution_ = new CDistributionClient(rank, this, serverDistribution_->getGlobalLocalIndex()); 
     533       else 
     534         clientDistribution_ = new CDistributionClient(rank, this); 
     535 
     536       // Get local data index on client 
     537       storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 
     538       int nbStoreIndex = storeIndex_client.numElements(); 
     539       for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 
     540       isDataDistributed_= clientDistribution_->isDataDistributed(); 
     541     } 
    538542   } 
    539543 
     
    541545   { 
    542546     CContext* context = CContext::getCurrent(); 
    543      CContextClient* client = (context->hasServer) ? context->clientPrimServer : context->client; 
    544  
    545      connectedServerRank_.clear(); 
    546  
    547      if (!doGridHaveDataDistributed()) 
     547     int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     548     for (int i = 0; i < nbSrvPools; ++i) 
    548549     { 
    549         if (client->isServerLeader()) 
    550         { 
    551           size_t ssize = clientDistribution_->getLocalDataIndexOnClient().size(); 
    552           const std::list<int>& ranks = client->getRanksServerLeader(); 
    553           for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     550       CContextClient* client = (context->hasServer) ? context->clientPrimServer[i] : context->client; 
     551 
     552       connectedServerRank_.clear(); 
     553 
     554       if (!doGridHaveDataDistributed()) 
     555       { 
     556          if (client->isServerLeader()) 
    554557          { 
    555             connectedServerRank_.push_back(*itRank); 
    556             connectedDataSize_[*itRank] = ssize; 
     558            size_t ssize = clientDistribution_->getLocalDataIndexOnClient().size(); 
     559            const std::list<int>& ranks = client->getRanksServerLeader(); 
     560            for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     561            { 
     562              connectedServerRank_.push_back(*itRank); 
     563              connectedDataSize_[*itRank] = ssize; 
     564            } 
    557565          } 
    558         } 
    559         return; 
     566          return; 
     567       } 
     568 
     569       // Compute mapping between client and server 
     570       std::vector<boost::unordered_map<size_t,std::vector<int> > > indexServerOnElement; 
     571       CServerDistributionDescription serverDistributionDescription(globalDim_, client->serverSize); 
     572       serverDistributionDescription.computeServerGlobalByElement(indexServerOnElement, 
     573                                                                  client->clientRank, 
     574                                                                  client->clientSize, 
     575                                                                  axis_domain_order, 
     576                                                                  positionDimensionDistributed_); 
     577       computeIndexByElement(indexServerOnElement, globalIndexOnServer_); 
     578 
     579       const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = clientDistribution_->getGlobalLocalDataSendToServer(); 
     580       CDistributionClient::GlobalLocalDataMap::const_iterator iteGlobalLocalIndexMap = globalLocalIndexSendToServer.end(), itGlobalLocalIndexMap; 
     581       CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 
     582       itGlobalMap  = itbGlobalMap = globalIndexOnServer_.begin(); 
     583       iteGlobalMap = globalIndexOnServer_.end(); 
     584 
     585       for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
     586       { 
     587         int serverRank = itGlobalMap->first; 
     588         int indexSize = itGlobalMap->second.size(); 
     589         const std::vector<size_t>& indexVec = itGlobalMap->second; 
     590         for (int idx = 0; idx < indexSize; ++idx) 
     591         { 
     592            itGlobalLocalIndexMap = globalLocalIndexSendToServer.find(indexVec[idx]); 
     593            if (iteGlobalLocalIndexMap != itGlobalLocalIndexMap) 
     594            { 
     595               if (connectedDataSize_.end() == connectedDataSize_.find(serverRank)) 
     596                 connectedDataSize_[serverRank] = 1; 
     597               else 
     598                 ++connectedDataSize_[serverRank]; 
     599            } 
     600         } 
     601       } 
     602 
     603       for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) { 
     604         connectedServerRank_.push_back(itGlobalMap->first); 
     605       } 
     606 
     607       nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    560608     } 
    561  
    562      // Compute mapping between client and server 
    563      std::vector<boost::unordered_map<size_t,std::vector<int> > > indexServerOnElement; 
    564      CServerDistributionDescription serverDistributionDescription(globalDim_, client->serverSize); 
    565      serverDistributionDescription.computeServerGlobalByElement(indexServerOnElement, 
    566                                                                 client->clientRank, 
    567                                                                 client->clientSize, 
    568                                                                 axis_domain_order, 
    569                                                                 positionDimensionDistributed_); 
    570      computeIndexByElement(indexServerOnElement, globalIndexOnServer_); 
    571  
    572      const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = clientDistribution_->getGlobalLocalDataSendToServer(); 
    573      CDistributionClient::GlobalLocalDataMap::const_iterator iteGlobalLocalIndexMap = globalLocalIndexSendToServer.end(), itGlobalLocalIndexMap; 
    574      CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 
    575      itGlobalMap  = itbGlobalMap = globalIndexOnServer_.begin(); 
    576      iteGlobalMap = globalIndexOnServer_.end(); 
    577  
    578      for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
    579      { 
    580        int serverRank = itGlobalMap->first; 
    581        int indexSize = itGlobalMap->second.size(); 
    582        const std::vector<size_t>& indexVec = itGlobalMap->second; 
    583        for (int idx = 0; idx < indexSize; ++idx) 
    584        { 
    585           itGlobalLocalIndexMap = globalLocalIndexSendToServer.find(indexVec[idx]); 
    586           if (iteGlobalLocalIndexMap != itGlobalLocalIndexMap) 
    587           { 
    588              if (connectedDataSize_.end() == connectedDataSize_.find(serverRank)) 
    589                connectedDataSize_[serverRank] = 1; 
    590              else 
    591                ++connectedDataSize_[serverRank]; 
    592           } 
    593        } 
    594      } 
    595  
    596      for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) { 
    597        connectedServerRank_.push_back(itGlobalMap->first); 
    598      } 
    599  
    600      nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    601609   } 
    602610 
     
    13651373  { 
    13661374    CContext* context = CContext::getCurrent(); 
    1367     CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer; 
    1368     CContextClient* client = (context->hasServer) ? context->client : context->clientPrimServer; 
    1369     numberWrittenIndexes_ = totalNumberWrittenIndexes_ = offsetWrittenIndexes_ = 0; 
    1370     connectedServerRank_ = ranks; 
    1371  
    1372     for (int n = 0; n < ranks.size(); n++) 
    1373     { 
    1374       int rank = ranks[n]; 
    1375       CBufferIn& buffer = *buffers[n]; 
    1376  
    1377       buffer >> isDataDistributed_ >> isCompressible_; 
    1378       size_t dataSize = 0; 
    1379  
    1380       if (0 == serverDistribution_) 
    1381       { 
    1382         int idx = 0, numElement = axis_domain_order.numElements(); 
    1383         int ssize = numElement; 
    1384         std::vector<int> indexMap(numElement); 
    1385         for (int i = 0; i < numElement; ++i) 
    1386         { 
    1387           indexMap[i] = idx; 
    1388           if (2 == axis_domain_order(i)) 
     1375    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     1376    for (int i = 0; i < nbSrvPools; ++i) 
     1377    { 
     1378      CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer[i]; 
     1379      CContextClient* client = (context->hasServer) ? context->client : context->clientPrimServer[i]; 
     1380      numberWrittenIndexes_ = totalNumberWrittenIndexes_ = offsetWrittenIndexes_ = 0; 
     1381      connectedServerRank_ = ranks; 
     1382 
     1383      for (int n = 0; n < ranks.size(); n++) 
     1384      { 
     1385        int rank = ranks[n]; 
     1386        CBufferIn& buffer = *buffers[n]; 
     1387 
     1388        buffer >> isDataDistributed_ >> isCompressible_; 
     1389        size_t dataSize = 0; 
     1390 
     1391        if (0 == serverDistribution_) 
     1392        { 
     1393          int idx = 0, numElement = axis_domain_order.numElements(); 
     1394          int ssize = numElement; 
     1395          std::vector<int> indexMap(numElement); 
     1396          for (int i = 0; i < numElement; ++i) 
    13891397          { 
    1390             ++ssize; 
    1391             idx += 2; 
     1398            indexMap[i] = idx; 
     1399            if (2 == axis_domain_order(i)) 
     1400            { 
     1401              ++ssize; 
     1402              idx += 2; 
     1403            } 
     1404            else 
     1405              ++idx; 
    13921406          } 
    1393           else 
    1394             ++idx; 
    1395         } 
    1396  
    1397         int axisId = 0, domainId = 0, scalarId = 0, globalSize = 1; 
    1398         std::vector<CDomain*> domainList = getDomains(); 
    1399         std::vector<CAxis*> axisList = getAxis(); 
    1400         std::vector<int> nZoomBegin(ssize), nZoomSize(ssize), nGlob(ssize), nZoomBeginGlobal(ssize), nGlobElement(numElement); 
    1401         std::vector<CArray<int,1> > zoomIndex;  
    1402         for (int i = 0; i < numElement; ++i) 
    1403         { 
    1404           nGlobElement[i] = globalSize;  
    1405           if (2 == axis_domain_order(i)) //domain 
     1407 
     1408          int axisId = 0, domainId = 0, scalarId = 0, globalSize = 1; 
     1409          std::vector<CDomain*> domainList = getDomains(); 
     1410          std::vector<CAxis*> axisList = getAxis(); 
     1411          std::vector<int> nZoomBegin(ssize), nZoomSize(ssize), nGlob(ssize), nZoomBeginGlobal(ssize), nGlobElement(numElement); 
     1412          std::vector<CArray<int,1> > zoomIndex; 
     1413          for (int i = 0; i < numElement; ++i) 
    14061414          { 
    1407             // nZoomBegin[indexMap[i]] = domainList[domainId]->zoom_ibegin_srv; 
    1408             // nZoomSize[indexMap[i]]  = domainList[domainId]->zoom_ni_srv; 
    1409             // nZoomBeginGlobal[indexMap[i]] = domainList[domainId]->global_zoom_ibegin; 
    1410             // zoomIndex.push_back(domainList[domainId]->zoom_i_index); 
    1411             // nGlob[indexMap[i]] = domainList[domainId]->ni_glo; 
    1412  
    1413             // nZoomBegin[indexMap[i] + 1] = domainList[domainId]->zoom_jbegin_srv; 
    1414             // nZoomSize[indexMap[i] + 1] = domainList[domainId]->zoom_nj_srv; 
    1415             // nZoomBeginGlobal[indexMap[i] + 1] = domainList[domainId]->global_zoom_jbegin; 
    1416             // zoomIndex.push_back(domainList[domainId]->zoom_j_index); 
    1417             // nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo; 
    1418  
    1419             int nbZoom = domainList[domainId]->zoom_i_index.numElements();             
    1420             zoomIndex.push_back(CArray<int,1>(nbZoom)); 
    1421             CArray<int,1>& zoomDomain = zoomIndex.back(); 
    1422             for (int ind = 0; ind < nbZoom; ++ind) 
     1415            nGlobElement[i] = globalSize; 
     1416            if (2 == axis_domain_order(i)) //domain 
    14231417            { 
    1424               zoomDomain(ind) = domainList[domainId]->zoom_i_index(ind) + domainList[domainId]->zoom_j_index(ind) * domainList[domainId]->ni_glo;   
     1418              // nZoomBegin[indexMap[i]] = domainList[domainId]->zoom_ibegin_srv; 
     1419              // nZoomSize[indexMap[i]]  = domainList[domainId]->zoom_ni_srv; 
     1420              // nZoomBeginGlobal[indexMap[i]] = domainList[domainId]->global_zoom_ibegin; 
     1421              // zoomIndex.push_back(domainList[domainId]->zoom_i_index); 
     1422              // nGlob[indexMap[i]] = domainList[domainId]->ni_glo; 
     1423 
     1424              // nZoomBegin[indexMap[i] + 1] = domainList[domainId]->zoom_jbegin_srv; 
     1425              // nZoomSize[indexMap[i] + 1] = domainList[domainId]->zoom_nj_srv; 
     1426              // nZoomBeginGlobal[indexMap[i] + 1] = domainList[domainId]->global_zoom_jbegin; 
     1427              // zoomIndex.push_back(domainList[domainId]->zoom_j_index); 
     1428              // nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo; 
     1429 
     1430              int nbZoom = domainList[domainId]->zoom_i_index.numElements(); 
     1431              zoomIndex.push_back(CArray<int,1>(nbZoom)); 
     1432              CArray<int,1>& zoomDomain = zoomIndex.back(); 
     1433              for (int ind = 0; ind < nbZoom; ++ind) 
     1434              { 
     1435                zoomDomain(ind) = domainList[domainId]->zoom_i_index(ind) + domainList[domainId]->zoom_j_index(ind) * domainList[domainId]->ni_glo; 
     1436              } 
     1437 
     1438              globalSize *= domainList[domainId]->ni_glo * domainList[domainId]->nj_glo; 
     1439              ++domainId; 
    14251440            } 
    1426  
    1427             globalSize *= domainList[domainId]->ni_glo * domainList[domainId]->nj_glo; 
    1428             ++domainId; 
     1441            else if (1 == axis_domain_order(i)) // axis 
     1442            { 
     1443              // nZoomBegin[indexMap[i]] = axisList[axisId]->zoom_begin_srv; 
     1444              // nZoomSize[indexMap[i]]  = axisList[axisId]->zoom_size_srv; 
     1445              // nZoomBeginGlobal[indexMap[i]] = axisList[axisId]->global_zoom_begin; 
     1446              zoomIndex.push_back(axisList[axisId]->zoom_index); 
     1447              // nGlob[indexMap[i]] = axisList[axisId]->n_glo; 
     1448              globalSize *= axisList[axisId]->n_glo; 
     1449              ++axisId; 
     1450            } 
     1451            else // scalar 
     1452            { 
     1453              CArray<int,1> zoomScalar(1); 
     1454              zoomScalar(0) = 0; 
     1455              // nZoomBegin[indexMap[i]] = 0; 
     1456              // nZoomSize[indexMap[i]]  = 1; 
     1457              // nZoomBeginGlobal[indexMap[i]] = 0; 
     1458              zoomIndex.push_back(zoomScalar); 
     1459              // nGlob[indexMap[i]] = 1; 
     1460              ++scalarId; 
     1461            } 
    14291462          } 
    1430           else if (1 == axis_domain_order(i)) // axis 
     1463          dataSize = 1; 
     1464 
     1465          // for (int i = 0; i < nZoomSize.size(); ++i) 
     1466          //   dataSize *= nZoomSize[i]; 
     1467          // serverDistribution_ = new CDistributionServer(server->intraCommRank, nZoomBegin, nZoomSize, 
     1468          //                                               nZoomBeginGlobal, nGlob); 
     1469          for (int i = 0; i < zoomIndex.size(); ++i) 
    14311470          { 
    1432             // nZoomBegin[indexMap[i]] = axisList[axisId]->zoom_begin_srv; 
    1433             // nZoomSize[indexMap[i]]  = axisList[axisId]->zoom_size_srv; 
    1434             // nZoomBeginGlobal[indexMap[i]] = axisList[axisId]->global_zoom_begin; 
    1435             zoomIndex.push_back(axisList[axisId]->zoom_index);             
    1436             // nGlob[indexMap[i]] = axisList[axisId]->n_glo; 
    1437             globalSize *= axisList[axisId]->n_glo; 
    1438             ++axisId; 
     1471            dataSize *= zoomIndex[i].numElements(); 
    14391472          } 
    1440           else // scalar 
    1441           { 
    1442             CArray<int,1> zoomScalar(1); 
    1443             zoomScalar(0) = 0; 
    1444             // nZoomBegin[indexMap[i]] = 0; 
    1445             // nZoomSize[indexMap[i]]  = 1; 
    1446             // nZoomBeginGlobal[indexMap[i]] = 0; 
    1447             zoomIndex.push_back(zoomScalar); 
    1448             // nGlob[indexMap[i]] = 1; 
    1449             ++scalarId; 
    1450           } 
    1451         } 
    1452         dataSize = 1; 
    1453  
    1454         // for (int i = 0; i < nZoomSize.size(); ++i) 
    1455         //   dataSize *= nZoomSize[i]; 
    1456         // serverDistribution_ = new CDistributionServer(server->intraCommRank, nZoomBegin, nZoomSize, 
    1457         //                                               nZoomBeginGlobal, nGlob); 
    1458         for (int i = 0; i < zoomIndex.size(); ++i) 
    1459         { 
    1460           dataSize *= zoomIndex[i].numElements(); 
    1461         } 
    1462         serverDistribution_ = new CDistributionServer(server->intraCommRank, zoomIndex, nGlobElement); 
    1463       } 
    1464  
    1465       CArray<size_t,1> outIndex; 
    1466       buffer >> outIndex; 
     1473          serverDistribution_ = new CDistributionServer(server->intraCommRank, zoomIndex, nGlobElement); 
     1474        } 
     1475 
     1476        CArray<size_t,1> outIndex; 
     1477        buffer >> outIndex; 
     1478        if (isDataDistributed_) 
     1479          serverDistribution_->computeLocalIndex(outIndex); 
     1480        else 
     1481        { 
     1482          dataSize = outIndex.numElements(); 
     1483          for (int i = 0; i < outIndex.numElements(); ++i) outIndex(i) = i; 
     1484        } 
     1485        writtenDataSize_ += dataSize; 
     1486 
     1487        outIndexFromClient.insert(std::make_pair(rank, outIndex)); 
     1488        connectedDataSize_[rank] = outIndex.numElements(); 
     1489        numberWrittenIndexes_ += outIndex.numElements(); 
     1490      } 
     1491 
     1492      int sizeData = 0; 
     1493      for (map<int, CArray<size_t, 1> >::iterator it = outIndexFromClient.begin(); it != outIndexFromClient.end(); ++it) 
     1494      { 
     1495        sizeData += it->second.numElements(); 
     1496      } 
     1497      indexFromClients.resize(sizeData); 
     1498      sizeData = 0; 
     1499      for (map<int, CArray<size_t, 1> >::iterator it = outIndexFromClient.begin(); it != outIndexFromClient.end(); ++it) 
     1500      { 
     1501         CArray<size_t, 1>& tmp0 = it->second; 
     1502         CArray<size_t, 1> tmp1 = indexFromClients(Range(sizeData, sizeData + tmp0.numElements() - 1)); 
     1503         tmp1 = tmp0; 
     1504         sizeData += tmp0.numElements(); 
     1505      } 
     1506 
     1507      // if (isScalarGrid()) return; 
     1508 
    14671509      if (isDataDistributed_) 
    1468         serverDistribution_->computeLocalIndex(outIndex); 
     1510      { 
     1511        MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
     1512        MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
     1513        offsetWrittenIndexes_ -= numberWrittenIndexes_; 
     1514      } 
    14691515      else 
    1470       { 
    1471         dataSize = outIndex.numElements(); 
    1472         for (int i = 0; i < outIndex.numElements(); ++i) outIndex(i) = i; 
    1473       } 
    1474       writtenDataSize_ += dataSize; 
    1475        
    1476       outIndexFromClient.insert(std::make_pair(rank, outIndex)); 
    1477       connectedDataSize_[rank] = outIndex.numElements(); 
    1478       numberWrittenIndexes_ += outIndex.numElements(); 
    1479     } 
    1480      
    1481     int sizeData = 0; 
    1482     for (map<int, CArray<size_t, 1> >::iterator it = outIndexFromClient.begin(); it != outIndexFromClient.end(); ++it) 
    1483     { 
    1484       sizeData += it->second.numElements(); 
    1485     } 
    1486     indexFromClients.resize(sizeData); 
    1487     sizeData = 0; 
    1488     for (map<int, CArray<size_t, 1> >::iterator it = outIndexFromClient.begin(); it != outIndexFromClient.end(); ++it) 
    1489     { 
    1490        CArray<size_t, 1>& tmp0 = it->second; 
    1491        CArray<size_t, 1> tmp1 = indexFromClients(Range(sizeData, sizeData + tmp0.numElements() - 1)); 
    1492        tmp1 = tmp0; 
    1493        sizeData += tmp0.numElements(); 
    1494     } 
    1495  
    1496     // if (isScalarGrid()) return; 
    1497  
    1498     if (isDataDistributed_) 
    1499     { 
    1500       MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    1501       MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    1502       offsetWrittenIndexes_ -= numberWrittenIndexes_; 
    1503     } 
    1504     else 
    1505       totalNumberWrittenIndexes_ = numberWrittenIndexes_; 
    1506  
    1507     nbSenders = CClientServerMappingDistributed::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, ranks); 
     1516        totalNumberWrittenIndexes_ = numberWrittenIndexes_; 
     1517 
     1518      nbSenders = CClientServerMappingDistributed::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, ranks); 
     1519    } 
    15081520  } 
    15091521 
Note: See TracChangeset for help on using the changeset viewer.