Make XDR type into enum class
authorArtem Zhmurov <zhmurov@gmail.com>
Mon, 19 Apr 2021 18:49:05 +0000 (18:49 +0000)
committerArtem Zhmurov <zhmurov@gmail.com>
Mon, 19 Apr 2021 18:49:05 +0000 (18:49 +0000)
12 files changed:
src/gromacs/applied_forces/awh/biaswriter.cpp
src/gromacs/fileio/checkpoint.cpp
src/gromacs/fileio/enxio.cpp
src/gromacs/fileio/enxio.h
src/gromacs/fileio/libxdrf.cpp
src/gromacs/fileio/xdr_datatype.h
src/gromacs/gmxana/gmx_bar.cpp
src/gromacs/gmxana/gmx_energy.cpp
src/gromacs/gmxana/gmx_nmr.cpp
src/gromacs/mdlib/energyoutput.cpp
src/gromacs/mdlib/mdebin_bar.cpp
src/gromacs/tools/dump.cpp

index 8fd09eedbca37be6fa5be9238867923a958b1b37..aa0b916dfea272d1e54c8ea433ee8b2c8c4e9ca9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -390,7 +390,7 @@ int BiasWriter::writeToEnergySubblocks(const Bias& bias, t_enxsubblock* sub)
 
     for (size_t b = 0; b < block_.size(); b++)
     {
-        sub[b].type = xdr_datatype_float;
+        sub[b].type = XdrDataType::Float;
         sub[b].nr   = block_[b].data().size();
         sub[b].fval = block_[b].data().data();
     }
index 6ba495992db560dfc6460b665d6fabb4e83ca430..c23b1df16264a6ee4462f429e6da0a383923725c 100644 (file)
@@ -558,29 +558,29 @@ struct xdr_type
 template<>
 struct xdr_type<int>
 {
-    static const int value = xdr_datatype_int;
+    static const XdrDataType value = XdrDataType::Int;
 };
 
 template<>
 struct xdr_type<float>
 {
-    static const int value = xdr_datatype_float;
+    static const XdrDataType value = XdrDataType::Float;
 };
 
 template<>
 struct xdr_type<double>
 {
-    static const int value = xdr_datatype_double;
+    static const XdrDataType value = XdrDataType::Double;
 };
 
-//! \brief Returns size in byte of an xdr_datatype
-static inline unsigned int sizeOfXdrType(int xdrType)
+//! \brief Returns size in byte of an XdrDataType
+static inline unsigned int sizeOfXdrType(XdrDataType xdrType)
 {
     switch (xdrType)
     {
-        case xdr_datatype_int: return sizeof(int);
-        case xdr_datatype_float: return sizeof(float);
-        case xdr_datatype_double: return sizeof(double);
+        case XdrDataType::Int: return sizeof(int);
+        case XdrDataType::Float: return sizeof(float);
+        case XdrDataType::Double: return sizeof(double);
         default: GMX_RELEASE_ASSERT(false, "XDR data type not implemented");
     }
 
@@ -588,13 +588,13 @@ static inline unsigned int sizeOfXdrType(int xdrType)
 }
 
 //! \brief Returns the XDR process function for i/o of an XDR type
-static inline xdrproc_t xdrProc(int xdrType)
+static inline xdrproc_t xdrProc(XdrDataType xdrType)
 {
     switch (xdrType)
     {
-        case xdr_datatype_int: return reinterpret_cast<xdrproc_t>(xdr_int);
-        case xdr_datatype_float: return reinterpret_cast<xdrproc_t>(xdr_float);
-        case xdr_datatype_double: return reinterpret_cast<xdrproc_t>(xdr_double);
+        case XdrDataType::Int: return reinterpret_cast<xdrproc_t>(xdr_int);
+        case XdrDataType::Float: return reinterpret_cast<xdrproc_t>(xdr_float);
+        case XdrDataType::Double: return reinterpret_cast<xdrproc_t>(xdr_double);
         default: GMX_RELEASE_ASSERT(false, "XDR data type not implemented");
     }
 
@@ -609,7 +609,7 @@ static inline xdrproc_t xdrProc(int xdrType)
  * When list==NULL only reads the elements.
  */
 template<typename Enum>
-static bool_t listXdrVector(XDR* xd, Enum ecpt, int nf, int xdrType, FILE* list, CptElementType cptElementType)
+static bool_t listXdrVector(XDR* xd, Enum ecpt, int nf, XdrDataType xdrType, FILE* list, CptElementType cptElementType)
 {
     bool_t res = 0;
 
@@ -621,10 +621,10 @@ static bool_t listXdrVector(XDR* xd, Enum ecpt, int nf, int xdrType, FILE* list,
     {
         switch (xdrType)
         {
-            case xdr_datatype_int:
+            case XdrDataType::Int:
                 pr_ivec(list, 0, enumValueToString(ecpt), reinterpret_cast<const int*>(data.data()), nf, TRUE);
                 break;
-            case xdr_datatype_float:
+            case XdrDataType::Float:
 #if !GMX_DOUBLE
                 if (cptElementType == CptElementType::real3)
                 {
@@ -637,7 +637,7 @@ static bool_t listXdrVector(XDR* xd, Enum ecpt, int nf, int xdrType, FILE* list,
                     pr_fvec(list, 0, enumValueToString(ecpt), reinterpret_cast<const float*>(data.data()), nf, TRUE);
                 }
                 break;
-            case xdr_datatype_double:
+            case XdrDataType::Double:
 #if GMX_DOUBLE
                 if (cptElementType == CptElementType::real3)
                 {
@@ -748,9 +748,11 @@ static int doVectorLow(XDR*                           xd,
         return -1;
     }
     /* Read/write the element data type */
-    constexpr int xdrTypeInTheCode = xdr_type<T>::value;
-    int           xdrTypeInTheFile = xdrTypeInTheCode;
-    res                            = xdr_int(xd, &xdrTypeInTheFile);
+    constexpr XdrDataType xdrTypeInTheCode      = xdr_type<T>::value;
+    XdrDataType           xdrTypeInTheFile      = xdrTypeInTheCode;
+    int                   xdrTypeInTheFileAsInt = static_cast<int>(xdrTypeInTheFile);
+    res                                         = xdr_int(xd, &xdrTypeInTheFileAsInt);
+    xdrTypeInTheFile                            = static_cast<XdrDataType>(xdrTypeInTheFileAsInt);
     if (res == 0)
     {
         return -1;
@@ -781,11 +783,11 @@ static int doVectorLow(XDR*                           xd,
             sprintf(buf,
                     "mismatch for state entry %s, code precision is %s, file precision is %s",
                     enumValueToString(ecpt),
-                    xdr_datatype_names[xdrTypeInTheCode],
-                    xdr_datatype_names[xdrTypeInTheFile]);
+                    enumValueToString(xdrTypeInTheCode),
+                    enumValueToString(xdrTypeInTheFile));
 
             /* Matching int and real should never occur, but check anyhow */
-            if (xdrTypeInTheFile == xdr_datatype_int || xdrTypeInTheCode == xdr_datatype_int)
+            if (xdrTypeInTheFile == XdrDataType::Int || xdrTypeInTheCode == XdrDataType::Int)
             {
                 gmx_fatal(FARGS,
                           "Type %s: incompatible checkpoint formats or corrupted checkpoint file.",
index 278306e20840fc0622458c40c6e275ea8d406f83..ce94d52fed3e05a404dd3a2718840b02a92c68d4 100644 (file)
@@ -100,9 +100,9 @@ static void enxsubblock_init(t_enxsubblock* sb)
 {
     sb->nr = 0;
 #if GMX_DOUBLE
-    sb->type = xdr_datatype_double;
+    sb->type = XdrDataType::Double;
 #else
-    sb->type            = xdr_datatype_float;
+    sb->type                = XdrDataType::Float;
 #endif
     sb->fval       = nullptr;
     sb->dval       = nullptr;
@@ -173,42 +173,42 @@ static void enxsubblock_alloc(t_enxsubblock* sb)
     /* allocate the appropriate amount of memory */
     switch (sb->type)
     {
-        case xdr_datatype_float:
+        case XdrDataType::Float:
             if (sb->nr > sb->fval_alloc)
             {
                 srenew(sb->fval, sb->nr);
                 sb->fval_alloc = sb->nr;
             }
             break;
-        case xdr_datatype_double:
+        case XdrDataType::Double:
             if (sb->nr > sb->dval_alloc)
             {
                 srenew(sb->dval, sb->nr);
                 sb->dval_alloc = sb->nr;
             }
             break;
-        case xdr_datatype_int:
+        case XdrDataType::Int:
             if (sb->nr > sb->ival_alloc)
             {
                 srenew(sb->ival, sb->nr);
                 sb->ival_alloc = sb->nr;
             }
             break;
-        case xdr_datatype_int64:
+        case XdrDataType::Int64:
             if (sb->nr > sb->lval_alloc)
             {
                 srenew(sb->lval, sb->nr);
                 sb->lval_alloc = sb->nr;
             }
             break;
-        case xdr_datatype_char:
+        case XdrDataType::Char:
             if (sb->nr > sb->cval_alloc)
             {
                 srenew(sb->cval, sb->nr);
                 sb->cval_alloc = sb->nr;
             }
             break;
-        case xdr_datatype_string:
+        case XdrDataType::String:
             if (sb->nr > sb->sval_alloc)
             {
                 int i;
@@ -456,9 +456,9 @@ static gmx_bool do_eheader(ener_file_t ef,
     int      ndisre = 0;
     int      startb = 0;
 #if !GMX_DOUBLE
-    xdr_datatype dtreal = xdr_datatype_float;
+    XdrDataType xdrDataType = XdrDataType::Float;
 #else
-    xdr_datatype dtreal = xdr_datatype_double;
+    XdrDataType xdrDataType = XdrDataType::Double;
 #endif
 
     if (bWrongPrecision)
@@ -643,8 +643,8 @@ static gmx_bool do_eheader(ener_file_t ef,
         fr->block[0].id          = enxDISRE;
         fr->block[0].sub[0].nr   = ndisre;
         fr->block[0].sub[1].nr   = ndisre;
-        fr->block[0].sub[0].type = dtreal;
-        fr->block[0].sub[1].type = dtreal;
+        fr->block[0].sub[0].type = xdrDataType;
+        fr->block[0].sub[1].type = xdrDataType;
         startb++;
     }
 
@@ -667,7 +667,7 @@ static gmx_bool do_eheader(ener_file_t ef,
                 {
                     gmx_incons("Writing an old version .edr file with too many subblocks");
                 }
-                if (fr->block[b].sub[0].type != dtreal)
+                if (fr->block[b].sub[0].type != xdrDataType)
                 {
                     gmx_incons("Writing an old version .edr file the wrong subblock type");
                 }
@@ -680,7 +680,7 @@ static gmx_bool do_eheader(ener_file_t ef,
             }
             fr->block[b].id          = b - startb;
             fr->block[b].sub[0].nr   = nrint;
-            fr->block[b].sub[0].type = dtreal;
+            fr->block[b].sub[0].type = xdrDataType;
         }
         else
         {
@@ -701,12 +701,12 @@ static gmx_bool do_eheader(ener_file_t ef,
             for (i = 0; i < nsub; i++)
             {
                 t_enxsubblock* sub    = &(fr->block[b].sub[i]); /* shortcut */
-                int            typenr = sub->type;
+                int            typenr = static_cast<int>(sub->type);
 
                 *bOK = *bOK && gmx_fio_do_int(ef->fio, typenr);
                 *bOK = *bOK && gmx_fio_do_int(ef->fio, sub->nr);
 
-                sub->type = static_cast<xdr_datatype>(typenr);
+                sub->type = static_cast<XdrDataType>(typenr);
             }
         }
     }
@@ -1092,20 +1092,20 @@ gmx_bool do_enx(ener_file_t ef, t_enxframe* fr)
             /* read/write data */
             switch (sub->type)
             {
-                case xdr_datatype_float:
+                case XdrDataType::Float:
                     bOK1 = gmx_fio_ndo_float(ef->fio, sub->fval, sub->nr);
                     break;
-                case xdr_datatype_double:
+                case XdrDataType::Double:
                     bOK1 = gmx_fio_ndo_double(ef->fio, sub->dval, sub->nr);
                     break;
-                case xdr_datatype_int: bOK1 = gmx_fio_ndo_int(ef->fio, sub->ival, sub->nr); break;
-                case xdr_datatype_int64:
+                case XdrDataType::Int: bOK1 = gmx_fio_ndo_int(ef->fio, sub->ival, sub->nr); break;
+                case XdrDataType::Int64:
                     bOK1 = gmx_fio_ndo_int64(ef->fio, sub->lval, sub->nr);
                     break;
-                case xdr_datatype_char:
+                case XdrDataType::Char:
                     bOK1 = gmx_fio_ndo_uchar(ef->fio, sub->cval, sub->nr);
                     break;
-                case xdr_datatype_string:
+                case XdrDataType::String:
                     bOK1 = gmx_fio_ndo_string(ef->fio, sub->sval, sub->nr);
                     break;
                 default:
@@ -1455,37 +1455,37 @@ static void cmp_eblocks(t_enxframe* fr1, t_enxframe* fr2, real ftol, real abstol
                     {
                         switch (s1->type)
                         {
-                            case xdr_datatype_float:
+                            case XdrDataType::Float:
                                 for (k = 0; k < s1->nr; k++)
                                 {
                                     cmp_float(stdout, buf, i, s1->fval[k], s2->fval[k], ftol, abstol);
                                 }
                                 break;
-                            case xdr_datatype_double:
+                            case XdrDataType::Double:
                                 for (k = 0; k < s1->nr; k++)
                                 {
                                     cmp_double(stdout, buf, i, s1->dval[k], s2->dval[k], ftol, abstol);
                                 }
                                 break;
-                            case xdr_datatype_int:
+                            case XdrDataType::Int:
                                 for (k = 0; k < s1->nr; k++)
                                 {
                                     cmp_int(stdout, buf, i, s1->ival[k], s2->ival[k]);
                                 }
                                 break;
-                            case xdr_datatype_int64:
+                            case XdrDataType::Int64:
                                 for (k = 0; k < s1->nr; k++)
                                 {
                                     cmp_int64(stdout, buf, s1->lval[k], s2->lval[k]);
                                 }
                                 break;
-                            case xdr_datatype_char:
+                            case XdrDataType::Char:
                                 for (k = 0; k < s1->nr; k++)
                                 {
                                     cmp_uc(stdout, buf, i, s1->cval[k], s2->cval[k]);
                                 }
                                 break;
-                            case xdr_datatype_string:
+                            case XdrDataType::String:
                                 for (k = 0; k < s1->nr; k++)
                                 {
                                     cmp_str(stdout, buf, i, s1->sval[k], s2->sval[k]);
index 18c46aa79cc549abe194f7c667d4d5c425a94fd8..77ae446cd7b98107040d73663a7df5a4d7288e7e 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -102,8 +102,8 @@ extern const char* enx_block_id_name[];
    has a number of values of a single data type in a .edr file. */
 struct t_enxsubblock
 {
-    int          nr;   /* number of items in subblock */
-    xdr_datatype type; /* the block type */
+    int         nr;   /* number of items in subblock */
+    XdrDataType type; /* the block type */
 
     /* the values: pointers for each type */
     float*         fval;
index e9dcc679f9861b7aecfd52f0c34ee14764b2117f..823262ac7838b8f87e42d0cfad7705b6103843d1 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 
 #include "gromacs/fileio/xdr_datatype.h"
 #include "gromacs/fileio/xdrf.h"
+#include "gromacs/utility/enumerationhelpers.h"
 #include "gromacs/utility/futil.h"
 
 /* This is just for clarity - it can never be anything but 4! */
 #define XDR_INT_SIZE 4
 
-/* same order as the definition of xdr_datatype */
-const char* xdr_datatype_names[] = { "int", "float", "double", "large int", "char", "string" };
+/* Human-friendly names for XdrDataType enum class */
+const char* enumValueToString(XdrDataType enumValue)
+{
+    constexpr gmx::EnumerationArray<XdrDataType, const char*> xdrDataTypeNames = {
+        "int", "float", "double", "large int", "char", "string"
+    };
+    return xdrDataTypeNames[enumValue];
+}
 
 
 /*___________________________________________________________________________
index 108bd92c586d791b0d8b918f0bbde4b37467558c..6b097e867eccc19ae21fece0c944fde8a0855477 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2013,2018,2019,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 
 /* the xdr data types; note that there is no data type 'real' because
    here we deal with the types as they are actually written to disk.  */
-typedef enum
+enum class XdrDataType : int
 {
-    xdr_datatype_int,
-    xdr_datatype_float,
-    xdr_datatype_double,
-    xdr_datatype_int64,
-    xdr_datatype_char,
-    xdr_datatype_string
-} xdr_datatype;
+    Int,
+    Float,
+    Double,
+    Int64,
+    Char,
+    String,
+    Count
+};
 
-/* names corresponding to the xdr_datatype enum */
-extern const char* xdr_datatype_names[];
+/* names corresponding to the XdrDataType enum */
+const char* enumValueToString(XdrDataType enumValue);
 
 #endif
index fa6c81011d09048029ca9701c875312bed5cedad..9f02e4aa89b714c8aa6513d3a9e74e28b9acf712 100644 (file)
@@ -2815,8 +2815,9 @@ static void read_edr_rawdh_block(samples_t**   smp,
     int           startj;
 
     /* check the block types etc. */
-    if ((blk->nsub < 3) || (blk->sub[0].type != xdr_datatype_int) || (blk->sub[1].type != xdr_datatype_double)
-        || ((blk->sub[2].type != xdr_datatype_float) && (blk->sub[2].type != xdr_datatype_double))
+    if ((blk->nsub < 3) || (blk->sub[0].type != XdrDataType::Int)
+        || (blk->sub[1].type != XdrDataType::Double)
+        || ((blk->sub[2].type != XdrDataType::Float) && (blk->sub[2].type != XdrDataType::Double))
         || (blk->sub[0].nr < 1) || (blk->sub[1].nr < 1))
     {
         gmx_fatal(FARGS, "Unexpected/corrupted block data in file %s around time %f.", filename, start_time);
@@ -2883,7 +2884,7 @@ static void read_edr_rawdh_block(samples_t**   smp,
     /* and copy the data*/
     for (j = 0; j < blk->sub[2].nr; j++)
     {
-        if (blk->sub[2].type == xdr_datatype_float)
+        if (blk->sub[2].type == XdrDataType::Float)
         {
             s->du[startj + j] = blk->sub[2].fval[j];
         }
@@ -2915,8 +2916,8 @@ static samples_t* read_edr_hist_block(int*          nsamples,
     int           nbins[2];
 
     /* check the block types etc. */
-    if ((blk->nsub < 2) || (blk->sub[0].type != xdr_datatype_double)
-        || (blk->sub[1].type != xdr_datatype_int64) || (blk->sub[0].nr < 2) || (blk->sub[1].nr < 2))
+    if ((blk->nsub < 2) || (blk->sub[0].type != XdrDataType::Double)
+        || (blk->sub[1].type != XdrDataType::Int64) || (blk->sub[0].nr < 2) || (blk->sub[1].nr < 2))
     {
         gmx_fatal(FARGS, "Unexpected/corrupted block data in file %s around time %f", filename, start_time);
     }
@@ -3083,7 +3084,7 @@ static void read_barsim_edr(const char* fn, real* temp, sim_data_t* sd)
             if (fr->block[i].id == enxDHCOLL)
             {
                 nlam++;
-                if ((fr->block[i].nsub < 1) || (fr->block[i].sub[0].type != xdr_datatype_double)
+                if ((fr->block[i].nsub < 1) || (fr->block[i].sub[0].type != XdrDataType::Double)
                     || (fr->block[i].sub[0].nr < 5))
                 {
                     gmx_fatal(FARGS, "Unexpected block data in file %s", fn);
index ebd5f5a3f4a14ffd72db5b9176a5d8e6224f2545..b62f88bf0c130a852912e772744d2efd97ec6aec 100644 (file)
@@ -1438,7 +1438,7 @@ static void do_dhdl(t_enxframe*             fr,
         else if (fr->block[i].id == enxDHCOLL)
         {
             nblock_dhcoll++;
-            if ((fr->block[i].nsub < 1) || (fr->block[i].sub[0].type != xdr_datatype_double)
+            if ((fr->block[i].nsub < 1) || (fr->block[i].sub[0].type != XdrDataType::Double)
                 || (fr->block[i].sub[0].nr < 5))
             {
                 gmx_fatal(FARGS, "Unexpected block data");
@@ -1531,8 +1531,8 @@ static void do_dhdl(t_enxframe*             fr,
                 int     nhist, derivative;
 
                 /* check the block types etc. */
-                if ((blk->nsub < 2) || (blk->sub[0].type != xdr_datatype_double)
-                    || (blk->sub[1].type != xdr_datatype_int64) || (blk->sub[0].nr < 2)
+                if ((blk->nsub < 2) || (blk->sub[0].type != XdrDataType::Double)
+                    || (blk->sub[1].type != XdrDataType::Int64) || (blk->sub[0].nr < 2)
                     || (blk->sub[1].nr < 2))
                 {
                     gmx_fatal(FARGS, "Unexpected block data in file");
@@ -1616,7 +1616,7 @@ static void do_dhdl(t_enxframe*             fr,
                 if (blk->id == enxDH)
                 {
                     double value;
-                    if (blk->sub[2].type == xdr_datatype_float)
+                    if (blk->sub[2].type == XdrDataType::Float)
                     {
                         value = blk->sub[2].fval[i];
                     }
index d98f5fc236b5f2f2f5c7813ff28962eaf55cbb2e..9b35ed9a621bd61f7977f630bb18ba9d7cd8385b 100644 (file)
@@ -90,11 +90,11 @@ static double mypow(double x, double y)
 static real blk_value(t_enxblock* blk, int sub, int index)
 {
     range_check(index, 0, blk->sub[sub].nr);
-    if (blk->sub[sub].type == xdr_datatype_float)
+    if (blk->sub[sub].type == XdrDataType::Float)
     {
         return blk->sub[sub].fval[index];
     }
-    else if (blk->sub[sub].type == xdr_datatype_double)
+    else if (blk->sub[sub].type == XdrDataType::Double)
     {
         return blk->sub[sub].dval[index];
     }
index 1def84ec7b56e21dcbb0347cf2a19033feaac281..860666b8373f7e924ede86c6732ad3fec75d8911 100644 (file)
@@ -1223,10 +1223,10 @@ void EnergyOutput::printStepToEnergyFile(ener_file* fp_ene,
             fr.block[b].id        = id[b];
             fr.block[b].sub[0].nr = nr[b];
 #if !GMX_DOUBLE
-            fr.block[b].sub[0].type = xdr_datatype_float;
+            fr.block[b].sub[0].type = XdrDataType::Float;
             fr.block[b].sub[0].fval = block[b];
 #else
-            fr.block[b].sub[0].type  = xdr_datatype_double;
+            fr.block[b].sub[0].type  = XdrDataType::Double;
             fr.block[b].sub[0].dval  = block[b];
 #endif
         }
@@ -1244,13 +1244,13 @@ void EnergyOutput::printStepToEnergyFile(ener_file* fp_ene,
             fr.block[db].sub[0].nr     = ndisre;
             fr.block[db].sub[1].nr     = ndisre;
 #if !GMX_DOUBLE
-            fr.block[db].sub[0].type = xdr_datatype_float;
-            fr.block[db].sub[1].type = xdr_datatype_float;
+            fr.block[db].sub[0].type = XdrDataType::Float;
+            fr.block[db].sub[1].type = XdrDataType::Float;
             fr.block[db].sub[0].fval = disres.rt;
             fr.block[db].sub[1].fval = disres.rm3tav;
 #else
-            fr.block[db].sub[0].type = xdr_datatype_double;
-            fr.block[db].sub[1].type = xdr_datatype_double;
+            fr.block[db].sub[0].type = XdrDataType::Double;
+            fr.block[db].sub[1].type = XdrDataType::Double;
             fr.block[db].sub[0].dval = disres.rt;
             fr.block[db].sub[1].dval = disres.rm3tav;
 #endif
index 1beddf1f98cb6ead6d90b9a8cde05b4cba1055c5..a1242a039e1853ff085a474d9b3d03de8dbe1cf6 100644 (file)
@@ -255,7 +255,7 @@ static void mde_delta_h_handle_block(t_mde_delta_h* dh, t_enxblock* blk)
                                                     starting from first coord in
                                                     the main delta_h_coll) */
         blk->sub[0].nr   = 2;
-        blk->sub[0].type = xdr_datatype_int;
+        blk->sub[0].type = XdrDataType::Int;
         blk->sub[0].ival = dh->subblock_meta_i;
 
         /* subblock 2 */
@@ -264,7 +264,7 @@ static void mde_delta_h_handle_block(t_mde_delta_h* dh, t_enxblock* blk)
             dh->subblock_meta_d[i] = dh->lambda[i];
         }
         blk->sub[1].nr   = dh->nlambda;
-        blk->sub[1].type = xdr_datatype_double;
+        blk->sub[1].type = XdrDataType::Double;
         blk->sub[1].dval = dh->subblock_meta_d;
 
         /* subblock 3 */
@@ -276,9 +276,9 @@ static void mde_delta_h_handle_block(t_mde_delta_h* dh, t_enxblock* blk)
 
             blk->sub[2].nr = dh->ndh;
             /* Michael commented in 2012 that this use of explicit
-               xdr_datatype_float was good for F@H for now.
+               XdrDataType::Float was good for F@H for now.
                Apparently it's still good enough. */
-            blk->sub[2].type = xdr_datatype_float;
+            blk->sub[2].type = XdrDataType::Float;
             for (i = 0; i < dh->ndh; i++)
             {
                 dh->dhf[i] = static_cast<float>(dh->dh[i]);
@@ -289,7 +289,7 @@ static void mde_delta_h_handle_block(t_mde_delta_h* dh, t_enxblock* blk)
         else
         {
             blk->sub[2].nr   = 0;
-            blk->sub[2].type = xdr_datatype_float;
+            blk->sub[2].type = XdrDataType::Float;
             blk->sub[2].fval = nullptr;
         }
     }
@@ -350,7 +350,7 @@ static void mde_delta_h_handle_block(t_mde_delta_h* dh, t_enxblock* blk)
         }
         dh->subblock_meta_d[1] = dh->dx;
         blk->sub[0].nr         = 2 + ((dh->nlambda > 1) ? dh->nlambda : 0);
-        blk->sub[0].type       = xdr_datatype_double;
+        blk->sub[0].type       = XdrDataType::Double;
         blk->sub[0].dval       = dh->subblock_meta_d;
 
         /* subblock 2: the starting point(s) as a long integer */
@@ -365,7 +365,7 @@ static void mde_delta_h_handle_block(t_mde_delta_h* dh, t_enxblock* blk)
         dh->subblock_meta_l[k++] = dh->derivative;
 
         blk->sub[1].nr   = nhist_written + 3;
-        blk->sub[1].type = xdr_datatype_int64;
+        blk->sub[1].type = XdrDataType::Int64;
         blk->sub[1].lval = dh->subblock_meta_l;
 
         /* subblock 3 + 4 : the histogram data */
@@ -373,7 +373,7 @@ static void mde_delta_h_handle_block(t_mde_delta_h* dh, t_enxblock* blk)
         {
             blk->sub[i + 2].nr = dh->maxbin[i] + 1; /* it's +1 because size=index+1
                                                        in C */
-            blk->sub[i + 2].type = xdr_datatype_int;
+            blk->sub[i + 2].type = XdrDataType::Int;
             blk->sub[i + 2].ival = dh->bin[i];
         }
     }
@@ -700,7 +700,7 @@ void mde_delta_h_coll_handle_block(t_mde_delta_h_coll* dhc, t_enxframe* fr, int
     }
     blk->id          = enxDHCOLL;
     blk->sub[0].nr   = c_subblockDNumPreEntries + dhc->n_lambda_vec;
-    blk->sub[0].type = xdr_datatype_double;
+    blk->sub[0].type = XdrDataType::Double;
     blk->sub[0].dval = dhc->subblock_d;
 
     if (dhc->native_lambda_components != nullptr)
@@ -713,7 +713,7 @@ void mde_delta_h_coll_handle_block(t_mde_delta_h_coll* dhc, t_enxframe* fr, int
             dhc->subblock_i[c_subblockINumPreEntries + i] = dhc->native_lambda_components[i];
         }
         blk->sub[1].nr   = c_subblockINumPreEntries + dhc->n_lambda_vec;
-        blk->sub[1].type = xdr_datatype_int;
+        blk->sub[1].type = XdrDataType::Int;
         blk->sub[1].ival = dhc->subblock_i;
     }
 
index 849edfb215de8ab27c3ffa2f3a60e2a3d7dc5607..541d6da1bfdc2107cbfdbefee978d3fab0d15fe5 100644 (file)
@@ -517,41 +517,41 @@ void list_ene(const char* fn)
                     printf("  Sub block %3d (%5d elems, type=%s) values:\n",
                            i,
                            sb->nr,
-                           xdr_datatype_names[sb->type]);
+                           enumValueToString(sb->type));
 
                     switch (sb->type)
                     {
-                        case xdr_datatype_float:
+                        case XdrDataType::Float:
                             for (j = 0; j < sb->nr; j++)
                             {
                                 printf("%14d   %8.4f\n", j, sb->fval[j]);
                             }
                             break;
-                        case xdr_datatype_double:
+                        case XdrDataType::Double:
                             for (j = 0; j < sb->nr; j++)
                             {
                                 printf("%14d   %10.6f\n", j, sb->dval[j]);
                             }
                             break;
-                        case xdr_datatype_int:
+                        case XdrDataType::Int:
                             for (j = 0; j < sb->nr; j++)
                             {
                                 printf("%14d %10d\n", j, sb->ival[j]);
                             }
                             break;
-                        case xdr_datatype_int64:
+                        case XdrDataType::Int64:
                             for (j = 0; j < sb->nr; j++)
                             {
                                 printf("%14d %s\n", j, gmx_step_str(sb->lval[j], buf));
                             }
                             break;
-                        case xdr_datatype_char:
+                        case XdrDataType::Char:
                             for (j = 0; j < sb->nr; j++)
                             {
                                 printf("%14d %1c\n", j, sb->cval[j]);
                             }
                             break;
-                        case xdr_datatype_string:
+                        case XdrDataType::String:
                             for (j = 0; j < sb->nr; j++)
                             {
                                 printf("%14d %80s\n", j, sb->sval[j]);