Changeset 1571 for XIOS/dev


Ignore:
Timestamp:
09/06/18 18:55:44 (6 years ago)
Author:
oabramkina
Message:

Taking care of cases when a process doesn't possess a grid (its domain or axe size is zero).

Tested with CMIP6 toy models and IPSL model.

To do: remove grid mask from transformations.

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

Legend:

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

    r1559 r1571  
    5656      { 
    5757        StdString lonName,latName ; 
    58           
     58 
    5959        domain->computeWrittenIndex(); 
    6060        domain->computeWrittenCompressedIndex(comm_file); 
     
    154154*/ 
    155155 
    156          CArray<size_t, 1>& indexToWrite = domain->localIndexToWriteOnServer; 
     156         CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; 
    157157         int nbWritten = indexToWrite.numElements(); 
    158158         CArray<double,1> writtenLat, writtenLon; 
     
    166166           for (int idx = 0; idx < nbWritten; ++idx) 
    167167           { 
    168                   if (idx < domain->latvalue.numElements()) 
     168                  if (indexToWrite(idx) < 0) 
    169169                  { 
    170                 writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
    171                 writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
     170              writtenLat(idx) = -1.;   // hole 
     171              writtenLon(idx) = -1.; 
    172172                  } 
    173173                  else 
    174174                  { 
    175                 writtenLat(idx) = 0.; 
    176                 writtenLon(idx) = 0.; 
     175              writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
     176              writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
    177177                  } 
    178178           } 
     
    189189               for (int nv = 0; nv < nvertex; ++nv) 
    190190               { 
    191                  if (idx < boundslat.columns()) 
    192                  { 
     191                 if (indexToWrite(idx) < 0) 
     192                 { 
     193                   writtenBndsLat(nv, idx) = -1.;  // hole 
     194                   writtenBndsLon(nv, idx) = -1.; 
     195                 } 
     196                 else 
     197                 { 
    193198                   writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 
    194199                   writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 
    195                  } 
    196                  else 
    197                  { 
    198                    writtenBndsLat(nv, idx) = 0.; 
    199                    writtenBndsLon(nv, idx) = 0.; 
    200                  } 
     200                 } 
    201201               } 
    202202           } 
     
    208208           for (int idx = 0; idx < nbWritten; ++idx) 
    209209           { 
    210                   if (idx < domain->areavalue.numElements()) 
    211                 writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 
     210                  if (indexToWrite(idx) < 0) 
     211              writtenArea(idx) = -1.; 
    212212                  else 
    213                 writtenArea(idx) = 0.; 
     213              writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 
    214214           } 
    215215         } 
     
    426426                     std::vector<StdSize> start(2) ; 
    427427                     std::vector<StdSize> count(2) ; 
    428                      if (domain->isEmpty()) 
    429                      { 
    430                        start[0]=0 ; start[1]=0 ; 
    431                        count[0]=0 ; count[1]=0 ; 
    432                      } 
    433                      else 
     428// Comment out for a moment because it is not working for a hole 
     429//                     if (domain->isEmpty()) 
     430//                     { 
     431//                       start[0]=0 ; start[1]=0 ; 
     432//                       count[0]=0 ; count[1]=0 ; 
     433//                     } 
     434//                     else 
    434435                     { 
    435436                       start[1]=domain->ibegin; 
     
    875876          case (MULTI_FILE) : 
    876877          { 
     878            ERROR("CNc4DataOutput::writeDomain(domain)", 
     879            << "[ type = multiple_file ]" 
     880            << " is not yet implemented for UGRID files !"); 
    877881            break; 
    878882          } 
     
    940944         int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; 
    941945 
    942          CArray<size_t, 1>& indexToWrite = domain->localIndexToWriteOnServer; 
     946         CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; 
    943947         int nbWritten = indexToWrite.numElements(); 
    944948         CArray<double,1> writtenLat, writtenLon; 
     
    952956           for (int idx = 0; idx < nbWritten; ++idx) 
    953957           { 
    954              if (idx < domain->latvalue.numElements()) 
    955              { 
    956                writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
    957                writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
    958              } 
    959              else 
    960              { 
    961                writtenLat(idx) = 0.; 
    962                writtenLon(idx) = 0.; 
    963              } 
     958             if (indexToWrite(idx) < 0) 
     959             { 
     960               writtenLat(idx) = -1.; 
     961               writtenLon(idx) = -1.; 
     962             } 
     963             else 
     964             { 
     965               writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
     966               writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
     967             } 
    964968           } 
    965969         } 
     
    976980             for (int nv = 0; nv < nvertex; ++nv) 
    977981             { 
    978                if (idx < boundslat.columns()) 
     982               if (indexToWrite(idx) < 0) 
     983               { 
     984                 writtenBndsLat(nv, idx) = -1.; 
     985                 writtenBndsLon(nv, idx) = -1.; 
     986               } 
     987               else 
    979988               { 
    980989                 writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 
    981990                 writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 
    982                } 
    983                else 
    984                { 
    985                  writtenBndsLat(nv, idx) = 0.; 
    986                  writtenBndsLon(nv, idx) = 0.; 
    987991                } 
    988992             } 
     
    995999           for (int idx = 0; idx < nbWritten; ++idx) 
    9961000           { 
    997                   if (idx < domain->areavalue.numElements()) 
    998                 writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 
     1001                  if (indexToWrite(idx) < 0) 
     1002              writtenArea(idx) = -1.; 
    9991003                  else 
    1000                 writtenArea(idx) = 0.; 
     1004                    writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 
    10011005           } 
    10021006         } 
     
    12751279          SuperClassWriter::definition_end(); 
    12761280 
    1277           CArray<size_t, 1>& indexToWrite = axis->localIndexToWriteOnServer; 
     1281          CArray<int, 1>& indexToWrite = axis->localIndexToWriteOnServer; 
    12781282          int nbWritten = indexToWrite.numElements(); 
    12791283          CArray<double,1> axis_value(indexToWrite.numElements()); 
     
    12821286            for (int i = 0; i < nbWritten; i++) 
    12831287            { 
    1284               if (i < axis->value.numElements()) 
     1288              if (indexToWrite(i) < 0) 
     1289                axis_value(i) = -1;   // Some value in case of a hole 
     1290              else 
    12851291                axis_value(i) = axis->value(indexToWrite(i)); 
    1286               else 
    1287                 axis_value(i) = 0.; 
    12881292            } 
    12891293          } 
     
    12951299            for (int i = 0; i < nbWritten; i++) 
    12961300            { 
    1297               if (i < axis->label.numElements()) 
     1301              if (indexToWrite(i) < 0) 
     1302                axis_label(i) = boost::lexical_cast<string>(-1);  // Some value in case of a hole 
     1303              else 
    12981304                axis_label(i) = axis->label(indexToWrite(i)); 
    1299               else 
    1300                 axis_label(i) = boost::lexical_cast<string>(0);  // Write 0 as a label 
    13011305            } 
    13021306          } 
     
    13161320                  for (int i = 0; i < nbWritten; ++i) 
    13171321                  { 
    1318                     if (i < axis->bounds.columns()) 
     1322                    if (indexToWrite(i) < 0) 
     1323                    { 
     1324                      axis_bounds(0, i) = -1.; // Some value in case of a hole 
     1325                      axis_bounds(1, i) = -1.; 
     1326                    } 
     1327                    else 
    13191328                    { 
    13201329                      axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 
    13211330                      axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 
    1322                     } 
    1323                     else 
    1324                     { 
    1325                       axis_bounds(0, i) = 0.; 
    1326                       axis_bounds(1, i) = 0.; 
    13271331 
    13281332                    } 
     
    13561360                  for (int i = 0; i < nbWritten; ++i) 
    13571361                  { 
    1358                     if (i < axis->bounds.columns()) 
     1362                    if (indexToWrite(i) < 0) 
     1363                    { 
     1364                      axis_bounds(0, i) = -1.; 
     1365                      axis_bounds(1, i) = -1.; 
     1366                    } 
     1367                    else 
    13591368                    { 
    13601369                      axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 
    13611370                      axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 
    1362                     } 
    1363                     else 
    1364                     { 
    1365                       axis_bounds(0, i) = 0.; 
    1366                       axis_bounds(1, i) = 0.; 
    13671371                    } 
    13681372                  } 
  • XIOS/dev/dev_olga/src/node/axis.cpp

    r1570 r1571  
    245245   void CAxis::checkAttributes(void) 
    246246   { 
    247       if (this->n_glo.isEmpty()) 
     247     CContext* context=CContext::getCurrent(); 
     248 
     249     if (this->n_glo.isEmpty()) 
    248250        ERROR("CAxis::checkAttributes(void)", 
    249251              << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     
    287289      if (!this->value.isEmpty()) 
    288290      { 
    289         StdSize true_size = value.numElements(); 
    290         if (this->n.getValue() != true_size) 
    291           ERROR("CAxis::checkAttributes(void)", 
     291        // Avoid this check at writing because it fails in case of a hole 
     292        if (context->hasClient) 
     293        { 
     294          StdSize true_size = value.numElements(); 
     295          if (this->n.getValue() != true_size) 
     296            ERROR("CAxis::checkAttributes(void)", 
    292297                << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
    293                 << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
     298                << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size 
     299                << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
     300        } 
    294301        this->hasValue = true; 
    295302      } 
     
    297304      this->checkBounds(); 
    298305 
    299       CContext* context=CContext::getCurrent(); 
    300306      if (context->hasClient) 
    301307      { 
     
    651657         // Even if a client has no index, it must connect to at least one server and  
    652658         // send an "empty" data to this server 
    653          if (connectedServerRank_[nbServer].empty()) 
    654           connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 
     659//         if (connectedServerRank_[nbServer].empty()) 
     660//          connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 
     661        // Send empty data to all servers 
     662        if (connectedServerRank_[nbServer].empty()) 
     663          for (int i=0; i<nbServer; ++i) 
     664            connectedServerRank_[nbServer].push_back(i); 
     665 
    655666 
    656667         nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 
     
    690701    CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 
    691702                                     itSrve = writtenGlobalIndex.end(), itSrv;   
     703//    for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
     704//    { 
     705//      indGlo = *itSrv; 
     706//      if (ite != globalLocalIndexMap_.find(indGlo)) 
     707//      { 
     708//        ++nbWritten; 
     709//      } 
     710//    } 
     711 
     712    localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
     713//    localIndexToWriteOnServer.resize(nbWritten); 
     714 
     715    nbWritten = 0; 
    692716    for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    693717    { 
     
    695719      if (ite != globalLocalIndexMap_.find(indGlo)) 
    696720      { 
    697         ++nbWritten; 
    698       } 
    699     } 
    700  
    701     localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
    702 //      localIndexToWriteOnServer.resize(nbWritten); 
    703  
    704     nbWritten = 0; 
    705     for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    706     { 
    707       indGlo = *itSrv; 
    708       if (ite != globalLocalIndexMap_.find(indGlo)) 
    709       { 
    710721        localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
    711         ++nbWritten; 
    712       } 
    713     } 
     722      } 
     723      else 
     724      { 
     725        localIndexToWriteOnServer(nbWritten) = -1; 
     726      } 
     727      ++nbWritten; 
     728    } 
     729 
    714730  } 
    715731 
     
    11941210         if (0 == globalLocalIndexMap_.count(gloInd)) 
    11951211         { 
    1196            index(nbIndLoc) = gloInd % n_glo; 
    1197            globalLocalIndexMap_[gloInd] = nbIndLoc; 
     1212//           index(nbIndLoc) = gloInd % n_glo; 
     1213//           globalLocalIndexMap_[gloInd] = nbIndLoc; 
     1214//           ++nbIndexGlob; 
     1215           index(nbIndexGlob) = gloInd % n_glo; 
     1216           globalLocalIndexMap_[gloInd] = nbIndexGlob; 
    11981217           ++nbIndexGlob; 
    11991218         }  
     
    12711290  } 
    12721291 
    1273  
    12741292  /*! 
    12751293    Compare two axis objects.  
  • XIOS/dev/dev_olga/src/node/axis.hpp

    r1568 r1571  
    114114         void computeWrittenIndex(); 
    115115         void computeWrittenCompressedIndex(MPI_Comm); 
     116 
     117         template <class T> void outputAxis(CArray<T,1>& valueIn, CArray<T,1>& valueOut); 
     118 
    116119         bool hasTransformation(); 
    117120         void solveInheritanceTransformation(); 
     
    126129        bool hasLabel; 
    127130 
    128         CArray<size_t,1> localIndexToWriteOnServer; 
     131//        CArray<size_t,1> localIndexToWriteOnServer; 
     132        CArray<int,1> localIndexToWriteOnServer; 
     133        CArray<size_t,1> localIndexToWriteOnClient; 
    129134 
    130135      private: 
     
    185190   ///-------------------------------------------------------------- 
    186191 
     192   template <class T> void CAxis::outputAxis(CArray<T,1>& valueIn, CArray<T,1>& valueOut) 
     193   { 
     194     int sizeServer = localIndexToWriteOnServer.numElements(); 
     195     int sizeClient = localIndexToWriteOnClient.numElements(); 
     196     valueOut.resize(sizeClient); 
     197 
     198     if (sizeServer == sizeClient) 
     199     { 
     200       valueOut = valueIn; 
     201     } 
     202     else 
     203     // a hole 
     204     { 
     205       valueOut = valueIn; 
     206       //valueOut = -1; initialize here to some value ???? 
     207     } 
     208//      CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient; 
     209//      CArray<size_t,1>& outIndexServer = grid->localIndexToWriteOnServer; 
     210//      for (size_t idx = 0; idx < outIndexServer.numElements(); ++idx) 
     211//      { 
     212//        fieldOut(outIndexServer(idx)) = recvDataSrv(outIndexClient(idx)); 
     213//      } 
     214   } 
     215 
    187216   // Declare/Define CAxisGroup and CAxisDefinition 
    188217   DECLARE_GROUP(CAxis); 
  • XIOS/dev/dev_olga/src/node/domain.cpp

    r1570 r1571  
    18481848          // Even if a client has no index, it must connect to at least one server and 
    18491849          // send an "empty" data to this server 
     1850//          if (connectedServerRank_[nbServer].empty()) 
     1851//            connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 
     1852 
     1853          // Trying instead: send empty data to all servers 
    18501854          if (connectedServerRank_[nbServer].empty()) 
    1851             connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 
     1855            for (int i = 0; i < client->serverSize; ++i) 
     1856            connectedServerRank_[nbServer].push_back(i); 
     1857 
    18521858 
    18531859          nbSenders[nbServer] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 
     
    19041910        { 
    19051911          localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
    1906           ++nbWritten; 
    19071912        } 
    19081913        else 
    19091914        { 
    1910           localIndexToWriteOnServer(nbWritten) = 0; 
    1911           ++nbWritten; 
    1912         } 
     1915          localIndexToWriteOnServer(nbWritten) = -1; 
     1916        } 
     1917        ++nbWritten; 
    19131918      } 
    19141919       
     
    25122517           nbIndLoc = iIndex + ni * jIndex; 
    25132518//           if (nbIndLoc < nbIndexGlobMax)  // THIS CONDITION IMPEDES THE CASE OF A HOLE 
    2514            { 
    2515              i_index(nbIndLoc) = index % ni_glo; 
    2516              j_index(nbIndLoc) = index / ni_glo; 
    2517              globalLocalIndexMap_[index] = nbIndLoc;   
    2518              ++nbIndGlob; 
    2519            } 
    2520            // i_index(nbIndGlob) = index % ni_glo; 
    2521            // j_index(nbIndGlob) = index / ni_glo; 
    2522            // globalLocalIndexMap_[index] = nbIndGlob;   
    2523            // ++nbIndGlob; 
     2519//           { 
     2520//             i_index(nbIndLoc) = index % ni_glo; 
     2521//             j_index(nbIndLoc) = index / ni_glo; 
     2522//             globalLocalIndexMap_[index] = nbIndLoc; 
     2523//             ++nbIndGlob; 
     2524//           } 
     2525            i_index(nbIndGlob) = index % ni_glo; 
     2526            j_index(nbIndGlob) = index / ni_glo; 
     2527            globalLocalIndexMap_[index] = nbIndGlob; 
     2528            ++nbIndGlob; 
    25242529         }  
    25252530      }  
  • XIOS/dev/dev_olga/src/node/domain.hpp

    r1553 r1571  
    142142         CArray<double, 1> areavalue; 
    143143 
    144          CArray<size_t,1> localIndexToWriteOnServer;          
     144         CArray<int,1> localIndexToWriteOnServer; 
    145145 
    146146         CArray<bool, 1> domainMask; // mask_1d, mask_2d -> domainMask 
  • XIOS/dev/dev_olga/src/node/grid.cpp

    r1570 r1571  
    841841         // Even if a client has no index, it must connect to at least one server and 
    842842         // send an "empty" data to this server 
     843//         if (connectedServerRank_[receiverSize].empty()) 
     844//          connectedServerRank_[receiverSize].push_back(client->clientRank % client->serverSize); 
     845 
     846         // Trying instead: send empty data to all servers 
    843847         if (connectedServerRank_[receiverSize].empty()) 
    844           connectedServerRank_[receiverSize].push_back(client->clientRank % client->serverSize); 
     848           for (int i = 0; i < client->serverSize; ++i) 
     849           connectedServerRank_[receiverSize].push_back(i); 
    845850 
    846851         nbSenders[receiverSize] = clientServerMap_->computeConnectedClients(receiverSize, client->clientSize, client->intraComm, connectedServerRank_[receiverSize]); 
Note: See TracChangeset for help on using the changeset viewer.