From 43c5902fb92e9c90f8e20bb21e4e88d10f52e0be Mon Sep 17 00:00:00 2001 From: Artem Zhmurov Date: Mon, 19 Apr 2021 18:49:05 +0000 Subject: [PATCH] Make XDR type into enum class --- src/gromacs/applied_forces/awh/biaswriter.cpp | 4 +- src/gromacs/fileio/checkpoint.cpp | 46 +++++++-------- src/gromacs/fileio/enxio.cpp | 56 +++++++++---------- src/gromacs/fileio/enxio.h | 6 +- src/gromacs/fileio/libxdrf.cpp | 13 ++++- src/gromacs/fileio/xdr_datatype.h | 23 ++++---- src/gromacs/gmxana/gmx_bar.cpp | 13 +++-- src/gromacs/gmxana/gmx_energy.cpp | 8 +-- src/gromacs/gmxana/gmx_nmr.cpp | 4 +- src/gromacs/mdlib/energyoutput.cpp | 12 ++-- src/gromacs/mdlib/mdebin_bar.cpp | 20 +++---- src/gromacs/tools/dump.cpp | 14 ++--- 12 files changed, 115 insertions(+), 104 deletions(-) diff --git a/src/gromacs/applied_forces/awh/biaswriter.cpp b/src/gromacs/applied_forces/awh/biaswriter.cpp index 8fd09eedbc..aa0b916dfe 100644 --- a/src/gromacs/applied_forces/awh/biaswriter.cpp +++ b/src/gromacs/applied_forces/awh/biaswriter.cpp @@ -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(); } diff --git a/src/gromacs/fileio/checkpoint.cpp b/src/gromacs/fileio/checkpoint.cpp index 6ba495992d..c23b1df162 100644 --- a/src/gromacs/fileio/checkpoint.cpp +++ b/src/gromacs/fileio/checkpoint.cpp @@ -558,29 +558,29 @@ struct xdr_type template<> struct xdr_type { - static const int value = xdr_datatype_int; + static const XdrDataType value = XdrDataType::Int; }; template<> struct xdr_type { - static const int value = xdr_datatype_float; + static const XdrDataType value = XdrDataType::Float; }; template<> struct xdr_type { - 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(xdr_int); - case xdr_datatype_float: return reinterpret_cast(xdr_float); - case xdr_datatype_double: return reinterpret_cast(xdr_double); + case XdrDataType::Int: return reinterpret_cast(xdr_int); + case XdrDataType::Float: return reinterpret_cast(xdr_float); + case XdrDataType::Double: return reinterpret_cast(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 -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(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(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::value; - int xdrTypeInTheFile = xdrTypeInTheCode; - res = xdr_int(xd, &xdrTypeInTheFile); + constexpr XdrDataType xdrTypeInTheCode = xdr_type::value; + XdrDataType xdrTypeInTheFile = xdrTypeInTheCode; + int xdrTypeInTheFileAsInt = static_cast(xdrTypeInTheFile); + res = xdr_int(xd, &xdrTypeInTheFileAsInt); + xdrTypeInTheFile = static_cast(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.", diff --git a/src/gromacs/fileio/enxio.cpp b/src/gromacs/fileio/enxio.cpp index 278306e208..ce94d52fed 100644 --- a/src/gromacs/fileio/enxio.cpp +++ b/src/gromacs/fileio/enxio.cpp @@ -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(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(typenr); + sub->type = static_cast(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]); diff --git a/src/gromacs/fileio/enxio.h b/src/gromacs/fileio/enxio.h index 18c46aa79c..77ae446cd7 100644 --- a/src/gromacs/fileio/enxio.h +++ b/src/gromacs/fileio/enxio.h @@ -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; diff --git a/src/gromacs/fileio/libxdrf.cpp b/src/gromacs/fileio/libxdrf.cpp index e9dcc679f9..823262ac78 100644 --- a/src/gromacs/fileio/libxdrf.cpp +++ b/src/gromacs/fileio/libxdrf.cpp @@ -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. @@ -47,13 +47,20 @@ #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 xdrDataTypeNames = { + "int", "float", "double", "large int", "char", "string" + }; + return xdrDataTypeNames[enumValue]; +} /*___________________________________________________________________________ diff --git a/src/gromacs/fileio/xdr_datatype.h b/src/gromacs/fileio/xdr_datatype.h index 108bd92c58..6b097e867e 100644 --- a/src/gromacs/fileio/xdr_datatype.h +++ b/src/gromacs/fileio/xdr_datatype.h @@ -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. @@ -39,17 +39,18 @@ /* 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 diff --git a/src/gromacs/gmxana/gmx_bar.cpp b/src/gromacs/gmxana/gmx_bar.cpp index fa6c81011d..9f02e4aa89 100644 --- a/src/gromacs/gmxana/gmx_bar.cpp +++ b/src/gromacs/gmxana/gmx_bar.cpp @@ -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); diff --git a/src/gromacs/gmxana/gmx_energy.cpp b/src/gromacs/gmxana/gmx_energy.cpp index ebd5f5a3f4..b62f88bf0c 100644 --- a/src/gromacs/gmxana/gmx_energy.cpp +++ b/src/gromacs/gmxana/gmx_energy.cpp @@ -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]; } diff --git a/src/gromacs/gmxana/gmx_nmr.cpp b/src/gromacs/gmxana/gmx_nmr.cpp index d98f5fc236..9b35ed9a62 100644 --- a/src/gromacs/gmxana/gmx_nmr.cpp +++ b/src/gromacs/gmxana/gmx_nmr.cpp @@ -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]; } diff --git a/src/gromacs/mdlib/energyoutput.cpp b/src/gromacs/mdlib/energyoutput.cpp index 1def84ec7b..860666b837 100644 --- a/src/gromacs/mdlib/energyoutput.cpp +++ b/src/gromacs/mdlib/energyoutput.cpp @@ -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 diff --git a/src/gromacs/mdlib/mdebin_bar.cpp b/src/gromacs/mdlib/mdebin_bar.cpp index 1beddf1f98..a1242a039e 100644 --- a/src/gromacs/mdlib/mdebin_bar.cpp +++ b/src/gromacs/mdlib/mdebin_bar.cpp @@ -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(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; } diff --git a/src/gromacs/tools/dump.cpp b/src/gromacs/tools/dump.cpp index 849edfb215..541d6da1bf 100644 --- a/src/gromacs/tools/dump.cpp +++ b/src/gromacs/tools/dump.cpp @@ -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]); -- 2.22.0