--- trunk/OOPSE/libmdtools/do_Forces.F90 2004/05/24 21:03:30 1192 +++ trunk/OOPSE/libmdtools/do_Forces.F90 2004/05/27 15:21:20 1199 @@ -4,7 +4,7 @@ !! @author Charles F. Vardeman II !! @author Matthew Meineke -!! @version $Id: do_Forces.F90,v 1.61 2004-05-24 21:03:25 gezelter Exp $, $Date: 2004-05-24 21:03:25 $, $Name: not supported by cvs2svn $, $Revision: 1.61 $ +!! @version $Id: do_Forces.F90,v 1.64 2004-05-27 15:21:20 gezelter Exp $, $Date: 2004-05-27 15:21:20 $, $Name: not supported by cvs2svn $, $Revision: 1.64 $ module do_Forces use force_globals @@ -33,6 +33,9 @@ module do_Forces #include "fForceField.h" #include "fSwitchingFunction.h" + INTEGER, PARAMETER:: PREPAIR_LOOP = 1 + INTEGER, PARAMETER:: PAIR_LOOP = 2 + logical, save :: haveRlist = .false. logical, save :: haveNeighborList = .false. logical, save :: havePolicies = .false. @@ -372,7 +375,7 @@ contains !! Position array provided by C, dimensioned by getNlocal real ( kind = dp ), dimension(3, nLocal) :: q !! molecular center-of-mass position array - real ( kind = dp ), dimension(3, nGroup) :: q_group + real ( kind = dp ), dimension(3, nGroups) :: q_group !! Rotation Matrix for each long range particle in simulation. real( kind = dp), dimension(9, nLocal) :: A !! Unit vectors for dipoles (lab frame) @@ -391,16 +394,16 @@ contains logical :: in_switching_region #ifdef IS_MPI real( kind = DP ) :: pot_local - integer :: nrow - integer :: ncol + integer :: nAtomsInRow + integer :: nAtomsInCol integer :: nprocs - integer :: nrow_group - integer :: ncol_group + integer :: nGroupsInRow + integer :: nGroupsInCol #endif integer :: natoms logical :: update_nlist - integer :: i, j, jbeg, jend, jnab - integer :: istart, iend, jstart + integer :: i, j, jstart, jend, jnab + integer :: istart, iend integer :: ia, jb, atom1, atom2 integer :: nlist real( kind = DP ) :: ratmsq, rgrpsq, rgrp, vpair, vij @@ -413,6 +416,7 @@ contains integer :: listerror, error integer :: localError integer :: propPack_i, propPack_j + integer :: loopStart, loopEnd, loop real(kind=dp) :: listSkin = 1.0 @@ -420,10 +424,10 @@ contains #ifdef IS_MPI pot_local = 0.0_dp - nrow = getNrow(plan_row) - ncol = getNcol(plan_col) - nrow_group = getNrowGroup(plan_row) - ncol_group = getNcolGroup(plan_col) + nAtomsInRow = getNatomsInRow(plan_atom_row) + nAtomsInCol = getNatomsInCol(plan_atom_col) + nGroupsInRow = getNgroupsInRow(plan_group_row) + nGroupsInCol = getNgroupsInCol(plan_group_col) #else natoms = nlocal #endif @@ -443,18 +447,18 @@ contains #ifdef IS_MPI - call gather(q, q_Row, plan_row3d) - call gather(q, q_Col, plan_col3d) + call gather(q, q_Row, plan_atom_row_3d) + call gather(q, q_Col, plan_atom_col_3d) - call gather(q_group, q_group_Row, plan_row_Group_3d) - call gather(q_group, q_group_Col, plan_col_Group_3d) + call gather(q_group, q_group_Row, plan_group_row_3d) + call gather(q_group, q_group_Col, plan_group_col_3d) if (FF_UsesDirectionalAtoms() .and. SIM_uses_directional_atoms) then - call gather(u_l,u_l_Row,plan_row3d) - call gather(u_l,u_l_Col,plan_col3d) + call gather(u_l, u_l_Row, plan_atom_row_3d) + call gather(u_l, u_l_Col, plan_atom_col_3d) - call gather(A,A_Row,plan_row_rotation) - call gather(A,A_Col,plan_col_rotation) + call gather(A, A_Row, plan_atom_row_rotation) + call gather(A, A_Col, plan_atom_col_rotation) endif #endif @@ -465,61 +469,84 @@ contains nloops = nloops + 1 #endif + loopEnd = PAIR_LOOP if (FF_RequiresPrepairCalc() .and. SIM_requires_prepair_calc) then - !! See if we need to update neighbor lists - - call checkNeighborList(nGroup, q_group, listSkin, update_nlist) + loopStart = PREPAIR_LOOP + else + loopStart = PAIR_LOOP + endif - !! if_mpi_gather_stuff_for_prepair - !! do_prepair_loop_if_needed - !! if_mpi_scatter_stuff_from_prepair - !! if_mpi_gather_stuff_from_prepair_to_main_loop - - !--------------------PREFORCE LOOP----------->>>>>>>>>>>>>>>>>>>>>>>>>>> + do loop = loopStart, loopEnd + ! See if we need to update neighbor lists + ! (but only on the first time through): + if (loop .eq. loopStart) then + call checkNeighborList(nGroups, q_group, listSkin, update_nlist) + endif + if (update_nlist) then - - !! save current configuration, construct neighbor list, - !! and calculate forces - - call saveNeighborList(nGroup, q_group) - - neighborListSize = size(list) - nlist = 0 - - istart = 1 + !! save current configuration and construct neighbor list #ifdef IS_MPI - iend = nrow_group + call saveNeighborList(nGroupsInRow, q_group) #else - iend = nGroup - 1 -#endif - do i = istart, iend - - point(i) = nlist + 1 - - n_in_i = groupStart(i+1) - groupStart(i) - -#ifdef IS_MPI - jstart = 1 - jend = ncol_group + call saveNeighborList(nGroups, q_group) +#endif + neighborListSize = size(list) + nlist = 0 + endif + + istart = 1 +#ifdef IS_MPI + iend = nGroupsInRow #else + iend = nGroups - 1 +#endif + outer: do i = istart, iend + + if (update_nlist) point(i) = nlist + 1 + + n_in_i = groupStartRow(i+1) - groupStartRow(i) + + if (update_nlist) then +#ifdef IS_MPI + jstart = 1 + jend = nGroupsInCol +#else jstart = i+1 - jend = nGroup + jend = nGroups #endif - do j = jstart, jend - + else + jstart = point(i) + jend = point(i+1) - 1 + ! make sure group i has neighbors + if (jstart .gt. jend) cycle outer + endif + + do jnab = jstart, jend + if (update_nlist) then + j = jnab + else + j = list(jnab) + endif + #ifdef IS_MPI - call get_interatomic_vector(q_group_Row(:,i), & - q_group_Col(:,j), d_grp, rgrpsq) + call get_interatomic_vector(q_group_Row(:,i), & + q_group_Col(:,j), d_grp, rgrpsq) #else - call get_interatomic_vector(q_group(:,i), & - q_group(:,j), d_grp, rgrpsq) -#endif - if (rgrpsq < rlistsq) then + call get_interatomic_vector(q_group(:,i), & + q_group(:,j), d_grp, rgrpsq) +#endif + + if (rgrpsq < rlistsq) then + if (update_nlist) then nlist = nlist + 1 if (nlist > neighborListSize) then - call expandNeighborList(nGroup, listerror) +#ifdef IS_MPI + call expandNeighborList(nGroupsInRow, listerror) +#else + call expandNeighborList(nGroups, listerror) +#endif if (listerror /= 0) then error = -1 write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." @@ -528,33 +555,42 @@ contains neighborListSize = size(list) endif - list(nlist) = j + list(nlist) = j + endif + + if (loop .eq. PAIR_LOOP) then + vij = 0.0d0 + fij(1:3) = 0.0d0 + endif + + call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & + in_switching_region) + + n_in_j = groupStartCol(j+1) - groupStartCol(j) + + do ia = groupStartRow(i), groupStartRow(i+1)-1 - call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & - in_switching_region) + atom1 = groupListRow(ia) - n_in_j = groupStart(j+1) - groupStart(j) - - do ia = groupStart(i), groupStart(i+1)-1 - atom1 = groupList(ia) + inner: do jb = groupStartCol(j), groupStartCol(j+1)-1 - prepair_inner1: do jb = groupStart(j), groupStart(j+1)-1 - atom2 = groupList(jb) - - if (skipThisPair(atom1, atom2)) cycle prepair_inner1 - - if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then - d_atm(1:3) = d_grp(1:3) - ratmsq = rgrpsq - else + atom2 = groupListCol(jb) + + if (skipThisPair(atom1, atom2)) cycle inner + + if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then + d_atm(1:3) = d_grp(1:3) + ratmsq = rgrpsq + else #ifdef IS_MPI - call get_interatomic_vector(q_Row(:,atom1), & - q_Col(:,atom2), d_atm, ratmsq) + call get_interatomic_vector(q_Row(:,atom1), & + q_Col(:,atom2), d_atm, ratmsq) #else - call get_interatomic_vector(q(:,atom1), & - q(:,atom2), d_atm, ratmsq) + call get_interatomic_vector(q(:,atom1), & + q(:,atom2), d_atm, ratmsq) #endif - endif + endif + if (loop .eq. PREPAIR_LOOP) then #ifdef IS_MPI call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & rgrpsq, d_grp, do_pot, do_stress, & @@ -564,363 +600,83 @@ contains rgrpsq, d_grp, do_pot, do_stress, & u_l, A, f, t, pot) #endif - enddo prepair_inner1 - enddo - - end if - enddo - enddo - -#ifdef IS_MPI - point(nrow_group + 1) = nlist + 1 -#else - point(nGroup) = nlist + 1 -#endif - - else !! (of update_check) - - ! use the list to find the neighbors - - istart = 1 -#ifdef IS_MPI - iend = nrow_group + else +#ifdef IS_MPI + call do_pair(atom1, atom2, ratmsq, d_atm, sw, & + do_pot, & + u_l, A, f, t, pot_local, vpair, fpair) #else - iend = nGroup - 1 + call do_pair(atom1, atom2, ratmsq, d_atm, sw, & + do_pot, & + u_l, A, f, t, pot, vpair, fpair) #endif - - do i = istart, iend - - n_in_i = groupStart(i+1) - groupStart(i) - - JBEG = POINT(i) - JEND = POINT(i+1) - 1 - ! check that group i has neighbors - if (jbeg .le. jend) then + vij = vij + vpair + fij(1:3) = fij(1:3) + fpair(1:3) + endif + enddo inner + enddo - do jnab = jbeg, jend - j = list(jnab) - + if (loop .eq. PAIR_LOOP) then + if (in_switching_region) then + swderiv = vij*dswdr/rgrp + fij(1) = fij(1) + swderiv*d_grp(1) + fij(2) = fij(2) + swderiv*d_grp(2) + fij(3) = fij(3) + swderiv*d_grp(3) + + do ia=groupStartRow(i), groupStartRow(i+1)-1 + atom1=groupListRow(ia) + mf = mfactRow(atom1) #ifdef IS_MPI - call get_interatomic_vector(q_group_Row(:,i), & - q_group_Col(:,j), d_grp, rgrpsq) + f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf + f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf + f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf #else - call get_interatomic_vector(q_group(:,i), & - q_group(:,j), d_grp, rgrpsq) -#endif - call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & - in_switching_region) - - n_in_j = groupStart(j+1) - groupStart(j) - - do ia = groupStart(i), groupStart(i+1)-1 - atom1 = groupList(ia) + f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf + f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf + f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf +#endif + enddo - prepair_inner2: do jb = groupStart(j), groupStart(j+1)-1 - - atom2 = groupList(jb) - - if (skipThisPair(atom1, atom2)) cycle prepair_inner2 - - if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then - d_atm(1:3) = d_grp(1:3) - ratmsq = rgrpsq - else + do jb=groupStartCol(j), groupStartCol(j+1)-1 + atom2=groupListCol(jb) + mf = mfactCol(atom2) #ifdef IS_MPI - call get_interatomic_vector(q_Row(:,atom1), & - q_Col(:,atom2), d_atm, ratmsq) + f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf + f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf + f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf #else - call get_interatomic_vector(q(:,atom1), & - q(:,atom2), d_atm, ratmsq) + f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf + f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf + f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf #endif - endif - -#ifdef IS_MPI - call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & - rgrpsq, d_grp, do_pot, do_stress, & - u_l, A, f, t, pot_local) -#else - call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & - rgrpsq, d_grp, do_pot, do_stress, & - u_l, A, f, t, pot) -#endif - enddo prepair_inner2 - enddo - enddo - endif - enddo - endif - !! Do rest of preforce calculations - !! do necessary preforce calculations - call do_preforce(nlocal,pot) - ! we have already updated the neighbor list set it to false... - update_nlist = .false. - else - !! See if we need to update neighbor lists for non pre-pair - call checkNeighborList(nGroup, q_group, listSkin, update_nlist) - end if - - !---------------------------------MAIN Pair LOOP->>>>>>>>>>>>> - - if (update_nlist) then - - !! save current configuration, construct neighbor list, - !! and calculate forces - - call saveNeighborList(nGroup, q_group) - - neighborListSize = size(list) - nlist = 0 - - istart = 1 -#ifdef IS_MPI - iend = nrow_group -#else - iend = nGroup - 1 -#endif - do i = istart, iend - - point(i) = nlist + 1 - - n_in_i = groupStart(i+1) - groupStart(i) - -#ifdef IS_MPI - jstart = 1 - jend = ncol_group -#else - jstart = i+1 - jend = nGroup -#endif - do j = jstart, jend - -#ifdef IS_MPI - call get_interatomic_vector(q_group_Row(:,i), & - q_group_Col(:,j), d_grp, rgrpsq) -#else - call get_interatomic_vector(q_group(:,i), & - q_group(:,j), d_grp, rgrpsq) -#endif - if (rgrpsq < rlistsq) then - nlist = nlist + 1 - - if (nlist > neighborListSize) then - call expandNeighborList(nGroup, listerror) - if (listerror /= 0) then - error = -1 - write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." - return - end if - neighborListSize = size(list) - endif - - list(nlist) = j - - vij = 0.0d0 - fij(1:3) = 0.0d0 - - call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & - in_switching_region) - - n_in_j = groupStart(j+1) - groupStart(j) - - do ia = groupStart(i), groupStart(i+1)-1 - atom1 = groupList(ia) + enddo + endif - inner1: do jb = groupStart(j), groupStart(j+1)-1 - atom2 = groupList(jb) - - if (skipThisPair(atom1, atom2)) cycle inner1 - - if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then - d_atm(1:3) = d_grp(1:3) - ratmsq = rgrpsq - else -#ifdef IS_MPI - call get_interatomic_vector(q_Row(:,atom1), & - q_Col(:,atom2), d_atm, ratmsq) -#else - call get_interatomic_vector(q(:,atom1), & - q(:,atom2), d_atm, ratmsq) -#endif - endif -#ifdef IS_MPI - call do_pair(atom1, atom2, ratmsq, d_atm, sw, & - do_pot, & - u_l, A, f, t, pot_local, vpair, fpair) -#else - call do_pair(atom1, atom2, ratmsq, d_atm, sw, & - do_pot, & - u_l, A, f, t, pot, vpair, fpair) -#endif - vij = vij + vpair - fij(1:3) = fij(1:3) + fpair(1:3) - - enddo inner1 - enddo - - if (in_switching_region) then - swderiv = vij*dswdr/rgrp - fij(1) = fij(1) + swderiv*d_grp(1) - fij(2) = fij(2) + swderiv*d_grp(2) - fij(3) = fij(3) + swderiv*d_grp(3) - - do ia=groupStart(i), groupStart(i+1)-1 - atom1=groupList(ia) - mf = mfact(atom1) -#ifdef IS_MPI - f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf - f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf - f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf -#else - f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf - f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf - f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf -#endif - enddo - - do jb=groupStart(j), groupStart(j+1)-1 - atom2=groupList(jb) - mf = mfact(atom2) -#ifdef IS_MPI - f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf - f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf - f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf -#else - f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf - f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf - f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf -#endif - enddo + if (do_stress) call add_stress_tensor(d_grp, fij) endif - - if (do_stress) call add_stress_tensor(d_grp, fij) - end if enddo - enddo - + enddo outer + + if (update_nlist) then #ifdef IS_MPI - point(nrow_group + 1) = nlist + 1 + point(nGroupsInRow + 1) = nlist + 1 #else - point(nGroup) = nlist + 1 + point(nGroups) = nlist + 1 #endif - - else !! (of update_check) - - ! use the list to find the neighbors - - istart = 1 -#ifdef IS_MPI - iend = nrow_group -#else - iend = nGroup - 1 -#endif - - do i = istart, iend - - n_in_i = groupStart(i+1) - groupStart(i) - - JBEG = POINT(i) - JEND = POINT(i+1) - 1 - ! check that group i has neighbors - if (jbeg .le. jend) then + if (loop .eq. PREPAIR_LOOP) then + ! we just did the neighbor list update on the first + ! pass, so we don't need to do it + ! again on the second pass + update_nlist = .false. + endif + endif - do jnab = jbeg, jend - j = list(jnab) - -#ifdef IS_MPI - call get_interatomic_vector(q_group_Row(:,i), & - q_group_Col(:,j), d_grp, rgrpsq) -#else - call get_interatomic_vector(q_group(:,i), & - q_group(:,j), d_grp, rgrpsq) -#endif - vij = 0.0d0 - fij(1:3) = 0.0d0 - - call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & - in_switching_region) - - n_in_j = groupStart(j+1) - groupStart(j) - - do ia = groupStart(i), groupStart(i+1)-1 - atom1 = groupList(ia) - - inner2: do jb = groupStart(j), groupStart(j+1)-1 - - atom2 = groupList(jb) - - if (skipThisPair(atom1, atom2)) cycle inner2 - - if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then - d_atm(1:3) = d_grp(1:3) - ratmsq = rgrpsq - else -#ifdef IS_MPI - call get_interatomic_vector(q_Row(:,atom1), & - q_Col(:,atom2), d_atm, ratmsq) -#else - call get_interatomic_vector(q(:,atom1), & - q(:,atom2), d_atm, ratmsq) -#endif - endif -#ifdef IS_MPI - call do_pair(atom1, atom2, ratmsq, d_atm, sw, & - do_pot, & - u_l, A, f, t, pot_local, vpair, fpair) -#else - call do_pair(atom1, atom2, ratmsq, d_atm, sw, & - do_pot, & - u_l, A, f, t, pot, vpair, fpair) -#endif - vij = vij + vpair - fij(1:3) = fij(1:3) + fpair(1:3) - - enddo inner2 - enddo - - if (in_switching_region) then - swderiv = vij*dswdr/rgrp - fij(1) = fij(1) + swderiv*d_grp(1) - fij(2) = fij(2) + swderiv*d_grp(2) - fij(3) = fij(3) + swderiv*d_grp(3) - - do ia=groupStart(i), groupStart(i+1)-1 - atom1=groupList(ia) - mf = mfact(atom1) -#ifdef IS_MPI - f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf - f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf - f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf -#else - f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf - f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf - f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf -#endif - enddo - - do jb=groupStart(j), groupStart(j+1)-1 - atom2=groupList(jb) - mf = mfact(atom2) -#ifdef IS_MPI - f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf - f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf - f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf -#else - f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf - f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf - f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf -#endif - enddo - endif - - if (do_stress) call add_stress_tensor(d_grp, fij) - - enddo - endif - enddo - endif - - ! phew, done with main loop. + if (loop .eq. PREPAIR_LOOP) then + call do_preforce(nlocal, pot) + endif + + enddo !! Do timing #ifdef PROFILE @@ -932,25 +688,25 @@ contains !!distribute forces f_temp = 0.0_dp - call scatter(f_Row,f_temp,plan_row3d) + call scatter(f_Row,f_temp,plan_atom_row_3d) do i = 1,nlocal f(1:3,i) = f(1:3,i) + f_temp(1:3,i) end do f_temp = 0.0_dp - call scatter(f_Col,f_temp,plan_col3d) + call scatter(f_Col,f_temp,plan_atom_col_3d) do i = 1,nlocal f(1:3,i) = f(1:3,i) + f_temp(1:3,i) end do if (FF_UsesDirectionalAtoms() .and. SIM_uses_directional_atoms) then t_temp = 0.0_dp - call scatter(t_Row,t_temp,plan_row3d) + call scatter(t_Row,t_temp,plan_atom_row_3d) do i = 1,nlocal t(1:3,i) = t(1:3,i) + t_temp(1:3,i) end do t_temp = 0.0_dp - call scatter(t_Col,t_temp,plan_col3d) + call scatter(t_Col,t_temp,plan_atom_col_3d) do i = 1,nlocal t(1:3,i) = t(1:3,i) + t_temp(1:3,i) @@ -959,7 +715,7 @@ contains if (do_pot) then ! scatter/gather pot_row into the members of my column - call scatter(pot_Row, pot_Temp, plan_row) + call scatter(pot_Row, pot_Temp, plan_atom_row) ! scatter/gather pot_local into all other procs ! add resultant to get total pot @@ -969,7 +725,7 @@ contains pot_Temp = 0.0_DP - call scatter(pot_Col, pot_Temp, plan_col) + call scatter(pot_Col, pot_Temp, plan_atom_col) do i = 1, nlocal pot_local = pot_local + pot_Temp(i) enddo @@ -982,8 +738,8 @@ contains if (FF_uses_RF .and. SIM_uses_RF) then #ifdef IS_MPI - call scatter(rf_Row,rf,plan_row3d) - call scatter(rf_Col,rf_Temp,plan_col3d) + call scatter(rf_Row,rf,plan_atom_row_3d) + call scatter(rf_Col,rf_Temp,plan_atom_col_3d) do i = 1,nlocal rf(1:3,i) = rf(1:3,i) + rf_Temp(1:3,i) end do @@ -1043,10 +799,8 @@ contains endif #endif - - + end subroutine do_force_loop - subroutine do_pair(i, j, rijsq, d, sw, do_pot, & u_l, A, f, t, pot, vpair, fpair) @@ -1071,8 +825,8 @@ contains fpair(1:3) = 0.0d0 #ifdef IS_MPI - if (tagRow(i) .eq. tagColumn(j)) then - write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j) + if (AtomRowToGlobal(i) .eq. AtomColToGlobal(j)) then + write(0,*) 'do_pair is doing', i , j, AtomRowToGlobal(i), AtomColToGlobal(j) endif me_i = atid_row(i) me_j = atid_col(j) @@ -1175,8 +929,8 @@ contains #ifdef IS_MPI - if (tagRow(i) .eq. tagColumn(j)) then - write(0,*) 'do_prepair is doing', i , j, tagRow(i), tagColumn(j) + if (AtomRowToGlobal(i) .eq. AtomColToGlobal(j)) then + write(0,*) 'do_prepair is doing', i , j, AtomRowToGlobal(i), AtomColToGlobal(j) endif me_i = atid_row(i) @@ -1323,7 +1077,7 @@ contains #ifdef IS_MPI !! in MPI, we have to look up the unique IDs for each atom - unique_id_1 = tagRow(atom1) + unique_id_1 = AtomRowToGlobal(atom1) #else !! in the normal loop, the atom numbers are unique unique_id_1 = atom1 @@ -1342,7 +1096,7 @@ contains end if #ifdef IS_MPI - unique_id_2 = tagColumn(atom2) + unique_id_2 = AtomColToGlobal(atom2) #else unique_id_2 = atom2 #endif