ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/do_Forces.F90
(Generate patch)

Comparing trunk/OOPSE/libmdtools/do_Forces.F90 (file contents):
Revision 394 by gezelter, Mon Mar 24 21:55:34 2003 UTC vs.
Revision 441 by chuckv, Tue Apr 1 16:50:14 2003 UTC

# Line 4 | Line 4
4  
5   !! @author Charles F. Vardeman II
6   !! @author Matthew Meineke
7 < !! @version $Id: do_Forces.F90,v 1.4 2003-03-24 21:55:34 gezelter Exp $, $Date: 2003-03-24 21:55:34 $, $Name: not supported by cvs2svn $, $Revision: 1.4 $
7 > !! @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 $
8  
9   module do_Forces
10    use force_globals
# Line 167 | Line 167 | contains
167      logical ( kind = 2) :: do_pot_c, do_stress_c
168      logical :: do_pot
169      logical :: do_stress
170 < #ifdef IS_MPI
170 > #ifdef IS_MPI
171      real( kind = DP ) :: pot_local
172      integer :: nrow
173      integer :: ncol
# Line 189 | Line 189 | contains
189      !! initialize local variables  
190  
191   #ifdef IS_MPI
192 +    pot_local = 0.0_dp
193      nlocal = getNlocal()
194      nrow   = getNrow(plan_row)
195      ncol   = getNcol(plan_col)
# Line 196 | Line 197 | contains
197      nlocal = getNlocal()
198      natoms = nlocal
199   #endif
200 <
200 >  
201      call getRcut(rcut,rc2=rcutsq)
202      call getRlist(rlist,rlistsq)
203      
# Line 277 | Line 278 | contains
278                                  
279                  if (rijsq <  rcutsq) then
280                     call do_pair(i, j, rijsq, d, do_pot, do_stress, &
281 <                        u_l, A, f, t,pot)
281 >                        u_l, A, f, t, pot_local)
282                  endif
283               endif
284            enddo inner
# Line 299 | Line 300 | contains
300  
301                  call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq)
302                  call do_pair(i, j, rijsq, d, do_pot, do_stress, &
303 <                     u_l, A, f, t,pot)
303 >                     u_l, A, f, t, pot_local)
304  
305               enddo
306            endif
# Line 346 | Line 347 | contains
347                  
348                  if (rijsq <  rcutsq) then
349                     call do_pair(i, j, rijsq, d, do_pot, do_stress, &
350 <                        u_l, A, f, t,pot)
350 >                        u_l, A, f, t, pot)
351                  endif
352               endif
353            enddo inner
# Line 368 | Line 369 | contains
369  
370                  call get_interatomic_vector(q(:,i), q(:,j), d, rijsq)
371                  call do_pair(i, j, rijsq, d, do_pot, do_stress, &
372 <                     u_l, A, f, t,pot)
372 >                     u_l, A, f, t, pot)
373  
374               enddo
375            endif
# Line 381 | Line 382 | contains
382      
383   #ifdef IS_MPI
384      !!distribute forces
385 <    
386 <    call scatter(f_Row,f,plan_row3d)
385 >  
386 >    f_temp = 0.0_dp
387 >    call scatter(f_Row,f_temp,plan_row3d)
388 >    do i = 1,nlocal
389 >       f(1:3,i) = f(1:3,i) + f_temp(1:3,i)
390 >    end do
391 >
392 >    f_temp = 0.0_dp
393      call scatter(f_Col,f_temp,plan_col3d)
394      do i = 1,nlocal
395         f(1:3,i) = f(1:3,i) + f_temp(1:3,i)
396      end do
397      
398      if (FF_UsesDirectionalAtoms() .and. SimUsesDirectionalAtoms()) then
399 <       call scatter(t_Row,t,plan_row3d)
399 >       t_temp = 0.0_dp
400 >       call scatter(t_Row,t_temp,plan_row3d)
401 >       do i = 1,nlocal
402 >          t(1:3,i) = t(1:3,i) + t_temp(1:3,i)
403 >       end do
404 >       t_temp = 0.0_dp
405         call scatter(t_Col,t_temp,plan_col3d)
406        
407         do i = 1,nlocal
# Line 400 | Line 412 | contains
412      if (do_pot) then
413         ! scatter/gather pot_row into the members of my column
414         call scatter(pot_Row, pot_Temp, plan_row)
415 <      
415 >
416         ! scatter/gather pot_local into all other procs
417         ! add resultant to get total pot
418         do i = 1, nlocal
419            pot_local = pot_local + pot_Temp(i)
420         enddo
421 +      
422 +       pot_Temp = 0.0_DP
423  
410       pot_Temp = 0.0_DP
411
424         call scatter(pot_Col, pot_Temp, plan_col)
425         do i = 1, nlocal
426            pot_local = pot_local + pot_Temp(i)
427         enddo
428 <      
428 >
429      endif    
430   #endif
431  
# Line 461 | Line 473 | contains
473   #ifdef IS_MPI
474  
475      if (do_pot) then
476 <       pot = pot_local
476 >       pot = pot + pot_local
477         !! we assume the c code will do the allreduce to get the total potential
478         !! we could do it right here if we needed to...
479      endif
# Line 484 | Line 496 | contains
496      
497    end subroutine do_force_loop
498  
499 <  subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t,pot)
499 >  subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot)
500  
501      real( kind = dp ) :: pot
502      real( kind = dp ), dimension(:,:) :: u_l
# Line 687 | Line 699 | contains
699   #else
700      unique_id_2 = atom2
701   #endif
702 <    
702 >
703   #ifdef IS_MPI
704      !! this situation should only arise in MPI simulations
705      if (unique_id_1 == unique_id_2) then
# Line 697 | Line 709 | contains
709      
710      !! this prevents us from doing the pair on multiple processors
711      if (unique_id_1 < unique_id_2) then
712 <       if (mod(unique_id_1 + unique_id_2,2) == 0) skip_it = .true.
713 <       return
712 >       if (mod(unique_id_1 + unique_id_2,2) == 0) then
713 >          skip_it = .true.
714 >          return
715 >       endif
716      else                
717 <       if (mod(unique_id_1 + unique_id_2,2) == 1) skip_it = .true.
718 <       return
717 >       if (mod(unique_id_1 + unique_id_2,2) == 1) then
718 >          skip_it = .true.
719 >          return
720 >       endif
721      endif
722   #endif
723 <
723 >
724      !! the rest of these situations can happen in all simulations:
725      do i = 1, nExcludes_global      
726         if ((excludesGlobal(i) == unique_id_1) .or. &
# Line 713 | Line 729 | contains
729            return
730         endif
731      enddo
732 <
732 >
733      do i = 1, nExcludes_local
734         if (excludesLocal(1,i) == unique_id_1) then
735            if (excludesLocal(2,i) == unique_id_2) then

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines