diff --git a/ChangeLog b/ChangeLog index 258953d0d7df6635e9061ea812fe308d2c0a497c..ab4f36f1a4752abfeb44623af17c0e30d459147d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,11 @@ -2025-02-28 Uwe Schulzweida +2025-02-06 Uwe Schulzweida * Using CDI library version 2.5.1 * Version 2.5.1 release -2025-01-10 Uwe Schulzweida +2025-01-17 Uwe Schulzweida - * enable NETCDF_LAZY_GRID_LOAD for operators without output stream + * consects/consecsum: wrong result since release 2.4.0 [Bug #12030] 2024-11-28 Uwe Schulzweida diff --git a/NEWS b/NEWS index 1412285be7004eeb7c9c2fab017cdc1cb638becf..45e8656135ca5d78a98cabbe557963b467a71ea6 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,11 @@ CDO NEWS Improvement +Version 2.5.1 (6 Feb 2025): + + Fixed bugs: + * consects/consecsum: wrong result since release 2.4.0 [Bug #12030] + Version 2.5.0 (28 Nov 2024): New features: diff --git a/src/Consecstat.cc b/src/Consecstat.cc index 0e9097d2e205fe623edf6f3f7e148c86ff1deee6..f3276b72d815e49040bf5fb316ff4b21e20f0b91 100644 --- a/src/Consecstat.cc +++ b/src/Consecstat.cc @@ -27,12 +27,6 @@ #include "param_conversion.h" #include "field_functions.h" -enum -{ - CONSECSUM, - CONSECTS -}; - #define SWITCHWARN "Hit default case! This should never happen (%s).\n" static void @@ -108,11 +102,20 @@ selEndOfPeriod(Field &periods, const Field &history, const Field ¤t, int i class Consecstat : public Process { + enum + { + CONSECSUM, + CONSECTS + }; + public: using Process::Process; inline static CdoModule module = { .name = "Consecstat", - .operators = { { "consects", CONSECTS, 0, ConsecstatHelp }, { "consecsum", CONSECSUM, 0, "refval", ConsecstatHelp } }, + // clang-format off + .operators = { { "consects", CONSECTS, 0, ConsecstatHelp }, + { "consecsum", CONSECSUM, 0, "refval", ConsecstatHelp } }, + // clang-format on .aliases = {}, .mode = EXPOSED, // Module mode: 0:intern 1:extern .number = CDI_REAL, // Allowed number type @@ -133,7 +136,7 @@ public: int ovlistID; int otaxisID; - int operatorID; + int operfunc; VarList varList1; @@ -141,9 +144,10 @@ public: void init() override { - operatorID = cdo_operator_id(); + auto operatorID = cdo_operator_id(); + operfunc = cdo_operator_f1(operatorID); - if (operatorID == CONSECSUM) + if (operfunc == CONSECSUM) if (cdo_operator_argc() > 0) refval = parameter_to_double(cdo_operator_argv(0)); istreamID = cdo_open_read(0); @@ -171,8 +175,8 @@ public: FieldVector2D varsData, histData, periodsData; field2D_init(varsData, varList1, FIELD_VEC, 0); - if (operatorID == CONSECTS) field2D_init(histData, varList1, FIELD_VEC); - if (operatorID == CONSECTS) field2D_init(periodsData, varList1, FIELD_VEC); + if (operfunc == CONSECTS) field2D_init(histData, varList1, FIELD_VEC); + if (operfunc == CONSECTS) field2D_init(periodsData, varList1, FIELD_VEC); int itsID = 0; int otsID = 0; @@ -182,7 +186,7 @@ public: if (numFields == 0) break; vDateTime = taxisInqVdatetime(itaxisID); - switch (operatorID) + switch (operfunc) { case CONSECSUM: taxisDefVdatetime(otaxisID, vDateTime); @@ -208,7 +212,7 @@ public: auto &varData = varsData[varID][levelID]; field2_sumtr(varData, field, refval); - switch (operatorID) + switch (operfunc) { case CONSECSUM: cdo_def_field(ostreamID, varID, levelID); @@ -232,7 +236,7 @@ public: otsID++; } - if (operatorID == CONSECTS) /* Save the last timestep */ + if (operfunc == CONSECTS) // Save the last timestep { taxisDefVdatetime(otaxisID, vDateTime); cdo_def_timestep(ostreamID, otsID - 1); diff --git a/src/Fldstat.cc b/src/Fldstat.cc index 41b41ba0a32241e2ebbe0f9fc827afae43a699cf..c0a902b61152d0fe65dfae6cc9d1f97957f44aa7 100644 --- a/src/Fldstat.cc +++ b/src/Fldstat.cc @@ -270,6 +270,8 @@ public: void init() override { + // if (this_is_the_only_process()) { cdiDefGlobal("NETCDF_LAZY_GRID_LOAD", true); } + FLDINT = module.get_id("fldint"); auto operatorID = cdo_operator_id(); diff --git a/src/Timstat.cc b/src/Timstat.cc index 5e8c01284c3d96fd1694604ec3a9f644b725b10e..a4e9b19faef0bb84b7fe6388f19cada603fdfe91 100644 --- a/src/Timstat.cc +++ b/src/Timstat.cc @@ -268,6 +268,8 @@ public: void init() override { + // if (this_is_the_only_process()) { cdiDefGlobal("NETCDF_LAZY_GRID_LOAD", true); } + auto operatorID = cdo_operator_id(); auto operfunc = cdo_operator_f1(operatorID); compareDate = cdo_operator_f2(operatorID); diff --git a/src/cdo_timer.h b/src/cdo_timer.h index e22a55a41d9a07d591ed204f7aec38c253163035..4ac16053c8af991d7eebe38f29fa667951bf2482 100644 --- a/src/cdo_timer.h +++ b/src/cdo_timer.h @@ -29,7 +29,7 @@ public: } double - time_span() + time_span() const { auto timeSpan = duration_cast<duration<double>>(clock::now() - startPoint); return timeSpan.count(); @@ -48,15 +48,15 @@ private: }; // interval timer (stop watch) -static bool timerNeedInit = true; -static double timerShift = 0.0; // minimal internal time needed to do one measurement +static bool timerNeedInit{ true }; +static double timerShift{ 0.0 }; // minimal internal time needed to do one measurement // interval timer (stop watch) class iTimer { private: double - get_shift(void) + get_shift(void) const { constexpr int numTests = 100; double dt0 = 1.0; @@ -78,14 +78,14 @@ private: } double - get_time_val(const clock::time_point &_startPoint) + get_time_val(const clock::time_point &_startPoint) const { auto dt = duration_cast<duration<double>>(clock::now() - _startPoint); return dt.count(); } clock::time_point startPoint; - bool isRunning = false; + bool isRunning{ false }; public: iTimer() @@ -127,11 +127,11 @@ public: return sum; } - int calls = 0; - int stat = 0; - double sum = 0.0; - double min = 1.e30; - double max = 0.0; + int calls{ 0 }; + int stat{ 0 }; + double sum{ 0.0 }; + double min{ 1.e30 }; + double max{ 0.0 }; std::string name; }; diff --git a/test/data/consecsum_ref b/test/data/consecsum_ref index 43dc167f2c51bb12965810e274515a6ad54c9b12..4a1508798b2b720608c078e63bb287f144f893f1 100644 Binary files a/test/data/consecsum_ref and b/test/data/consecsum_ref differ diff --git a/test/data/consects_ref b/test/data/consects_ref index 4a1508798b2b720608c078e63bb287f144f893f1..43dc167f2c51bb12965810e274515a6ad54c9b12 100644 Binary files a/test/data/consects_ref and b/test/data/consects_ref differ