Changeset 2511 for XIOS2


Ignore:
Timestamp:
06/02/23 15:18:25 (13 months ago)
Author:
ymipsl
Message:

Revert commit 2440 & 2442 that introduced bounds management for rectilinear grid, that make transformations unstable. A specific branch has been created to keep this modifications.
YM

Location:
XIOS2/trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • XIOS2/trunk/src/io/nc4_data_output.cpp

    r2440 r2511  
    142142         } 
    143143 
    144          StdString dimVertId ; 
    145          if (domain->type==CDomain::type_attr::rectilinear)  dimVertId=StdString("domain_nbounds").append(appendDomid); 
    146          else dimVertId=StdString("nvertex").append(appendDomid); 
     144         StdString dimVertId = StdString("nvertex").append(appendDomid); 
    147145 
    148146         string lonid,latid,bounds_lonid,bounds_latid ; 
     
    183181           if (domain->hasBounds) 
    184182           {          
    185              int idx; 
    186              int nvertexValue = (domain->type==CDomain::type_attr::rectilinear || type==CDomain::type_attr::curvilinear) ? 4 : domain->nvertex ; 
    187  
    188              writtenBndsLat.resize(nvertexValue, nbWritten); 
    189              writtenBndsLon.resize(nvertexValue, nbWritten); 
     183             int nvertex = domain->nvertex, idx; 
     184             writtenBndsLat.resize(nvertex, nbWritten); 
     185             writtenBndsLon.resize(nvertex, nbWritten); 
    190186             CArray<double,2>& boundslat = domain->bounds_latvalue; 
    191187             CArray<double,2>& boundslon = domain->bounds_lonvalue;    
    192188             for (idx = 0; idx < nbWritten; ++idx) 
    193                for (int nv = 0; nv < nvertexValue; ++nv) 
     189               for (int nv = 0; nv < nvertex; ++nv) 
    194190               { 
    195191                 if (indexToWrite(idx) < 0) 
     
    248244 
    249245                 if (domain->hasBounds) 
    250                  {   
    251                     
    252                    if (domain->type==CDomain::type_attr::rectilinear) SuperClassWriter::addDimension(dimVertId,2); 
    253                    else if (domain->type==CDomain::type_attr::curvilinear) SuperClassWriter::addDimension(dimVertId,4); 
    254                    else SuperClassWriter::addDimension(dimVertId, domain->nvertex); 
    255                  } 
     246                   SuperClassWriter::addDimension(dimVertId, domain->nvertex); 
    256247 
    257248                 int commRank ; 
     
    299290                     SuperClassWriter::addAttribute("bounds", bounds_latid, &latid); 
    300291 
    301                      if (domain->type==CDomain::type_attr::curvilinear) 
    302                      { 
    303                        dim0.clear(); 
    304                        dim0.push_back(dimYid); 
    305                        dim0.push_back(dimXid); 
    306                        dim0.push_back(dimVertId); 
    307                        SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); 
    308                        SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); 
    309                      } 
    310                      else if(domain->type==CDomain::type_attr::rectilinear) 
    311                      { 
    312                        dim0.clear(); 
    313                        dim0.push_back(dimXid); 
    314                        dim0.push_back(dimVertId); 
    315                        SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); 
    316                        dim0.clear(); 
    317                        dim0.push_back(dimYid); 
    318                        dim0.push_back(dimVertId); 
    319                        SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); 
    320                      } 
    321  
     292                     dim0.clear(); 
     293                     dim0.push_back(dimYid); 
     294                     dim0.push_back(dimXid); 
     295                     dim0.push_back(dimVertId); 
     296                     SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); 
     297                     SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); 
    322298                   } 
    323299                 } 
    324                  
     300 
     301                 dim0.clear(); 
     302                 dim0.push_back(dimYid); 
     303                 dim0.push_back(dimXid); 
     304 
    325305 
    326306  // supress mask               if (server->intraCommSize > 1) 
     
    354334                       SuperClassWriter::writeData(writtenLat, latid, isCollective, 0); 
    355335                       SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0); 
    356                        if (domain->hasBounds) 
    357                        { 
    358                           SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0); 
    359                           SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0); 
    360                        } 
    361336                       break; 
    362337                     case CDomain::type_attr::rectilinear : 
     
    365340                       CArray<double,1> lon = writtenLon(Range(0,domain->ni-1)) ; 
    366341                       SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0); 
    367                        if (domain->hasBounds) 
    368                        { 
    369                           CArray<double,2> BoundsLon = writtenBndsLon(Range(0,1),Range(0,domain->ni-1)); 
    370                           CArray<double,2> BoundsLat = writtenBndsLat(Range(1,2),Range(fromStart,toEnd,domain->ni)); 
    371                           SuperClassWriter::writeData(BoundsLon.copy(), bounds_lonid, isCollective, 0); 
    372                           SuperClassWriter::writeData(BoundsLat.copy(), bounds_latid, isCollective, 0); 
    373                        } 
    374342                       break; 
     343                   } 
     344 
     345                   if (domain->hasBounds) 
     346                   { 
     347                     SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0); 
     348                     SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0); 
    375349                   } 
    376350                 } 
     
    391365 
    392366                 if (domain->hasBounds) 
    393                  {   
    394                     
    395                    if (domain->type==CDomain::type_attr::rectilinear) SuperClassWriter::addDimension(dimVertId,2); 
    396                    else if (domain->type==CDomain::type_attr::curvilinear) SuperClassWriter::addDimension(dimVertId,4); 
    397                    else SuperClassWriter::addDimension(dimVertId, domain->nvertex); 
    398                  } 
     367                   SuperClassWriter::addDimension(dimVertId, domain->nvertex); 
    399368 
    400369                 if (domain->hasLonLat) 
     
    434403                     SuperClassWriter::addAttribute("bounds", bounds_latid, &latid); 
    435404 
    436                      if (domain->type==CDomain::type_attr::curvilinear) 
    437                      { 
    438                        dim0.clear(); 
    439                        dim0.push_back(dimYid); 
    440                        dim0.push_back(dimXid); 
    441                        dim0.push_back(dimVertId); 
    442                        SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); 
    443                        SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); 
    444                      } 
    445                      else if(domain->type==CDomain::type_attr::rectilinear) 
    446                      { 
    447                        dim0.clear(); 
    448                        dim0.push_back(dimXid); 
    449                        dim0.push_back(dimVertId); 
    450                        SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); 
    451                        dim0.clear(); 
    452                        dim0.push_back(dimYid); 
    453                        dim0.push_back(dimVertId); 
    454                        SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); 
    455                      } 
    456  
     405                     dim0.clear(); 
     406                     dim0.push_back(dimYid); 
     407                     dim0.push_back(dimXid); 
     408                     dim0.push_back(dimVertId); 
     409                     SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); 
     410                     SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); 
    457411                   } 
    458  
    459  
    460  
    461  
    462412                 } 
    463413 
     
    498448                       SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); 
    499449                     } 
    500                      if (domain->hasBounds) 
    501                      { 
    502                        std::vector<StdSize> start(3); 
    503                        std::vector<StdSize> count(3); 
    504                       //  if (domain->isEmpty()) 
    505                       //  { 
    506                       //   start[2] = start[1] = start[0] = 0; 
    507                       //   count[2] = count[1] = count[0] = 0; 
    508                       // } 
    509                       // else 
    510                        { 
    511                          start[2] = 0; 
    512                          start[1] = domain->ibegin; 
    513                          start[0] = domain->jbegin; 
    514                          count[2] = 4; 
    515                          count[1] = domain->ni; 
    516                          count[0] = domain->nj; 
    517                         } 
    518                         SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0, &start, &count); 
    519                         SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0, &start, &count); 
    520                       } 
    521                     break; 
    522                   } 
    523                   case CDomain::type_attr::rectilinear : 
    524                   { 
     450                     break; 
     451                   } 
     452                   case CDomain::type_attr::rectilinear : 
     453                   { 
    525454                     if (domain->hasLonLat) 
    526455                     { 
     
    547476                       } 
    548477                     } 
    549                      
    550                      if (domain->hasBounds) 
    551                      { 
    552                        std::vector<StdSize> start(2); 
    553                        std::vector<StdSize> count(2); 
    554                        if (domain->isEmpty()) 
    555                        { 
    556                          start[1] = start[0] = 0; 
    557                          count[1] = count[0] = 0; 
    558                          SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0,&start,&count); 
    559                          SuperClassWriter::writeData(writtenBndsLon, bounds_latid, isCollective, 0,&start,&count); 
    560                        } 
    561                        else 
    562                        { 
    563                          start[1]=0 ; 
    564                          count[1]=2 ; 
    565                          start[0]=domain->jbegin; 
    566                          count[0]=domain->nj; 
    567                          CArray<double,2> BoundsLat = writtenBndsLat(Range(1,2),Range(fromStart,toEnd,domain->ni)); 
    568                          SuperClassWriter::writeData(CArray<double,2>(BoundsLat.copy()), bounds_latid, isCollective, 0,&start,&count); 
    569                           
    570                          start[1]=0 ; 
    571                          count[1]=2 ; 
    572                          start[0]=domain->ibegin; 
    573                          count[0]=domain->ni; 
    574                          CArray<double,2> BoundsLon = writtenBndsLon(Range(0,1),Range(0,domain->ni-1)); 
    575                          SuperClassWriter::writeData(CArray<double,2>(BoundsLon.copy()), bounds_lonid, isCollective, 0,&start,&count); 
    576                        } 
    577                      } 
    578478                     break; 
    579479                   } 
     480                 } 
     481 
     482                 if (domain->hasBounds) 
     483                 { 
     484                   std::vector<StdSize> start(3); 
     485                   std::vector<StdSize> count(3); 
     486                   if (domain->isEmpty()) 
     487                   { 
     488                     start[2] = start[1] = start[0] = 0; 
     489                     count[2] = count[1] = count[0] = 0; 
     490                   } 
     491                   else 
     492                   { 
     493                     start[2] = 0; 
     494                     start[1] = domain->ibegin; 
     495                     start[0] = domain->jbegin; 
     496                     count[2] = domain->nvertex; 
     497                     count[1] = domain->ni; 
     498                     count[0] = domain->nj; 
     499                   } 
     500                  
     501                   SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0, &start, &count); 
     502                   SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0, &start, &count); 
    580503                 } 
    581504 
  • XIOS2/trunk/src/node/domain.cpp

    r2440 r2511  
    187187       size_t sizeLonLatEvent = CArray<double,1>::size(idxCount); 
    188188       if (hasBounds) 
    189        { 
    190          int nvertexValue ; 
    191          if (type==type_attr::rectilinear || type==type_attr::curvilinear) nvertexValue=4 ; 
    192          else nvertexValue=nvertex ; 
    193          sizeLonLatEvent += CArray<double,2>::size(nvertexValue * idxCount); 
    194        } 
     189         sizeLonLatEvent += CArray<double,2>::size(nvertex * idxCount); 
    195190 
    196191       size_t size = CEventClient::headerSize + getId().size() + sizeof(size_t) + std::max(sizeIndexEvent, sizeLonLatEvent); 
     
    14331428           if (hasBounds) 
    14341429           { 
    1435              bounds_lonvalue.resize(4, ni * nj); 
    1436              bounds_latvalue.resize(4, ni * nj); 
     1430             bounds_lonvalue.resize(nvertex, ni * nj); 
     1431             bounds_latvalue.resize(nvertex, ni * nj); 
    14371432           } 
    14381433 
     
    14481443               if (hasBounds) 
    14491444               { 
    1450                   bounds_lonvalue(0,k) = bounds_lon_1d(0,i); 
    1451                   bounds_latvalue(0,k) = bounds_lat_1d(0,j); 
    1452                   bounds_lonvalue(1,k) = bounds_lon_1d(1,i); 
    1453                   bounds_latvalue(1,k) = bounds_lat_1d(0,j); 
    1454                   bounds_lonvalue(2,k) = bounds_lon_1d(1,i); 
    1455                   bounds_latvalue(2,k) = bounds_lat_1d(1,j); 
    1456                   bounds_lonvalue(3,k) = bounds_lon_1d(0,i); 
    1457                   bounds_latvalue(3,k) = bounds_lat_1d(1,j); 
     1445                 for (int n = 0; n < nvertex; ++n) 
     1446                 { 
     1447                   bounds_lonvalue(n,k) = bounds_lon_1d(n,i); 
     1448                   bounds_latvalue(n,k) = bounds_lat_1d(n,j); 
     1449                 } 
    14581450               } 
    14591451             } 
     
    15531545           if (hasBounds) 
    15541546           { 
    1555              bounds_lonvalue.resize(4, ni * nj); 
    1556              bounds_latvalue.resize(4, ni * nj); 
     1547             bounds_lonvalue.resize(nvertex, ni * nj); 
     1548             bounds_latvalue.resize(nvertex, ni * nj); 
    15571549           } 
    15581550 
     
    15681560               if (hasBounds) 
    15691561               { 
    1570                   bounds_lonvalue(0,k) = bounds_lon_1d(0,i); 
    1571                   bounds_latvalue(0,k) = bounds_lat_1d(0,j); 
    1572                   bounds_lonvalue(1,k) = bounds_lon_1d(1,i); 
    1573                   bounds_latvalue(1,k) = bounds_lat_1d(0,j); 
    1574                   bounds_lonvalue(2,k) = bounds_lon_1d(1,i); 
    1575                   bounds_latvalue(2,k) = bounds_lat_1d(1,j); 
    1576                   bounds_lonvalue(3,k) = bounds_lon_1d(0,i); 
    1577                   bounds_latvalue(3,k) = bounds_lat_1d(1,j); 
     1562                 for (int n = 0; n < nvertex; ++n) 
     1563                 { 
     1564                   bounds_lonvalue(n,k) = bounds_lon_1d(n,i); 
     1565                   bounds_latvalue(n,k) = bounds_lat_1d(n,j); 
     1566                 } 
    15781567               } 
    15791568             } 
     
    16161605   TRY 
    16171606   { 
    1618      int nvertexValue ;  
    16191607     bool hasBoundValues = (0 != bounds_lonvalue.numElements()) || (0 != bounds_latvalue.numElements()); 
    1620      if (hasBoundValues)  
    1621      { 
    1622        hasBounds=true ; 
    1623        return ; 
    1624       } 
    1625  
    1626      if (type_attr::rectilinear == type) nvertexValue=2 ; 
    1627      else if (type_attr::curvilinear == type) nvertexValue=4 ; 
    1628      else if (!nvertex.isEmpty() && nvertex>0) nvertexValue = nvertex ; 
    1629      else  
    1630      { 
    1631        hasBounds=false ; 
    1632        return ; 
    1633      } 
    1634      
    1635       if (!bounds_lon_1d.isEmpty() && !bounds_lon_2d.isEmpty()) 
    1636         ERROR("CDomain::checkBounds(void)", 
    1637               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    1638               << "Only one longitude boundary attribute can be used but both 'bounds_lon_1d' and 'bounds_lon_2d' are defined." << std::endl 
    1639               << "Define only one longitude boundary attribute: 'bounds_lon_1d' or 'bounds_lon_2d'."); 
    1640  
    1641       if (!bounds_lat_1d.isEmpty() && !bounds_lat_2d.isEmpty()) 
    1642         ERROR("CDomain::checkBounds(void)", 
    1643               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    1644               << "Only one latitude boundary attribute can be used but both 'bounds_lat_1d' and 'bounds_lat_2d' are defined." << std::endl 
    1645               << "Define only one latitude boundary attribute: 'bounds_lat_1d' or 'bounds_lat_2d'."); 
    1646  
    1647       if ((!bounds_lon_1d.isEmpty() && bounds_lat_1d.isEmpty()) || (bounds_lon_1d.isEmpty() && !bounds_lat_1d.isEmpty())) 
    1648       { 
    1649         ERROR("CDomain::checkBounds(void)", 
    1650               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    1651               << "Only 'bounds_lon_1d' or 'bounds_lat_1d' is defined." << std::endl 
    1652               << "Please define either both attributes or none."); 
    1653       } 
    1654  
    1655       if ((!bounds_lon_2d.isEmpty() && bounds_lat_2d.isEmpty()) || (bounds_lon_2d.isEmpty() && !bounds_lat_2d.isEmpty())) 
    1656       { 
    1657         ERROR("CDomain::checkBounds(void)", 
    1658               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    1659               << "Only 'bounds_lon_2d' or 'bounds_lat_2d' is defined." << std::endl 
    1660               << "Please define either both attributes or none."); 
    1661       } 
    1662  
    1663       if (!bounds_lon_1d.isEmpty() && nvertexValue != bounds_lon_1d.extent(0)) 
    1664         ERROR("CDomain::checkBounds(void)", 
    1665               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    1666               << "'bounds_lon_1d' dimension is not compatible with 'nvertex'." << std::endl 
    1667               << "'bounds_lon_1d' dimension is " << bounds_lon_1d.extent(0) 
    1668               << " but nvertex is " << nvertexValue << "."); 
    1669  
    1670       if (!bounds_lon_2d.isEmpty() && nvertexValue != bounds_lon_2d.extent(0)) 
    1671         ERROR("CDomain::checkBounds(void)", 
    1672               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    1673               << "'bounds_lon_2d' dimension is not compatible with 'nvertex'." << std::endl 
    1674               << "'bounds_lon_2d' dimension is " << bounds_lon_2d.extent(0) 
    1675               << " but nvertex is " << nvertexValue << "."); 
    1676  
    1677       if (!bounds_lon_1d.isEmpty() && lonvalue_1d.isEmpty()) 
    1678         ERROR("CDomain::checkBounds(void)", 
    1679               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    1680               << "Since 'bounds_lon_1d' is defined, 'lonvalue_1d' must be defined too." << std::endl); 
    1681  
    1682       if (!bounds_lon_2d.isEmpty() && lonvalue_2d.isEmpty()) 
    1683         ERROR("CDomain::checkBounds(void)", 
    1684               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    1685               << "Since 'bounds_lon_2d' is defined, 'lonvalue_2d' must be defined too." << std::endl); 
    1686  
    1687       if (!bounds_lat_1d.isEmpty() && nvertexValue != bounds_lat_1d.extent(0)) 
    1688         ERROR("CDomain::checkBounds(void)", 
    1689               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    1690               << "'bounds_lat_1d' dimension is not compatible with 'nvertex'." << std::endl 
    1691               << "'bounds_lat_1d' dimension is " << bounds_lat_1d.extent(0) 
    1692               << " but nvertex is " << nvertexValue << "."); 
    1693  
    1694       if (!bounds_lat_2d.isEmpty() && nvertex.getValue() != bounds_lat_2d.extent(0)) 
    1695         ERROR("CDomain::checkBounds(void)", 
    1696               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    1697               << "'bounds_lat_2d' dimension is not compatible with 'nvertex'." << std::endl 
    1698               << "'bounds_lat_2d' dimension is " << bounds_lat_2d.extent(0) 
    1699               << " but nvertex is " << nvertexValue << "."); 
    1700  
    1701       if (!bounds_lat_1d.isEmpty() && latvalue_1d.isEmpty()) 
    1702         ERROR("CDomain::checkBounds(void)", 
    1703               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    1704               << "Since 'bounds_lat_1d' is defined, 'latvalue_1d' must be defined too." << std::endl); 
    1705  
    1706       if (!bounds_lat_2d.isEmpty() && latvalue_2d.isEmpty()) 
    1707         ERROR("CDomain::checkBounds(void)", 
    1708               << "Since 'bounds_lat_2d' is defined, 'latvalue_2d' must be defined too." << std::endl); 
    1709  
    1710       // In case of reading UGRID bounds values are not required 
    1711       hasBounds = (!bounds_lat_1d.isEmpty() || !bounds_lat_2d.isEmpty() ); 
     1608     if (!nvertex.isEmpty() && nvertex > 0 && !hasBoundValues) 
     1609     { 
     1610       if (!bounds_lon_1d.isEmpty() && !bounds_lon_2d.isEmpty()) 
     1611         ERROR("CDomain::checkBounds(void)", 
     1612               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1613               << "Only one longitude boundary attribute can be used but both 'bounds_lon_1d' and 'bounds_lon_2d' are defined." << std::endl 
     1614               << "Define only one longitude boundary attribute: 'bounds_lon_1d' or 'bounds_lon_2d'."); 
     1615 
     1616       if (!bounds_lat_1d.isEmpty() && !bounds_lat_2d.isEmpty()) 
     1617         ERROR("CDomain::checkBounds(void)", 
     1618               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1619               << "Only one latitude boundary attribute can be used but both 'bounds_lat_1d' and 'bounds_lat_2d' are defined." << std::endl 
     1620               << "Define only one latitude boundary attribute: 'bounds_lat_1d' or 'bounds_lat_2d'."); 
     1621 
     1622       if ((!bounds_lon_1d.isEmpty() && bounds_lat_1d.isEmpty()) || (bounds_lon_1d.isEmpty() && !bounds_lat_1d.isEmpty())) 
     1623       { 
     1624         ERROR("CDomain::checkBounds(void)", 
     1625               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1626               << "Only 'bounds_lon_1d' or 'bounds_lat_1d' is defined." << std::endl 
     1627               << "Please define either both attributes or none."); 
     1628       } 
     1629 
     1630       if ((!bounds_lon_2d.isEmpty() && bounds_lat_2d.isEmpty()) || (bounds_lon_2d.isEmpty() && !bounds_lat_2d.isEmpty())) 
     1631       { 
     1632         ERROR("CDomain::checkBounds(void)", 
     1633               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1634               << "Only 'bounds_lon_2d' or 'bounds_lat_2d' is defined." << std::endl 
     1635               << "Please define either both attributes or none."); 
     1636       } 
     1637 
     1638       if (!bounds_lon_1d.isEmpty() && nvertex.getValue() != bounds_lon_1d.extent(0)) 
     1639         ERROR("CDomain::checkBounds(void)", 
     1640               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1641               << "'bounds_lon_1d' dimension is not compatible with 'nvertex'." << std::endl 
     1642               << "'bounds_lon_1d' dimension is " << bounds_lon_1d.extent(0) 
     1643               << " but nvertex is " << nvertex.getValue() << "."); 
     1644 
     1645       if (!bounds_lon_2d.isEmpty() && nvertex.getValue() != bounds_lon_2d.extent(0)) 
     1646         ERROR("CDomain::checkBounds(void)", 
     1647               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1648               << "'bounds_lon_2d' dimension is not compatible with 'nvertex'." << std::endl 
     1649               << "'bounds_lon_2d' dimension is " << bounds_lon_2d.extent(0) 
     1650               << " but nvertex is " << nvertex.getValue() << "."); 
     1651 
     1652       if (!bounds_lon_1d.isEmpty() && lonvalue_1d.isEmpty()) 
     1653         ERROR("CDomain::checkBounds(void)", 
     1654               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1655               << "Since 'bounds_lon_1d' is defined, 'lonvalue_1d' must be defined too." << std::endl); 
     1656 
     1657       if (!bounds_lon_2d.isEmpty() && lonvalue_2d.isEmpty()) 
     1658         ERROR("CDomain::checkBounds(void)", 
     1659               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1660               << "Since 'bounds_lon_2d' is defined, 'lonvalue_2d' must be defined too." << std::endl); 
     1661 
     1662       if (!bounds_lat_1d.isEmpty() && nvertex.getValue() != bounds_lat_1d.extent(0)) 
     1663         ERROR("CDomain::checkBounds(void)", 
     1664               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1665               << "'bounds_lat_1d' dimension is not compatible with 'nvertex'." << std::endl 
     1666               << "'bounds_lat_1d' dimension is " << bounds_lat_1d.extent(0) 
     1667               << " but nvertex is " << nvertex.getValue() << "."); 
     1668 
     1669       if (!bounds_lat_2d.isEmpty() && nvertex.getValue() != bounds_lat_2d.extent(0)) 
     1670         ERROR("CDomain::checkBounds(void)", 
     1671               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1672               << "'bounds_lat_2d' dimension is not compatible with 'nvertex'." << std::endl 
     1673               << "'bounds_lat_2d' dimension is " << bounds_lat_2d.extent(0) 
     1674               << " but nvertex is " << nvertex.getValue() << "."); 
     1675 
     1676       if (!bounds_lat_1d.isEmpty() && latvalue_1d.isEmpty()) 
     1677         ERROR("CDomain::checkBounds(void)", 
     1678               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1679               << "Since 'bounds_lat_1d' is defined, 'latvalue_1d' must be defined too." << std::endl); 
     1680 
     1681       if (!bounds_lat_2d.isEmpty() && latvalue_2d.isEmpty()) 
     1682         ERROR("CDomain::checkBounds(void)", 
     1683               << "Since 'bounds_lat_2d' is defined, 'latvalue_2d' must be defined too." << std::endl); 
     1684 
     1685       // In case of reading UGRID bounds values are not required 
     1686       hasBounds = (!bounds_lat_1d.isEmpty() || !bounds_lat_2d.isEmpty() ); 
     1687     } 
     1688     else if (hasBoundValues) 
     1689     { 
     1690       hasBounds = true;        
     1691     } 
     1692     else 
     1693     { 
     1694       hasBounds = false; 
     1695     } 
    17121696   } 
    17131697   CATCH_DUMP_ATTR 
     
    24672451        if (hasBounds) 
    24682452        { 
    2469           int nvertexValue ; 
    2470           if (type==type_attr::rectilinear || type==type_attr::curvilinear) nvertexValue=4 ; 
    2471           else nvertexValue=nvertex ; 
    2472           list_boundslon.push_back(CArray<double,2>(nvertexValue, nbData)); 
    2473           list_boundslat.push_back(CArray<double,2>(nvertexValue, nbData)); 
     2453          list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); 
     2454          list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 
    24742455        } 
    24752456 
     
    24882469            CArray<double,2>& boundslon = list_boundslon.back(); 
    24892470            CArray<double,2>& boundslat = list_boundslat.back(); 
    2490              
    2491             int nvertexValue ; 
    2492             if (type==type_attr::rectilinear || type==type_attr::curvilinear) nvertexValue=4 ; 
    2493             else nvertexValue=nvertex ; 
    2494              
    2495             for (nv = 0; nv < nvertexValue; ++nv) 
     2471 
     2472            for (nv = 0; nv < nvertex; ++nv) 
    24962473            { 
    24972474              boundslon(nv, n) = bounds_lonvalue(nv, localInd); 
     
    28402817      if (hasBounds) 
    28412818      { 
    2842         int nvertexValue = (type==type_attr::rectilinear || type==type_attr::curvilinear) ? 4 : nvertex ; 
    2843         bounds_lonvalue.resize(nvertexValue,nbLonInd); 
     2819        bounds_lonvalue.resize(nvertex,nbLonInd); 
    28442820        bounds_lonvalue = 0.; 
    28452821      } 
     
    28562832           if (hasBounds) 
    28572833           {           
    2858               int nvertexValue = (type==type_attr::rectilinear || type==type_attr::curvilinear) ? 4 : nvertex ; 
    2859               for (int nv = 0; nv < nvertexValue; ++nv) 
    2860                 bounds_lonvalue(nv, lInd) = recvBoundsLonValue[i](nv, ind); 
     2834            for (int nv = 0; nv < nvertex; ++nv) 
     2835              bounds_lonvalue(nv, lInd) = recvBoundsLonValue[i](nv, ind); 
    28612836           }                   
    28622837        } 
     
    29302905      if (hasBounds) 
    29312906      { 
    2932         int nvertexValue = (type==type_attr::rectilinear || type==type_attr::curvilinear) ? 4 : nvertex ; 
    2933          
    2934         bounds_latvalue.resize(nvertexValue,nbLatInd); 
     2907        bounds_latvalue.resize(nvertex,nbLatInd); 
    29352908        bounds_latvalue = 0. ; 
    29362909      } 
     
    29472920           if (hasBounds) 
    29482921           { 
    2949              int nvertexValue = (type==type_attr::rectilinear || type==type_attr::curvilinear) ? 4 : nvertex ; 
    2950  
    2951              CArray<double,2>& boundslat = recvBoundsLatValue[i]; 
    2952              for (int nv = 0; nv < nvertexValue; ++nv) 
    2953              bounds_latvalue(nv, lInd) = boundslat(nv, ind); 
     2922            CArray<double,2>& boundslat = recvBoundsLatValue[i]; 
     2923            for (int nv = 0; nv < nvertex; ++nv) 
     2924              bounds_latvalue(nv, lInd) = boundslat(nv, ind); 
    29542925           }    
    29552926          ++nbLatInd; 
  • XIOS2/trunk/src/test/generic_testcase.f90

    r2442 r2511  
    14151415    INTEGER :: nbp,nbp_glo, offset 
    14161416    DOUBLE PRECISION, ALLOCATABLE :: lon_glo(:), lat_glo(:), lon(:), lat(:) 
    1417     DOUBLE PRECISION, ALLOCATABLE :: bounds_lon_glo(:,:), bounds_lat_glo(:,:), bounds_lon(:,:), bounds_lat(:,:) 
    14181417    LOGICAL,ALLOCATABLE :: mask(:) 
    14191418    LOGICAL,ALLOCATABLE :: dom_mask(:) 
     
    14451444     
    14461445    ALLOCATE(lon(0:ni-1), lat(0:nj-1), mask(0:ni*nj-1), dom_mask(0:ni*nj-1)) 
    1447     ALLOCATE(bounds_lon(2,0:ni-1), bounds_lat(2,0:nj-1)) 
    14481446    mask(:)=.FALSE. 
    14491447    mask(offset:offset+nbp-1)=.TRUE. 
    14501448     
    14511449    ALLOCATE(lon_glo(0:ni_glo-1), lat_glo(0:nj_glo-1)) 
    1452     ALLOCATE(bounds_lon_glo(2,0:ni_glo-1), bounds_lat_glo(2,0:nj_glo-1)) 
    1453  
     1450     
    14541451    DO i=0,ni_glo-1 
    14551452      lon_glo(i)=-180+(i+0.5)*(360./ni_glo) 
    14561453    ENDDO 
    14571454 
    1458     DO i=0,ni_glo-1 
    1459       IF (i==0) THEN 
    1460         bounds_lon_glo(1,0) = (lon_glo(ni_glo-1)-360 + lon_glo(i))/2 
    1461       ELSE 
    1462         bounds_lon_glo(1,i)=(lon_glo(i-1) + lon_glo(i))/2 
    1463       ENDIF 
    1464       IF (i==ni_glo-1) THEN 
    1465         bounds_lon_glo(2,ni_glo-1) = (lon_glo(ni_glo-1) + lon_glo(0)+360)/2 
    1466       ELSE 
    1467         bounds_lon_glo(2,i)=(lon_glo(i+1) + lon_glo(i))/2 
    1468       ENDIF 
    1469     ENDDO 
    1470  
    14711455    DO j=0,nj_glo-1 
    14721456      lat_glo(j)=-90+(j+0.5)*(180./nj_glo) 
    14731457    ENDDO 
    1474    
    1475     DO j=0,nj_glo-1 
    1476       IF (j==0) THEN 
    1477         bounds_lat_glo(1,0) = -90 
    1478       ELSE 
    1479         bounds_lat_glo(1,j)=(lat_glo(j-1) + lat_glo(j))/2 
    1480       ENDIF 
    1481       IF (j==nj_glo-1) THEN 
    1482         bounds_lat_glo(2,nj_glo-1) = 90 
    1483       ELSE 
    1484         bounds_lat_glo(2,j)=(lat_glo(j+1) + lat_glo(j))/2 
    1485       ENDIF 
    1486     ENDDO 
    1487  
     1458      
    14881459    lon(:)=lon_glo(:) 
    14891460    lat(:)=lat_glo(jbegin:jbegin+nj-1) 
    1490     bounds_lon(:,:)=bounds_lon_glo(:,:) 
    1491     bounds_lat(:,:)=bounds_lat_glo(:,jbegin:jbegin+nj-1) 
    14921461 
    14931462    ALLOCATE(return_lon(0:ni*nj-1)) 
     
    15401509                                jbegin=jbegin, nj=nj) 
    15411510      CALL xios_set_domain_attr(TRIM(domain_id), data_dim=2, lonvalue_1d=lon, latvalue_1d=lat, mask_1d=return_mask) 
    1542       !CALL xios_set_domain_attr(TRIM(domain_id), bounds_lon_1d=bounds_lon, bounds_lat_1d=bounds_lat) 
    15431511    ENDIF 
    15441512     
  • XIOS2/trunk/src/transformation/domain_algorithm_extract.cpp

    r2442 r2511  
    135135    if (!domainSrc_->bounds_lon_2d.isEmpty()) 
    136136    { 
    137       domainDest_->bounds_lon_2d.resize(domainSrc_->bounds_lon_2d.shape()[0], niDest, njDest); 
    138       domainDest_->bounds_lon_2d.resize(domainSrc_->bounds_lon_2d.shape()[0], niDest, njDest); 
     137      domainDest_->bounds_lon_2d.resize(domainDest_->nvertex, niDest, njDest); 
     138      domainDest_->bounds_lon_2d.resize(domainDest_->nvertex, niDest, njDest); 
    139139    } 
    140140    else if (!domainSrc_->bounds_lon_1d.isEmpty()) 
    141141    { 
    142       domainDest_->bounds_lon_1d.resize(domainSrc_->bounds_lon_1d.shape()[0], niDest); 
    143       domainDest_->bounds_lon_1d.resize(domainSrc_->bounds_lon_1d.shape()[0], niDest); 
     142      domainDest_->bounds_lon_1d.resize(domainDest_->nvertex, niDest); 
     143      domainDest_->bounds_lon_1d.resize(domainDest_->nvertex, niDest); 
    144144    } 
    145145  } 
     
    177177        if (!domainSrc_->bounds_lon_2d.isEmpty()) 
    178178        { 
    179           for (int n = 0; n < domainSrc_->bounds_lon_2d.shape()[0]; ++n) 
     179          for (int n = 0; n < domainSrc_->nvertex; ++n) 
    180180          { 
    181181            domainDest_->bounds_lon_2d(n,iDest,jDest) = domainSrc_->bounds_lon_2d(n,iSrc,jSrc); 
     
    185185        else if (!domainSrc_->bounds_lon_1d.isEmpty()) 
    186186        { 
    187           for (int n = 0; n < domainSrc_->bounds_lon_1d.shape()[0]; ++n) 
     187          for (int n = 0; n < domainSrc_->nvertex; ++n) 
    188188          { 
    189189            domainDest_->bounds_lon_1d(n,iDest) = domainSrc_->bounds_lon_1d(n,iSrc); 
  • XIOS2/trunk/src/transformation/domain_algorithm_interpolate.cpp

    r2442 r2511  
    125125  int niSrc = domainSrc_->ni.getValue(), njSrc = domainSrc_->nj.getValue(); 
    126126  bool hasBoundSrc = domainSrc_->hasBounds; 
    127   if ((hasBoundSrc) && (!domainSrc_->nvertex.isEmpty())) nVertexSrc = domainSrc_->nvertex.getValue(); // default is constNVertex = 4 
     127  if (hasBoundSrc) nVertexSrc = domainSrc_->nvertex.getValue(); 
    128128  CArray<double,2> boundsLonSrc(nVertexSrc,localDomainSrcSize); 
    129129  CArray<double,2> boundsLatSrc(nVertexSrc,localDomainSrcSize); 
     
    197197  int niDest = domainDest_->ni.getValue(), njDest = domainDest_->nj.getValue(); 
    198198  bool hasBoundDest = domainDest_->hasBounds; 
    199   if ((hasBoundDest) && (!domainDest_->nvertex.isEmpty())) nVertexDest = domainDest_->nvertex.getValue(); // default is constNVertex = 4 
     199  if (hasBoundDest) nVertexDest = domainDest_->nvertex.getValue(); 
    200200  CArray<double,2> boundsLonDest(nVertexDest,localDomainDestSize); 
    201201  CArray<double,2> boundsLatDest(nVertexDest,localDomainDestSize); 
  • XIOS2/trunk/src/transformation/domain_algorithm_zoom.cpp

    r2442 r2511  
    55#include "grid_transformation_factory_impl.hpp" 
    66#include "attribute_template.hpp" 
    7 #include "type.hpp" 
    87 
    98namespace xios { 
     
    147146  if (domainSrc_->hasBounds) 
    148147  { 
    149     nvertex = ( domainSrc_->type==CDomain::type_attr::rectilinear || domainSrc_->type==CDomain::type_attr::curvilinear) ? 4 : domainSrc_->nvertex ; 
     148    nvertex = domainSrc_->nvertex; 
    150149    domainDest_->nvertex.setValue(nvertex); 
    151150    if (!domainSrc_->bounds_lon_1d.isEmpty()) 
Note: See TracChangeset for help on using the changeset viewer.