Skip to content

Commit

Permalink
Merge branch 'v2.8' into v2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
GiovanniBussi committed May 15, 2024
2 parents 0512e4d + be82f14 commit ad252bd
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/v2.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@ Changes from version 2.7 which are relevant for users:
- Fixed an error in checking array shapes in the interface. Arrays with shape (N,4) should not be accepted for positions or forces.
- Small fix in Python, where we do not assume anymore that strings are null terminated.
- Environment variables such as `PLUMED_INCLUDEDIR` and similar are sanitized before they are used for running commands.
- Fixed a bug leading to a crash when using python selectors (e.g., `@mda:` or `@mdt:`) and multiple MPI processes per replica.

1 change: 1 addition & 0 deletions regtest/basic/rt32b-mpi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../scripts/test.make
32 changes: 32 additions & 0 deletions regtest/basic/rt32b-mpi/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
type=driver
mpiprocs=2
arg="--plumed plumed.dat --trajectory-stride 10 --timestep 0.005 --ixyz ala12_trajectory.xyz --dump-forces forces --dump-forces-fmt=%10.6f --debug-dd yes"
extra_files="
../rt32b/colvar.reference
../rt32b/helix.pdb
../rt32b/test.gro.reference
../rt32b/test1.gro.reference
../rt32b/test2.gro.reference
../rt32b/test3.gro.reference
../rt32b/test4.gro.reference
../rt32b/test5.gro.reference
../rt32b/ala12_trajectory.xyz
../rt32b/plumed.dat
"


function plumed_custom_skip() {
if test -n "$PLUMED_PYTHON_SELECT" ; then
export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT"
return 1
fi
for python_bin in python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7 python ; do
if $python_bin -c "import MDAnalysis; import mdtraj" 2>/dev/null ; then
if [ $python_bin != python ] ; then
export PLUMED_PYTHON_BIN=$python_bin
fi
return 1
fi
done
return 0
}
2 changes: 1 addition & 1 deletion regtest/basic/rt32b/config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function plumed_custom_skip() {
export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT"
return 1
fi
for python_bin in python python2.7 python3.6 python3.7 ; do
for python_bin in python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7 python ; do
if $python_bin -c "import MDAnalysis; import mdtraj" 2>/dev/null ; then
if [ $python_bin != python ] ; then
export PLUMED_PYTHON_BIN=$python_bin
Expand Down
10 changes: 7 additions & 3 deletions src/core/GenericMolInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,17 @@ void GenericMolInfo::interpretSymbol( const std::string& symbol, std::vector<Ato
plumed_assert(enablePythonInterpreter);

log<<" symbol " + symbol + " will be sent to python interpreter\n";
if(!selector) {
if(!selector_running) {
log<<" MOLINFO "<<getLabel()<<": starting python interpreter\n";
if(comm.Get_rank()==0) {
selector=Tools::make_unique<Subprocess>(pythonCmd+" \""+config::getPlumedRoot()+"\"/scripts/selector.sh --pdb " + reference);
selector->stop();
}
selector_running=true;
}

atoms.resize(0);

if(comm.Get_rank()==0) {
int ok=0;
std::string error_msg;
Expand All @@ -279,7 +282,6 @@ void GenericMolInfo::interpretSymbol( const std::string& symbol, std::vector<Ato
if(!words.empty() && words[0]=="Selection:") break;
}
words.erase(words.begin());
atoms.resize(0);
for(const auto & w : words) {
int n;
if(w.empty()) continue;
Expand Down Expand Up @@ -313,6 +315,7 @@ void GenericMolInfo::interpretSymbol( const std::string& symbol, std::vector<Ato
}
size_t nat=0;
comm.Bcast(nat,0);
atoms.resize(nat);
comm.Bcast(atoms,0);
}
log<<" selection interpreted using ";
Expand Down Expand Up @@ -359,9 +362,10 @@ bool GenericMolInfo::isWhole() const {
}

void GenericMolInfo::prepare() {
if(selector) {
if(selector_running) {
log<<" MOLINFO "<<getLabel()<<": killing python interpreter\n";
selector.reset();
selector_running=false;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/core/GenericMolInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class GenericMolInfo :
std::string pythonCmd;
/// Selector subprocess
std::unique_ptr<Subprocess> selector;
/// Track is selector is running
/// Needed on Get_rank()>0
bool selector_running=false;
/// Structure in pdb file is whole
bool iswhole_;
public:
Expand Down

0 comments on commit ad252bd

Please sign in to comment.