Ignore:
Timestamp:
01/08/18 16:46:46 (6 years ago)
Author:
oabramkina
Message:

Taking into account a possibility of having a hole on the client side (NEMO-like grid).

File:
1 edited

Legend:

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

    r1333 r1390  
    128128           for (int idx = 0; idx < nbWritten; ++idx) 
    129129           { 
    130               writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
    131               writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
     130                  if (idx < domain->latvalue.numElements()) 
     131                  { 
     132                writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
     133                writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
     134                  } 
     135                  else 
     136                  { 
     137                writtenLat(idx) = 0.; 
     138                writtenLon(idx) = 0.; 
     139                  } 
    132140           } 
    133141          
     
    143151               for (int nv = 0; nv < nvertex; ++nv) 
    144152               { 
    145                  writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 
    146                  writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 
     153                 if (idx < boundslat.columns()) 
     154                 { 
     155                   writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 
     156                   writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 
     157                 } 
     158                 else 
     159                 { 
     160                   writtenBndsLat(nv, idx) = 0.; 
     161                   writtenBndsLon(nv, idx) = 0.; 
     162                 } 
    147163               } 
    148164           } 
     
    154170           for (int idx = 0; idx < nbWritten; ++idx) 
    155171           { 
    156               writtenArea(idx) = domain->areavalue(indexToWrite(idx));                       
     172                  if (idx < domain->areavalue.numElements()) 
     173                writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 
     174                  else 
     175                writtenArea(idx) = 0.; 
    157176           } 
    158177         } 
     
    940959           for (int idx = 0; idx < nbWritten; ++idx) 
    941960           { 
    942               writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
    943               writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
    944            } 
     961             if (idx < domain->latvalue.numElements()) 
     962             { 
     963               writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
     964               writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
     965             } 
     966             else 
     967             { 
     968               writtenLat(idx) = 0.; 
     969               writtenLon(idx) = 0.; 
     970             } 
     971           } 
     972         } 
    945973          
    946  
    947            if (domain->hasBounds) 
    948            {          
    949              int nvertex = domain->nvertex, idx; 
    950              writtenBndsLat.resize(nvertex, nbWritten); 
    951              writtenBndsLon.resize(nvertex, nbWritten); 
    952              CArray<double,2>& boundslat = domain->bounds_latvalue; 
    953              CArray<double,2>& boundslon = domain->bounds_lonvalue;    
    954              for (idx = 0; idx < nbWritten; ++idx) 
    955                for (int nv = 0; nv < nvertex; ++nv) 
     974         if (domain->hasBounds) 
     975         { 
     976           int nvertex = domain->nvertex, idx; 
     977           writtenBndsLat.resize(nvertex, nbWritten); 
     978           writtenBndsLon.resize(nvertex, nbWritten); 
     979           CArray<double,2>& boundslat = domain->bounds_latvalue; 
     980           CArray<double,2>& boundslon = domain->bounds_lonvalue; 
     981           for (idx = 0; idx < nbWritten; ++idx) 
     982           { 
     983             for (int nv = 0; nv < nvertex; ++nv) 
     984             { 
     985               if (idx < boundslat.columns()) 
    956986               { 
    957987                 writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 
    958988                 writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 
    959989               } 
     990               else 
     991               { 
     992                 writtenBndsLat(nv, idx) = 0.; 
     993                 writtenBndsLon(nv, idx) = 0.; 
     994                } 
     995             } 
    960996           } 
    961997         } 
     
    9661002           for (int idx = 0; idx < nbWritten; ++idx) 
    9671003           { 
    968               writtenArea(idx) = domain->areavalue(indexToWrite(idx));                       
     1004                  if (idx < domain->areavalue.numElements()) 
     1005                writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 
     1006                  else 
     1007                writtenArea(idx) = 0.; 
    9691008           } 
    9701009         } 
Note: See TracChangeset for help on using the changeset viewer.