--- trunk/OOPSE/libmdtools/do_Forces.F90 2003/03/31 22:09:39 439 +++ trunk/OOPSE/libmdtools/do_Forces.F90 2003/04/01 16:50:14 441 @@ -4,7 +4,7 @@ !! @author Charles F. Vardeman II !! @author Matthew Meineke -!! @version $Id: do_Forces.F90,v 1.6 2003-03-31 22:09:39 chuckv Exp $, $Date: 2003-03-31 22:09:39 $, $Name: not supported by cvs2svn $, $Revision: 1.6 $ +!! @version $Id: do_Forces.F90,v 1.7 2003-04-01 16:50:14 chuckv Exp $, $Date: 2003-04-01 16:50:14 $, $Name: not supported by cvs2svn $, $Revision: 1.7 $ module do_Forces use force_globals @@ -168,7 +168,7 @@ contains logical :: do_pot logical :: do_stress #ifdef IS_MPI - real( kind = DP ) :: pot_local = 0.0_dp + real( kind = DP ) :: pot_local integer :: nrow integer :: ncol #endif @@ -189,6 +189,7 @@ contains !! initialize local variables #ifdef IS_MPI + pot_local = 0.0_dp nlocal = getNlocal() nrow = getNrow(plan_row) ncol = getNcol(plan_col) @@ -196,7 +197,7 @@ contains nlocal = getNlocal() natoms = nlocal #endif - + call getRcut(rcut,rc2=rcutsq) call getRlist(rlist,rlistsq) @@ -277,7 +278,7 @@ contains if (rijsq < rcutsq) then call do_pair(i, j, rijsq, d, do_pot, do_stress, & - u_l, A, f, t,pot) + u_l, A, f, t, pot_local) endif endif enddo inner @@ -299,7 +300,7 @@ contains call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq) call do_pair(i, j, rijsq, d, do_pot, do_stress, & - u_l, A, f, t,pot) + u_l, A, f, t, pot_local) enddo endif @@ -346,7 +347,7 @@ contains if (rijsq < rcutsq) then call do_pair(i, j, rijsq, d, do_pot, do_stress, & - u_l, A, f, t,pot) + u_l, A, f, t, pot) endif endif enddo inner @@ -368,7 +369,7 @@ contains call get_interatomic_vector(q(:,i), q(:,j), d, rijsq) call do_pair(i, j, rijsq, d, do_pot, do_stress, & - u_l, A, f, t,pot) + u_l, A, f, t, pot) enddo endif @@ -472,7 +473,7 @@ contains #ifdef IS_MPI if (do_pot) then - pot = pot_local + pot = pot + pot_local !! we assume the c code will do the allreduce to get the total potential !! we could do it right here if we needed to... endif @@ -495,7 +496,7 @@ contains end subroutine do_force_loop - subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t,pot) + subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot) real( kind = dp ) :: pot real( kind = dp ), dimension(:,:) :: u_l @@ -698,7 +699,7 @@ contains #else unique_id_2 = atom2 #endif - + #ifdef IS_MPI !! this situation should only arise in MPI simulations if (unique_id_1 == unique_id_2) then @@ -708,14 +709,18 @@ contains !! this prevents us from doing the pair on multiple processors if (unique_id_1 < unique_id_2) then - if (mod(unique_id_1 + unique_id_2,2) == 0) skip_it = .true. - return + if (mod(unique_id_1 + unique_id_2,2) == 0) then + skip_it = .true. + return + endif else - if (mod(unique_id_1 + unique_id_2,2) == 1) skip_it = .true. - return + if (mod(unique_id_1 + unique_id_2,2) == 1) then + skip_it = .true. + return + endif endif #endif - + !! the rest of these situations can happen in all simulations: do i = 1, nExcludes_global if ((excludesGlobal(i) == unique_id_1) .or. & @@ -724,7 +729,7 @@ contains return endif enddo - + do i = 1, nExcludes_local if (excludesLocal(1,i) == unique_id_1) then if (excludesLocal(2,i) == unique_id_2) then