Ignore:
Timestamp:
12/14/18 11:20:33 (5 years ago)
Author:
oabramkina
Message:

Bugfix for NEMO-like land processes elimination.

Values describing a domain (latitude, longitude, bounds,...) are set to -1 on land processes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/branchs/xios-2.5/src/io/nc4_data_output.cpp

    r1509 r1624  
    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()) 
    169                   { 
    170                 writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
    171                 writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
    172                   } 
    173                   else 
    174                   { 
    175                 writtenLat(idx) = 0.; 
    176                 writtenLon(idx) = 0.; 
    177                   } 
     168             if (indexToWrite(idx) < 0) 
     169             { 
     170               writtenLat(idx) = -1.;   // hole 
     171               writtenLon(idx) = -1.; 
     172             } 
     173             else 
     174             { 
     175               writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
     176               writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
     177             } 
    178178           } 
    179           
    180179 
    181180           if (domain->hasBounds) 
     
    189188               for (int nv = 0; nv < nvertex; ++nv) 
    190189               { 
    191                  if (idx < boundslat.columns()) 
    192                  { 
     190                 if (indexToWrite(idx) < 0) 
     191                 { 
     192                   writtenBndsLat(nv, idx) = -1.;  // hole 
     193                   writtenBndsLon(nv, idx) = -1.; 
     194                 } 
     195                 else 
     196                 { 
    193197                   writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 
    194198                   writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 
    195                  } 
    196                  else 
    197                  { 
    198                    writtenBndsLat(nv, idx) = 0.; 
    199                    writtenBndsLon(nv, idx) = 0.; 
    200                  } 
     199                 } 
    201200               } 
    202201           } 
     
    208207           for (int idx = 0; idx < nbWritten; ++idx) 
    209208           { 
    210                   if (idx < domain->areavalue.numElements()) 
    211                 writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 
     209                  if (indexToWrite(idx) < 0) 
     210              writtenArea(idx) = -1.; 
    212211                  else 
    213                 writtenArea(idx) = 0.; 
     212              writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 
    214213           } 
    215214         } 
     
    221220              case (MULTI_FILE) : 
    222221              { 
    223   //               if (domain->isEmpty()) return; 
    224  
    225                  if (server->intraCommSize > 1) 
    226                  { 
    227   //                 SuperClassWriter::addDimension(lonid, domain->zoom_ni.getValue()); 
    228   //                 SuperClassWriter::addDimension(latid, domain->zoom_nj.getValue()); 
    229                  } 
    230  
    231222                 switch (domain->type) 
    232223                 { 
     
    434425                     std::vector<StdSize> start(2) ; 
    435426                     std::vector<StdSize> count(2) ; 
    436                      if (domain->isEmpty()) 
    437                      { 
    438                        start[0]=0 ; start[1]=0 ; 
    439                        count[0]=0 ; count[1]=0 ; 
    440                      } 
    441                      else 
     427// Comment out because it is not working for a hole 
     428//                     if (domain->isEmpty()) 
     429//                     { 
     430//                       start[0]=0 ; start[1]=0 ; 
     431//                       count[0]=0 ; count[1]=0 ; 
     432//                     } 
     433//                     else 
    442434                     { 
    443435                       start[1]=domain->zoom_ibegin-domain->global_zoom_ibegin; 
     
    883875          case (MULTI_FILE) : 
    884876          { 
     877            ERROR("CNc4DataOutput::writeDomain(domain)", 
     878            << "[ type = multiple_file ]" 
     879            << " is not yet implemented for UGRID files !"); 
    885880            break; 
    886881          } 
     
    948943         int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; 
    949944 
    950          CArray<size_t, 1>& indexToWrite = domain->localIndexToWriteOnServer; 
     945         CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; 
    951946         int nbWritten = indexToWrite.numElements(); 
    952947         CArray<double,1> writtenLat, writtenLon; 
     
    960955           for (int idx = 0; idx < nbWritten; ++idx) 
    961956           { 
    962              if (idx < domain->latvalue.numElements()) 
    963              { 
    964                writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
    965                writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
    966              } 
    967              else 
    968              { 
    969                writtenLat(idx) = 0.; 
    970                writtenLon(idx) = 0.; 
    971              } 
     957             if (indexToWrite(idx) < 0) 
     958             { 
     959               writtenLat(idx) = -1.; 
     960               writtenLon(idx) = -1.; 
     961             } 
     962             else 
     963             { 
     964               writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
     965               writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
     966             } 
    972967           } 
    973968         } 
     
    984979             for (int nv = 0; nv < nvertex; ++nv) 
    985980             { 
    986                if (idx < boundslat.columns()) 
     981               if (indexToWrite(idx) < 0) 
     982               { 
     983                 writtenBndsLat(nv, idx) = -1.; 
     984                 writtenBndsLon(nv, idx) = -1.; 
     985               } 
     986               else 
    987987               { 
    988988                 writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 
    989989                 writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 
    990                } 
    991                else 
    992                { 
    993                  writtenBndsLat(nv, idx) = 0.; 
    994                  writtenBndsLon(nv, idx) = 0.; 
    995990                } 
    996991             } 
     
    1003998           for (int idx = 0; idx < nbWritten; ++idx) 
    1004999           { 
    1005                   if (idx < domain->areavalue.numElements()) 
    1006                 writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 
    1007                   else 
    1008                 writtenArea(idx) = 0.; 
     1000             if (indexToWrite(idx) < 0) 
     1001               writtenArea(idx) = -1.; 
     1002             else 
     1003               writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 
    10091004           } 
    10101005         } 
     
    12881283          SuperClassWriter::definition_end(); 
    12891284 
    1290           CArray<size_t, 1>& indexToWrite = axis->localIndexToWriteOnServer; 
     1285          CArray<int, 1>& indexToWrite = axis->localIndexToWriteOnServer; 
    12911286          int nbWritten = indexToWrite.numElements(); 
    12921287          CArray<double,1> axis_value(indexToWrite.numElements()); 
     
    12951290            for (int i = 0; i < nbWritten; i++) 
    12961291            { 
    1297               if (i < axis->value.numElements()) 
     1292              if (indexToWrite(i) < 0) 
     1293                axis_value(i) = -1;   // Some value in case of a hole 
     1294              else 
    12981295                axis_value(i) = axis->value(indexToWrite(i)); 
    1299               else 
    1300                 axis_value(i) = 0.; 
    13011296            } 
    13021297          } 
     
    13081303            for (int i = 0; i < nbWritten; i++) 
    13091304            { 
    1310               if (i < axis->label.numElements()) 
     1305              if (indexToWrite(i) < 0) 
     1306                axis_label(i) = boost::lexical_cast<string>(-1);  // Some value in case of a hole 
     1307              else 
    13111308                axis_label(i) = axis->label(indexToWrite(i)); 
    1312               else 
    1313                 axis_label(i) = boost::lexical_cast<string>(0);  // Write 0 as a label 
    13141309            } 
    13151310          } 
     
    13291324                  for (int i = 0; i < nbWritten; ++i) 
    13301325                  { 
    1331                     if (i < axis->bounds.columns()) 
     1326                    if (indexToWrite(i) < 0) 
     1327                    { 
     1328                      axis_bounds(0, i) = -1.; // Some value in case of a hole 
     1329                      axis_bounds(1, i) = -1.; 
     1330                    } 
     1331                    else 
    13321332                    { 
    13331333                      axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 
    13341334                      axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 
    1335                     } 
    1336                     else 
    1337                     { 
    1338                       axis_bounds(0, i) = 0.; 
    1339                       axis_bounds(1, i) = 0.; 
    1340  
    13411335                    } 
    13421336                  } 
     
    13691363                  for (int i = 0; i < nbWritten; ++i) 
    13701364                  { 
    1371                     if (i < axis->bounds.columns()) 
     1365                    if (indexToWrite(i) < 0) 
     1366                    { 
     1367                      axis_bounds(0, i) = -1.; 
     1368                      axis_bounds(1, i) = -1.; 
     1369                    } 
     1370                    else 
    13721371                    { 
    13731372                      axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 
    13741373                      axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 
    1375                     } 
    1376                     else 
    1377                     { 
    1378                       axis_bounds(0, i) = 0.; 
    1379                       axis_bounds(1, i) = 0.; 
    13801374                    } 
    13811375                  } 
     
    25122506                   if ( wtimeData) 
    25132507                   { 
    2514 //                     SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1); 
    2515 //                     SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1); 
    25162508                       SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 
    25172509                       SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); 
     
    25192511                   if (wtimeCounter) 
    25202512                   { 
    2521 //                     SuperClassWriter::writeData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1); 
    2522 //                     if (timeCounterType!=record) SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1); 
    25232513                     SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot); 
    25242514                     if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); 
     
    25962586                          count.push_back(nZoomSizeServer[idx]); 
    25972587                        } 
    2598  
    25992588                        --idxAxis; 
    26002589                        --idx; 
     
    26102599                  int numElement = axisDomainOrder.numElements(); 
    26112600                  int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 
    2612                   int idx = domainList.size() * 2 + axisList.size() - 1;// nZoomBeginGlobal.size() - 1; 
     2601                  int idx = domainList.size() * 2 + axisList.size() - 1; 
    26132602 
    26142603                  start.reserve(nZoomBeginGlobal.size()); 
     
    26622651                   if ( wtimeData) 
    26632652                   { 
    2664 //                     SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1); 
    2665 //                     SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1); 
    26662653                     SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 
    26672654                     SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); 
     
    26692656                   if (wtimeCounter) 
    26702657                   { 
    2671 //                     SuperClassWriter::writeData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1); 
    2672 //                     if (timeCounterType!=record) SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1); 
    26732658                     SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot); 
    26742659                     if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); 
Note: See TracChangeset for help on using the changeset viewer.