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 648 by chuckv, Wed Jul 23 22:13:59 2003 UTC vs.
Revision 872 by chrisfen, Fri Nov 21 19:31:05 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.24 2003-07-23 22:13:59 chuckv Exp $, $Date: 2003-07-23 22:13:59 $, $Name: not supported by cvs2svn $, $Revision: 1.24 $
7 > !! @version $Id: do_Forces.F90,v 1.37 2003-11-21 19:31:05 chrisfen Exp $, $Date: 2003-11-21 19:31:05 $, $Name: not supported by cvs2svn $, $Revision: 1.37 $
8  
9   module do_Forces
10    use force_globals
# Line 18 | Line 18 | module do_Forces
18    use reaction_field
19    use gb_pair
20    use vector_class
21 +  use eam
22 +  use status
23   #ifdef IS_MPI
24    use mpiSimulation
25   #endif
# Line 43 | 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 141 | Line 151 | contains
151            return
152         end if
153      endif
154 +
155 +
156 +    if (FF_uses_EAM) then
157 +         call init_EAM_FF(my_status)
158 +       if (my_status /= 0) then
159 +          write(*,*) "init_EAM_FF returned a bad status"
160 +          thisStat = -1
161 +          return
162 +       end if
163 +    endif
164 +
165 +
166      
167      if (FF_uses_GB) then
168         call check_gb_pair_FF(my_status)
# Line 161 | Line 183 | contains
183            return
184         endif
185      endif
186 +    
187  
188      havePolicies = .true.
189      if( haveRlist ) do_forces_initialized = .true.
190 <    
190 >
191    end subroutine init_FF
192    
193  
# Line 192 | Line 215 | contains
215      real( kind = DP ) :: pot_local
216      integer :: nrow
217      integer :: ncol
218 +    integer :: nprocs
219   #endif
220      integer :: nlocal
221      integer :: natoms    
# Line 207 | Line 231 | contains
231      integer :: listerror, error
232      integer :: localError
233  
234 <    real(kind=dp) :: listSkin = 1.0
211 <    
234 >    real(kind=dp) :: listSkin = 1.0  
235  
236      !! initialize local variables  
237  
# Line 221 | Line 244 | contains
244      nlocal = getNlocal()
245      natoms = nlocal
246   #endif
247 <  
247 >
248      call check_initialization(localError)
249      if ( localError .ne. 0 ) then
250 +       call handleError("do_force_loop","Not Initialized")
251         error = -1
252         return
253      end if
# Line 232 | 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 248 | 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 256 | 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 332 | 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 344 | Line 375 | contains
375            
376  
377               if (rijsq < rlistsq) then
378 <                
378 >
379 >          
380                  nlist = nlist + 1
381                
382                  if (nlist > neighborListSize) then
# Line 369 | 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 390 | 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 409 | Line 444 | contains
444   #ifdef IS_MPI
445      
446      if (update_nlist) then
412      
447         !! save current configuration, construct neighbor list,
448         !! and calculate forces
449         call saveNeighborList(nlocal, q)
# Line 475 | Line 509 | contains
509   #else
510      
511      if (update_nlist) then
512 <      
512 >
513         ! save current configuration, contruct neighbor list,
514         ! and calculate forces
515         call saveNeighborList(natoms, q)
# Line 543 | Line 577 | contains
577   #endif
578      
579      ! phew, done with main loop.
580 <    
580 >
581 > !! Do timing
582 > #ifdef PROFILE
583 >    call cpu_time(forceTimeFinal)
584 >    forceTime = forceTime + forceTimeFinal - forceTimeInitial
585 > #endif
586 >
587 >
588   #ifdef IS_MPI
589      !!distribute forces
590    
# Line 657 | Line 698 | contains
698      endif
699  
700   #endif
701 <    
701 >
702 > #ifdef PROFILE
703 >    if (do_pot) then
704 >
705 > #ifdef IS_MPI
706 >
707 >      
708 >       call printCommTime()
709 >
710 >       call mpi_allreduce(forceTime,globalForceTime,1,MPI_DOUBLE_PRECISION, &
711 >            mpi_sum,mpi_comm_world,mpi_err)
712 >
713 >       call mpi_allreduce(forceTime,maxForceTime,1,MPI_DOUBLE_PRECISION, &
714 >            MPI_MAX,mpi_comm_world,mpi_err)
715 >      
716 >       call mpi_comm_size( MPI_COMM_WORLD, nprocs,mpi_err)
717 >      
718 >       if (getMyNode() == 0) then
719 >          write(*,*) "Total processor time spent in force calculations is: ", globalForceTime
720 >          write(*,*) "Total Time spent in force loop per processor is: ", globalforceTime/nprocs
721 >          write(*,*) "Maximum force time on any processor is: ", maxForceTime
722 >       end if
723 > #else
724 >       write(*,*) "Time spent in force loop is: ", forceTime
725 > #endif
726 >
727 >    
728 >    endif
729 >
730 > #endif
731 >
732    end subroutine do_force_loop
733  
734    subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot)
# Line 710 | Line 781 | contains
781         call getElementProperty(atypes, me_j, "is_DP", is_DP_j)
782        
783         if ( is_DP_i .and. is_DP_j ) then
713          
784            call do_dipole_pair(i, j, d, r, rijsq, pot, u_l, f, t, &
785                 do_pot, do_stress)
786            if (FF_uses_RF .and. SimUsesRF()) then
# Line 735 | Line 805 | contains
805  
806      if (FF_uses_GB .and. SimUsesGB()) then
807  
808 +
809         call getElementProperty(atypes, me_i, "is_GB", is_GB_i)
810         call getElementProperty(atypes, me_j, "is_GB", is_GB_j)
811        
# Line 780 | Line 851 | contains
851    
852     r = sqrt(rijsq)
853    
854 +
855   #ifdef IS_MPI
856     if (tagRow(i) .eq. tagColumn(j)) then
857        write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j)
# Line 794 | Line 866 | contains
866     me_j = atid(j)
867    
868   #endif
869 <  
869 >    
870     if (FF_uses_EAM .and. SimUsesEAM()) then
871        call getElementProperty(atypes, me_i, "is_EAM", is_EAM_i)
872        call getElementProperty(atypes, me_j, "is_EAM", is_EAM_j)
# Line 802 | Line 874 | contains
874        if ( is_EAM_i .and. is_EAM_j ) &
875             call calc_EAM_prepair_rho(i, j, d, r, rijsq )
876     endif
805  end subroutine do_prepair
877  
878 + end subroutine do_prepair
879  
880  
881  
882 +
883    subroutine do_preforce(nlocal,pot)
884      integer :: nlocal
885      real( kind = dp ) :: pot
886  
887 <   if (FF_uses_EAM .and. SimUsesEAM()) then
888 <      call calc_EAM_preforce_Frho(nlocal,pot)
889 <   endif
887 >    if (FF_uses_EAM .and. SimUsesEAM()) then
888 >       call calc_EAM_preforce_Frho(nlocal,pot)
889 >    endif
890  
891  
892    end subroutine do_preforce
# Line 876 | Line 949 | contains
949      error = 0
950      ! Make sure we are properly initialized.
951      if (.not. do_forces_initialized) then
952 +       write(*,*) "Forces not initialized"
953         error = -1
954         return
955      endif
# Line 923 | Line 997 | contains
997  
998   #endif
999  
1000 +
1001 +    if (FF_uses_EAM .and. SimUsesEAM()) then
1002 +       call clean_EAM()
1003 +    endif
1004 +
1005 +
1006 +
1007 +
1008 +
1009      rf = 0.0_dp
1010      tau_Temp = 0.0_dp
1011      virial_Temp = 0.0_dp
# Line 1035 | Line 1118 | end module do_Forces
1118      doesit = FF_uses_RF
1119    end function FF_RequiresPostpairCalc
1120    
1121 + !! This cleans componets of force arrays belonging only to fortran
1122 +
1123   end module do_Forces

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines