Changeset 1435
- Timestamp:
- 02/21/18 09:09:30 (7 years ago)
- 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 8 8 DECLARE_ATTRIBUTE(StdString, formula_bounds) 9 9 DECLARE_ATTRIBUTE(StdString, formula_term_bounds) 10 DECLARE_ATTRIBUTE(StdString, bounds_name) 10 11 11 12 DECLARE_ATTRIBUTE(int, n_glo) -
XIOS/dev/XIOS_DEV_CMIP6/src/config/scalar_attribute.conf
r1430 r1435 7 7 /* LOCAL and GLOBAL*/ 8 8 DECLARE_ATTRIBUTE(double, value) 9 DECLARE_ATTRIBUTE(StdString, bounds_ value_name)10 DECLARE_ATTRIBUTE(double, bounds _value)9 DECLARE_ATTRIBUTE(StdString, bounds_name) 10 DECLARE_ATTRIBUTE(double, bounds) 11 11 12 12 DECLARE_ATTRIBUTE(StdString, scalar_ref) … … 14 14 15 15 DECLARE_ENUM4(axis_type, X, Y, Z, T) 16 DECLARE_ENUM2(positive, up, down) 17 DECLARE_ATTRIBUTE(StdString, label) -
XIOS/dev/XIOS_DEV_CMIP6/src/io/nc4_data_output.cpp
r1433 r1435 1241 1241 std::vector<StdString> dims; 1242 1242 StdString axisid = axis->getAxisOutputName(); 1243 StdString axisDim ;1243 StdString axisDim, axisBoundsId; 1244 1244 if (isWrittenAxis(axisid)) return ; 1245 1245 else setWrittenAxis(axisid); … … 1261 1261 if (!axis->label.isEmpty()) SuperClassWriter::addDimension(strId, stringArrayLen); 1262 1262 1263 if (axis->hasValue )1263 if (axis->hasValue || !axis->label.isEmpty()) 1264 1264 { 1265 1265 if (!axis->label.isEmpty()) dims.push_back(strId); … … 1311 1311 SuperClassWriter::addAttribute("formula_term", axis->formula_term.getValue(), &axisid); 1312 1312 1313 StdString axisBoundsId = axisid + "_bounds";1313 axisBoundsId = (axis->bounds_name.isEmpty()) ? axisid + "_bounds" : axis->bounds_name; 1314 1314 if (!axis->bounds.isEmpty() && axis->label.isEmpty()) 1315 1315 { … … 1330 1330 SuperClassWriter::addAttribute("formula_term", axis->formula_term_bounds.getValue(), &axisBoundsId); 1331 1331 } 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 { 1338 1341 for (int i = 0; i < nbWritten; i++) 1339 1342 { … … 1343 1346 axis_value(i) = 0.; 1344 1347 } 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++) 1349 1355 { 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()) 1352 1371 { 1353 if (i < axis->label.numElements())1354 axis_label(i) = axis->label(indexToWrite(i));1355 else1356 axis_label(i) = boost::lexical_cast<string>(0); // Write 0 as a label1357 }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 else1378 {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 after1389 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_size1401 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 {1409 1372 axis_bounds.resize(2, indexToWrite.numElements()); 1410 1373 for (int i = 0; i < nbWritten; ++i) … … 1419 1382 axis_bounds(0, i) = 0.; 1420 1383 axis_bounds(1, i) = 0.; 1384 1421 1385 } 1422 1386 } 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 } 1424 1425 } 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); 1438 1427 } 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; 1443 1441 } 1442 default : 1443 ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", 1444 << "[ type = " << SuperClass::type << "]" 1445 << " not implemented yet !"); 1444 1446 } 1445 1447 } … … 1473 1475 else if (scalar->prec==8) typePrec = NC_DOUBLE ; 1474 1476 1477 if (!scalar->label.isEmpty()) typePrec = NC_CHAR ; 1478 string strId="str_len" ; 1479 1475 1480 try 1476 1481 { 1477 if (!scalar->value.isEmpty()) 1482 if (!scalar->label.isEmpty()) SuperClassWriter::addDimension(strId, stringArrayLen); 1483 1484 if (!scalar->value.isEmpty() || !scalar->label.isEmpty()) 1478 1485 { 1479 1486 std::vector<StdString> dims; 1480 // dims.push_back(scalaId);1481 1487 StdString scalarDim = scalaId; 1488 1489 if (!scalar->label.isEmpty()) dims.push_back(strId); 1482 1490 1483 1491 SuperClassWriter::addVariable(scalaId, typePrec, dims); … … 1514 1522 } 1515 1523 1516 if (!scalar-> bounds_value.isEmpty())1524 if (!scalar->positive.isEmpty()) 1517 1525 { 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); 1523 1535 SuperClassWriter::addDimension(boundsId, 1); 1524 1536 SuperClassWriter::addVariable(boundsId, typePrec, dims); … … 1532 1544 { 1533 1545 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()) 1537 1549 { 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; 1539 1557 SuperClassWriter::writeData(scalarValue, boundsId, isCollective, 0); 1540 1558 } 1559 1560 if (!scalar->label.isEmpty()) 1561 { 1562 scalarLabel(0) = scalar->label; 1563 SuperClassWriter::writeData(scalarLabel, scalaId, isCollective, 0); 1564 } 1565 1541 1566 SuperClassWriter::definition_start(); 1542 1567 … … 1546 1571 { 1547 1572 CArray<double,1> scalarValue(scalarSize); 1548 scalarValue(0) = scalar->value;1573 CArray<string,1> scalarLabel(scalarSize); 1549 1574 1550 1575 std::vector<StdSize> start(1); … … 1552 1577 start[0] = 0; 1553 1578 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()) 1556 1580 { 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; 1558 1587 SuperClassWriter::writeData(scalarValue, boundsId, isCollective, 0, &start, &count); 1559 1588 } 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 1560 1596 SuperClassWriter::definition_start(); 1561 1597 -
XIOS/dev/XIOS_DEV_CMIP6/src/io/onetcdf4_impl.hpp
r1158 r1435 63 63 { 64 64 ERROR("CONetCDF4::writeData(...)", 65 << "[ input array size = " << data.numElements() 65 << "[ input array size = " << data.numElements()*stringArrayLen 66 66 << ", intern array size = " << array_size 67 67 << " ] Invalid input data !" );
Note: See TracChangeset
for help on using the changeset viewer.