Merge release-2019 into master
[gromacs.git] / src / programs / mdrun / tests / multisim.cpp
blob315e9b97d2b8ad97dbee244075e52111b86b2bd6
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2013,2014,2015,2016,2018, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 /*! \internal \file
37 * \brief
38 * Tests for the mdrun multi-simulation functionality
40 * \author Mark Abraham <mark.j.abraham@gmail.com>
41 * \ingroup module_mdrun_integration_tests
43 #include "gmxpre.h"
45 #include "config.h"
47 #include <gtest/gtest.h>
49 #include "multisimtest.h"
51 namespace gmx
53 namespace test
56 /* This test ensures mdrun can run multi-simulations. It runs one
57 * simulation per MPI rank.
59 * TODO Preferably, we could test that mdrun correctly refuses to run
60 * multi-simulation unless compiled with real MPI with more than one
61 * rank available. However, if we just call mdrun blindly, those cases
62 * trigger an error that is currently fatal to mdrun and also to the
63 * test binary. So, in the meantime we must not test those cases. If
64 * there is no MPI, we disable the test, so that there is a reminder
65 * that it is disabled. There's no elegant way to conditionally
66 * disable a test at run time, so currently there is no feedback if
67 * only one rank is available. However, the test harness knows to run
68 * this test with more than one rank.
70 * Strictly, this test does not need to be parameterized, but
71 * conditionally disabling it with respect to GMX_LIB_MPI is easier if
72 * it is parameterized. */
73 TEST_P(MultiSimTest, ExitsNormally)
75 runExitsNormallyTest();
78 TEST_P(MultiSimTest, ExitsNormallyWithDifferentNumbersOfStepsPerSimulation)
80 if (size_ <= 1)
82 /* Can't test multi-sim without multiple ranks. */
83 return;
85 SimulationRunner runner(&fileManager_);
86 runner.useTopGroAndNdxFromDatabase("spc2");
88 const char *pcoupl = GetParam();
89 // Do some different small numbers of steps in each simulation
90 int numSteps = rank_ % 4;
91 organizeMdpFile(&runner, pcoupl, numSteps);
92 /* Call grompp on every rank - the standard callGrompp() only runs
93 grompp on rank 0. */
94 EXPECT_EQ(0, runner.callGromppOnThisRank());
96 ASSERT_EQ(0, runner.callMdrun(*mdrunCaller_));
99 /* Note, not all preprocessor implementations nest macro expansions
100 the same way / at all, if we would try to duplicate less code. */
101 #if GMX_LIB_MPI
102 INSTANTIATE_TEST_CASE_P(InNvt, MultiSimTest,
103 ::testing::Values("pcoupl = no"));
104 #else
105 // Test needs real MPI to run
106 INSTANTIATE_TEST_CASE_P(DISABLED_InNvt, MultiSimTest,
107 ::testing::Values("pcoupl = no"));
108 #endif
110 //! Convenience typedef
111 typedef MultiSimTest MultiSimTerminationTest;
113 TEST_F(MultiSimTerminationTest, WritesCheckpointAfterMaxhTerminationAndThenRestarts)
115 runMaxhTest();
118 } // namespace test
119 } // namespace gmx