-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New warnings for METAD adn WALKERS_MPI (#931)
* Test with and without MPI * WALKERS_MPI now throws without MPI initializated * test and error message now are more clear * clearer comments in the tests * added the last newline to the new files * PlumedHasMPI is now a function * camelCased plumedHasMPI * style aligned * moved files * created compiledtest type * compiled tests now support align with the other tests * Moved the new test in the basic directory * now the new test is completely aligned with the old ones * removed compiled test * updated the reference --------- Co-authored-by: Daniele Rapetti <[email protected]>
- Loading branch information
Showing
8 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../scripts/test.make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type=make | ||
# this is needed because we are explicitly checking some exception message | ||
export PLUMED_STACK_TRACE=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
METAD WALKER_MPI : Exception thrown, correct message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include <fstream> | ||
|
||
#include "plumed/wrapper/Plumed.h" | ||
#include "plumed/tools/Communicator.h" | ||
|
||
constexpr unsigned nat=10; | ||
//it is a struct because we don't need getter/setters (for now) | ||
struct plumedThrowChecker{ | ||
unsigned natoms=nat; | ||
std::vector<double> positions=[](unsigned natoms){ | ||
std::vector<double> toret(natoms*3,0.0); | ||
for(unsigned i=0; i<3*natoms; i++) toret[i]=i; | ||
return toret; | ||
}(nat); | ||
std::vector<double> masses{nat,1.0}; | ||
std::vector<double> forces{3*nat,0.0}; | ||
std::vector<double> box{9,0.0}; | ||
std::vector<double> virial{9,0.0}; | ||
///This initializes a new plumed to test each throw in the cleanliest way possible | ||
int checkThrow (std::ostream& out,std::string name, std::string cmd, std::string expectedMessage){ | ||
//GIVEN an initialized Plumed interface | ||
PLMD::Plumed plumed; | ||
|
||
plumed.cmd("setNatoms",&natoms); | ||
int step=0; | ||
plumed.cmd("setLogFile","test.log"); | ||
plumed.cmd("init"); | ||
plumed.cmd("setStep",&step); | ||
plumed.cmd("setPositions",positions.data()); | ||
plumed.cmd("setBox",box.data()); | ||
plumed.cmd("setForces",forces.data()); | ||
plumed.cmd("setVirial",virial.data()); | ||
plumed.cmd("setMasses",masses.data()); | ||
|
||
plumed.cmd("readInputLine","d: DISTANCE ATOMS=1,2"); | ||
plumed.cmd("readInputLine","d1: DISTANCE ATOMS={1 2}"); | ||
///TODO: expand with a "readInputLines" to give the possibility to test in more situations | ||
try { | ||
//WHEN the user ask for the given input | ||
plumed.cmd("readInputLine",cmd.c_str()); | ||
//THEN plumed should gracefully exit with a clear error message | ||
} catch(PLMD::Plumed::ExceptionError &e) { //correct throw, we are happy | ||
std::string exceptionText{e.what()}; | ||
out << name << " : "; | ||
if (exceptionText.find(expectedMessage) != std::string::npos) { | ||
out << "Exception thrown, correct message\n"; | ||
return 0; | ||
} | ||
|
||
out << "Exception thrown, wrong message: " | ||
<< e.what() ; | ||
out << "\tExpected message should contain: \"" | ||
<< expectedMessage << "\"\n"; | ||
return 1; | ||
} | ||
out << "Exception not thrown\n"; | ||
return 1; | ||
} | ||
}; | ||
|
||
int main(int, char**) { | ||
std::ofstream out("output"); | ||
plumedThrowChecker ptc; | ||
//When the user aks for a WALKERS_MPI in the METAD action, | ||
//if MPI is not installed then the user must be informed | ||
//if MPI is installed then the comunications must be already set up | ||
//WHEN PLUMED is not compiled with MPI or the MPI routines are not initialized | ||
std::string expectedMessage="WALKERS_MPI flag requires MPI compilation"; | ||
if (PLMD::Communicator::plumedHasMPI()) { | ||
expectedMessage="WALKERS_MPI needs the communicator correctly initialized"; | ||
} | ||
ptc.checkThrow(out,"METAD WALKER_MPI", | ||
"METAD ARG=d,d1 SIGMA=0.1,0.2 HEIGHT=0.1 PACE=2 RESTART=YES WALKERS_MPI", | ||
expectedMessage); | ||
|
||
//add other throw messages checks | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ba817b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found broken examples in automatic/a-masterclass-22-09.txt
Found broken examples in automatic/a-masterclass-22-11.txt
Found broken examples in automatic/a-masterclass-22-12.txt
Found broken examples in automatic/performance-optimization.txt
Found broken examples in automatic/a-trieste-6.txt
Found broken examples in automatic/munster.txt
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/ENVIRONMENTSIMILARITY.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/GHBFIX.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/MAZE_MEMETIC_SAMPLING.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_RANDOM_WALK.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in MiscelaneousPP.md