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 438 by chuckv, Mon Mar 31 21:50:59 2003 UTC vs.
Revision 482 by chuckv, Tue Apr 8 22:38:43 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.5 2003-03-31 21:50:59 chuckv Exp $, $Date: 2003-03-31 21:50:59 $, $Name: not supported by cvs2svn $, $Revision: 1.5 $
7 > !! @version $Id: do_Forces.F90,v 1.13 2003-04-08 22:38:43 chuckv Exp $, $Date: 2003-04-08 22:38:43 $, $Name: not supported by cvs2svn $, $Revision: 1.13 $
8  
9   module do_Forces
10    use force_globals
# Line 140 | Line 140 | contains
140  
141      if (FF_uses_GB .and. FF_uses_LJ) then
142      endif
143 +    if (.not. do_forces_initialized) then
144 +       !! Create neighbor lists
145 +       call expandNeighborList(getNlocal(), my_status)
146 +       if (my_Status /= 0) then
147 +          write(default_error,*) "SimSetup: ExpandNeighborList returned error."
148 +          thisStat = -1
149 +          return
150 +       endif
151 +    endif
152  
144
153      do_forces_initialized = .true.    
154  
155    end subroutine init_FF
# Line 167 | Line 175 | contains
175      logical ( kind = 2) :: do_pot_c, do_stress_c
176      logical :: do_pot
177      logical :: do_stress
178 < #ifdef IS_MPI
178 > #ifdef IS_MPI
179      real( kind = DP ) :: pot_local
180      integer :: nrow
181      integer :: ncol
# Line 189 | Line 197 | contains
197      !! initialize local variables  
198  
199   #ifdef IS_MPI
200 +    pot_local = 0.0_dp
201      nlocal = getNlocal()
202      nrow   = getNrow(plan_row)
203      ncol   = getNcol(plan_col)
# Line 196 | Line 205 | contains
205      nlocal = getNlocal()
206      natoms = nlocal
207   #endif
208 <
208 >  
209      call getRcut(rcut,rc2=rcutsq)
210      call getRlist(rlist,rlistsq)
211      
# Line 209 | Line 218 | contains
218  
219      do_pot = do_pot_c
220      do_stress = do_stress_c
221 +    
222  
223      ! Gather all information needed by all force loops:
224      
# Line 245 | Line 255 | contains
255        
256         !! save current configuration, construct neighbor list,
257         !! and calculate forces
258 <       call saveNeighborList(q)
258 >       call saveNeighborList(nlocal, q)
259        
260         neighborListSize = size(list)
261         nlist = 0      
# Line 277 | Line 287 | contains
287                                  
288                  if (rijsq <  rcutsq) then
289                     call do_pair(i, j, rijsq, d, do_pot, do_stress, &
290 <                        u_l, A, f, t,pot)
290 >                        u_l, A, f, t, pot_local)
291                  endif
292               endif
293            enddo inner
# Line 299 | Line 309 | contains
309  
310                  call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq)
311                  call do_pair(i, j, rijsq, d, do_pot, do_stress, &
312 <                     u_l, A, f, t,pot)
312 >                     u_l, A, f, t, pot_local)
313  
314               enddo
315            endif
# Line 312 | Line 322 | contains
322        
323         ! save current configuration, contruct neighbor list,
324         ! and calculate forces
325 <       call saveNeighborList(q)
325 >       call saveNeighborList(natoms, q)
326        
327         neighborListSize = size(list)
328    
# Line 346 | Line 356 | contains
356                  
357                  if (rijsq <  rcutsq) then
358                     call do_pair(i, j, rijsq, d, do_pot, do_stress, &
359 <                        u_l, A, f, t,pot)
359 >                        u_l, A, f, t, pot)
360                  endif
361               endif
362            enddo inner
# Line 368 | Line 378 | contains
378  
379                  call get_interatomic_vector(q(:,i), q(:,j), d, rijsq)
380                  call do_pair(i, j, rijsq, d, do_pot, do_stress, &
381 <                     u_l, A, f, t,pot)
381 >                     u_l, A, f, t, pot)
382  
383               enddo
384            endif
# Line 411 | Line 421 | contains
421      if (do_pot) then
422         ! scatter/gather pot_row into the members of my column
423         call scatter(pot_Row, pot_Temp, plan_row)
424 <      
424 >
425         ! scatter/gather pot_local into all other procs
426         ! add resultant to get total pot
427         do i = 1, nlocal
428            pot_local = pot_local + pot_Temp(i)
429         enddo
430 +      
431 +       pot_Temp = 0.0_DP
432  
421       pot_Temp = 0.0_DP
422
433         call scatter(pot_Col, pot_Temp, plan_col)
434         do i = 1, nlocal
435            pot_local = pot_local + pot_Temp(i)
436         enddo
437 <      
437 >
438      endif    
439   #endif
440  
# Line 472 | Line 482 | contains
482   #ifdef IS_MPI
483  
484      if (do_pot) then
485 <       write(*,*) "Fortran is on pot:, pot, pot_local ", pot,pot_local
476 <       pot = pot_local
485 >       pot = pot + pot_local
486         !! we assume the c code will do the allreduce to get the total potential
487         !! we could do it right here if we needed to...
488      endif
489  
490      if (do_stress) then
491 <       call mpi_allreduce(tau, tau_Temp,9,mpi_double_precision,mpi_sum, &
491 >       call mpi_allreduce(tau_Temp, tau,9,mpi_double_precision,mpi_sum, &
492              mpi_comm_world,mpi_err)
493 <       call mpi_allreduce(virial, virial_Temp,1,mpi_double_precision,mpi_sum, &
493 >       call mpi_allreduce(virial_Temp, virial,1,mpi_double_precision,mpi_sum, &
494              mpi_comm_world,mpi_err)
495      endif
496  
# Line 496 | Line 505 | contains
505      
506    end subroutine do_force_loop
507  
508 <  subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t,pot)
508 >  subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot)
509  
510      real( kind = dp ) :: pot
511 <    real( kind = dp ), dimension(:,:) :: u_l
512 <    real (kind=dp), dimension(:,:) :: A
513 <    real (kind=dp), dimension(:,:) :: f
514 <    real (kind=dp), dimension(:,:) :: t
511 >    real( kind = dp ), dimension(3,getNlocal()) :: u_l
512 >    real (kind=dp), dimension(9,getNlocal()) :: A
513 >    real (kind=dp), dimension(3,getNlocal()) :: f
514 >    real (kind=dp), dimension(3,getNlocal()) :: t
515  
516      logical, intent(inout) :: do_pot, do_stress
517      integer, intent(in) :: i, j
# Line 586 | Line 595 | contains
595      real ( kind = dp ), intent(out) :: r_sq
596      real( kind = dp ) :: d(3)
597      real( kind = dp ) :: d_old(3)
598 <    d(1:3) = q_i(1:3) - q_j(1:3)
598 >    d(1:3) = q_j(1:3) - q_i(1:3)
599      d_old = d
600      ! Wrap back into periodic box if necessary
601      if ( SimUsesPBC() ) then
# Line 655 | Line 664 | contains
664      rf = 0.0_dp
665      tau_Temp = 0.0_dp
666      virial_Temp = 0.0_dp
658    
667    end subroutine zero_work_arrays
668    
669    function skipThisPair(atom1, atom2) result(skip_it)
# Line 699 | Line 707 | contains
707   #else
708      unique_id_2 = atom2
709   #endif
710 <    
710 >
711   #ifdef IS_MPI
712      !! this situation should only arise in MPI simulations
713      if (unique_id_1 == unique_id_2) then
# Line 709 | Line 717 | contains
717      
718      !! this prevents us from doing the pair on multiple processors
719      if (unique_id_1 < unique_id_2) then
720 <       if (mod(unique_id_1 + unique_id_2,2) == 0) skip_it = .true.
721 <       return
720 >       if (mod(unique_id_1 + unique_id_2,2) == 0) then
721 >          skip_it = .true.
722 >          return
723 >       endif
724      else                
725 <       if (mod(unique_id_1 + unique_id_2,2) == 1) skip_it = .true.
726 <       return
725 >       if (mod(unique_id_1 + unique_id_2,2) == 1) then
726 >          skip_it = .true.
727 >          return
728 >       endif
729      endif
730   #endif
731 <
731 >
732      !! the rest of these situations can happen in all simulations:
733      do i = 1, nExcludes_global      
734         if ((excludesGlobal(i) == unique_id_1) .or. &
# Line 725 | Line 737 | contains
737            return
738         endif
739      enddo
740 <
740 >
741      do i = 1, nExcludes_local
742         if (excludesLocal(1,i) == unique_id_1) then
743            if (excludesLocal(2,i) == unique_id_2) then

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines