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

Comparing:
branches/mmeineke/OOPSE/libmdtools/do_Forces.F90 (file contents), Revision 377 by mmeineke, Fri Mar 21 17:42:12 2003 UTC vs.
trunk/OOPSE/libmdtools/do_Forces.F90 (file contents), Revision 462 by gezelter, Sat Apr 5 02:56:27 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.1.1.1 2003-03-21 17:42:12 mmeineke Exp $, $Date: 2003-03-21 17:42:12 $, $Name: not supported by cvs2svn $, $Revision: 1.1.1.1 $
7 > !! @version $Id: do_Forces.F90,v 1.10 2003-04-05 02:56:27 gezelter Exp $, $Date: 2003-04-05 02:56:27 $, $Name: not supported by cvs2svn $, $Revision: 1.10 $
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 245 | Line 246 | contains
246        
247         !! save current configuration, construct neighbor list,
248         !! and calculate forces
249 <       call saveNeighborList(q)
249 >       call saveNeighborList(nlocal, q)
250        
251         neighborListSize = size(list)
252         nlist = 0      
# 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 312 | Line 313 | contains
313        
314         ! save current configuration, contruct neighbor list,
315         ! and calculate forces
316 <       call saveNeighborList(q)
316 >       call saveNeighborList(natoms, q)
317        
318         neighborListSize = size(list)
319    
# Line 323 | Line 324 | contains
324            
325            inner: do j = i+1, natoms
326              
327 <             if (skipThisPair(i,j)) cycle inner
328 <            
327 >             if (skipThisPair(i,j))  cycle inner
328 >                          
329               call get_interatomic_vector(q(:,i), q(:,j), d, rijsq)
330            
331 +
332               if (rijsq <  rlistsq) then
333                  
334                  nlist = nlist + 1
# Line 345 | 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 367 | 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 380 | 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 399 | 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
421 >      
422 >       pot_Temp = 0.0_DP
423  
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 460 | 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 483 | 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
503 <    real (kind=dp), dimension(:,:) :: A
504 <    real (kind=dp), dimension(:,:) :: f
505 <    real (kind=dp), dimension(:,:) :: t
502 >    real( kind = dp ), dimension(3,getNlocal()) :: u_l
503 >    real (kind=dp), dimension(9,getNlocal()) :: A
504 >    real (kind=dp), dimension(3,getNlocal()) :: f
505 >    real (kind=dp), dimension(3,getNlocal()) :: t
506  
507      logical, intent(inout) :: do_pot, do_stress
508      integer, intent(in) :: i, j
# Line 532 | Line 545 | contains
545            
546            call do_dipole_pair(i, j, d, r, rijsq, pot, u_l, f, t, &
547                 do_pot, do_stress)
535          
548            if (FF_uses_RF .and. SimUsesRF()) then
537            
549               call accumulate_rf(i, j, r, u_l)
550               call rf_correct_forces(i, j, d, r, u_l, f, do_stress)
540            
551            endif
552            
553         endif
# Line 547 | Line 557 | contains
557  
558         call getElementProperty(atypes, me_i, "is_Sticky", is_Sticky_i)
559         call getElementProperty(atypes, me_j, "is_Sticky", is_Sticky_j)
560 <      
560 >
561         if ( is_Sticky_i .and. is_Sticky_j ) then
562            call do_sticky_pair(i, j, d, r, rijsq, A, pot, f, t, &
563                 do_pot, do_stress)
# Line 580 | Line 590 | contains
590      d_old = d
591      ! Wrap back into periodic box if necessary
592      if ( SimUsesPBC() ) then
593 <
593 >      
594         d(1:3) = d(1:3) - box(1:3) * sign(1.0_dp,d(1:3)) * &
595              int(abs(d(1:3)/box(1:3)) + 0.5_dp)
596 <
596 >      
597      endif
598      r_sq = dot_product(d,d)
599          
# Line 649 | Line 659 | contains
659    end subroutine zero_work_arrays
660    
661    function skipThisPair(atom1, atom2) result(skip_it)
652    
662      integer, intent(in) :: atom1
663      integer, intent(in), optional :: atom2
664      logical :: skip_it
665      integer :: unique_id_1, unique_id_2
666 +    integer :: me_i,me_j
667      integer :: i
668  
669      skip_it = .false.
# Line 671 | Line 681 | contains
681      !! in the normal loop, the atom numbers are unique
682      unique_id_1 = atom1
683   #endif
684 <    
684 >
685      !! We were called with only one atom, so just check the global exclude
686      !! list for this atom
687      if (.not. present(atom2)) then
# Line 689 | 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 699 | 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 715 | 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