Changeset 692


Ignore:
Timestamp:
09/16/15 16:26:32 (6 years ago)
Author:
rlacroix
Message:

Add a new file attribute to give our users more control on the time counter.

The time_counter attribute can take one of the following values:

  • centered: use centered times for the time counter (previous behavior, used by default)
  • instant: use instant times for the time counter
  • record: use record indexes for the time counter
  • none: disable the output of the time counter completely.
Location:
XIOS
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • XIOS/branchs/xios-1.0/src/config/file_attribute.conf

    r606 r692  
    1313DECLARE_ENUM2(type,one_file,multiple_file) 
    1414DECLARE_ATTRIBUTE(StdString,      par_access) 
     15DECLARE_ENUM4(time_counter, centered, instant, record, none) 
    1516 
    1617DECLARE_ATTRIBUTE(int,       compression_level) 
  • XIOS/branchs/xios-1.0/src/node/file.cpp

    r609 r692  
    201201      MPI_Comm_split(server->intraComm,color,server->intraCommRank,&fileComm) ; 
    202202      if (allDomainEmpty) MPI_Comm_free(&fileComm) ; 
    203       // 
    204        
     203 
     204      if (time_counter.isEmpty()) time_counter.setValue(time_counter_attr::centered); 
    205205    } 
    206206     
  • XIOS/branchs/xios-1.0/src/output/nc4_data_output.cpp

    r629 r692  
    10871087 
    10881088         CArray<double,1> time_data(1) ; 
     1089         CArray<double,1> time_data_bound(2); 
    10891090         CArray<double,1> time_counter(1) ; 
    10901091         CArray<double,1> time_counter_bound(2); 
    1091          CArray<double,1> time_data_bound(2); 
    10921092 
    10931093        bool wtime   = !(!field->operation.isEmpty() && (field->foperation->timeType() == func::CFunctor::once)); 
     
    10951095        if (wtime) 
    10961096        { 
    1097           time_counter(0)= (Time(*field->last_Write_srv) + Time(*field->lastlast_Write_srv)) / 2; 
     1097          Time lastWrite = *field->last_Write_srv; 
     1098          Time lastLastWrite = *field->lastlast_Write_srv; 
     1099 
    10981100          if (field->foperation->timeType() == func::CFunctor::instant) 
    1099             time_data(0) = Time(*field->last_Write_srv); 
    1100           else if (field->foperation->timeType() == func::CFunctor::centered) time_data(0) = time_counter(0); 
    1101  
    1102           time_counter_bound(0) = Time(*field->lastlast_Write_srv); 
    1103           time_counter_bound(1) = Time(*field->last_Write_srv); 
     1101            time_data(0) = lastWrite; 
     1102          else if (field->foperation->timeType() == func::CFunctor::centered) 
     1103            time_data(0) = (lastWrite + lastLastWrite) / 2; 
     1104 
    11041105          if (field->foperation->timeType() == func::CFunctor::instant) 
    1105             time_data_bound(0) = time_data_bound(1) = Time(*field->last_Write_srv); 
     1106            time_data_bound(0) = time_data_bound(1) = lastWrite; 
    11061107          else if (field->foperation->timeType() == func::CFunctor::centered) 
    11071108          { 
    1108             time_data_bound(0) = time_counter_bound(0); 
    1109             time_data_bound(1) = time_counter_bound(1); 
     1109            time_data_bound(0) = lastLastWrite; 
     1110            time_data_bound(1) = lastWrite; 
    11101111          } 
     1112 
     1113          if (field->file->time_counter == CFile::time_counter_attr::instant) 
     1114            time_counter(0) = lastWrite; 
     1115          else if (field->file->time_counter == CFile::time_counter_attr::centered) 
     1116            time_counter(0) = (lastWrite + lastLastWrite) / 2; 
     1117          else if (field->file->time_counter == CFile::time_counter_attr::record) 
     1118            time_counter(0) = field->getNStep() - 1; 
     1119 
     1120 
     1121          if (field->file->time_counter == CFile::time_counter_attr::instant) 
     1122            time_counter_bound(0) = time_counter_bound(1) = lastWrite; 
     1123          else if (field->file->time_counter == CFile::time_counter_attr::centered) 
     1124          { 
     1125            time_counter_bound(0) = lastLastWrite; 
     1126            time_counter_bound(1) = lastWrite; 
     1127          } 
     1128          else if (field->file->time_counter == CFile::time_counter_attr::record) 
     1129            time_counter_bound(0) = time_counter_bound(1) = field->getNStep() - 1; 
    11111130         } 
    11121131 
     
    11401159                case (MULTI_FILE) : 
    11411160                { 
    1142                    SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1); 
     1161                   SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep() - 1); 
    11431162                   if (wtime) 
    11441163                   { 
    1145                      SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); 
    1146                      SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); 
    1147                      SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); 
    1148                      SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); 
     1164                     SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1); 
     1165                     SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1); 
     1166                     if (field->file->time_counter != CFile::time_counter_attr::none) 
     1167                     { 
     1168                       SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep() - 1); 
     1169                       if (field->file->time_counter != CFile::time_counter_attr::record) 
     1170                         SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1); 
     1171                     } 
    11491172                   } 
    11501173                   break ; 
     
    11651188                     count[2]=domain->zoom_ni_srv ; count[1]=domain->zoom_nj_srv ; count[0] = axis->zoom_size.getValue(); 
    11661189                   } 
    1167                    SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1,&start,&count ); 
     1190                   SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep() - 1, &start, &count); 
    11681191                   if (wtime) 
    11691192                   { 
    1170                      SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot ); 
    1171                      SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot ); 
    1172                      SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot ); 
    1173                      SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot); 
     1193                     SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 
     1194                     SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); 
     1195                     if (field->file->time_counter != CFile::time_counter_attr::none) 
     1196                     { 
     1197                       SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep() - 1, isRoot); 
     1198                       if (field->file->time_counter != CFile::time_counter_attr::record) 
     1199                         SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); 
     1200                     } 
    11741201                   } 
    11751202                   break; 
     
    11881215                case (MULTI_FILE) : 
    11891216                { 
    1190                   SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1); 
     1217                  SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep() - 1); 
    11911218                  if (wtime) 
    11921219                  { 
    1193                     SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); 
    1194                     SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); 
    1195                     SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); 
    1196                     SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); 
     1220                    SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1); 
     1221                    SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1); 
     1222                    if (field->file->time_counter != CFile::time_counter_attr::none) 
     1223                    { 
     1224                      SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep() - 1); 
     1225                      if (field->file->time_counter != CFile::time_counter_attr::record) 
     1226                        SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1); 
     1227                    } 
    11971228                  } 
    11981229                  break; 
     
    12131244                   } 
    12141245 
    1215                    SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1,&start,&count); 
     1246                   SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep() - 1, &start, &count); 
    12161247                   if (wtime) 
    12171248                   { 
    1218                      SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot); 
    1219                      SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot); 
    1220                      SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot); 
    1221                      SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot); 
     1249                     SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 
     1250                     SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); 
     1251                     if (field->file->time_counter != CFile::time_counter_attr::none) 
     1252                     { 
     1253                       SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep() - 1, isRoot); 
     1254                       if (field->file->time_counter != CFile::time_counter_attr::record) 
     1255                         SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); 
     1256                     } 
    12221257                   } 
    12231258                   break; 
     
    12981333 
    12991334           // Adding time_counter 
    1300            axisid = "time_counter" ; 
    1301            axisBoundId = "time_counter_bounds" ; 
    1302            dims.clear() ; 
    1303            dims.push_back(timeid); 
    1304            if (!SuperClassWriter::varExist(axisid)) 
     1335           if (field->file->time_counter != CFile::time_counter_attr::none) 
    13051336           { 
    1306               SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims); 
    1307               SuperClassWriter::addAttribute("axis", string("T"), &axisid); 
    1308               CDate timeOrigin=cal->getTimeOrigin() ; 
    1309               StdString strTimeOrigin=timeOrigin.toString() ; 
    1310  
    1311               this->writeTimeAxisAttributes 
    1312                  (axisid, cal->getType(), 
    1313                   StdString("seconds since ").append(strTimeOrigin), 
    1314                   strTimeOrigin, axisBoundId); 
    1315            } 
    1316  
    1317            // Adding time_counter_bound dimension 
    1318            if (!SuperClassWriter::varExist(axisBoundId)) 
    1319            { 
    1320               dims.clear(); 
    1321               dims.push_back(timeid); 
    1322               dims.push_back(timeBoundId); 
    1323               SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); 
     1337             axisid = "time_counter"; 
     1338             axisBoundId = "time_counter_bounds"; 
     1339             dims.clear(); 
     1340             dims.push_back(timeid); 
     1341             if (!SuperClassWriter::varExist(axisid)) 
     1342             { 
     1343                SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims); 
     1344                SuperClassWriter::addAttribute("axis", string("T"), &axisid); 
     1345 
     1346                if (field->file->time_counter != CFile::time_counter_attr::record) 
     1347                { 
     1348                  CDate timeOrigin = cal->getTimeOrigin(); 
     1349                  StdString strTimeOrigin = timeOrigin.toString(); 
     1350 
     1351                  this->writeTimeAxisAttributes(axisid, cal->getType(), 
     1352                                                StdString("seconds since ").append(strTimeOrigin), 
     1353                                                strTimeOrigin, axisBoundId); 
     1354                } 
     1355             } 
     1356 
     1357             // Adding time_counter_bound dimension 
     1358             if (field->file->time_counter != CFile::time_counter_attr::record) 
     1359             { 
     1360               if (!SuperClassWriter::varExist(axisBoundId)) 
     1361               { 
     1362                  dims.clear(); 
     1363                  dims.push_back(timeid); 
     1364                  dims.push_back(timeBoundId); 
     1365                  SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); 
     1366               } 
     1367             } 
    13241368           } 
    13251369         } 
  • XIOS/trunk/src/config/file_attribute.conf

    r606 r692  
    1616DECLARE_ATTRIBUTE(bool,      append) 
    1717DECLARE_ENUM2(mode, read, write) 
     18DECLARE_ENUM4(time_counter, centered, instant, record, none) 
    1819 
    1920DECLARE_ATTRIBUTE(int,       compression_level) 
  • XIOS/trunk/src/io/nc4_data_output.cpp

    r686 r692  
    14091409 
    14101410         CArray<double,1> time_data(1) ; 
     1411         CArray<double,1> time_data_bound(2); 
    14111412         CArray<double,1> time_counter(1) ; 
    14121413         CArray<double,1> time_counter_bound(2); 
    1413          CArray<double,1> time_data_bound(2); 
    14141414 
    14151415        bool wtime   = !(!field->operation.isEmpty() && (field->getOperationTimeType() == func::CFunctor::once)); 
     
    14171417        if (wtime) 
    14181418        { 
    1419           time_counter(0)= (Time(field->last_Write_srv) + Time(field->lastlast_Write_srv)) / 2; 
     1419          Time lastWrite = field->last_Write_srv; 
     1420          Time lastLastWrite = field->lastlast_Write_srv; 
     1421 
    14201422          if (field->getOperationTimeType() == func::CFunctor::instant) 
    1421             time_data(0) = Time(field->last_Write_srv); 
    1422           else if (field->getOperationTimeType() == func::CFunctor::centered) time_data(0) = time_counter(0); 
    1423  
    1424           time_counter_bound(0) = Time(field->lastlast_Write_srv); 
    1425           time_counter_bound(1) = Time(field->last_Write_srv); 
     1423            time_data(0) = lastWrite; 
     1424          else if (field->getOperationTimeType() == func::CFunctor::centered) 
     1425            time_data(0) = (lastWrite + lastLastWrite) / 2; 
     1426 
    14261427          if (field->getOperationTimeType() == func::CFunctor::instant) 
    1427             time_data_bound(0) = time_data_bound(1) = Time(field->last_Write_srv); 
     1428            time_data_bound(0) = time_data_bound(1) = lastWrite; 
    14281429          else if (field->getOperationTimeType() == func::CFunctor::centered) 
    14291430          { 
    1430             time_data_bound(0) = time_counter_bound(0); 
    1431             time_data_bound(1) = time_counter_bound(1); 
     1431            time_data_bound(0) = lastLastWrite; 
     1432            time_data_bound(1) = lastWrite; 
    14321433          } 
    1433          } 
     1434 
     1435          if (field->file->time_counter == CFile::time_counter_attr::instant) 
     1436            time_counter(0) = lastWrite; 
     1437          else if (field->file->time_counter == CFile::time_counter_attr::centered) 
     1438            time_counter(0) = (lastWrite + lastLastWrite) / 2; 
     1439          else if (field->file->time_counter == CFile::time_counter_attr::record) 
     1440            time_counter(0) = field->getNStep() - 1; 
     1441 
     1442 
     1443          if (field->file->time_counter == CFile::time_counter_attr::instant) 
     1444            time_counter_bound(0) = time_counter_bound(1) = lastWrite; 
     1445          else if (field->file->time_counter == CFile::time_counter_attr::centered) 
     1446          { 
     1447            time_counter_bound(0) = lastLastWrite; 
     1448            time_counter_bound(1) = lastWrite; 
     1449          } 
     1450          else if (field->file->time_counter == CFile::time_counter_attr::record) 
     1451            time_counter_bound(0) = time_counter_bound(1) = field->getNStep() - 1; 
     1452        } 
    14341453 
    14351454         bool isRoot ; 
     
    14681487              case (MULTI_FILE) : 
    14691488              { 
    1470                  SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep()-1); 
     1489                 SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep() - 1); 
    14711490                 if (wtime) 
    14721491                 { 
    1473                    SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); 
    1474                    SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); 
    1475                    SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); 
    1476                    SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); 
     1492                   SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1); 
     1493                   SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1); 
     1494                   if (field->file->time_counter != CFile::time_counter_attr::none) 
     1495                   { 
     1496                     SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep() - 1); 
     1497                     if (field->file->time_counter != CFile::time_counter_attr::record) 
     1498                       SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1); 
     1499                   } 
    14771500                 } 
    14781501                 break ; 
     
    15661589                if (wtime) 
    15671590                { 
    1568                   SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 
    1569                   SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep() - 1, isRoot); 
    1570                   SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); 
    1571                   SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); 
     1591                   SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 
     1592                   SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); 
     1593                   if (field->file->time_counter != CFile::time_counter_attr::none) 
     1594                   { 
     1595                     SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep() - 1, isRoot); 
     1596                     if (field->file->time_counter != CFile::time_counter_attr::record) 
     1597                       SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); 
     1598                   } 
    15721599                } 
    15731600 
     
    16451672           } 
    16461673 
    1647            // Adding time_counter 
    1648            axisid = "time_counter" ; 
    1649            axisBoundId = "time_counter_bounds" ; 
    1650            dims.clear() ; 
    1651            dims.push_back(timeid); 
    1652            if (!SuperClassWriter::varExist(axisid)) 
     1674           if (field->file->time_counter != CFile::time_counter_attr::none) 
    16531675           { 
    1654               SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims); 
    1655               SuperClassWriter::addAttribute("axis", string("T"), &axisid); 
    1656               CDate timeOrigin=cal->getTimeOrigin() ; 
    1657               StdString strTimeOrigin=timeOrigin.toString() ; 
    1658  
    1659               this->writeTimeAxisAttributes 
    1660                  (axisid, cal->getType(), 
    1661                   StdString("seconds since ").append(strTimeOrigin), 
    1662                   strTimeOrigin, axisBoundId); 
    1663            } 
    1664  
    1665            // Adding time_counter_bound dimension 
    1666            if (!SuperClassWriter::varExist(axisBoundId)) 
    1667            { 
    1668               dims.clear(); 
    1669               dims.push_back(timeid); 
    1670               dims.push_back(timeBoundId); 
    1671               SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); 
     1676             // Adding time_counter 
     1677             axisid = "time_counter"; 
     1678             axisBoundId = "time_counter_bounds"; 
     1679             dims.clear(); 
     1680             dims.push_back(timeid); 
     1681             if (!SuperClassWriter::varExist(axisid)) 
     1682             { 
     1683                SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims); 
     1684                SuperClassWriter::addAttribute("axis", string("T"), &axisid); 
     1685 
     1686                if (field->file->time_counter != CFile::time_counter_attr::record) 
     1687                { 
     1688                  CDate timeOrigin = cal->getTimeOrigin(); 
     1689                  StdString strTimeOrigin = timeOrigin.toString(); 
     1690 
     1691                  this->writeTimeAxisAttributes(axisid, cal->getType(), 
     1692                                                StdString("seconds since ").append(strTimeOrigin), 
     1693                                                strTimeOrigin, axisBoundId); 
     1694                } 
     1695             } 
     1696 
     1697             // Adding time_counter_bound dimension 
     1698             if (field->file->time_counter != CFile::time_counter_attr::record) 
     1699             { 
     1700                if (!SuperClassWriter::varExist(axisBoundId)) 
     1701                { 
     1702                  dims.clear(); 
     1703                  dims.push_back(timeid); 
     1704                  dims.push_back(timeBoundId); 
     1705                  SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); 
     1706                } 
     1707             } 
    16721708           } 
    16731709         } 
  • XIOS/trunk/src/node/file.cpp

    r651 r692  
    246246      MPI_Comm_split(server->intraComm, color, server->intraCommRank, &fileComm); 
    247247      if (allDomainEmpty) MPI_Comm_free(&fileComm); 
     248 
     249      if (time_counter.isEmpty()) time_counter.setValue(time_counter_attr::centered); 
    248250    } 
    249251 
Note: See TracChangeset for help on using the changeset viewer.