Changeset 1435 for XIOS/dev


Ignore:
Timestamp:
02/21/18 09:09:30 (6 years ago)
Author:
oabramkina
Message:

Few more grid attributes introduced in addition to r1430.

Location:
XIOS/dev/XIOS_DEV_CMIP6/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/config/axis_attribute.conf

    r1430 r1435  
    88DECLARE_ATTRIBUTE(StdString, formula_bounds) 
    99DECLARE_ATTRIBUTE(StdString, formula_term_bounds) 
     10DECLARE_ATTRIBUTE(StdString, bounds_name) 
    1011 
    1112DECLARE_ATTRIBUTE(int,       n_glo) 
  • XIOS/dev/XIOS_DEV_CMIP6/src/config/scalar_attribute.conf

    r1430 r1435  
    77/* LOCAL and GLOBAL*/ 
    88DECLARE_ATTRIBUTE(double, value) 
    9 DECLARE_ATTRIBUTE(StdString, bounds_value_name) 
    10 DECLARE_ATTRIBUTE(double, bounds_value) 
     9DECLARE_ATTRIBUTE(StdString, bounds_name) 
     10DECLARE_ATTRIBUTE(double, bounds) 
    1111 
    1212DECLARE_ATTRIBUTE(StdString, scalar_ref) 
     
    1414 
    1515DECLARE_ENUM4(axis_type, X, Y, Z, T) 
     16DECLARE_ENUM2(positive, up, down) 
     17DECLARE_ATTRIBUTE(StdString, label) 
  • XIOS/dev/XIOS_DEV_CMIP6/src/io/nc4_data_output.cpp

    r1433 r1435  
    12411241        std::vector<StdString> dims; 
    12421242        StdString axisid = axis->getAxisOutputName(); 
    1243         StdString axisDim; 
     1243        StdString axisDim, axisBoundsId; 
    12441244        if (isWrittenAxis(axisid)) return ; 
    12451245        else setWrittenAxis(axisid); 
     
    12611261          if (!axis->label.isEmpty()) SuperClassWriter::addDimension(strId, stringArrayLen); 
    12621262 
    1263           if (axis->hasValue) 
     1263          if (axis->hasValue || !axis->label.isEmpty()) 
    12641264          { 
    12651265            if (!axis->label.isEmpty()) dims.push_back(strId); 
     
    13111311              SuperClassWriter::addAttribute("formula_term", axis->formula_term.getValue(), &axisid); 
    13121312               
    1313             StdString axisBoundsId = axisid + "_bounds"; 
     1313            axisBoundsId = (axis->bounds_name.isEmpty()) ? axisid + "_bounds" : axis->bounds_name; 
    13141314            if (!axis->bounds.isEmpty() && axis->label.isEmpty()) 
    13151315            { 
     
    13301330                SuperClassWriter::addAttribute("formula_term", axis->formula_term_bounds.getValue(), &axisBoundsId); 
    13311331            } 
    1332                
    1333             SuperClassWriter::definition_end(); 
    1334  
    1335             CArray<size_t, 1>& indexToWrite = axis->localIndexToWriteOnServer; 
    1336             int nbWritten = indexToWrite.numElements(); 
    1337             CArray<double,1> axis_value(indexToWrite.numElements()); 
     1332          } 
     1333 
     1334          SuperClassWriter::definition_end(); 
     1335 
     1336          CArray<size_t, 1>& indexToWrite = axis->localIndexToWriteOnServer; 
     1337          int nbWritten = indexToWrite.numElements(); 
     1338          CArray<double,1> axis_value(indexToWrite.numElements()); 
     1339          if (!axis->value.isEmpty()) 
     1340          { 
    13381341            for (int i = 0; i < nbWritten; i++) 
    13391342            { 
     
    13431346                axis_value(i) = 0.; 
    13441347            } 
    1345  
    1346             CArray<double,2> axis_bounds; 
    1347             CArray<string,1> axis_label; 
    1348             if (!axis->label.isEmpty()) 
     1348          } 
     1349          CArray<double,2> axis_bounds; 
     1350          CArray<string,1> axis_label; 
     1351          if (!axis->label.isEmpty()) 
     1352          { 
     1353            axis_label.resize(indexToWrite.numElements()); 
     1354            for (int i = 0; i < nbWritten; i++) 
    13491355            { 
    1350               axis_label.resize(indexToWrite.numElements()); 
    1351               for (int i = 0; i < nbWritten; i++) 
     1356              if (i < axis->label.numElements()) 
     1357                axis_label(i) = axis->label(indexToWrite(i)); 
     1358              else 
     1359                axis_label(i) = boost::lexical_cast<string>(0);  // Write 0 as a label 
     1360            } 
     1361          } 
     1362 
     1363          switch (SuperClass::type) 
     1364          { 
     1365            case MULTI_FILE: 
     1366            { 
     1367              if (axis->label.isEmpty()) 
     1368                SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 
     1369 
     1370              if (!axis->bounds.isEmpty() && axis->label.isEmpty()) 
    13521371              { 
    1353                 if (i < axis->label.numElements()) 
    1354                   axis_label(i) = axis->label(indexToWrite(i)); 
    1355                 else 
    1356                   axis_label(i) = boost::lexical_cast<string>(0);  // Write 0 as a label 
    1357               } 
    1358             } 
    1359  
    1360             switch (SuperClass::type) 
    1361             { 
    1362               case MULTI_FILE: 
    1363               { 
    1364                 if (axis->label.isEmpty()) 
    1365                   SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 
    1366  
    1367                 if (!axis->bounds.isEmpty() && axis->label.isEmpty()) 
    1368                 { 
    1369                     axis_bounds.resize(2, indexToWrite.numElements()); 
    1370                     for (int i = 0; i < nbWritten; ++i) 
    1371                     { 
    1372                       if (i < axis->bounds.columns()) 
    1373                       { 
    1374                         axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 
    1375                         axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 
    1376                       } 
    1377                       else 
    1378                       { 
    1379                         axis_bounds(0, i) = 0.; 
    1380                         axis_bounds(1, i) = 0.; 
    1381  
    1382                       } 
    1383                     } 
    1384  
    1385                         SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0); 
    1386                 } 
    1387  
    1388                 // Need to check after 
    1389                 if (!axis->label.isEmpty())  
    1390                   SuperClassWriter::writeData(axis_label, axisid, isCollective, 0); 
    1391   
    1392                 SuperClassWriter::definition_start(); 
    1393                 break; 
    1394               } 
    1395               case ONE_FILE: 
    1396               { 
    1397                 std::vector<StdSize> start(1), startBounds(2) ; 
    1398                 std::vector<StdSize> count(1), countBounds(2) ; 
    1399                 start[0] = startBounds[0] = zoom_begin - axis->global_zoom_begin; 
    1400                 count[0] = countBounds[0] = zoom_count; // zoom_size 
    1401                 startBounds[1] = 0; 
    1402                 countBounds[1] = 2; 
    1403  
    1404                 if (axis->label.isEmpty()) 
    1405                   SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 
    1406  
    1407                 if (!axis->bounds.isEmpty() && axis->label.isEmpty()) 
    1408                 { 
    14091372                  axis_bounds.resize(2, indexToWrite.numElements()); 
    14101373                  for (int i = 0; i < nbWritten; ++i) 
     
    14191382                      axis_bounds(0, i) = 0.; 
    14201383                      axis_bounds(1, i) = 0.; 
     1384 
    14211385                    } 
    14221386                  } 
    1423                   SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 
     1387 
     1388                SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0); 
     1389              } 
     1390 
     1391              // Need to check after 
     1392              if (!axis->label.isEmpty()) 
     1393                SuperClassWriter::writeData(axis_label, axisid, isCollective, 0); 
     1394 
     1395              SuperClassWriter::definition_start(); 
     1396              break; 
     1397            } 
     1398            case ONE_FILE: 
     1399            { 
     1400              std::vector<StdSize> start(1), startBounds(2) ; 
     1401              std::vector<StdSize> count(1), countBounds(2) ; 
     1402              start[0] = startBounds[0] = zoom_begin - axis->global_zoom_begin; 
     1403              count[0] = countBounds[0] = zoom_count; // zoom_size 
     1404              startBounds[1] = 0; 
     1405              countBounds[1] = 2; 
     1406 
     1407              if (axis->label.isEmpty()) 
     1408                SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 
     1409 
     1410              if (!axis->bounds.isEmpty() && axis->label.isEmpty()) 
     1411              { 
     1412                axis_bounds.resize(2, indexToWrite.numElements()); 
     1413                for (int i = 0; i < nbWritten; ++i) 
     1414                { 
     1415                  if (i < axis->bounds.columns()) 
     1416                  { 
     1417                    axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 
     1418                    axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 
     1419                  } 
     1420                  else 
     1421                  { 
     1422                    axis_bounds(0, i) = 0.; 
     1423                    axis_bounds(1, i) = 0.; 
     1424                  } 
    14241425                } 
    1425  
    1426                 // Need to check after 
    1427                 if (!axis->label.isEmpty()) 
    1428                 { 
    1429                   std::vector<StdSize> startLabel(2), countLabel(2); 
    1430                   startLabel[0] = start[0]; startLabel[1] = 0; 
    1431                   countLabel[0] = count[0]; countLabel[1] = stringArrayLen; 
    1432                   SuperClassWriter::writeData(axis_label, axisid, isCollective, 0, &startLabel, &countLabel); 
    1433                 } 
    1434  
    1435                 SuperClassWriter::definition_start(); 
    1436  
    1437                 break; 
     1426                SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 
    14381427              } 
    1439               default : 
    1440                 ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", 
    1441                       << "[ type = " << SuperClass::type << "]" 
    1442                       << " not implemented yet !"); 
     1428 
     1429              // Need to check after 
     1430              if (!axis->label.isEmpty()) 
     1431              { 
     1432                std::vector<StdSize> startLabel(2), countLabel(2); 
     1433                startLabel[0] = start[0]; startLabel[1] = 0; 
     1434                countLabel[0] = count[0]; countLabel[1] = stringArrayLen; 
     1435                SuperClassWriter::writeData(axis_label, axisid, isCollective, 0, &startLabel, &countLabel); 
     1436              } 
     1437 
     1438              SuperClassWriter::definition_start(); 
     1439 
     1440              break; 
    14431441            } 
     1442            default : 
     1443              ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", 
     1444                    << "[ type = " << SuperClass::type << "]" 
     1445                    << " not implemented yet !"); 
    14441446          } 
    14451447        } 
     
    14731475        else if (scalar->prec==8)   typePrec =  NC_DOUBLE ; 
    14741476 
     1477        if (!scalar->label.isEmpty()) typePrec = NC_CHAR ; 
     1478        string strId="str_len" ; 
     1479 
    14751480        try 
    14761481        { 
    1477           if (!scalar->value.isEmpty()) 
     1482          if (!scalar->label.isEmpty()) SuperClassWriter::addDimension(strId, stringArrayLen); 
     1483 
     1484          if (!scalar->value.isEmpty() || !scalar->label.isEmpty()) 
    14781485          { 
    14791486            std::vector<StdString> dims; 
    1480 //            dims.push_back(scalaId); 
    14811487            StdString scalarDim = scalaId; 
     1488 
     1489            if (!scalar->label.isEmpty()) dims.push_back(strId); 
    14821490 
    14831491            SuperClassWriter::addVariable(scalaId, typePrec, dims); 
     
    15141522            } 
    15151523 
    1516             if (!scalar->bounds_value.isEmpty()) 
     1524            if (!scalar->positive.isEmpty()) 
    15171525            { 
    1518               if (!scalar->bounds_value_name.isEmpty()) 
    1519               { 
    1520                 boundsId = scalar->bounds_value_name.getValue(); 
    1521                 SuperClassWriter::addAttribute("bounds_value_name", boundsId, &scalaId); 
    1522               } 
     1526              SuperClassWriter::addAttribute("positive", 
     1527                                             (scalar->positive == CScalar::positive_attr::up) ? string("up") : string("down"), 
     1528                                             &scalaId); 
     1529            } 
     1530 
     1531            if (!scalar->bounds.isEmpty() && scalar->label.isEmpty()) 
     1532            { 
     1533              boundsId = (scalar->bounds_name.isEmpty()) ? (scalaId + "_bounds") : scalar->bounds_name.getValue(); 
     1534              SuperClassWriter::addAttribute("bounds_name", boundsId, &scalaId); 
    15231535              SuperClassWriter::addDimension(boundsId, 1); 
    15241536              SuperClassWriter::addVariable(boundsId, typePrec, dims); 
     
    15321544              { 
    15331545                CArray<double,1> scalarValue(scalarSize); 
    1534                 scalarValue(0) = scalar->value; 
    1535                 SuperClassWriter::writeData(scalarValue, scalaId, isCollective, 0); 
    1536                 if (!scalar->bounds_value.isEmpty()) 
     1546                CArray<string,1> scalarLabel(scalarSize); 
     1547 
     1548                if (!scalar->value.isEmpty() && scalar->label.isEmpty()) 
    15371549                { 
    1538                   scalarValue(0) = scalar->bounds_value; 
     1550                  scalarValue(0) = scalar->value; 
     1551                  SuperClassWriter::writeData(scalarValue, scalaId, isCollective, 0); 
     1552                } 
     1553 
     1554                if (!scalar->bounds.isEmpty() && scalar->label.isEmpty()) 
     1555                { 
     1556                  scalarValue(0) = scalar->bounds; 
    15391557                  SuperClassWriter::writeData(scalarValue, boundsId, isCollective, 0); 
    15401558                } 
     1559 
     1560                if (!scalar->label.isEmpty()) 
     1561                { 
     1562                  scalarLabel(0) = scalar->label; 
     1563                  SuperClassWriter::writeData(scalarLabel, scalaId, isCollective, 0); 
     1564                } 
     1565 
    15411566                SuperClassWriter::definition_start(); 
    15421567 
     
    15461571              { 
    15471572                CArray<double,1> scalarValue(scalarSize); 
    1548                 scalarValue(0) = scalar->value; 
     1573                CArray<string,1> scalarLabel(scalarSize); 
    15491574 
    15501575                std::vector<StdSize> start(1); 
     
    15521577                start[0] = 0; 
    15531578                count[0] = 1; 
    1554                 SuperClassWriter::writeData(scalarValue, scalaId, isCollective, 0, &start, &count); 
    1555                 if (!scalar->bounds_value.isEmpty()) 
     1579                if (!scalar->value.isEmpty() && scalar->label.isEmpty()) 
    15561580                { 
    1557                   scalarValue(0) = scalar->bounds_value; 
     1581                  scalarValue(0) = scalar->value; 
     1582                  SuperClassWriter::writeData(scalarValue, scalaId, isCollective, 0, &start, &count); 
     1583                } 
     1584                if (!scalar->bounds.isEmpty() && scalar->label.isEmpty()) 
     1585                { 
     1586                  scalarValue(0) = scalar->bounds; 
    15581587                  SuperClassWriter::writeData(scalarValue, boundsId, isCollective, 0, &start, &count); 
    15591588                } 
     1589                if (!scalar->label.isEmpty()) 
     1590                { 
     1591                  scalarLabel(0) = scalar->label; 
     1592                  count[0] = stringArrayLen; 
     1593                  SuperClassWriter::writeData(scalarLabel, scalaId, isCollective, 0, &start, &count); 
     1594                } 
     1595 
    15601596                SuperClassWriter::definition_start(); 
    15611597 
  • XIOS/dev/XIOS_DEV_CMIP6/src/io/onetcdf4_impl.hpp

    r1158 r1435  
    6363    { 
    6464      ERROR("CONetCDF4::writeData(...)", 
    65       << "[ input array size = "  << data.numElements() 
     65      << "[ input array size = "  << data.numElements()*stringArrayLen 
    6666      << ", intern array size = " << array_size 
    6767      << " ] Invalid input data !" ); 
Note: See TracChangeset for help on using the changeset viewer.