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 657 by chuckv, Wed Jul 30 21:17:01 2003 UTC vs.
Revision 726 by tim, Tue Aug 26 20:37:30 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.26 2003-07-30 21:17:01 chuckv Exp $, $Date: 2003-07-30 21:17:01 $, $Name: not supported by cvs2svn $, $Revision: 1.26 $
7 > !! @version $Id: do_Forces.F90,v 1.30 2003-08-26 20:37:30 tim Exp $, $Date: 2003-08-26 20:37:30 $, $Name: not supported by cvs2svn $, $Revision: 1.30 $
8  
9   module do_Forces
10    use force_globals
# Line 45 | Line 45 | contains
45    public :: do_force_loop
46    public :: setRlistDF
47  
48 + #ifdef PROFILE
49 +  real(kind = dp) :: forceTime
50 +  real(kind = dp) :: forceTimeInitial, forceTimeFinal
51 +  real(kind = dp) :: globalForceTime
52 +  real(kind = dp) :: maxForceTime
53 +  integer, save :: nloops = 0
54 + #endif
55 +
56   contains
57  
58    subroutine setRlistDF( this_rlist )
# Line 206 | Line 214 | contains
214      real( kind = DP ) :: pot_local
215      integer :: nrow
216      integer :: ncol
217 +    integer :: nprocs
218   #endif
219      integer :: nlocal
220      integer :: natoms    
# Line 235 | Line 244 | contains
244      nlocal = getNlocal()
245      natoms = nlocal
246   #endif
247 <    write(*,*) "Inside do_Force Loop"
247 >
248      call check_initialization(localError)
249      if ( localError .ne. 0 ) then
250         call handleError("do_force_loop","Not Initialized")
# Line 247 | Line 256 | contains
256      do_pot = do_pot_c
257      do_stress = do_stress_c
258  
259 +
260      ! Gather all information needed by all force loops:
261      
262   #ifdef IS_MPI    
# Line 263 | Line 273 | contains
273      endif
274      
275   #endif
276 <    
276 >
277 > !! Begin force loop timing:
278 > #ifdef PROFILE
279 >    call cpu_time(forceTimeInitial)
280 >    nloops = nloops + 1
281 > #endif
282 >  
283      if (FF_RequiresPrepairCalc() .and. SimRequiresPrepairCalc()) then
284         !! See if we need to update neighbor lists
285         call checkNeighborList(nlocal, q, listSkin, update_nlist)  
# Line 271 | Line 287 | contains
287         !! do_prepair_loop_if_needed
288         !! if_mpi_scatter_stuff_from_prepair
289         !! if_mpi_gather_stuff_from_prepair_to_main_loop
290 <
290 >    
291   !--------------------PREFORCE LOOP----------->>>>>>>>>>>>>>>>>>>>>>>>>>>
292   #ifdef IS_MPI
293      
# Line 347 | Line 363 | contains
363         neighborListSize = size(list)
364    
365         nlist = 0
366 <      
366 >
367         do i = 1, natoms-1
368            point(i) = nlist + 1
369            
# Line 359 | Line 375 | contains
375            
376  
377               if (rijsq < rlistsq) then
378 <                
378 >
379 >          
380                  nlist = nlist + 1
381                
382                  if (nlist > neighborListSize) then
# Line 384 | Line 401 | contains
401         point(natoms) = nlist + 1
402        
403      else !! (update)
404 <      
404 >  
405         ! use the list to find the neighbors
406         do i = 1, natoms-1
407            JBEG = POINT(i)
# Line 405 | Line 422 | contains
422      endif    
423   #endif
424      !! Do rest of preforce calculations
425 <   call do_preforce(nlocal,pot)
425 >    !! do necessary preforce calculations  
426 >    call do_preforce(nlocal,pot)
427 >   ! we have already updated the neighbor list set it to false...
428 >   update_nlist = .false.
429      else
430         !! See if we need to update neighbor lists for non pre-pair
431         call checkNeighborList(nlocal, q, listSkin, update_nlist)  
# Line 558 | Line 578 | contains
578   #endif
579      
580      ! phew, done with main loop.
581 <    
581 >
582 > !! Do timing
583 > #ifdef PROFILE
584 >    call cpu_time(forceTimeFinal)
585 >    forceTime = forceTime + forceTimeFinal - forceTimeInitial
586 > #endif
587 >
588 >
589   #ifdef IS_MPI
590      !!distribute forces
591    
# Line 672 | Line 699 | contains
699      endif
700  
701   #endif
702 <    
702 >
703 > #ifdef PROFILE
704 >    if (do_pot) then
705 >
706 > #ifdef IS_MPI
707 >
708 >      
709 >       call printCommTime()
710 >
711 >       call mpi_allreduce(forceTime,globalForceTime,1,MPI_DOUBLE_PRECISION, &
712 >            mpi_sum,mpi_comm_world,mpi_err)
713 >
714 >       call mpi_allreduce(forceTime,maxForceTime,1,MPI_DOUBLE_PRECISION, &
715 >            MPI_MAX,mpi_comm_world,mpi_err)
716 >      
717 >       call mpi_comm_size( MPI_COMM_WORLD, nprocs,mpi_err)
718 >      
719 >       if (getMyNode() == 0) then
720 >          write(*,*) "Total processor time spent in force calculations is: ", globalForceTime
721 >          write(*,*) "Total Time spent in force loop per processor is: ", globalforceTime/nprocs
722 >          write(*,*) "Maximum force time on any processor is: ", maxForceTime
723 >       end if
724 > #else
725 >       write(*,*) "Time spent in force loop is: ", forceTime
726 > #endif
727 >
728 >    
729 >    endif
730 >
731 > #endif
732 >
733 >
734 >
735    end subroutine do_force_loop
736  
737    subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot)
# Line 725 | Line 784 | contains
784         call getElementProperty(atypes, me_j, "is_DP", is_DP_j)
785        
786         if ( is_DP_i .and. is_DP_j ) then
728          
787            call do_dipole_pair(i, j, d, r, rijsq, pot, u_l, f, t, &
788                 do_pot, do_stress)
789            if (FF_uses_RF .and. SimUsesRF()) then
# Line 750 | Line 808 | contains
808  
809      if (FF_uses_GB .and. SimUsesGB()) then
810  
811 +
812         call getElementProperty(atypes, me_i, "is_GB", is_GB_i)
813         call getElementProperty(atypes, me_j, "is_GB", is_GB_j)
814        
# Line 795 | Line 854 | contains
854    
855     r = sqrt(rijsq)
856    
857 +
858   #ifdef IS_MPI
859     if (tagRow(i) .eq. tagColumn(j)) then
860        write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j)
# Line 809 | Line 869 | contains
869     me_j = atid(j)
870    
871   #endif
872 <  
872 >    
873     if (FF_uses_EAM .and. SimUsesEAM()) then
874        call getElementProperty(atypes, me_i, "is_EAM", is_EAM_i)
875        call getElementProperty(atypes, me_j, "is_EAM", is_EAM_j)
# Line 817 | Line 877 | contains
877        if ( is_EAM_i .and. is_EAM_j ) &
878             call calc_EAM_prepair_rho(i, j, d, r, rijsq )
879     endif
820  end subroutine do_prepair
880  
881 + end subroutine do_prepair
882  
883  
884  
885 +
886    subroutine do_preforce(nlocal,pot)
887      integer :: nlocal
888      real( kind = dp ) :: pot
889  
890 <   if (FF_uses_EAM .and. SimUsesEAM()) then
891 <      call calc_EAM_preforce_Frho(nlocal,pot)
892 <   endif
890 >    if (FF_uses_EAM .and. SimUsesEAM()) then
891 >       call calc_EAM_preforce_Frho(nlocal,pot)
892 >    endif
893  
894  
895    end subroutine do_preforce
# Line 939 | Line 1000 | contains
1000  
1001   #endif
1002  
1003 +
1004 +    if (FF_uses_EAM .and. SimUsesEAM()) then
1005 +       call clean_EAM()
1006 +    endif
1007 +
1008 +
1009 +
1010 +
1011 +
1012      rf = 0.0_dp
1013      tau_Temp = 0.0_dp
1014      virial_Temp = 0.0_dp
# Line 1051 | Line 1121 | end module do_Forces
1121      doesit = FF_uses_RF
1122    end function FF_RequiresPostpairCalc
1123    
1124 + !! This cleans componets of force arrays belonging only to fortran
1125 +
1126   end module do_Forces

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines