diff --git a/patches/amber14.diff/AmberTools/src/sander/runmd.F90 b/patches/amber14.diff/AmberTools/src/sander/runmd.F90 index af3bc6f6f8c57c788754fafe769faa48d8ed1d73..42ed0e4c60a5f080aee82c457af6029f627b94cd 100644 --- a/patches/amber14.diff/AmberTools/src/sander/runmd.F90 +++ b/patches/amber14.diff/AmberTools/src/sander/runmd.F90 @@ -327,7 +327,7 @@ subroutine runmd(xx,ix,ih,ipairs,x,winv,amass,f, & ! variables for plumed _REAL_ :: plumed_box(3,3),plumed_virial(3,3), plumed_kbt - integer :: plumed_version,plumed_stopflag,plumed_ms + integer :: plumed_version,plumed_stopflag,plumed_ms,plumed_ss,plumed_ws _REAL_ :: plumed_energyUnits,plumed_timeUnits,plumed_lengthUnits !========================================================================== @@ -767,9 +767,21 @@ subroutine runmd(xx,ix,ih,ipairs,x,winv,amass,f, & call plumed_f_gcmd("setMPIFComm"//char(0),commsander) if(master)then call mpi_comm_size(commmaster,plumed_ms,ierr) + else + plumed_ms=1 endif call mpi_bcast(plumed_ms,1,MPI_INTEGER,0,commsander,ierr) - if(plumed_ms>1)then + call mpi_comm_size(commsander,plumed_ss,ierr) + call mpi_comm_size(commworld,plumed_ws,ierr) +! this is a hack that is necessary to detect multiple replicas +! commworld: all processors +! commsander: group related to a single replica +! commmaster: with replicas, group with the master of each replica +! without replicas, group with all processors +! thus, to detect multiple replicas, I check that +! size(commworld)==size(commmaster)*size(commsander) +! and at the same time size(commaster)>1 + if(plumed_ms>1 .and. plumed_ws==plumed_ms*plumed_ss)then call plumed_f_gcmd("GREX setMPIFIntracomm"//char(0),commsander) if(master) then call plumed_f_gcmd("GREX setMPIFIntercomm"//char(0),commmaster)