Changeset 993 for XIOS/trunk/src


Ignore:
Timestamp:
11/18/16 11:41:40 (7 years ago)
Author:
oabramkina
Message:

Minor corrections for UGRID.

Location:
XIOS/trunk/src
Files:
3 edited

Legend:

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

    r990 r993  
    14581458      void CNc4DataOutput::writeField_(CField* field) 
    14591459      { 
    1460          CContext* context = CContext::getCurrent() ; 
    1461          CContextServer* server=context->server ; 
    1462  
    1463          std::vector<StdString> dims, coodinates; 
    1464          CGrid* grid = field->grid; 
    1465          if (!grid->doGridHaveDataToWrite()) 
     1460        CContext* context = CContext::getCurrent() ; 
     1461        CContextServer* server=context->server ; 
     1462 
     1463        std::vector<StdString> dims, coodinates; 
     1464        CGrid* grid = field->grid; 
     1465        if (!grid->doGridHaveDataToWrite()) 
    14661466          if (SuperClass::type==MULTI_FILE) return ; 
    14671467 
    1468          CArray<int,1> axisDomainOrder = grid->axis_domain_order; 
    1469          int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0; 
    1470          std::vector<StdString> domainList = grid->getDomainList(); 
    1471          std::vector<StdString> axisList   = grid->getAxisList(); 
    1472          std::vector<StdString> scalarList = grid->getScalarList(); 
    1473  
    1474          StdString timeid  = getTimeCounterName(); 
    1475          StdString dimXid,dimYid; 
    1476          std::deque<StdString> dimIdList, dimCoordList; 
    1477          bool hasArea = false; 
    1478          StdString cellMeasures = "area:"; 
    1479          bool compressedOutput = !field->indexed_output.isEmpty() && field->indexed_output; 
    1480  
    1481          for (int i = 0; i < numElement; ++i) 
    1482          { 
    1483            if (2 == axisDomainOrder(i)) 
    1484            { 
    1485              CDomain* domain = CDomain::get(domainList[idxDomain]); 
    1486              StdString domId = domain->getDomainOutputName(); 
    1487              StdString appendDomId  = singleDomain ? "" : "_" + domId ; 
    1488  
    1489              if (compressedOutput && domain->isCompressible() && domain->type != CDomain::type_attr::unstructured) 
    1490              { 
    1491                dimIdList.push_back(domId + "_points"); 
    1492                field->setUseCompressedOutput(); 
    1493              } 
    1494  
    1495              switch (domain->type) 
    1496              { 
    1497                case CDomain::type_attr::curvilinear: 
    1498                  if (!compressedOutput || !domain->isCompressible()) 
    1499                  { 
    1500                    dimXid     = StdString("x").append(appendDomId); 
    1501                    dimIdList.push_back(dimXid); 
    1502                    dimYid     = StdString("y").append(appendDomId); 
    1503                    dimIdList.push_back(dimYid); 
    1504                  } 
    1505                  dimCoordList.push_back(StdString("nav_lon").append(appendDomId)); 
    1506                  dimCoordList.push_back(StdString("nav_lat").append(appendDomId)); 
    1507                  break ; 
    1508                case CDomain::type_attr::rectilinear: 
    1509                  if (!compressedOutput || !domain->isCompressible()) 
    1510                  { 
    1511                    dimXid     = StdString("lon").append(appendDomId); 
    1512                    dimIdList.push_back(dimXid); 
    1513                    dimYid     = StdString("lat").append(appendDomId); 
    1514                    dimIdList.push_back(dimYid); 
    1515                  } 
    1516                  break ; 
    1517                case CDomain::type_attr::unstructured: 
    1518                { 
    1519            if (SuperClassWriter::useCFConvention) 
    1520            { 
    1521             dimXid     = StdString("cell").append(appendDomId); 
    1522             dimIdList.push_back(dimXid); 
    1523             dimCoordList.push_back(StdString("lon").append(appendDomId)); 
    1524             dimCoordList.push_back(StdString("lat").append(appendDomId)); 
     1468        CArray<int,1> axisDomainOrder = grid->axis_domain_order; 
     1469        int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0; 
     1470        std::vector<StdString> domainList = grid->getDomainList(); 
     1471        std::vector<StdString> axisList   = grid->getAxisList(); 
     1472        std::vector<StdString> scalarList = grid->getScalarList(); 
     1473 
     1474        CDomain* domain = CDomain::get(domainList[idxDomain]); 
     1475 
     1476        StdString timeid  = getTimeCounterName(); 
     1477        StdString dimXid,dimYid; 
     1478        std::deque<StdString> dimIdList, dimCoordList; 
     1479        bool hasArea = false; 
     1480        StdString cellMeasures = "area:"; 
     1481        bool compressedOutput = !field->indexed_output.isEmpty() && field->indexed_output; 
     1482 
     1483        for (int i = 0; i < numElement; ++i) 
     1484        { 
     1485          if (2 == axisDomainOrder(i)) 
     1486          { 
     1487            StdString domId = domain->getDomainOutputName(); 
     1488            StdString appendDomId  = singleDomain ? "" : "_" + domId ; 
     1489 
     1490            if (compressedOutput && domain->isCompressible() && domain->type != CDomain::type_attr::unstructured) 
     1491            { 
     1492              dimIdList.push_back(domId + "_points"); 
     1493              field->setUseCompressedOutput(); 
     1494            } 
     1495 
     1496            switch (domain->type) 
     1497            { 
     1498              case CDomain::type_attr::curvilinear: 
     1499                if (!compressedOutput || !domain->isCompressible()) 
     1500                { 
     1501                  dimXid     = StdString("x").append(appendDomId); 
     1502                  dimIdList.push_back(dimXid); 
     1503                  dimYid     = StdString("y").append(appendDomId); 
     1504                  dimIdList.push_back(dimYid); 
     1505                } 
     1506                dimCoordList.push_back(StdString("nav_lon").append(appendDomId)); 
     1507                dimCoordList.push_back(StdString("nav_lat").append(appendDomId)); 
     1508              break ; 
     1509              case CDomain::type_attr::rectilinear: 
     1510                if (!compressedOutput || !domain->isCompressible()) 
     1511                { 
     1512                  dimXid     = StdString("lon").append(appendDomId); 
     1513                  dimIdList.push_back(dimXid); 
     1514                  dimYid     = StdString("lat").append(appendDomId); 
     1515                  dimIdList.push_back(dimYid); 
     1516                } 
     1517              break ; 
     1518              case CDomain::type_attr::unstructured: 
     1519              { 
     1520                if (SuperClassWriter::useCFConvention) 
     1521                { 
     1522                  dimXid     = StdString("cell").append(appendDomId); 
     1523                  dimIdList.push_back(dimXid); 
     1524                  dimCoordList.push_back(StdString("lon").append(appendDomId)); 
     1525                  dimCoordList.push_back(StdString("lat").append(appendDomId)); 
     1526                } 
     1527                else 
     1528                { 
     1529                  StdString domainName = domain->name; 
     1530                  if (domain->nvertex == 1) 
     1531                  { 
     1532                    dimXid     = "n" + domainName + "_node"; 
     1533                    dimIdList.push_back(dimXid); 
     1534                    dimCoordList.push_back(StdString(domainName + "_node_x")); 
     1535                    dimCoordList.push_back(StdString(domainName + "_node_y")); 
     1536                  } 
     1537                  else if (domain->nvertex == 2) 
     1538                  { 
     1539                    dimXid     = "n" + domainName + "_edge"; 
     1540                    dimIdList.push_back(dimXid); 
     1541                    dimCoordList.push_back(StdString(domainName + "_edge_x")); 
     1542                    dimCoordList.push_back(StdString(domainName + "_edge_y")); 
     1543                  } 
     1544                  else 
     1545                  { 
     1546                    dimXid     = "n" + domainName + "_face"; 
     1547                    dimIdList.push_back(dimXid); 
     1548                    dimCoordList.push_back(StdString(domainName + "_face_x")); 
     1549                    dimCoordList.push_back(StdString(domainName + "_face_y")); 
     1550                  } 
     1551                }  // ugrid convention 
     1552              }  // case unstructured domain 
     1553            } 
     1554 
     1555            if (domain->hasArea) 
     1556            { 
     1557              hasArea = true; 
     1558              cellMeasures += " area" + appendDomId; 
     1559            } 
     1560            ++idxDomain; 
    15251561          } 
    1526            else 
    1527            { 
    1528             StdString domainName = domain->name; 
    1529             if (domain->nvertex == 1) 
     1562          else if (1 == axisDomainOrder(i)) 
     1563          { 
     1564            CAxis* axis = CAxis::get(axisList[idxAxis]); 
     1565            StdString axisId = axis->getAxisOutputName(); 
     1566 
     1567            if (compressedOutput && axis->isCompressible()) 
    15301568            { 
    1531               dimXid     = "n" + domainName + "_node"; 
    1532               dimIdList.push_back(dimXid); 
    1533               dimCoordList.push_back(StdString(domainName + "_node_x")); 
    1534               dimCoordList.push_back(StdString(domainName + "_node_y")); 
    1535             } 
    1536             else if (domain->nvertex == 2) 
    1537             { 
    1538               dimXid     = "n" + domainName + "_edge"; 
    1539               dimIdList.push_back(dimXid); 
    1540               dimCoordList.push_back(StdString(domainName + "_edge_x")); 
    1541               dimCoordList.push_back(StdString(domainName + "_edge_y")); 
     1569              dimIdList.push_back(axisId + "_points"); 
     1570              field->setUseCompressedOutput(); 
    15421571            } 
    15431572            else 
    1544             { 
    1545               dimXid     = "n" + domainName + "_face"; 
    1546               dimIdList.push_back(dimXid); 
    1547               dimCoordList.push_back(StdString(domainName + "_face_x")); 
    1548               dimCoordList.push_back(StdString(domainName + "_face_y")); 
    1549             } 
    1550           }  // ugrid convention 
    1551         }  // case unstructured domain 
    1552              } 
    1553  
    1554              if (domain->hasArea) 
    1555              { 
    1556                hasArea = true; 
    1557                cellMeasures += " area" + appendDomId; 
    1558              } 
    1559              ++idxDomain; 
    1560            } 
    1561            else if (1 == axisDomainOrder(i)) 
    1562            { 
    1563              CAxis* axis = CAxis::get(axisList[idxAxis]); 
    1564              StdString axisId = axis->getAxisOutputName(); 
    1565  
    1566              if (compressedOutput && axis->isCompressible()) 
    1567              { 
    1568                dimIdList.push_back(axisId + "_points"); 
    1569                field->setUseCompressedOutput(); 
    1570              } 
    1571              else 
    1572                dimIdList.push_back(axisId); 
    1573  
    1574              dimCoordList.push_back(axisId); 
    1575              ++idxAxis; 
    1576            } 
    1577            else // scalar 
    1578            { 
     1573              dimIdList.push_back(axisId); 
     1574 
     1575            dimCoordList.push_back(axisId); 
     1576            ++idxAxis; 
     1577          } 
     1578          else // scalar 
     1579          { 
    15791580             /* Do nothing here */ 
    1580            } 
    1581          } 
     1581          } 
     1582        } 
    15821583 
    15831584/* 
     
    15891590                             : latid; 
    15901591*/ 
    1591          StdString fieldid = field->getFieldOutputName(); 
    1592  
    1593          nc_type type ; 
    1594          if (field->prec.isEmpty()) type =  NC_FLOAT ; 
    1595          else 
    1596          { 
    1597            if (field->prec==2) type = NC_SHORT ; 
    1598            else if (field->prec==4)  type =  NC_FLOAT ; 
    1599            else if (field->prec==8)   type =  NC_DOUBLE ; 
    1600          } 
    1601  
    1602          bool wtime   = !(!field->operation.isEmpty() && field->getOperationTimeType() == func::CFunctor::once); 
    1603  
    1604          if (wtime) 
    1605          { 
    1606  
    1607             //StdOStringStream oss; 
    1608            // oss << "time_" << field->operation.getValue() 
    1609            //     << "_" << field->getRelFile()->output_freq.getValue(); 
     1592        StdString fieldid = field->getFieldOutputName(); 
     1593 
     1594        nc_type type ; 
     1595        if (field->prec.isEmpty()) type =  NC_FLOAT ; 
     1596        else 
     1597        { 
     1598          if (field->prec==2) type = NC_SHORT ; 
     1599          else if (field->prec==4)  type =  NC_FLOAT ; 
     1600          else if (field->prec==8)   type =  NC_DOUBLE ; 
     1601        } 
     1602 
     1603        bool wtime   = !(!field->operation.isEmpty() && field->getOperationTimeType() == func::CFunctor::once); 
     1604 
     1605        if (wtime) 
     1606        { 
     1607 
     1608          //StdOStringStream oss; 
     1609          // oss << "time_" << field->operation.getValue() 
     1610          //     << "_" << field->getRelFile()->output_freq.getValue(); 
    16101611          //oss 
    1611             if (field->getOperationTimeType() == func::CFunctor::instant) coodinates.push_back(string("time_instant")); 
    1612             else if (field->getOperationTimeType() == func::CFunctor::centered) coodinates.push_back(string("time_centered")); 
    1613             dims.push_back(timeid); 
    1614          } 
    1615  
    1616          if (compressedOutput && grid->isCompressible()) 
    1617          { 
    1618            dims.push_back(grid->getId() + "_points"); 
    1619            field->setUseCompressedOutput(); 
    1620          } 
    1621          else 
    1622          { 
    1623            while (!dimIdList.empty()) 
    1624            { 
    1625              dims.push_back(dimIdList.back()); 
    1626              dimIdList.pop_back(); 
    1627            } 
    1628          } 
    1629  
    1630          while (!dimCoordList.empty()) 
    1631          { 
    1632            coodinates.push_back(dimCoordList.back()); 
    1633            dimCoordList.pop_back(); 
    1634          } 
    1635  
    1636          try 
    1637          { 
     1612          if (field->getOperationTimeType() == func::CFunctor::instant) coodinates.push_back(string("time_instant")); 
     1613          else if (field->getOperationTimeType() == func::CFunctor::centered) coodinates.push_back(string("time_centered")); 
     1614          dims.push_back(timeid); 
     1615        } 
     1616 
     1617        if (compressedOutput && grid->isCompressible()) 
     1618        { 
     1619          dims.push_back(grid->getId() + "_points"); 
     1620          field->setUseCompressedOutput(); 
     1621        } 
     1622        else 
     1623        { 
     1624          while (!dimIdList.empty()) 
     1625          { 
     1626            dims.push_back(dimIdList.back()); 
     1627            dimIdList.pop_back(); 
     1628          } 
     1629        } 
     1630 
     1631        while (!dimCoordList.empty()) 
     1632        { 
     1633          coodinates.push_back(dimCoordList.back()); 
     1634          dimCoordList.pop_back(); 
     1635        } 
     1636 
     1637        try 
     1638        { 
    16381639           SuperClassWriter::addVariable(fieldid, type, dims); 
    16391640 
     
    16501651                 ("units", field->unit.getValue(), &fieldid); 
    16511652 
    1652             if (!field->valid_min.isEmpty()) 
     1653           // Ugrid field attributes "mesh" and "location" 
     1654           if (!SuperClassWriter::useCFConvention) 
     1655           { 
     1656             StdString mesh = domain->name; 
     1657             SuperClassWriter::addAttribute("mesh", mesh, &fieldid); 
     1658             StdString location; 
     1659             if (domain->nvertex == 1) 
     1660               location = "node"; 
     1661             else if (domain->nvertex == 2) 
     1662               location = "edge"; 
     1663             else if (domain->nvertex > 2) 
     1664               location = "face"; 
     1665             SuperClassWriter::addAttribute("location", location, &fieldid); 
     1666           } 
     1667 
     1668           if (!field->valid_min.isEmpty()) 
    16531669              SuperClassWriter::addAttribute 
    16541670                 ("valid_min", field->valid_min.getValue(), &fieldid); 
  • XIOS/trunk/src/node/mesh.cpp

    r946 r993  
    1111/// ////////////////////// Définitions ////////////////////// /// 
    1212 
    13   CMesh::CMesh(void) :  nbNodesGlo{0}, nbEdgesGlo{0} 
    14             ,  node_start{0}, node_count{0} 
    15             ,  edge_start{0}, edge_count{0} 
    16             ,  nbFaces_{0}, nbNodes_{0}, nbEdges_{0} 
    17             ,  nodesAreWritten{false}, edgesAreWritten{false}, facesAreWritten{false} 
     13  CMesh::CMesh(void) :  nbNodesGlo(0), nbEdgesGlo(0) 
     14            ,  node_start(0), node_count(0) 
     15            ,  edge_start(0), edge_count(0) 
     16            ,  nbFaces_(0), nbNodes_(0), nbEdges_(0) 
     17            ,  nodesAreWritten(false), edgesAreWritten(false), facesAreWritten(false) 
    1818            ,  node_lon(), node_lat() 
    1919            ,  edge_lon(), edge_lat(), edge_nodes() 
    2020            ,  face_lon(), face_lat() 
    2121            ,  face_nodes() 
    22             ,  pNodeGlobalIndex{NULL}, pEdgeGlobalIndex{NULL} 
     22            ,  pNodeGlobalIndex(NULL), pEdgeGlobalIndex(NULL) 
    2323  { 
    2424  } 
  • XIOS/trunk/src/test/test_regular.f90

    r924 r993  
    1818  INTEGER :: comm   
    1919  INTEGER :: ierr 
    20   INTEGER :: size, rank 
     20  INTEGER :: sizeComm, rank    ! SIZE is a fortran function 
    2121 
    22   INTEGER :: nlon = 100  
    23   INTEGER :: nlat = 100 
     22  INTEGER :: nlon = 5 !100  
     23  INTEGER :: nlat = 5 !100 
    2424  INTEGER :: ncell  
    2525  INTEGER :: ilat, ilon, ind 
     
    9494 
    9595  CALL MPI_COMM_RANK(comm,rank,ierr) 
    96   CALL MPI_COMM_SIZE(comm,size,ierr) 
     96  CALL MPI_COMM_SIZE(comm,sizeComm,ierr) 
    9797 
    98   IF (MOD(ncell, size) == 0) THEN 
    99     ni = ncell/size 
     98  IF (MOD(ncell, sizeComm) == 0) THEN 
     99    ni = ncell/sizeComm 
    100100    ibegin = rank*ni 
    101101  ELSE 
    102     IF (rank < MOD(ncell, size)) THEN 
    103       ni = ncell/size + 1 
    104       ibegin = rank*(ncell/size + 1) 
     102    IF (rank < MOD(ncell, sizeComm)) THEN 
     103      ni = ncell/sizeComm + 1 
     104      ibegin = rank*(ncell/sizeComm + 1) 
    105105    ELSE 
    106       ni = ncell/size 
    107       IF (rank == MOD(ncell, size)) THEN 
    108         ibegin = rank*(ncell/size + 1) 
     106      ni = ncell/sizeComm 
     107      IF (rank == MOD(ncell, sizeComm)) THEN 
     108        ibegin = rank*(ncell/sizeComm + 1) 
    109109      ELSE 
    110         ibegin = MOD(ncell,size)*(ncell/size + 1) + (rank-MOD(ncell,size))*ncell/size 
     110        ibegin = MOD(ncell,sizeComm)*(ncell/sizeComm + 1) + (rank-MOD(ncell,sizeComm))*ncell/sizeComm 
    111111      END IF 
    112112    END IF 
     
    118118  ALLOCATE(bounds_lat(4,ni)) 
    119119  ALLOCATE(field_temp(ni,ntime))  
    120   lon = lon_glo(1+ibegin:1+ibegin+ni) 
    121   lat = lat_glo(1+ibegin:1+ibegin+ni) 
    122   bounds_lon(:,:) = bounds_lon_glo(:,1+ibegin:1+ibegin+ni) 
    123   bounds_lat(:,:) = bounds_lat_glo(:,1+ibegin:1+ibegin+ni) 
     120  lon = lon_glo(1+ibegin:ibegin+ni) 
     121  lat = lat_glo(1+ibegin:ibegin+ni) 
     122  bounds_lon(:,:) = bounds_lon_glo(:,1+ibegin:ibegin+ni) 
     123  bounds_lat(:,:) = bounds_lat_glo(:,1+ibegin:ibegin+ni) 
    124124  field_temp(:,:) = rank 
    125125 
Note: See TracChangeset for help on using the changeset viewer.