Changeset 2440


Ignore:
Timestamp:
12/07/22 18:42:46 (19 months ago)
Author:
ymipsl
Message:

Add bounds management for rectilinear domain.
First try.
YM

Location:
XIOS2/trunk/src
Files:
3 edited

Legend:

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

    r2434 r2440  
    142142         } 
    143143 
    144          StdString dimVertId = StdString("nvertex").append(appendDomid); 
     144         StdString dimVertId ; 
     145         if (domain->type==CDomain::type_attr::rectilinear)  dimVertId=StdString("domain_nbounds").append(appendDomid); 
     146         else dimVertId=StdString("nvertex").append(appendDomid); 
    145147 
    146148         string lonid,latid,bounds_lonid,bounds_latid ; 
     
    181183           if (domain->hasBounds) 
    182184           {          
    183              int nvertex = domain->nvertex, idx; 
    184              writtenBndsLat.resize(nvertex, nbWritten); 
    185              writtenBndsLon.resize(nvertex, nbWritten); 
     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); 
    186190             CArray<double,2>& boundslat = domain->bounds_latvalue; 
    187191             CArray<double,2>& boundslon = domain->bounds_lonvalue;    
    188192             for (idx = 0; idx < nbWritten; ++idx) 
    189                for (int nv = 0; nv < nvertex; ++nv) 
     193               for (int nv = 0; nv < nvertexValue; ++nv) 
    190194               { 
    191195                 if (indexToWrite(idx) < 0) 
     
    244248 
    245249                 if (domain->hasBounds) 
    246                    SuperClassWriter::addDimension(dimVertId, domain->nvertex); 
     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                 } 
    247256 
    248257                 int commRank ; 
     
    290299                     SuperClassWriter::addAttribute("bounds", bounds_latid, &latid); 
    291300 
    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); 
     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 
    298322                   } 
    299323                 } 
    300  
    301                  dim0.clear(); 
    302                  dim0.push_back(dimYid); 
    303                  dim0.push_back(dimXid); 
    304  
     324                 
    305325 
    306326  // supress mask               if (server->intraCommSize > 1) 
     
    334354                       SuperClassWriter::writeData(writtenLat, latid, isCollective, 0); 
    335355                       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                       } 
    336361                       break; 
    337362                     case CDomain::type_attr::rectilinear : 
     
    340365                       CArray<double,1> lon = writtenLon(Range(0,domain->ni-1)) ; 
    341366                       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                       } 
    342374                       break; 
    343                    } 
    344  
    345                    if (domain->hasBounds) 
    346                    { 
    347                      SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0); 
    348                      SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0); 
    349375                   } 
    350376                 } 
     
    365391 
    366392                 if (domain->hasBounds) 
    367                    SuperClassWriter::addDimension(dimVertId, domain->nvertex); 
     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                 } 
    368399 
    369400                 if (domain->hasLonLat) 
     
    403434                     SuperClassWriter::addAttribute("bounds", bounds_latid, &latid); 
    404435 
    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); 
     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 
    411457                   } 
     458 
     459 
     460 
     461 
    412462                 } 
    413463 
     
    448498                       SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); 
    449499                     } 
    450                      break; 
    451                    } 
    452                    case CDomain::type_attr::rectilinear : 
    453                    { 
     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                  { 
    454525                     if (domain->hasLonLat) 
    455526                     { 
     
    476547                       } 
    477548                     } 
     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                     } 
    478578                     break; 
    479579                   } 
    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); 
    503580                 } 
    504581 
  • XIOS2/trunk/src/node/domain.cpp

    r2314 r2440  
    187187       size_t sizeLonLatEvent = CArray<double,1>::size(idxCount); 
    188188       if (hasBounds) 
    189          sizeLonLatEvent += CArray<double,2>::size(nvertex * idxCount); 
     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       } 
    190195 
    191196       size_t size = CEventClient::headerSize + getId().size() + sizeof(size_t) + std::max(sizeIndexEvent, sizeLonLatEvent); 
     
    14281433           if (hasBounds) 
    14291434           { 
    1430              bounds_lonvalue.resize(nvertex, ni * nj); 
    1431              bounds_latvalue.resize(nvertex, ni * nj); 
     1435             bounds_lonvalue.resize(4, ni * nj); 
     1436             bounds_latvalue.resize(4, ni * nj); 
    14321437           } 
    14331438 
     
    14431448               if (hasBounds) 
    14441449               { 
    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                  } 
     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); 
    14501458               } 
    14511459             } 
     
    15451553           if (hasBounds) 
    15461554           { 
    1547              bounds_lonvalue.resize(nvertex, ni * nj); 
    1548              bounds_latvalue.resize(nvertex, ni * nj); 
     1555             bounds_lonvalue.resize(4, ni * nj); 
     1556             bounds_latvalue.resize(4, ni * nj); 
    15491557           } 
    15501558 
     
    15601568               if (hasBounds) 
    15611569               { 
    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                  } 
     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); 
    15671578               } 
    15681579             } 
     
    16051616   TRY 
    16061617   { 
     1618     int nvertexValue ;  
    16071619     bool hasBoundValues = (0 != bounds_lonvalue.numElements()) || (0 != bounds_latvalue.numElements()); 
    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      } 
     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() ); 
    16961712   } 
    16971713   CATCH_DUMP_ATTR 
     
    24512467        if (hasBounds) 
    24522468        { 
    2453           list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); 
    2454           list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 
     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)); 
    24552474        } 
    24562475 
     
    24692488            CArray<double,2>& boundslon = list_boundslon.back(); 
    24702489            CArray<double,2>& boundslat = list_boundslat.back(); 
    2471  
    2472             for (nv = 0; nv < nvertex; ++nv) 
     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) 
    24732496            { 
    24742497              boundslon(nv, n) = bounds_lonvalue(nv, localInd); 
     
    28172840      if (hasBounds) 
    28182841      { 
    2819         bounds_lonvalue.resize(nvertex,nbLonInd); 
     2842        int nvertexValue = (type==type_attr::rectilinear || type==type_attr::curvilinear) ? 4 : nvertex ; 
     2843        bounds_lonvalue.resize(nvertexValue,nbLonInd); 
    28202844        bounds_lonvalue = 0.; 
    28212845      } 
     
    28322856           if (hasBounds) 
    28332857           {           
    2834             for (int nv = 0; nv < nvertex; ++nv) 
    2835               bounds_lonvalue(nv, lInd) = recvBoundsLonValue[i](nv, ind); 
     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); 
    28362861           }                   
    28372862        } 
     
    29052930      if (hasBounds) 
    29062931      { 
    2907         bounds_latvalue.resize(nvertex,nbLatInd); 
     2932        int nvertexValue = (type==type_attr::rectilinear || type==type_attr::curvilinear) ? 4 : nvertex ; 
     2933         
     2934        bounds_latvalue.resize(nvertexValue,nbLatInd); 
    29082935        bounds_latvalue = 0. ; 
    29092936      } 
     
    29202947           if (hasBounds) 
    29212948           { 
    2922             CArray<double,2>& boundslat = recvBoundsLatValue[i]; 
    2923             for (int nv = 0; nv < nvertex; ++nv) 
    2924               bounds_latvalue(nv, lInd) = boundslat(nv, ind); 
     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); 
    29252954           }    
    29262955          ++nbLatInd; 
  • XIOS2/trunk/src/test/generic_testcase.f90

    r2348 r2440  
    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(:,:) 
    14171418    LOGICAL,ALLOCATABLE :: mask(:) 
    14181419    LOGICAL,ALLOCATABLE :: dom_mask(:) 
     
    14441445     
    14451446    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)) 
    14461448    mask(:)=.FALSE. 
    14471449    mask(offset:offset+nbp-1)=.TRUE. 
    14481450     
    14491451    ALLOCATE(lon_glo(0:ni_glo-1), lat_glo(0:nj_glo-1)) 
    1450      
     1452    ALLOCATE(bounds_lon_glo(2,0:ni_glo-1), bounds_lat_glo(2,0:nj_glo-1)) 
     1453 
    14511454    DO i=0,ni_glo-1 
    14521455      lon_glo(i)=-180+(i+0.5)*(360./ni_glo) 
    14531456    ENDDO 
    14541457 
     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 
    14551471    DO j=0,nj_glo-1 
    14561472      lat_glo(j)=-90+(j+0.5)*(180./nj_glo) 
    14571473    ENDDO 
    1458       
     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 
    14591488    lon(:)=lon_glo(:) 
    14601489    lat(:)=lat_glo(jbegin:jbegin+nj-1) 
     1490    bounds_lon(:,:)=bounds_lon_glo(:,:) 
     1491    bounds_lat(:,:)=bounds_lat_glo(:,jbegin:jbegin+nj-1) 
    14611492 
    14621493    ALLOCATE(return_lon(0:ni*nj-1)) 
     
    15091540                                jbegin=jbegin, nj=nj) 
    15101541      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) 
    15111543    ENDIF 
    15121544     
Note: See TracChangeset for help on using the changeset viewer.