From d5682dd33775dc104029343f18ef5fb2a7135d39 Mon Sep 17 00:00:00 2001 From: Berk Hess Date: Tue, 25 Aug 2015 10:24:13 +0200 Subject: [PATCH] Simplify changing the tpx_version Added an element tpxv_Count to the tpxv enum and setting tpx_version to tpx_Count-1. When adding a new tpx version, one no longer needs edit the tpx_version field, nor add a comma to the next-to-last entry in tpxv. This results in fewer line changes and reduces the number of git conflicts between two commits that both add a new tpx version. Change-Id: I23ea253678be369edbe721668a09b9062c641edd --- src/gromacs/fileio/tpxio.cpp | 50 ++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/src/gromacs/fileio/tpxio.cpp b/src/gromacs/fileio/tpxio.cpp index 623c1d23fc..015ffad5f8 100644 --- a/src/gromacs/fileio/tpxio.cpp +++ b/src/gromacs/fileio/tpxio.cpp @@ -72,8 +72,7 @@ * formats around which cannot be distinguished, while not causing * problems rebasing the feature branch onto upstream changes. When * merging with mainstream GROMACS, set this tag string back to - * TPX_TAG_RELEASE, and instead add an element to tpxv and set - * tpx_version to that. + * TPX_TAG_RELEASE, and instead add an element to tpxv. */ static const char *tpx_tag = TPX_TAG_RELEASE; @@ -82,10 +81,10 @@ static const char *tpx_tag = TPX_TAG_RELEASE; * * The enum helps the code be more self-documenting and ensure merges * do not silently resolve when two patches make the same bump. When - * adding new functionality, add a new element to the end of this - * enumeration, change the definition of tpx_version, and write code - * below that does the right thing according to the value of - * file_version. */ + * adding new functionality, add a new element just above tpxv_Count + * in this enumeration, and write code below that does the right thing + * according to the value of file_version. + */ enum tpxv { tpxv_ComputationalElectrophysiology = 96, /**< support for ion/water position swaps (computational electrophysiology) */ tpxv_Use64BitRandomSeed, /**< change ld_seed from int to gmx_int64_t */ @@ -94,21 +93,22 @@ enum tpxv { tpxv_RemoveObsoleteParameters1, /**< remove optimize_fft, dihre_fc, nstcheckpoint */ tpxv_PullCoordTypeGeom, /**< add pull type and geometry per group and flat-bottom */ tpxv_PullGeomDirRel, /**< add pull geometry direction-relative */ - tpxv_IntermolecularBondeds /**< permit inter-molecular bonded interactions in the topology */ + tpxv_IntermolecularBondeds, /**< permit inter-molecular bonded interactions in the topology */ + tpxv_Count /**< the total number of tpxv versions */ }; /*! \brief Version number of the file format written to run input * files by this version of the code. * - * The tpx_version number should be increased whenever the file format - * in the main development branch changes, generally to the highest - * value present in tpxv. Backward compatibility for reading old run - * input files is maintained by checking this version number against - * that of the file and then using the correct code path. + * The tpx_version increases whenever the file format in the main + * development branch changes, due to an extension of the tpxv enum above. + * Backward compatibility for reading old run input files is maintained + * by checking this version number against that of the file and then using + * the correct code path. * * When developing a feature branch that needs to change the run input * file format, change tpx_tag instead. */ -static const int tpx_version = tpxv_IntermolecularBondeds; +static const int tpx_version = tpxv_Count - 1; /* This number should only be increased when you edit the TOPOLOGY section @@ -141,33 +141,9 @@ typedef struct { /* * The entries should be ordered in: - * 1. ascending file version number - * 2. ascending function type number - */ -/*static const t_ftupd ftupd[] = { - { 20, F_CUBICBONDS }, - { 20, F_CONNBONDS }, - { 20, F_HARMONIC }, - { 20, F_EQM, }, - { 22, F_DISRESVIOL }, - { 22, F_ORIRES }, - { 22, F_ORIRESDEV }, - { 26, F_FOURDIHS }, - { 26, F_PIDIHS }, - { 26, F_DIHRES }, - { 26, F_DIHRESVIOL }, - { 30, F_CROSS_BOND_BONDS }, - { 30, F_CROSS_BOND_ANGLES }, - { 30, F_UREY_BRADLEY }, - { 30, F_POLARIZATION }, - { 54, F_DHDL_CON }, - };*/ -/* - * The entries should be ordered in: * 1. ascending function type number * 2. ascending file version number */ -/* question; what is the purpose of the commented code above? */ static const t_ftupd ftupd[] = { { 20, F_CUBICBONDS }, { 20, F_CONNBONDS }, -- 2.11.4.GIT