From 3d48a287141eb911b4888440e09c262743b4db3c Mon Sep 17 00:00:00 2001
From: Mickael PHILIT <mickey.phy@gmail.com>
Date: Wed, 4 Mar 2020 14:54:30 +0100
Subject: [PATCH] Add support for new API cgio_read_***data***_type

CGNS 4.1 removed old cgio API and now support providing memory data type.
Changes are made to keep current behavior of CGNS reading.
Data conversion is not let to CGNS with new API as it may only be stable for HDF5 files.
---
 ParaViewCore/VTKExtensions/CGNSReader/cgio_helpers.cxx     | 14 +--
 ParaViewCore/VTKExtensions/CGNSReader/cgio_helpers.h       |  3 +-
 ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx    | 85 +++++++++++++------
 .../CGNSReader/vtkCGNSReaderInternal.cxx      | 44 +++++-----
 .../CGNSReader/vtkCGNSReaderInternal.h        | 53 ++++++++++--
 5 files changed, 133 insertions(+), 66 deletions(-)

diff --git ParaViewCore/VTKExtensions/CGNSReader/cgio_helpers.cxx ParaViewCore/VTKExtensions/CGNSReader/cgio_helpers.cxx
index 1e8ecae8c5..44429a4dd0 100644
--- ParaViewCore/VTKExtensions/CGNSReader/cgio_helpers.cxx
+++ ParaViewCore/VTKExtensions/CGNSReader/cgio_helpers.cxx
@@ -44,7 +44,7 @@ int readNodeStringData(int cgioNum, double nodeId, std::string& data)
 
   data.resize(size);
   // read data
-  if (cgio_read_all_data(cgioNum, nodeId, (void*)data.c_str()) != CG_OK)
+  if (cgio_read_all_data_type(cgioNum, nodeId, "C1", (void*)data.c_str()) != CG_OK)
   {
     return 1;
   }
@@ -80,7 +80,7 @@ int readNodeData<char>(int cgioNum, double nodeId, std::vector<char>& data)
   data.resize(size + 1);
 
   // read data
-  if (cgio_read_all_data(cgioNum, nodeId, &data[0]) != CG_OK)
+  if (cgio_read_all_data_type(cgioNum, nodeId, "C1", &data[0]) != CG_OK)
   {
     return 1;
   }
@@ -167,7 +167,7 @@ int readBaseIds(int cgioNum, double rootId, std::vector<double>& baseIds)
 int readBaseCoreInfo(int cgioNum, double baseId, CGNSRead::BaseInformation& baseInfo)
 {
   CGNSRead::char_33 dataType;
-  std::vector<int> mdata;
+  std::vector<int32_t> mdata;
 
   if (cgio_get_name(cgioNum, baseId, baseInfo.name) != CG_OK)
   {
@@ -187,7 +187,7 @@ int readBaseCoreInfo(int cgioNum, double baseId, CGNSRead::BaseInformation& base
     return 1;
   }
 
-  if (CGNSRead::readNodeData<int>(cgioNum, baseId, mdata) != 0)
+  if (CGNSRead::readNodeData<int32_t>(cgioNum, baseId, mdata) != 0)
   {
     std::cerr << "error while reading base dimension" << std::endl;
     return 1;
@@ -209,7 +209,7 @@ int readBaseIteration(int cgioNum, double nodeId, CGNSRead::BaseInformation& bas
   bool createTimeStates = true;
   bool createIterStates = true;
 
-  std::vector<int> ndata;
+  std::vector<int32_t> ndata;
   // read node data type
   if (cgio_get_data_type(cgioNum, nodeId, dataType) != CG_OK)
   {
@@ -222,7 +222,7 @@ int readBaseIteration(int cgioNum, double nodeId, CGNSRead::BaseInformation& bas
     return 1;
   }
 
-  if (CGNSRead::readNodeData<int>(cgioNum, nodeId, ndata) != 0)
+  if (CGNSRead::readNodeData<int32_t>(cgioNum, nodeId, ndata) != 0)
   {
     std::cerr << "error while reading number of state in base" << std::endl;
     return 1;
@@ -298,7 +298,7 @@ int readBaseIteration(int cgioNum, double nodeId, CGNSRead::BaseInformation& bas
       }
 
       baseInfo.steps.clear();
-      CGNSRead::readNodeData<int>(cgioNum, childrenIterative[nc], baseInfo.steps);
+      CGNSRead::readNodeData<int32_t>(cgioNum, childrenIterative[nc], baseInfo.steps);
       if (static_cast<int>(baseInfo.steps.size()) != nstates)
       {
         std::cerr << "Error reading steps node";
diff --git ParaViewCore/VTKExtensions/CGNSReader/cgio_helpers.h ParaViewCore/VTKExtensions/CGNSReader/cgio_helpers.h
index bef0f3fbfa..07deb54ebe 100644
--- ParaViewCore/VTKExtensions/CGNSReader/cgio_helpers.h
+++ ParaViewCore/VTKExtensions/CGNSReader/cgio_helpers.h
@@ -46,6 +46,7 @@ inline int readNodeData(int cgioNum, double nodeId, std::vector<T>& data)
   cgsize_t size = 1;
   cgsize_t dimVals[12];
   int ndim;
+  constexpr const char* dtName = CGNSRead::detail::cgns_type_name<T>();
 
   if (cgio_get_dimensions(cgioNum, nodeId, &ndim, dimVals) != CG_OK)
   {
@@ -65,7 +66,7 @@ inline int readNodeData(int cgioNum, double nodeId, std::vector<T>& data)
   data.resize(size);
 
   // read data
-  if (cgio_read_all_data(cgioNum, nodeId, &data[0]) != CG_OK)
+  if (cgio_read_all_data_type(cgioNum, nodeId, dtName, &data[0]) != CG_OK)
   {
     return 1;
   }
diff --git ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx
index a1c417b810..7ca523997a 100644
--- ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx
+++ ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx
@@ -526,6 +526,33 @@ int StartsWithFlowSolution(const char* s)
 
   return ret;
 }
+//----------------------------------------------------------------------------
+// Small helper
+const char* get_data_type(const CGNS_ENUMT(DataType_t) dt)
+{
+  const char* dataType;
+  switch (dt)
+  {
+    case CGNS_ENUMV(Integer):
+      dataType = "I4";
+      break;
+    case CGNS_ENUMV(LongInteger):
+      dataType = "I8";
+      break;
+    case CGNS_ENUMV(RealSingle):
+      dataType = "R4";
+      break;
+    case CGNS_ENUMV(RealDouble):
+      dataType = "R8";
+      break;
+    case CGNS_ENUMV(Character):
+      dataType = "C1";
+      break;
+    default:
+      dataType = "MT";
+  }
+  return dataType;
+}
 
 //----------------------------------------------------------------------------
 vtkCGNSReader::vtkCGNSReader()
@@ -672,7 +699,8 @@ int vtkCGNSReader::vtkPrivate::getGridAndSolutionNames(int base, std::string& gr
     {
       CGNSRead::char_33 gname;
       const cgsize_t offset = static_cast<cgsize_t>(self->ActualTimeStep * 32);
-      cgio_read_block_data(self->cgioNum, giterId, offset + 1, offset + 32, (void*)gname);
+      cgio_read_block_data_type(
+        self->cgioNum, giterId, offset + 1, offset + 32, "C1", (void*)gname);
       gname[32] = '\0';
       // NOTE: Names or identifiers contain no spaces and capitalization
       //       is used to distinguish individual words making up a name.
@@ -732,9 +760,9 @@ int vtkCGNSReader::vtkPrivate::getGridAndSolutionNames(int base, std::string& gr
         EndsWithPointers(nodeName))
       {
         CGNSRead::char_33 gname;
-        cgio_read_block_data(self->cgioNum, iterChildId[cc],
+        cgio_read_block_data_type(self->cgioNum, iterChildId[cc],
           (cgsize_t)(self->ActualTimeStep * 32 + 1), (cgsize_t)(self->ActualTimeStep * 32 + 32),
-          (void*)gname);
+          "C1", (void*)gname);
         gname[32] = '\0';
         CGNSRead::removeTrailingWhiteSpaces(gname);
         std::string tmpStr = std::string(gname);
@@ -1197,28 +1225,30 @@ int vtkCGNSReader::vtkPrivate::readSolution(const std::string& solutionNameStr,
       continue;
     }
     double cgioVarId = solChildId[ff];
+    const char* fieldDataType = get_data_type(cgnsVars[ff].dt);
 
     // quick transfer of data because data types is given by cgns database
     if (cgnsVars[ff].isComponent == false)
     {
-      if (cgio_read_data(self->cgioNum, cgioVarId, fieldSrcStart, fieldSrcEnd, fieldSrcStride,
-            cellDim, fieldMemDims, fieldMemStart, fieldMemEnd, fieldMemStride,
+      if (cgio_read_data_type(self->cgioNum, cgioVarId, fieldSrcStart, fieldSrcEnd, fieldSrcStride,
+            fieldDataType, cellDim, fieldMemDims, fieldMemStart, fieldMemEnd, fieldMemStride,
             (void*)vtkVars[ff]->GetVoidPointer(0)) != CG_OK)
       {
         char message[81];
         cgio_error_message(message);
-        vtkGenericWarningMacro(<< "cgio_read_data :" << message);
+        vtkGenericWarningMacro(<< "cgio_read_data_type :" << message);
       }
     }
     else
     {
-      if (cgio_read_data(self->cgioNum, cgioVarId, fieldSrcStart, fieldSrcEnd, fieldSrcStride,
-            cellDim, fieldVectMemDims, fieldVectMemStart, fieldVectMemEnd, fieldVectMemStride,
+      if (cgio_read_data_type(self->cgioNum, cgioVarId, fieldSrcStart, fieldSrcEnd, fieldSrcStride,
+            fieldDataType, cellDim, fieldVectMemDims, fieldVectMemStart, fieldVectMemEnd,
+            fieldVectMemStride,
             (void*)vtkVars[ff]->GetVoidPointer(cgnsVars[ff].xyzIndex - 1)) != CG_OK)
       {
         char message[81];
         cgio_error_message(message);
-        vtkGenericWarningMacro(<< "cgio_read_data :" << message);
+        vtkGenericWarningMacro(<< "cgio_read_data_type :" << message);
       }
     }
     cgio_release_id(self->cgioNum, cgioVarId);
@@ -1448,6 +1478,7 @@ int vtkCGNSReader::vtkPrivate::readBCData(const double nodeId, const int cellDim
             continue;
           }
           double cgioVarId = varIds[ff];
+          const char* fieldDataType = get_data_type(cgnsVars[ff].dt);
 
           cgsize_t dataSize = 1;
           cgsize_t dimVals[12];
@@ -1474,12 +1505,12 @@ int vtkCGNSReader::vtkPrivate::readBCData(const double nodeId, const int cellDim
             // quick transfer of data because data types is given by cgns database
             if (cgnsVars[ff].isComponent == false)
             {
-              if (cgio_read_all_data(
-                    self->cgioNum, cgioVarId, (void*)vtkVars[ff]->GetVoidPointer(0)) != CG_OK)
+              if (cgio_read_all_data_type(self->cgioNum, cgioVarId, fieldDataType,
+                    (void*)vtkVars[ff]->GetVoidPointer(0)) != CG_OK)
               {
                 char message[81];
                 cgio_error_message(message);
-                vtkGenericWarningMacro(<< "cgio_read_data :" << message);
+                vtkGenericWarningMacro(<< "cgio_read_all_data_type :" << message);
               }
               if (dataSize == 1)
               {
@@ -1510,14 +1541,14 @@ int vtkCGNSReader::vtkPrivate::readBCData(const double nodeId, const int cellDim
               fieldVectMemDims[0] = fieldSrcEnd[0] * fieldVectMemStride[0];
               fieldVectMemEnd[0] = fieldSrcEnd[0] * fieldVectMemStride[0];
 
-              if (cgio_read_data(self->cgioNum, cgioVarId, fieldSrcStart, fieldSrcEnd,
-                    fieldSrcStride, 1, fieldVectMemDims, fieldVectMemStart, fieldVectMemEnd,
-                    fieldVectMemStride,
+              if (cgio_read_data_type(self->cgioNum, cgioVarId, fieldSrcStart, fieldSrcEnd,
+                    fieldSrcStride, fieldDataType, 1, fieldVectMemDims, fieldVectMemStart,
+                    fieldVectMemEnd, fieldVectMemStride,
                     (void*)vtkVars[ff]->GetVoidPointer(cgnsVars[ff].xyzIndex - 1)) != CG_OK)
               {
                 char message[81];
                 cgio_error_message(message);
-                vtkGenericWarningMacro(<< "cgio_read_data :" << message);
+                vtkGenericWarningMacro(<< "cgio_read_data_type :" << message);
               }
               if (dataSize == 1)
               {
@@ -2231,7 +2262,7 @@ int vtkCGNSReader::GetUnstructuredZone(
 
     //
     CGNSRead::char_33 dataType;
-    std::vector<int> mdata;
+    std::vector<vtkTypeInt32> mdata;
 
     if (cgio_get_name(this->cgioNum, elemIdList[sec], sectionInfoList[sec].name) != CG_OK)
     {
@@ -2246,7 +2277,7 @@ int vtkCGNSReader::GetUnstructuredZone(
       vtkErrorMacro(<< "Unexpected data type for dimension data of Element\n");
     }
 
-    CGNSRead::readNodeData<int>(cgioNum, elemIdList[sec], mdata);
+    CGNSRead::readNodeData<vtkTypeInt32>(cgioNum, elemIdList[sec], mdata);
     if (mdata.size() != 2)
     {
       vtkErrorMacro(<< "Unexpected data for Elements_t node\n");
@@ -2267,8 +2298,8 @@ int vtkCGNSReader::GetUnstructuredZone(
 
     if (strcmp(dataType, "I4") == 0)
     {
-      std::vector<int> mdata2;
-      CGNSRead::readNodeData<int>(this->cgioNum, elemRangeId, mdata2);
+      std::vector<vtkTypeInt32> mdata2;
+      CGNSRead::readNodeData<vtkTypeInt32>(this->cgioNum, elemRangeId, mdata2);
       if (mdata2.size() != 2)
       {
         vtkErrorMacro(<< "Unexpected data for ElementRange node\n");
@@ -2278,8 +2309,8 @@ int vtkCGNSReader::GetUnstructuredZone(
     }
     else if (strcmp(dataType, "I8") == 0)
     {
-      std::vector<cglong_t> mdata2;
-      CGNSRead::readNodeData<cglong_t>(this->cgioNum, elemRangeId, mdata2);
+      std::vector<vtkTypeInt64> mdata2;
+      CGNSRead::readNodeData<vtkTypeInt64>(this->cgioNum, elemRangeId, mdata2);
       if (mdata2.size() != 2)
       {
         vtkErrorMacro(<< "Unexpected data for ElementRange node\n");
@@ -4437,8 +4468,8 @@ int vtkCGNSReader::RequestData(vtkInformation* vtkNotUsed(request),
 
       if (strcmp(dataType, "I4") == 0)
       {
-        std::vector<int> mdata;
-        CGNSRead::readNodeData<int>(this->cgioNum, baseChildId[zone], mdata);
+        std::vector<vtkTypeInt32> mdata;
+        CGNSRead::readNodeData<vtkTypeInt32>(this->cgioNum, baseChildId[zone], mdata);
         for (std::size_t index = 0; index < mdata.size(); index++)
         {
           zsize[index] = static_cast<cgsize_t>(mdata[index]);
@@ -4446,8 +4477,8 @@ int vtkCGNSReader::RequestData(vtkInformation* vtkNotUsed(request),
       }
       else if (strcmp(dataType, "I8") == 0)
       {
-        std::vector<cglong_t> mdata;
-        CGNSRead::readNodeData<cglong_t>(this->cgioNum, baseChildId[zone], mdata);
+        std::vector<vtkTypeInt64> mdata;
+        CGNSRead::readNodeData<vtkTypeInt64>(this->cgioNum, baseChildId[zone], mdata);
         for (std::size_t index = 0; index < mdata.size(); index++)
         {
           zsize[index] = static_cast<cgsize_t>(mdata[index]);
@@ -4724,7 +4755,7 @@ int vtkCGNSReader::CanReadFile(const char* name)
   }
 
   // read data
-  if (cgio_read_all_data(cgioFile, childId, &FileVersion))
+  if (cgio_read_all_data_type(cgioFile, childId, "R4", &FileVersion))
   {
     vtkErrorMacro(<< "read CGNS version number");
     ierr = 0;
diff --git ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReaderInternal.cxx ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReaderInternal.cxx
index 92c0d6ac51..a2bcf1a443 100644
--- ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReaderInternal.cxx
+++ ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReaderInternal.cxx
@@ -36,8 +36,8 @@ int setUpRind(const int cgioNum, const double rindId, int* rind)
 
   if (strcmp(dataType, "I4") == 0)
   {
-    std::vector<int> mdata;
-    CGNSRead::readNodeData<int>(cgioNum, rindId, mdata);
+    std::vector<vtkTypeInt32> mdata;
+    CGNSRead::readNodeData<vtkTypeInt32>(cgioNum, rindId, mdata);
     for (std::size_t index = 0; index < mdata.size(); index++)
     {
       rind[index] = static_cast<int>(mdata[index]);
@@ -45,8 +45,8 @@ int setUpRind(const int cgioNum, const double rindId, int* rind)
   }
   else if (strcmp(dataType, "I8") == 0)
   {
-    std::vector<cglong_t> mdata;
-    CGNSRead::readNodeData<cglong_t>(cgioNum, rindId, mdata);
+    std::vector<vtkTypeInt64> mdata;
+    CGNSRead::readNodeData<vtkTypeInt64>(cgioNum, rindId, mdata);
     for (std::size_t index = 0; index < mdata.size(); index++)
     {
       rind[index] = static_cast<int>(mdata[index]);
@@ -156,12 +156,12 @@ int get_section_connectivity(const int cgioNum, const double cgioSectionId, cons
 
   if (sizeOfCnt == sizeof(vtkIdType))
   {
-    if (cgio_read_data(cgioNum, cgioElemConnectId, srcStart, srcEnd, srcStride, dim, memDim,
-          memStart, memEnd, memStride, (void*)localElements) != CG_OK)
+    if (cgio_read_data_type(cgioNum, cgioElemConnectId, srcStart, srcEnd, srcStride, dataType, dim,
+          memDim, memStart, memEnd, memStride, (void*)localElements) != CG_OK)
     {
       char message[81];
       cgio_error_message(message);
-      std::cerr << "cgio_read_data :" << message;
+      std::cerr << "cgio_read_data_type :" << message;
       return 1;
     }
   }
@@ -181,13 +181,13 @@ int get_section_connectivity(const int cgioNum, const double cgioSectionId, cons
         std::cerr << "Allocation failed for temporary connectivity array\n";
       }
 
-      if (cgio_read_data(cgioNum, cgioElemConnectId, srcStart, srcEnd, srcStride, dim, memDim,
-            memStart, memEnd, memStride, (void*)data) != CG_OK)
+      if (cgio_read_data_type(cgioNum, cgioElemConnectId, srcStart, srcEnd, srcStride, "I4", dim,
+            memDim, memStart, memEnd, memStride, (void*)data) != CG_OK)
       {
         delete[] data;
         char message[81];
         cgio_error_message(message);
-        std::cerr << "cgio_read_data :" << message;
+        std::cerr << "cgio_read_data_type :" << message;
         return 1;
       }
       for (cgsize_t n = 0; n < nn; n++)
@@ -204,13 +204,13 @@ int get_section_connectivity(const int cgioNum, const double cgioSectionId, cons
         std::cerr << "Allocation failed for temporary connectivity array\n";
         return 1;
       }
-      if (cgio_read_data(cgioNum, cgioElemConnectId, srcStart, srcEnd, srcStride, dim, memDim,
-            memStart, memEnd, memStride, (void*)data) != CG_OK)
+      if (cgio_read_data_type(cgioNum, cgioElemConnectId, srcStart, srcEnd, srcStride, "I8", dim,
+            memDim, memStart, memEnd, memStride, (void*)data) != CG_OK)
       {
         delete[] data;
         char message[81];
         cgio_error_message(message);
-        std::cerr << "cgio_read_data :" << message;
+        std::cerr << "cgio_read_data_type :" << message;
         return 1;
       }
       for (cgsize_t n = 0; n < nn; n++)
@@ -258,12 +258,12 @@ int get_section_start_offset(const int cgioNum, const double cgioSectionId, cons
 
   if (sizeOfCnt == sizeof(vtkIdType))
   {
-    if (cgio_read_data(cgioNum, cgioElemOffsetId, srcStart, srcEnd, srcStride, dim, memDim,
-          memStart, memEnd, memStride, (void*)localElementsIdx) != CG_OK)
+    if (cgio_read_data_type(cgioNum, cgioElemOffsetId, srcStart, srcEnd, srcStride, dataType, dim,
+          memDim, memStart, memEnd, memStride, (void*)localElementsIdx) != CG_OK)
     {
       char message[81];
       cgio_error_message(message);
-      std::cerr << "cgio_read_data :" << message;
+      std::cerr << "cgio_read_data_type :" << message;
       return 1;
     }
   }
@@ -283,13 +283,13 @@ int get_section_start_offset(const int cgioNum, const double cgioSectionId, cons
         std::cerr << "Allocation failed for temporary connectivity offset array\n";
       }
 
-      if (cgio_read_data(cgioNum, cgioElemOffsetId, srcStart, srcEnd, srcStride, dim, memDim,
-            memStart, memEnd, memStride, (void*)data) != CG_OK)
+      if (cgio_read_data_type(cgioNum, cgioElemOffsetId, srcStart, srcEnd, srcStride, "I4", dim,
+            memDim, memStart, memEnd, memStride, (void*)data) != CG_OK)
       {
         delete[] data;
         char message[81];
         cgio_error_message(message);
-        std::cerr << "cgio_read_data :" << message;
+        std::cerr << "cgio_read_data_type :" << message;
         return 1;
       }
       for (cgsize_t n = 0; n < nn; n++)
@@ -306,13 +306,13 @@ int get_section_start_offset(const int cgioNum, const double cgioSectionId, cons
         std::cerr << "Allocation failed for temporary connectivity array\n";
         return 1;
       }
-      if (cgio_read_data(cgioNum, cgioElemOffsetId, srcStart, srcEnd, srcStride, dim, memDim,
-            memStart, memEnd, memStride, (void*)data) != CG_OK)
+      if (cgio_read_data_type(cgioNum, cgioElemOffsetId, srcStart, srcEnd, srcStride, "I8", dim,
+            memDim, memStart, memEnd, memStride, (void*)data) != CG_OK)
       {
         delete[] data;
         char message[81];
         cgio_error_message(message);
-        std::cerr << "cgio_read_data :" << message;
+        std::cerr << "cgio_read_data_type :" << message;
         return 1;
       }
       for (cgsize_t n = 0; n < nn; n++)
diff --git ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReaderInternal.h ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReaderInternal.h
index 4bcfd5c75a..3df3bae8de 100644
--- ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReaderInternal.h
+++ ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReaderInternal.h
@@ -72,6 +72,39 @@ struct is_float<float>
 };
 }
 
+namespace detail
+{
+template <typename T>
+constexpr const char* cgns_type_name() noexcept
+{
+  return "MT";
+}
+
+template <>
+constexpr const char* cgns_type_name<float>() noexcept
+{
+  return "R4";
+}
+
+template <>
+constexpr const char* cgns_type_name<double>() noexcept
+{
+  return "R8";
+}
+
+template <>
+constexpr const char* cgns_type_name<vtkTypeInt32>() noexcept
+{
+  return "I4";
+}
+
+template <>
+constexpr const char* cgns_type_name<vtkTypeInt64>() noexcept
+{
+  return "I8";
+}
+}
+
 typedef char char_33[33];
 
 //------------------------------------------------------------------------------
@@ -206,12 +239,12 @@ class BaseInformation
 public:
   char_33 name;
 
-  int cellDim;
-  int physicalDim;
+  int32_t cellDim;
+  int32_t physicalDim;
   //
   int baseNumber;
 
-  std::vector<int> steps;
+  std::vector<int32_t> steps;
   std::vector<double> times;
 
   // For unsteady meshes :
@@ -469,16 +502,18 @@ int get_XYZ_mesh(const int cgioNum, const std::vector<double>& gridChildId,
     // quick transfer of data if same data types
     if (sameType == true)
     {
-      if (cgio_read_data(cgioNum, coordId, srcStart, srcEnd, srcStride, cellDim, memEnd, memStart,
-            memEnd, memStride, (void*)currentCoord))
+      constexpr const char* dtNameT = detail::cgns_type_name<T>();
+      if (cgio_read_data_type(cgioNum, coordId, srcStart, srcEnd, srcStride, dtNameT, cellDim,
+            memEnd, memStart, memEnd, memStride, (void*)currentCoord))
       {
         char message[81];
         cgio_error_message(message);
-        std::cerr << "cgio_read_data :" << message;
+        std::cerr << "cgio_read_data_type :" << message;
       }
     }
     else
     {
+      constexpr const char* dtNameY = detail::cgns_type_name<Y>();
       Y* dataArray = 0;
       const cgsize_t memNoStride[3] = { 1, 1, 1 };
 
@@ -489,13 +524,13 @@ int get_XYZ_mesh(const int cgioNum, const std::vector<double>& gridChildId,
         std::cerr << "Error allocating buffer array\n";
         break;
       }
-      if (cgio_read_data(cgioNum, coordId, srcStart, srcEnd, srcStride, cellDim, memDims, memStart,
-            memDims, memNoStride, (void*)dataArray))
+      if (cgio_read_data_type(cgioNum, coordId, srcStart, srcEnd, srcStride, dtNameY, cellDim,
+            memDims, memStart, memDims, memNoStride, (void*)dataArray))
       {
         delete[] dataArray;
         char message[81];
         cgio_error_message(message);
-        std::cerr << "Buffer array cgio_read_data :" << message;
+        std::cerr << "Buffer array cgio_read_data_type :" << message;
         break;
       }
       for (vtkIdType ii = 0; ii < nPts; ++ii)
-- 
GitLab

