From 46ebf9d78c8576f7b4ee9a0524414a5cb502b526 Mon Sep 17 00:00:00 2001
From: Uwe Schulzweida <uwe.schulzweida@mpimet.mpg.de>
Date: Wed, 12 Feb 2025 11:49:44 +0100
Subject: [PATCH] Replaced gridDefDatatype()/gridInqDatatype() by
 cdiDefKeyInt()/cdiInqKeyInt() with CDI_KEY_DATATYPE

---
 app/printinfo.c                      | 9 +++++----
 examples/pio/compareResourcesArray.c | 2 +-
 tests/test_resource_copy.c           | 4 ++--
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/app/printinfo.c b/app/printinfo.c
index ccbeea004..8fd902e0b 100644
--- a/app/printinfo.c
+++ b/app/printinfo.c
@@ -300,8 +300,8 @@ printGridInfoKernel(int gridID, int index, bool lproj)
   size_t xsize = (size_t) gridInqXsize(gridID);
   size_t ysize = (size_t) gridInqYsize(gridID);
 
-  // int prec     = gridInqDatatype(gridID);
-  // int dig = (prec == CDI_DATATYPE_FLT64) ? 15 : 7;
+  // int datatype;
+  // cdiInqKeyInt(gridID, CDI_GLOBAL, CDI_KEY_DATATYPE, &datatype);
   int dig = 7;
 
   if (!lproj)
@@ -537,8 +537,9 @@ printZaxisInfo(int vlistID)
       int ltype = 0;
       cdiInqKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_TYPEOFFIRSTFIXEDSURFACE, &ltype);
       int levelsize = zaxisInqSize(zaxisID);
-      // int prec      = zaxisInqDatatype(zaxisID);
-      // int dig = (prec == CDI_DATATYPE_FLT64) ? 15 : 7;
+      // int datatype;
+      // cdiInqKeyInt(gridID, CDI_GLOBAL, CDI_KEY_DATATYPE, &datatype);
+      // int dig = (datatype == CDI_DATATYPE_FLT64) ? 15 : 7;
 
       zaxisName(zaxistype, zaxisname);
       int length = CDI_MAX_NAME;
diff --git a/examples/pio/compareResourcesArray.c b/examples/pio/compareResourcesArray.c
index 0082d60ca..4eb771089 100644
--- a/examples/pio/compareResourcesArray.c
+++ b/examples/pio/compareResourcesArray.c
@@ -60,7 +60,7 @@ defineGrid()
   cdiDefKeyString(gridID, CDI_XAXIS, CDI_KEY_UNITS, "myXunits");
   cdiDefKeyString(gridID, CDI_YAXIS, CDI_KEY_UNITS, "myYunits");
 
-  gridDefDatatype(gridID, DOUBLE_PRECISION);
+  cdiDefKeyInt(gridID, CDI_GLOBAL, CDI_KEY_DATATYPE, DOUBLE_PRECISION);
   gridDefTrunc(gridID, 1);
 
   cdiDefKeyInt(gridID, CDI_GLOBAL, CDI_KEY_NUMBEROFGRIDUSED, 6);
diff --git a/tests/test_resource_copy.c b/tests/test_resource_copy.c
index ce789c30d..ffd2c7793 100644
--- a/tests/test_resource_copy.c
+++ b/tests/test_resource_copy.c
@@ -63,7 +63,7 @@ defineGrid(void)
   cdiDefKeyString(gridID, CDI_XAXIS, CDI_KEY_UNITS, "myXunits");
   cdiDefKeyString(gridID, CDI_YAXIS, CDI_KEY_UNITS, "myYunits");
 
-  gridDefDatatype(gridID, DOUBLE_PRECISION);
+  cdiDefKeyInt(gridID, CDI_GLOBAL, CDI_KEY_DATATYPE, DOUBLE_PRECISION);
   gridDefTrunc(gridID, 1);
   gridDefParamGME(gridID, 2, 3, 4, 5);
 
@@ -164,7 +164,7 @@ defineVlist(int gridID, int zaxisID, int taxisID)
   cdiDefAttTxt(vlistID, varID2, "txt demo", 6, "banana");
   vlistDefTaxis(vlistID, taxisID);
   int vlistID2 = vlistDuplicate(vlistID);
-  return (struct idPair){ vlistID, vlistID2 };
+  return (struct idPair) { vlistID, vlistID2 };
 }
 
 static int
-- 
GitLab