From 9010e0d90fbf4abc6a8c779150ea7d66eb65e6ca Mon Sep 17 00:00:00 2001
From: Uwe Schulzweida <uwe.schulzweida@mpimet.mpg.de>
Date: Fri, 28 Mar 2025 15:18:28 +0100
Subject: [PATCH 1/3] Yseascomp: added Docu

---
 ChangeLog             |  4 +++
 OPERATORS             |  6 ++++
 doc/tex/Modules       |  1 +
 doc/tex/mod/Ymoncomp  |  4 +--
 doc/tex/mod/Yseascomp | 72 +++++++++++++++++++++++++++++++++++++++++++
 src/Ymoncomp.cc       | 70 ++++++++++++++++++++---------------------
 src/operator_help.cc  | 39 ++++++++++++++++++++---
 src/operator_help.h   |  1 +
 8 files changed, 154 insertions(+), 43 deletions(-)
 create mode 100644 doc/tex/mod/Yseascomp

diff --git a/ChangeLog b/ChangeLog
index cd4a172b8..c67c24eaa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2025-03-28  Uwe Schulzweida
+
+	* Yseascomp: added Docu
+
 2025-03-27  Uwe Schulzweida
 
 	* sortlevel: added NetCDF support
diff --git a/OPERATORS b/OPERATORS
index 876c5031c..0bb482ec1 100644
--- a/OPERATORS
+++ b/OPERATORS
@@ -150,6 +150,12 @@ Operator catalog:
    Ymoncomp      ymonlt          Compares if time series with LessThan
    Ymoncomp      ymonge          Compares if time series with GreaterEqual
    Ymoncomp      ymongt          Compares if time series with GreaterThan
+   Yseascomp     yseaseq         Compare time series with Equal
+   Yseascomp     yseasne         Compare time series with NotEqual
+   Yseascomp     yseasle         Compare time series with LessEqual
+   Yseascomp     yseaslt         Compares if time series with LessThan
+   Yseascomp     yseasge         Compares if time series with GreaterEqual
+   Yseascomp     yseasgt         Compares if time series with GreaterThan
 -------------------------------------------------------------
    Modification
 -------------------------------------------------------------
diff --git a/doc/tex/Modules b/doc/tex/Modules
index 7029e1caf..4251f0570 100644
--- a/doc/tex/Modules
+++ b/doc/tex/Modules
@@ -41,6 +41,7 @@ MapReduce     Conditional selection
 Comp	      Comparison
 Compc	      Comparison
 Ymoncomp      Comparison
+Yseascomp     Comparison
 Setattribute  Modification
 Setpartab     Modification
 Set           Modification
diff --git a/doc/tex/mod/Ymoncomp b/doc/tex/mod/Ymoncomp
index 7600e4f12..d16d87e21 100644
--- a/doc/tex/mod/Ymoncomp
+++ b/doc/tex/mod/Ymoncomp
@@ -8,9 +8,9 @@
 @Operators = ymoneq ymonne ymonle ymonlt ymonge ymongt
 
 @BeginDescription
-This module performs compaisons of a time series and one timestep with the same month of year.
+This module performs comparisons of a time series and one timestep with the same month of year.
 For each field in @file{infile1} the corresponding field of the timestep in @file{infile2} with the same month of year is used.
-The resulting field is a mask containing 1 if the comparison is true and 0 if not. 
+The resulting field is a mask containing 1 if the comparison is true and 0 if not.
 The type of comparison depends on the chosen operator.
 The input files need to have the same structure with the same variables.
 Usually @file{infile2} is generated by an operator of the module @mod{YMONSTAT}.
diff --git a/doc/tex/mod/Yseascomp b/doc/tex/mod/Yseascomp
new file mode 100644
index 000000000..7a63418ae
--- /dev/null
+++ b/doc/tex/mod/Yseascomp
@@ -0,0 +1,72 @@
+@BeginModule
+@NewPage
+@Name      = Yseascomp
+@Title     = Multi-year seasonal comparison
+@Section   = Comparison
+@Class     = Comparison
+@Arguments = infile1 infile2 outfile
+@Operators = yseaseq yseasne yseasle yseaslt yseasge yseasgt
+
+@BeginDescription
+This module performs comparisons of a time series and one timestep with the same season of year.
+For each field in @file{infile1} the corresponding field of the timestep in @file{infile2} with the same season of year is used.
+The resulting field is a mask containing 1 if the comparison is true and 0 if not.
+The type of comparison depends on the chosen operator.
+The input files need to have the same structure with the same variables.
+Usually @file{infile2} is generated by an operator of the module @mod{YseasSTAT}.
+@EndDescription
+@EndModule
+
+
+@BeginOperator_yseaseq
+@Title     = Compare time series with Equal
+
+@BeginDescription
+Compares whether a time series is equal to a multi-year seasonal time series.
+@EndDescription
+@EndOperator
+
+
+@BeginOperator_yseasne
+@Title     = Compare time series with NotEqual
+
+@BeginDescription
+Compares whether a time series is not equal to a multi-year seasonal time series.
+@EndDescription
+@EndOperator
+
+
+@BeginOperator_yseasle
+@Title     = Compare time series with LessEqual
+
+@BeginDescription
+Compares whether a time series is less than or equal to a multi-year seasonal time series.
+@EndDescription
+@EndOperator
+
+
+@BeginOperator_yseaslt
+@Title     = Compares if time series with LessThan
+
+@BeginDescription
+Compares whether a time series is less than a multi-year seasonal time series.
+@EndDescription
+@EndOperator
+
+
+@BeginOperator_yseasge
+@Title     = Compares if time series with GreaterEqual
+
+@BeginDescription
+Compares whether a time series is greater than or equal to a multi-year seasonal time series.
+@EndDescription
+@EndOperator
+
+
+@BeginOperator_yseasgt
+@Title     = Compares if time series with GreaterThan
+
+@BeginDescription
+Compares whether a time series is greater than a multi-year seasonal time series.
+@EndDescription
+@EndOperator
diff --git a/src/Ymoncomp.cc b/src/Ymoncomp.cc
index 17b925dab..db3b43350 100644
--- a/src/Ymoncomp.cc
+++ b/src/Ymoncomp.cc
@@ -29,34 +29,36 @@
 #include "process_int.h"
 #include "field_functions.h"
 
-static auto func_comp = [](auto hasMissvals, auto n, auto mv1, auto mv2, auto &v1, auto const &v2, auto binary_operator) {
-  if (hasMissvals)
-    {
-      if (std::isnan(mv1) || std::isnan(mv2))
-        for (size_t i = 0; i < n; ++i)
-          v1[i] = (fp_is_equal(v1[i], mv1) || fp_is_equal(v2[i], mv2)) ? mv1 : binary_operator(v1[i], v2[i]);
-      else
-        for (size_t i = 0; i < n; ++i) v1[i] = (is_equal(v1[i], mv1) || is_equal(v2[i], mv2)) ? mv1 : binary_operator(v1[i], v2[i]);
-    }
-  else
-    {
-      for (size_t i = 0; i < n; ++i) v1[i] = binary_operator(v1[i], v2[i]);
-    }
-};
-
 template <typename T1, typename T2>
 static void
-comp_function(Varray<T1> &v1, const Varray<T2> &v2, double missval1, double missval2, size_t ngp, int operFunc, bool hasMissvals)
+comp_function(Varray<T1> &v1, Varray<T2> const &v2, double missval1, double missval2, size_t n, int operFunc, bool hasMissvals)
 {
   T1 mv1 = missval1;
   T2 mv2 = missval2;
+
+  auto func_comp = [&](auto binary_operator) {
+    if (hasMissvals)
+      {
+        if (std::isnan(mv1) || std::isnan(mv2))
+          for (size_t i = 0; i < n; ++i)
+            v1[i] = (fp_is_equal(v1[i], mv1) || fp_is_equal(v2[i], mv2)) ? mv1 : binary_operator(v1[i], v2[i]);
+        else
+          for (size_t i = 0; i < n; ++i)
+            v1[i] = (is_equal(v1[i], mv1) || is_equal(v2[i], mv2)) ? mv1 : binary_operator(v1[i], v2[i]);
+      }
+    else
+      {
+        for (size_t i = 0; i < n; ++i) v1[i] = binary_operator(v1[i], v2[i]);
+      }
+  };
+
   // clang-format off
-  if      (operFunc == FieldFunc_EQ) func_comp(hasMissvals, ngp, mv1, mv2, v1, v2, binary_op_EQ);
-  else if (operFunc == FieldFunc_NE) func_comp(hasMissvals, ngp, mv1, mv2, v1, v2, binary_op_NE);
-  else if (operFunc == FieldFunc_LE) func_comp(hasMissvals, ngp, mv1, mv2, v1, v2, binary_op_LE);
-  else if (operFunc == FieldFunc_LT) func_comp(hasMissvals, ngp, mv1, mv2, v1, v2, binary_op_LT);
-  else if (operFunc == FieldFunc_GE) func_comp(hasMissvals, ngp, mv1, mv2, v1, v2, binary_op_GE);
-  else if (operFunc == FieldFunc_GT) func_comp(hasMissvals, ngp, mv1, mv2, v1, v2, binary_op_GT);
+  if      (operFunc == FieldFunc_EQ) func_comp(binary_op_EQ);
+  else if (operFunc == FieldFunc_NE) func_comp(binary_op_NE);
+  else if (operFunc == FieldFunc_LE) func_comp(binary_op_LE);
+  else if (operFunc == FieldFunc_LT) func_comp(binary_op_LT);
+  else if (operFunc == FieldFunc_GE) func_comp(binary_op_GE);
+  else if (operFunc == FieldFunc_GT) func_comp(binary_op_GT);
   else cdo_abort("Operator not implemented!");
   // clang-format on
 }
@@ -65,11 +67,8 @@ static void
 comp_function(Field &f1, Field const &f2, int operFunc)
 {
   auto hasMissvals = (f1.numMissVals > 0 || f2.numMissVals > 0);
-
-  auto func = [&](auto &v1, auto const &v2, double mv1, double mv2, size_t size) {
-    comp_function(v1, v2, mv1, mv2, size, operFunc, hasMissvals);
-  };
-  field_operation2(func, f1, f2, f1.missval, f2.missval, f1.size);
+  auto func = [&](auto &v1, auto const &v2) { comp_function(v1, v2, f1.missval, f2.missval, f1.size, operFunc, hasMissvals); };
+  field_operation2(func, f1, f2);
 }
 
 constexpr int MaxMonths = 12;
@@ -105,12 +104,12 @@ public:
                    { "ymonlt", FieldFunc_LT, MONTHLY, YmoncompHelp },
                    { "ymonge", FieldFunc_GE, MONTHLY, YmoncompHelp },
                    { "ymongt", FieldFunc_GT, MONTHLY, YmoncompHelp },
-                   { "yseaseq", FieldFunc_EQ, SEASONAL, nullptr },
-                   { "yseasne", FieldFunc_NE, SEASONAL, nullptr },
-                   { "yseasle", FieldFunc_LE, SEASONAL, nullptr },
-                   { "yseaslt", FieldFunc_LT, SEASONAL, nullptr },
-                   { "yseasge", FieldFunc_GE, SEASONAL, nullptr },
-                   { "yseasgt", FieldFunc_GT, SEASONAL, nullptr } },
+                   { "yseaseq", FieldFunc_EQ, SEASONAL, YseascompHelp },
+                   { "yseasne", FieldFunc_NE, SEASONAL, YseascompHelp },
+                   { "yseasle", FieldFunc_LE, SEASONAL, YseascompHelp },
+                   { "yseaslt", FieldFunc_LT, SEASONAL, YseascompHelp },
+                   { "yseasge", FieldFunc_GE, SEASONAL, YseascompHelp },
+                   { "yseasgt", FieldFunc_GT, SEASONAL, YseascompHelp } },
     .aliases = {},
     .mode = EXPOSED,     // Module mode: 0:intern 1:extern
     .number = CDI_REAL,  // Allowed number type
@@ -249,10 +248,7 @@ public:
   void
   run() override
   {
-    if (opertype == SEASONAL)
-      run_seasonal();
-    else
-      run_monthly();
+    (opertype == SEASONAL) ? run_seasonal() : run_monthly();
   }
 
   void
diff --git a/src/operator_help.cc b/src/operator_help.cc
index a5984f8d0..090fbeb98 100644
--- a/src/operator_help.cc
+++ b/src/operator_help.cc
@@ -1234,9 +1234,9 @@ const CdoHelp YmoncompHelp = {
     "    <operator>  infile1 infile2 outfile",
     "",
     "DESCRIPTION",
-    "    This module performs compaisons of a time series and one timestep with the same month of year.",
+    "    This module performs comparisons of a time series and one timestep with the same month of year.",
     "    For each field in infile1 the corresponding field of the timestep in infile2 with the same month of year is used.",
-    "    The resulting field is a mask containing 1 if the comparison is true and 0 if not. ",
+    "    The resulting field is a mask containing 1 if the comparison is true and 0 if not.",
     "    The type of comparison depends on the chosen operator.",
     "    The input files need to have the same structure with the same variables.",
     "    Usually infile2 is generated by an operator of the module YMONSTAT.",
@@ -1256,6 +1256,37 @@ const CdoHelp YmoncompHelp = {
     "            Compares whether a time series is greater than a multi-year monthly time series.",
 };
 
+const CdoHelp YseascompHelp = {
+    "NAME",
+    "    yseaseq, yseasne, yseasle, yseaslt, yseasge, yseasgt - ",
+    "    Multi-year seasonal comparison",
+    "",
+    "SYNOPSIS",
+    "    <operator>  infile1 infile2 outfile",
+    "",
+    "DESCRIPTION",
+    "    This module performs comparisons of a time series and one timestep with the same season of year.",
+    "    For each field in infile1 the corresponding field of the timestep in infile2 with the same season of year is used.",
+    "    The resulting field is a mask containing 1 if the comparison is true and 0 if not.",
+    "    The type of comparison depends on the chosen operator.",
+    "    The input files need to have the same structure with the same variables.",
+    "    Usually infile2 is generated by an operator of the module YseasSTAT.",
+    "",
+    "OPERATORS",
+    "    yseaseq  Compare time series with Equal",
+    "             Compares whether a time series is equal to a multi-year seasonal time series.",
+    "    yseasne  Compare time series with NotEqual",
+    "             Compares whether a time series is not equal to a multi-year seasonal time series.",
+    "    yseasle  Compare time series with LessEqual",
+    "             Compares whether a time series is less than or equal to a multi-year seasonal time series.",
+    "    yseaslt  Compares if time series with LessThan",
+    "             Compares whether a time series is less than a multi-year seasonal time series.",
+    "    yseasge  Compares if time series with GreaterEqual",
+    "             Compares whether a time series is greater than or equal to a multi-year seasonal time series.",
+    "    yseasgt  Compares if time series with GreaterThan",
+    "             Compares whether a time series is greater than a multi-year seasonal time series.",
+};
+
 const CdoHelp SetattributeHelp = {
     "NAME",
     "    setattribute, delattribute - Set attributes",
@@ -4588,8 +4619,8 @@ const CdoHelp RemapdisHelp = {
     "              In this case the mapfiles will be named <outfile><xxx>.nc. xxx will have five digits with the number of the mapfile.",
     "",
     "PARAMETER",
-    "    grid       STRING   Target grid description file or name",
-    "    neighbors  INTEGER  Number of nearest neighbors [default: 4]",
+    "    grid       STRING  Target grid description file or name",
+    "    neighbors  INTEGER Number of nearest neighbors [default: 4]",
     "    map3d      BOOL    Generate all mapfiles of the first 3D field",
     "",
     "ENVIRONMENT",
diff --git a/src/operator_help.h b/src/operator_help.h
index b79e36958..47e115f6f 100644
--- a/src/operator_help.h
+++ b/src/operator_help.h
@@ -51,6 +51,7 @@ extern const CdoHelp MapReduceHelp;
 extern const CdoHelp CompHelp;
 extern const CdoHelp CompcHelp;
 extern const CdoHelp YmoncompHelp;
+extern const CdoHelp YseascompHelp;
 extern const CdoHelp SetattributeHelp;
 extern const CdoHelp SetpartabHelp;
 extern const CdoHelp SetHelp;
-- 
GitLab


From 38b898b63c2601a5467f4a8e3024d319bee3f246 Mon Sep 17 00:00:00 2001
From: Uwe Schulzweida <uwe.schulzweida@mpimet.mpg.de>
Date: Fri, 28 Mar 2025 16:21:12 +0100
Subject: [PATCH 2/3] Removed unused includes

---
 src/CMOR.cc           | 47 +++++++++++++++++++++++++------------------
 src/afterburner.h     |  1 +
 src/cdo_getopt.h      |  6 ++----
 src/expr.cc           |  2 +-
 src/grid_define.cc    |  3 ++-
 src/grid_print.cc     |  3 ++-
 src/griddes.cc        |  5 +++--
 src/institution.cc    |  2 +-
 src/interpol.cc       |  6 ++----
 src/merge_axis.cc     |  3 ++-
 src/printinfo.cc      |  1 +
 src/printinfo.h       |  6 ++----
 src/process.h         |  9 +++------
 src/processManager.cc |  5 ++---
 src/process_int.h     |  1 -
 src/remap_bicubic.cc  |  6 +++---
 src/remap_bilinear.cc |  6 +++---
 src/remap_conserv.cc  |  6 +++---
 src/remap_knn.cc      |  2 +-
 src/remap_vars.cc     |  2 +-
 src/remaplib.cc       |  2 +-
 21 files changed, 63 insertions(+), 61 deletions(-)

diff --git a/src/CMOR.cc b/src/CMOR.cc
index cdb3fc70b..e2d80b105 100644
--- a/src/CMOR.cc
+++ b/src/CMOR.cc
@@ -23,7 +23,7 @@
 #include "cdo_cdi_wrapper.h"
 #include "varray.h"
 
-#ifndef HAVE_LIBCMOR //------------------------------------------------------------
+#ifndef HAVE_LIBCMOR  //------------------------------------------------------------
 class CMOR : public Process
 {
 public:
@@ -39,13 +39,25 @@ public:
   inline static RegisterEntry<CMOR> registration = RegisterEntry<CMOR>(module);
 
   /*  clang-format off */
-  void init() override { cdo_abort("CMOR support not compiled in!"); }
-  void run() override { cdo_abort("CMOR support not compiled in!"); }
-  void close() override { cdo_abort("CMOR support not compiled in!"); }
+  void
+  init() override
+  {
+    cdo_abort("CMOR support not compiled in!");
+  }
+  void
+  run() override
+  {
+    cdo_abort("CMOR support not compiled in!");
+  }
+  void
+  close() override
+  {
+    cdo_abort("CMOR support not compiled in!");
+  }
   /*  clang-format on */
 };
 
-#else //---------------------------------------------------------------------------
+#else  //---------------------------------------------------------------------------
 
 #include <cassert>
 #include <unistd.h>
@@ -5278,19 +5290,19 @@ empty_array(struct mapping vars[], char ***chunk_files)
 }
 
 static char **
-get_chunk_des_files(KVList *kvl, struct mapping vars[], char *miptab_freqptr, int nreq, int vlistID, char *charname,
-                    char *project_id)
+get_chunk_des_files(KVList *kvl, struct mapping vars[], std::string const &miptab_freqptr, int nreq, int vlistID, char *charname,
+                    std::string const &project_id)
 {
   char **chunk_des_files = (char **) std::malloc((nreq + 1) * sizeof(char *));
   chunk_des_files[nreq] = nullptr;
 
   char trunk[CMOR_MAX_STRING];
-  if (std::strcmp(project_id, "CMIP6") == 0)
+  if (project_id == "CMIP6")
     std::snprintf(trunk, CMOR_MAX_STRING, "%s_", kv_get_a_val(kvl, "source_id", "").c_str());
   else
     std::snprintf(trunk, CMOR_MAX_STRING, "%s_", kv_get_a_val(kvl, "model_id", "").c_str());
   const char *description_atts[] = { "experiment_id", "member", "sub_experiment_id", nullptr };
-  strcpy(trunk, miptab_freqptr);
+  strcpy(trunk, miptab_freqptr.c_str());
   for (int i = 0; description_atts[i]; ++i)
     {
       std::strcat(trunk, "_");
@@ -5318,8 +5330,8 @@ get_chunk_des_files(KVList *kvl, struct mapping vars[], char *miptab_freqptr, in
 }
 
 static char **
-get_chunk_files(KVList *kvl, struct mapping vars[], int vlistID, int ifreq, int time_axis, int calendar, char *miptab_freqptr,
-                char *project_id, int *mergeIDs, int psID)
+get_chunk_files(KVList *kvl, struct mapping vars[], int vlistID, int ifreq, int time_axis, int calendar,
+                std::string const &miptab_freqptr, std::string const &project_id, int *mergeIDs, int psID)
 {
   int i = 0;
   for (i = 0; vars[i].cmor_varID != CMOR_UNDEFID; ++i);
@@ -5404,7 +5416,7 @@ get_chunk_files(KVList *kvl, struct mapping vars[], int vlistID, int ifreq, int
 
 static void
 write_variables(KVList *kvl, CdoStreamID streamID, struct mapping vars[], int miptab_freq, int time_axis, int calendar,
-                std::string miptab_freqptr, std::string project_id, int *mergeIDs)
+                std::string const &miptab_freqptr, std::string const &project_id, int *mergeIDs)
 {
   int cmf = 0;
   int vlistID = cdo_stream_inq_vlist(streamID);
@@ -5451,8 +5463,7 @@ write_variables(KVList *kvl, CdoStreamID streamID, struct mapping vars[], int mi
   if (Options::cdoVerbose) cdo_print("10.2. Start to get chunk files.");
   char **chunk_files = nullptr;
   if (ifreq > 0 && ifreq != 7)
-    chunk_files = get_chunk_files(kvl, vars, vlistID, ifreq, time_axis, calendar, (char *) miptab_freqptr.c_str(),
-                                  (char *) project_id.c_str(), mergeIDs, psID);
+    chunk_files = get_chunk_files(kvl, vars, vlistID, ifreq, time_axis, calendar, miptab_freqptr, project_id, mergeIDs, psID);
   else
     {
       int number = 0;
@@ -5648,7 +5659,7 @@ write_variables(KVList *kvl, CdoStreamID streamID, struct mapping vars[], int mi
   char **chunkdf = nullptr;
   if (mergeIDs[0] != CMOR_UNDEFID) i = 1;
   if (kv_get_a_val(kvl, "d", "y") == "y")
-    chunkdf = get_chunk_des_files(kvl, vars, (char *) miptab_freqptr.c_str(), i, vlistID, charname, (char *) project_id.c_str());
+    chunkdf = get_chunk_des_files(kvl, vars, miptab_freqptr, i, vlistID, charname, project_id);
 
   char file_name[CMOR_MAX_STRING];
   for (i = 0; vars[i].cmor_varID != CMOR_UNDEFID; ++i)
@@ -6342,7 +6353,6 @@ cmor_load_and_set_table(KVList *kvl, std::string const &param0, std::string cons
   return table_id;
 }
 
-
 class CMOR : public Process
 {
 public:
@@ -6375,7 +6385,6 @@ public:
   init() override
   {
     int nparams = cdo_operator_argc();
-
     if (nparams < 1) cdo_abort("ERROR (infile: '%s')! No parameter found. Need at least a MIP-table.", cdo_get_stream_name(0));
 
     auto params = cdo_get_oper_argv();
@@ -6419,7 +6428,6 @@ public:
   void
   run() override
   {
-
     if (Options::cdoVerbose) cdo_print("4. Start to check attributes.");
     /* Short keys from rtu, mt, gi must be included similar to global atts */
     add_globalhybrids(&kvl, vlistID);
@@ -6456,6 +6464,5 @@ public:
     destruct_var_mapping(vars);
     /* std::free(miptableInput); */
   }
-
 };
-#endif //HAVE_LIBCMOR
+#endif  // HAVE_LIBCMOR
diff --git a/src/afterburner.h b/src/afterburner.h
index fc2ca98ed..1ab3b4758 100644
--- a/src/afterburner.h
+++ b/src/afterburner.h
@@ -11,6 +11,7 @@
 #include <cstdarg>
 
 #include "process_int.h"
+#include "cdo_output.h"
 #include "transform.h"
 #include "workerthread.h"
 #include "varray.h"
diff --git a/src/cdo_getopt.h b/src/cdo_getopt.h
index 3108cda6a..44c7a8500 100644
--- a/src/cdo_getopt.h
+++ b/src/cdo_getopt.h
@@ -6,7 +6,6 @@
 #endif
 
 #include <map>
-#include <set>
 #include <vector>
 #include <string>
 #include <functional>
@@ -29,7 +28,6 @@ struct cdo_option_argument
 
 struct cdo_option_2
 {
-
   std::function<void(std::string argument)> effect = [](std::string) {
     printf("ERROR");
     exit(0);
@@ -129,6 +127,7 @@ struct cdo_option_2
   {
     return argument.value;
   }
+
   void
   execute()
   {
@@ -193,8 +192,7 @@ public:
   static bool print_settings;
   static bool print_envvars;
 
-  static int
-  parse(std::vector<std::string> p_argv);
+  static int parse(std::vector<std::string> p_argv);
   static void get_env_vars();
   static std::shared_ptr<cdo_option_2> &option(std::string const &p_name, std::string const &p_short_form = std::string());
   static std::shared_ptr<cdo_option_2> &envvar(std::string const &p_name);
diff --git a/src/expr.cc b/src/expr.cc
index 5d422c108..afb66f6fa 100644
--- a/src/expr.cc
+++ b/src/expr.cc
@@ -10,8 +10,8 @@
 #include <cdi.h>
 
 #include "cdo_options.h"
-#include "process_int.h"
 #include "field_functions.h"
+#include "cdo_output.h"
 #include "cdo_omp.h"
 #include "interpol.h"
 #include "expr.h"
diff --git a/src/grid_define.cc b/src/grid_define.cc
index f5bd72f29..d8b903b25 100644
--- a/src/grid_define.cc
+++ b/src/grid_define.cc
@@ -9,7 +9,8 @@
 
 #include <cdi.h>
 
-#include "process_int.h"
+#include "cdo_output.h"
+#include "cdo_cdi_wrapper.h"
 #include <mpim_grid.h>
 
 /*
diff --git a/src/grid_print.cc b/src/grid_print.cc
index a0ff9f1f6..264893031 100644
--- a/src/grid_print.cc
+++ b/src/grid_print.cc
@@ -9,7 +9,8 @@
 #include "cdi_uuid.h"
 
 #include "cdo_options.h"
-#include "process_int.h"
+#include "cdo_cdi_wrapper.h"
+#include "compare.h"
 #include "util_string.h"
 
 constexpr int MaxLen = 120;
diff --git a/src/griddes.cc b/src/griddes.cc
index 35f792c34..853e93596 100644
--- a/src/griddes.cc
+++ b/src/griddes.cc
@@ -13,8 +13,9 @@
 #include <cdi.h>
 
 #include "cdi_uuid.h"
-#include "cdo_options.h"
-#include "process_int.h"
+#include "cdo_output.h"
+#include "cdo_varlist.h"
+#include "compare.h"
 #include "util_string.h"
 #include "griddes.h"
 #include "util_wildcards.h"
diff --git a/src/institution.cc b/src/institution.cc
index 99bfc0e02..3cfef6ed2 100644
--- a/src/institution.cc
+++ b/src/institution.cc
@@ -9,8 +9,8 @@
 
 #include <cdi.h>
 
-#include "process_int.h"
 #include "cdo_default_values.h"
+#include "cdo_output.h"
 
 static int
 read_institution(std::string const &filename)
diff --git a/src/interpol.cc b/src/interpol.cc
index 93c20f6e3..fc290a900 100644
--- a/src/interpol.cc
+++ b/src/interpol.cc
@@ -6,17 +6,15 @@
 */
 
 #include <atomic>
-#include <algorithm>
 
 #include <cdi.h>
 
-#include "process_int.h"
 #include <mpim_grid.h>
-#include "cdo_options.h"
+#include "cdo_output.h"
 #include "interpol.h"
+#include "field.h"
 #include "progress.h"
 #include "cdo_omp.h"
-#include "matrix_view.h"
 
 /**
 * Find the interval i-1 .. i in which an element x fits and return i, the
diff --git a/src/merge_axis.cc b/src/merge_axis.cc
index e7b6affe1..34d82f2fd 100644
--- a/src/merge_axis.cc
+++ b/src/merge_axis.cc
@@ -7,10 +7,11 @@
 
 #include <cdi.h>
 
+#include <unistd.h>
+
 #include "process_int.h"
 #include "varray.h"
 
-#include <unistd.h>
 #include <mpim_grid.h>
 
 #include "pmlist.h"
diff --git a/src/printinfo.cc b/src/printinfo.cc
index 1965812e9..93e0851bd 100644
--- a/src/printinfo.cc
+++ b/src/printinfo.cc
@@ -1,5 +1,6 @@
 #include <cdi.h>
 
+#include "process_int.h"
 #include <mpim_grid.h>
 #include "cdo_options.h"
 #include "util_string.h"
diff --git a/src/printinfo.h b/src/printinfo.h
index 6a7d72acf..f76d13f11 100644
--- a/src/printinfo.h
+++ b/src/printinfo.h
@@ -1,10 +1,8 @@
 #ifndef PRINTINFO_H
 #define PRINTINFO_H
 
-#include <stdio.h>
-#include <inttypes.h>
-
-#include "process_int.h"
+#include <string>
+#include <cdoStream.h>
 
 std::string date_to_string(CdiDate date);
 std::string time_to_string(CdiTime time);
diff --git a/src/process.h b/src/process.h
index bfc6c840f..61985281f 100644
--- a/src/process.h
+++ b/src/process.h
@@ -12,12 +12,7 @@
 #include "cdo_module.h"
 
 #include <vector>
-#include <iostream>
 #include <string>
-#include <set>
-
-constexpr int MAX_PROCESS = 65536;
-constexpr int MAX_OPERATOR = 128;
 
 enum struct ProcessStatus
 {
@@ -28,12 +23,14 @@ enum struct ProcessStatus
   TooManyStreams = -4,
   TooFewStreams = -5,
 };
+
 enum struct ProcessWriteMode
 {
   FILEIO = 0,
   MEMORY = 1
 
 };
+
 void *execute(void *process);
 
 class Process
@@ -69,7 +66,7 @@ public:
 
   /* Member Functions  */
   Process(int p_ID, std::string const &p_operatorName, const std::vector<std::string> &p_arguments, const CdoModule &p_module);
-  virtual ~Process() {Debug(PROCESS,"destruction of %s",operatorName);}
+  virtual ~Process() { Debug(PROCESS, "destruction of %s", operatorName); }
 
   pthread_t start_thread();
   virtual void init() = 0;
diff --git a/src/processManager.cc b/src/processManager.cc
index c5cf2a9f8..02d59960b 100644
--- a/src/processManager.cc
+++ b/src/processManager.cc
@@ -10,13 +10,12 @@
 #include "cdo_timer.h"
 #include "cdo_output.h"
 #include "cdo_options.h"
-#include "fileStream.h"
 #include "factory.h"
 #include "util_string.h"
 
-#include <stack>
 #include <mutex>
-#include <ranges>
+
+constexpr int MAX_PROCESS = 65536;
 
 static std::mutex processMutex;
 
diff --git a/src/process_int.h b/src/process_int.h
index f6b1811b4..0bcffd347 100644
--- a/src/process_int.h
+++ b/src/process_int.h
@@ -8,7 +8,6 @@
 #ifndef PROCESS_INT_H
 #define PROCESS_INT_H
 
-#include "cdo_cdi_wrapper.h"
 #include "process.h"
 #include "factory.h"
 
diff --git a/src/remap_bicubic.cc b/src/remap_bicubic.cc
index f57690210..546952ccc 100644
--- a/src/remap_bicubic.cc
+++ b/src/remap_bicubic.cc
@@ -8,14 +8,14 @@
 #include <atomic>
 
 #include "cpp_lib.h"
-#include "process_int.h"
+#include "cdo_options.h"
+#include "cdo_output.h"
 #include "cdo_timer.h"
+#include "cdo_omp.h"
 #include <mpim_grid.h>
-#include "cdo_options.h"
 #include "remap.h"
 #include "remap_store_link.h"
 #include "progress.h"
-#include "cdo_omp.h"
 
 // bicubic interpolation
 
diff --git a/src/remap_bilinear.cc b/src/remap_bilinear.cc
index 4985eadc4..0e58d1a9b 100644
--- a/src/remap_bilinear.cc
+++ b/src/remap_bilinear.cc
@@ -8,13 +8,13 @@
 #include <atomic>
 
 #include "cpp_lib.h"
-#include "process_int.h"
+#include "cdo_options.h"
+#include "cdo_output.h"
 #include "cdo_timer.h"
+#include "cdo_omp.h"
 #include "remap.h"
 #include "remap_store_link.h"
-#include "cdo_options.h"
 #include "progress.h"
-#include "cdo_omp.h"
 #include "grid_healpix.h"
 
 // bilinear interpolation
diff --git a/src/remap_conserv.cc b/src/remap_conserv.cc
index 379656b7b..9cd3fddb5 100644
--- a/src/remap_conserv.cc
+++ b/src/remap_conserv.cc
@@ -8,14 +8,14 @@
 #include <atomic>
 
 #include "cpp_lib.h"
-#include "process_int.h"
 #include "cdo_timer.h"
+#include "cdo_options.h"
+#include "cdo_output.h"
+#include "cdo_omp.h"
 #include "remap.h"
 #include "remap_method_conserv.h"
 #include "remap_store_link.h"
-#include "cdo_options.h"
 #include "progress.h"
-#include "cdo_omp.h"
 #include <mpim_grid.h>
 
 // 1st order conservative interpolation
diff --git a/src/remap_knn.cc b/src/remap_knn.cc
index f82cb88fa..ce750aa64 100644
--- a/src/remap_knn.cc
+++ b/src/remap_knn.cc
@@ -7,9 +7,9 @@
 
 #include <atomic>
 
-#include "process_int.h"
 #include "cdo_timer.h"
 #include "cdo_options.h"
+#include "cdo_output.h"
 #include "remap.h"
 #include "remap_store_link.h"
 #include "progress.h"
diff --git a/src/remap_vars.cc b/src/remap_vars.cc
index 0cc2ad3c8..5c8ebf8d0 100644
--- a/src/remap_vars.cc
+++ b/src/remap_vars.cc
@@ -6,9 +6,9 @@
 */
 
 #include "field.h"
-#include "process_int.h"
 #include "cdo_timer.h"
 #include "cdo_options.h"
+#include "cdo_output.h"
 #include "cdo_omp.h"
 #include "remap_vars.h"
 
diff --git a/src/remaplib.cc b/src/remaplib.cc
index af4fe30df..3950dcd41 100644
--- a/src/remaplib.cc
+++ b/src/remaplib.cc
@@ -9,8 +9,8 @@
 
 #include "cdo_options.h"
 #include "cdo_timer.h"
+#include "cdo_output.h"
 #include "cdo_omp.h"
-#include "process_int.h"
 #include <mpim_grid.h>
 #include "gridreference.h"
 #include "remap.h"
-- 
GitLab


From 31f8b686489cc2ba8a44515affe98b0a4bf01226 Mon Sep 17 00:00:00 2001
From: Uwe Schulzweida <uwe.schulzweida@mpimet.mpg.de>
Date: Fri, 28 Mar 2025 16:43:02 +0100
Subject: [PATCH 3/3] Include cstring

---
 src/grid_print.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/grid_print.cc b/src/grid_print.cc
index 264893031..33d779e32 100644
--- a/src/grid_print.cc
+++ b/src/grid_print.cc
@@ -8,6 +8,8 @@
 #include <cdi.h>
 #include "cdi_uuid.h"
 
+#include <cstring>
+
 #include "cdo_options.h"
 #include "cdo_cdi_wrapper.h"
 #include "compare.h"
-- 
GitLab