diff --git a/libcdi b/libcdi
index bd90f1f6913b8d3e704d667cac4bbd886418e09c..e890330ebfcf84fbc95a6ab932302459314ca695 160000
--- a/libcdi
+++ b/libcdi
@@ -1 +1 @@
-Subproject commit bd90f1f6913b8d3e704d667cac4bbd886418e09c
+Subproject commit e890330ebfcf84fbc95a6ab932302459314ca695
diff --git a/src/remap_bicubic.cc b/src/remap_bicubic.cc
index 0f8af997d7b3a126baf5651279c6041fede6c07d..8c1b8e6b4a0040cef6779ba82b5b23fbbb6f820d 100644
--- a/src/remap_bicubic.cc
+++ b/src/remap_bicubic.cc
@@ -114,7 +114,7 @@ bicubic_warning()
 void
 remap_bicubic_weights(RemapSearch &rsearch, RemapVars &rv)
 {
-  auto srcGrid = rsearch.srcGrid;
+  const auto srcGrid = rsearch.srcGrid;
   auto tgtGrid = rsearch.tgtGrid;
 
   if (Options::cdoVerbose) cdo_print("Called %s()", __func__);
diff --git a/src/remap_bilinear.cc b/src/remap_bilinear.cc
index 1658c6a6316f5994841d2bc5b0f666be568fb6b8..cb123f2bd07b49a3bd0f5ba236f0882f76629618 100644
--- a/src/remap_bilinear.cc
+++ b/src/remap_bilinear.cc
@@ -239,7 +239,7 @@ remap_bilinear_weights_healpix(const RemapSearch &rsearch, const Varray<short> &
 void
 remap_bilinear_weights(RemapSearch &rsearch, RemapVars &rv)
 {
-  auto srcGrid = rsearch.srcGrid;
+  const auto srcGrid = rsearch.srcGrid;
   auto tgtGrid = rsearch.tgtGrid;
 
   auto isHealpixGrid = (srcGrid->type == RemapGridType::HealPix);
@@ -381,7 +381,7 @@ template <typename T>
 static void
 remap_bilinear(RemapSearch &rsearch, const Varray<T> &srcArray, Varray<T> &tgtArray, T missval, size_t nmiss)
 {
-  auto srcGrid = rsearch.srcGrid;
+  const auto srcGrid = rsearch.srcGrid;
   auto tgtGrid = rsearch.tgtGrid;
 
   auto isHealpixGrid = (srcGrid->type == RemapGridType::HealPix);
diff --git a/src/remap_conserv.cc b/src/remap_conserv.cc
index 048eb0206db7cf4bcd3d7528720a7aece4c35b2c..bee27efcbd3f7cd3aa731a2589be2686bd2fb7ae 100644
--- a/src/remap_conserv.cc
+++ b/src/remap_conserv.cc
@@ -144,7 +144,7 @@ cdo_compute_overlap_areas(size_t numSearchCells, CellSearch &search, const GridC
 }
 
 static double
-get_edge_direction(double *ref_corner, double *corner_a, double *corner_b)
+get_edge_direction(const double *ref_corner, double *corner_a, double *corner_b)
 {
   double edge_norm[3];
   crossproduct_ld(corner_a, corner_b, edge_norm);
@@ -244,8 +244,8 @@ set_cell_coordinates_yac(RemapGridType remapGridType, size_t cellIndex, size_t n
       auto nx = remapGrid->dims[0];
       auto iy = cellIndex / nx;
       auto ix = cellIndex - iy * nx;
-      auto reg2d_corner_lon = &remapGrid->reg2d_corner_lon[ix];
-      auto reg2d_corner_lat = &remapGrid->reg2d_corner_lat[iy];
+      const auto reg2d_corner_lon = &remapGrid->reg2d_corner_lon[ix];
+      const auto reg2d_corner_lat = &remapGrid->reg2d_corner_lat[iy];
       constexpr int xi[4] = { 0, 1, 1, 0 };
       constexpr int yi[4] = { 0, 0, 1, 1 };
       for (int k = 0; k < 4; ++k)
diff --git a/src/remap_store_link.cc b/src/remap_store_link.cc
index 48ef9a66deca03d77addc999c2d25b36420c57d9..664ead2ee87dc8d5fd675a4bd7d39d2f5597a490 100644
--- a/src/remap_store_link.cc
+++ b/src/remap_store_link.cc
@@ -23,13 +23,13 @@ is_sorted_list(size_t n, const size_t *list)
 static int
 qcompare_index(const void *a, const void *b)
 {
-  return (((const IndexWeight *) a)->index < ((const IndexWeight *) b)->index);
+  return (static_cast<const IndexWeight *>(a)->index < static_cast<const IndexWeight *>(b)->index);
 }
 
 static int
 qcompare_index4(const void *a, const void *b)
 {
-  return (((const IndexWeight4 *) a)->index < ((const IndexWeight4 *) b)->index);
+  return (static_cast<const IndexWeight4 *>(a)->index < static_cast<const IndexWeight4 *>(b)->index);
 }
 
 static void
@@ -45,7 +45,7 @@ sort_indexWeights4(IndexWeight4 *indexWeights)
 }
 
 void
-store_weightlinks(int doAlloc, size_t numWeights, size_t *indices, double *weights, size_t cellIndex,
+store_weightlinks(int doAlloc, size_t numWeights, const size_t *indices, const double *weights, size_t cellIndex,
                   std::vector<WeightLinks> &weightLinks)
 {
   weightLinks[cellIndex].nlinks = 0;
@@ -70,7 +70,7 @@ store_weightlinks(int doAlloc, size_t numWeights, size_t *indices, double *weigh
 }
 
 void
-store_weightlinks_bicubic(size_t *indices, double (&weights)[4][4], size_t cellIndex, std::vector<WeightLinks4> &weightLinks)
+store_weightlinks_bicubic(const size_t *indices, double (&weights)[4][4], size_t cellIndex, std::vector<WeightLinks4> &weightLinks)
 {
   weightLinks[cellIndex].nlinks = 0;
   weightLinks[cellIndex].offset = 0;
diff --git a/src/remap_store_link.h b/src/remap_store_link.h
index 215f5ec3d83d84e34d10c9d7e766b2f3eeb9cac3..2821f1e8dc2f24b26250f1fe3ae821e29065ad26 100644
--- a/src/remap_store_link.h
+++ b/src/remap_store_link.h
@@ -42,9 +42,9 @@ bool is_sorted_list(size_t n, const size_t *list);
 
 void weight_links_alloc(size_t numNeighbors, size_t gridSize, std::vector<WeightLinks> &weightLinks);
 void weight_links_4_alloc(size_t gridSize, std::vector<WeightLinks4> &weightLinks);
-void store_weightlinks(int doAlloc, size_t numWeights, size_t *indices, double *weights, size_t cellIndex,
+void store_weightlinks(int doAlloc, size_t numWeights, const size_t *indices, const double *weights, size_t cellIndex,
                        std::vector<WeightLinks> &weightLinks);
-void store_weightlinks_bicubic(size_t *indices, double (&weights)[4][4], size_t cellIndex, std::vector<WeightLinks4> &weightLinks);
+void store_weightlinks_bicubic(const size_t *indices, double (&weights)[4][4], size_t cellIndex, std::vector<WeightLinks4> &weightLinks);
 void weight_links_to_remap_links(int doAlloc, size_t gridSize, std::vector<WeightLinks> &weightLinks, RemapVars &rv);
 void weight_links_4_to_remap_links(size_t gridSize, std::vector<WeightLinks4> &weightLinks, RemapVars &rv);
 
diff --git a/src/remap_vars.cc b/src/remap_vars.cc
index ac98c090da15a7f432acb9a17201444533661bd3..aa0cd6096a2da70ee366f4273eaf70660f56203a 100644
--- a/src/remap_vars.cc
+++ b/src/remap_vars.cc
@@ -51,8 +51,8 @@ remap_first_order(Varray<T2> &tgtArray, const RemapVars &rv, const Varray<T1> &s
           for (size_t i = 0; i < nlinks; ++i)
             {
               auto noff = i * 2;
-              auto s = &srcIndices[noff];
-              auto w = &weights[noff];
+              const auto s = &srcIndices[noff];
+              const auto w = &weights[noff];
               auto tgtPoint = srcArray[s[0]] * w[0] + srcArray[s[1]] * w[1];
               tgtArray[tgtIndices[noff]] = tgtPoint;
             }
@@ -65,8 +65,8 @@ remap_first_order(Varray<T2> &tgtArray, const RemapVars &rv, const Varray<T1> &s
           for (size_t i = 0; i < nlinks; ++i)
             {
               auto noff = i * 3;
-              auto s = &srcIndices[noff];
-              auto w = &weights[noff];
+              const auto s = &srcIndices[noff];
+              const auto w = &weights[noff];
               auto tgtPoint = srcArray[s[0]] * w[0] + srcArray[s[1]] * w[1] + srcArray[s[2]] * w[2];
               tgtArray[tgtIndices[noff]] = tgtPoint;
             }
@@ -79,8 +79,8 @@ remap_first_order(Varray<T2> &tgtArray, const RemapVars &rv, const Varray<T1> &s
           for (size_t i = 0; i < nlinks; ++i)
             {
               auto noff = i * 4;
-              auto s = &srcIndices[noff];
-              auto w = &weights[noff];
+              const auto s = &srcIndices[noff];
+              const auto w = &weights[noff];
               auto tgtPoint = srcArray[s[0]] * w[0] + srcArray[s[1]] * w[1] + srcArray[s[2]] * w[2] + srcArray[s[3]] * w[3];
               tgtArray[tgtIndices[noff]] = tgtPoint;
             }
@@ -93,8 +93,8 @@ remap_first_order(Varray<T2> &tgtArray, const RemapVars &rv, const Varray<T1> &s
           for (size_t i = 0; i < nlinks; ++i)
             {
               auto noff = i * linksPerValue;
-              auto s = &srcIndices[noff];
-              auto w = &weights[noff];
+              const auto s = &srcIndices[noff];
+              const auto w = &weights[noff];
               auto tgtPoint = srcArray[s[0]] * w[0];
               for (size_t k = 1; k < (size_t) linksPerValue; ++k) tgtPoint += srcArray[s[k]] * w[k];
               tgtArray[tgtIndices[noff]] = tgtPoint;
@@ -149,7 +149,7 @@ remap_second_order(Varray<T2> &tgtArray, const RemapVars &rv, const Varray<T1> &
                 {
                   auto noff = i * 4 + k;
                   auto ik = srcIndices[noff];
-                  auto w = &weights[numWeights * noff];
+                  const auto w = &weights[numWeights * noff];
                   tgtPoint += srcArray[ik] * w[0] + grad1[ik] * w[1] + grad2[ik] * w[2] + grad3[ik] * w[3];
                 }
               tgtArray[tgtIndices[i * 4]] = tgtPoint;
@@ -161,7 +161,7 @@ remap_second_order(Varray<T2> &tgtArray, const RemapVars &rv, const Varray<T1> &
           for (size_t i = 0; i < numLinks; ++i)
             {
               auto k = srcIndices[i];
-              auto w = &weights[4 * i];
+              const auto w = &weights[4 * i];
               tgtArray[tgtIndices[i]] += srcArray[k] * w[0] + grad1[k] * w[1] + grad2[k] * w[2] + grad3[k] * w[3];
             }
         }
diff --git a/src/sellist.cc b/src/sellist.cc
index 0d0b906a2ef9412b367271699ab2643eaf3a8426..5c7c844535260ff0d112b4de08aa9824d8b9df7b 100644
--- a/src/sellist.cc
+++ b/src/sellist.cc
@@ -197,7 +197,7 @@ selinfo_check(SelectInfo &selInfo, int listIdx, void *par)
         {
         case SelType::INT:
           {
-            int ival = *(int *) par;
+            int ival = *static_cast<int *>(par);
             for (int i = 0; i < nvalues; ++i)
               {
                 if (ival == e.ivalues[i])
@@ -210,7 +210,7 @@ selinfo_check(SelectInfo &selInfo, int listIdx, void *par)
           }
         case SelType::FLT:
           {
-            const double dval = *(double *) par;
+            const double dval = *static_cast<double *>(par);
             for (int i = 0; i < nvalues; ++i)
               {
                 if (std::fabs(dval - e.dvalues[i]) < 1.e-4)
@@ -223,7 +223,7 @@ selinfo_check(SelectInfo &selInfo, int listIdx, void *par)
           }
         case SelType::WORD:
           {
-            const char *cval = *(char **) par;
+            const char *cval = *static_cast<char **>(par);
             for (int i = 0; i < nvalues; ++i)
               {
                 if (wildcardmatch(e.cvalues[i], cval) == 0)
@@ -342,8 +342,11 @@ selinfo_def_flag(SelectInfo &selInfo, int listIdx, int valIdx, bool flag)
   auto nvalues = selInfo.nvalues(listIdx);
   if (nvalues)
     {
-      auto &e = selList[listIdx];
-      if (valIdx >= 0 && valIdx < nvalues) e.flag[valIdx] = flag;
+      if (valIdx >= 0 && valIdx < nvalues)
+        {
+          auto &e = selList[listIdx];
+          e.flag[valIdx] = flag;
+        }
     }
 }
 
@@ -359,9 +362,9 @@ selinfo_get_val(const SelectInfo &selInfo, int listIdx, int valIdx, void *val)
       const auto &e = selList[listIdx];
       switch (e.type)
         {
-        case SelType::INT: *(int *) val = e.ivalues[valIdx]; break;
-        case SelType::FLT: *(double *) val = e.dvalues[valIdx]; break;
-        case SelType::WORD: *(const char **) val = e.cvalues[valIdx]; break;
+        case SelType::INT: *static_cast<int *>(val) = e.ivalues[valIdx]; break;
+        case SelType::FLT: *static_cast<double *>(val) = e.dvalues[valIdx]; break;
+        case SelType::WORD: *static_cast<const char **>(val) = e.cvalues[valIdx]; break;
         case SelType::UNDEF: break;
         }
     }
@@ -379,9 +382,9 @@ selinfo_def_val(SelectInfo &selInfo, int listIdx, int valIdx, void *val)
       auto &e = selList[listIdx];
       switch (e.type)
         {
-        case SelType::INT: e.ivalues[valIdx] = *(int *) val; break;
-        case SelType::FLT: e.dvalues[valIdx] = *(double *) val; break;
-        case SelType::WORD: e.cvalues[valIdx] = *(const char **) val; break;
+        case SelType::INT: e.ivalues[valIdx] = *static_cast<int *>(val); break;
+        case SelType::FLT: e.dvalues[valIdx] = *static_cast<double *>(val); break;
+        case SelType::WORD: e.cvalues[valIdx] = *static_cast<char **>(val); break;
         case SelType::UNDEF: break;
         }
     }
diff --git a/src/specspace.cc b/src/specspace.cc
index dd5338bb1f3b11e19d4433a9cbb3567e9fe938c1..ea33b9ac7e45364ad3d8bca0e94fca9b42cc12c7 100644
--- a/src/specspace.cc
+++ b/src/specspace.cc
@@ -122,7 +122,7 @@ spec2spec(int gridIDin, const Varray<double> &arrayIn, int gridIDout, Varray<dou
 }
 
 void
-speccut(int gridIDin, const Varray<double> &arrayIn, Varray<double> &arrayOut, Varray<int> &waves)
+speccut(int gridIDin, const Varray<double> &arrayIn, Varray<double> &arrayOut, const Varray<int> &waves)
 {
   long ntr = gridInqTrunc(gridIDin);
 
@@ -130,7 +130,8 @@ speccut(int gridIDin, const Varray<double> &arrayIn, Varray<double> &arrayOut, V
 }
 
 void
-trans_uv2dv(const SP_Transformation &spTrans, long nlev, int gridID1, double *gu, double *gv, int gridID2, double *sd, double *svo)
+trans_uv2dv(const SP_Transformation &spTrans, long nlev, int gridID1, const double *gu, const double *gv, int gridID2, double *sd,
+            double *svo)
 {
   if (gridInqType(gridID1) != GRID_GAUSSIAN)
     cdo_abort("unexpected grid1 type: %s instead of Gaussian", gridNamePtr(gridInqType(gridID1)));
@@ -166,8 +167,8 @@ trans_uv2dv(const SP_Transformation &spTrans, long nlev, int gridID1, double *gu
 }
 
 void
-trans_dv2uv(const SP_Transformation &spTrans, const DV_Transformation &dvTrans, long nlev, int gridID1, double *sd, double *svo,
-            int gridID2, double *gu, double *gv)
+trans_dv2uv(const SP_Transformation &spTrans, const DV_Transformation &dvTrans, long nlev, int gridID1, const double *sd,
+            const double *svo, int gridID2, double *gu, double *gv)
 {
   if (gridInqType(gridID1) != GRID_SPECTRAL)
     cdo_warning("unexpected grid1 type: %s instead of spectral", gridNamePtr(gridInqType(gridID1)));
diff --git a/src/specspace.h b/src/specspace.h
index ece06c863ecd1c432f6d524b4cf4d2a632fb9bc0..800c16ecd97465c33e3a8ec7c188df68c9367efa 100644
--- a/src/specspace.h
+++ b/src/specspace.h
@@ -167,11 +167,11 @@ public:
 
 void dv2ps(const double *div, double *pot, long nlev, long ntr);
 
-void trans_uv2dv(const SP_Transformation &spTrans, long nlev, int gridID1, double *gu, double *gv, int gridID2, double *sd,
-                 double *svo);
+void trans_uv2dv(const SP_Transformation &spTrans, long nlev, int gridID1, const double *gu, const double *gv, int gridID2,
+                 double *sd, double *svo);
 
-void trans_dv2uv(const SP_Transformation &spTrans, const DV_Transformation &dvTrans, long nlev, int gridID1, double *sd,
-                 double *svo, int gridID2, double *gu, double *gv);
+void trans_dv2uv(const SP_Transformation &spTrans, const DV_Transformation &dvTrans, long nlev, int gridID1, const double *sd,
+                 const double *svo, int gridID2, double *gu, double *gv);
 
 void grid2spec(const SP_Transformation &spTrans, int gridIDin, const Varray<double> &arrayIn, int gridIDout,
                Varray<double> &arrayOut);
@@ -187,7 +187,7 @@ void grid2four(const FC_Transformation &fcTrans, int gridIDin, const Varray<doub
                Varray<double> &arrayOut);
 
 void spec2spec(int gridIDin, const Varray<double> &arrayIn, int gridIDout, Varray<double> &arrayOut);
-void speccut(int gridIDin, const Varray<double> &arrayIn, Varray<double> &arrayOut, Varray<int> &waves);
+void speccut(int gridIDin, const Varray<double> &arrayIn, Varray<double> &arrayOut, const Varray<int> &waves);
 
 void spcut(const double *arrayIn, double *arrayOut, long ntr, const int *waves);