Changeset 2440 for XIOS2/trunk/src/node/domain.cpp
- Timestamp:
- 12/07/22 18:42:46 (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS2/trunk/src/node/domain.cpp
r2314 r2440 187 187 size_t sizeLonLatEvent = CArray<double,1>::size(idxCount); 188 188 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 } 190 195 191 196 size_t size = CEventClient::headerSize + getId().size() + sizeof(size_t) + std::max(sizeIndexEvent, sizeLonLatEvent); … … 1428 1433 if (hasBounds) 1429 1434 { 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); 1432 1437 } 1433 1438 … … 1443 1448 if (hasBounds) 1444 1449 { 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); 1450 1458 } 1451 1459 } … … 1545 1553 if (hasBounds) 1546 1554 { 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); 1549 1557 } 1550 1558 … … 1560 1568 if (hasBounds) 1561 1569 { 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); 1567 1578 } 1568 1579 } … … 1605 1616 TRY 1606 1617 { 1618 int nvertexValue ; 1607 1619 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() ); 1696 1712 } 1697 1713 CATCH_DUMP_ATTR … … 2451 2467 if (hasBounds) 2452 2468 { 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)); 2455 2474 } 2456 2475 … … 2469 2488 CArray<double,2>& boundslon = list_boundslon.back(); 2470 2489 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) 2473 2496 { 2474 2497 boundslon(nv, n) = bounds_lonvalue(nv, localInd); … … 2817 2840 if (hasBounds) 2818 2841 { 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); 2820 2844 bounds_lonvalue = 0.; 2821 2845 } … … 2832 2856 if (hasBounds) 2833 2857 { 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); 2836 2861 } 2837 2862 } … … 2905 2930 if (hasBounds) 2906 2931 { 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); 2908 2935 bounds_latvalue = 0. ; 2909 2936 } … … 2920 2947 if (hasBounds) 2921 2948 { 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); 2925 2954 } 2926 2955 ++nbLatInd;
Note: See TracChangeset
for help on using the changeset viewer.