--- trunk/OOPSE/libmdtools/do_Forces.F90 2003/07/30 21:17:01 657 +++ trunk/OOPSE/libmdtools/do_Forces.F90 2003/10/29 20:41:39 843 @@ -4,7 +4,7 @@ !! @author Charles F. Vardeman II !! @author Matthew Meineke -!! @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 $ +!! @version $Id: do_Forces.F90,v 1.35 2003-10-29 20:41:39 mmeineke Exp $, $Date: 2003-10-29 20:41:39 $, $Name: not supported by cvs2svn $, $Revision: 1.35 $ module do_Forces use force_globals @@ -45,6 +45,14 @@ contains public :: do_force_loop public :: setRlistDF +#ifdef PROFILE + real(kind = dp) :: forceTime + real(kind = dp) :: forceTimeInitial, forceTimeFinal + real(kind = dp) :: globalForceTime + real(kind = dp) :: maxForceTime + integer, save :: nloops = 0 +#endif + contains subroutine setRlistDF( this_rlist ) @@ -146,8 +154,9 @@ contains if (FF_uses_EAM) then - call init_EAM_FF(my_status) + call init_EAM_FF(my_status) if (my_status /= 0) then + write(*,*) "init_EAM_FF returned a bad status" thisStat = -1 return end if @@ -206,6 +215,7 @@ contains real( kind = DP ) :: pot_local integer :: nrow integer :: ncol + integer :: nprocs #endif integer :: nlocal integer :: natoms @@ -235,7 +245,7 @@ contains nlocal = getNlocal() natoms = nlocal #endif - write(*,*) "Inside do_Force Loop" + call check_initialization(localError) if ( localError .ne. 0 ) then call handleError("do_force_loop","Not Initialized") @@ -247,6 +257,7 @@ contains do_pot = do_pot_c do_stress = do_stress_c + ! Gather all information needed by all force loops: #ifdef IS_MPI @@ -263,7 +274,13 @@ contains endif #endif - + +!! Begin force loop timing: +#ifdef PROFILE + call cpu_time(forceTimeInitial) + nloops = nloops + 1 +#endif + if (FF_RequiresPrepairCalc() .and. SimRequiresPrepairCalc()) then !! See if we need to update neighbor lists call checkNeighborList(nlocal, q, listSkin, update_nlist) @@ -271,7 +288,7 @@ contains !! do_prepair_loop_if_needed !! if_mpi_scatter_stuff_from_prepair !! if_mpi_gather_stuff_from_prepair_to_main_loop - + !--------------------PREFORCE LOOP----------->>>>>>>>>>>>>>>>>>>>>>>>>>> #ifdef IS_MPI @@ -347,7 +364,7 @@ contains neighborListSize = size(list) nlist = 0 - + do i = 1, natoms-1 point(i) = nlist + 1 @@ -359,7 +376,8 @@ contains if (rijsq < rlistsq) then - + + nlist = nlist + 1 if (nlist > neighborListSize) then @@ -384,7 +402,7 @@ contains point(natoms) = nlist + 1 else !! (update) - + ! use the list to find the neighbors do i = 1, natoms-1 JBEG = POINT(i) @@ -405,7 +423,10 @@ contains endif #endif !! Do rest of preforce calculations - call do_preforce(nlocal,pot) + !! do necessary preforce calculations + call do_preforce(nlocal,pot) + ! we have already updated the neighbor list set it to false... + update_nlist = .false. else !! See if we need to update neighbor lists for non pre-pair call checkNeighborList(nlocal, q, listSkin, update_nlist) @@ -558,7 +579,14 @@ contains #endif ! phew, done with main loop. - + +!! Do timing +#ifdef PROFILE + call cpu_time(forceTimeFinal) + forceTime = forceTime + forceTimeFinal - forceTimeInitial +#endif + + #ifdef IS_MPI !!distribute forces @@ -672,7 +700,37 @@ contains endif #endif - + +#ifdef PROFILE + if (do_pot) then + +#ifdef IS_MPI + + + call printCommTime() + + call mpi_allreduce(forceTime,globalForceTime,1,MPI_DOUBLE_PRECISION, & + mpi_sum,mpi_comm_world,mpi_err) + + call mpi_allreduce(forceTime,maxForceTime,1,MPI_DOUBLE_PRECISION, & + MPI_MAX,mpi_comm_world,mpi_err) + + call mpi_comm_size( MPI_COMM_WORLD, nprocs,mpi_err) + + if (getMyNode() == 0) then + write(*,*) "Total processor time spent in force calculations is: ", globalForceTime + write(*,*) "Total Time spent in force loop per processor is: ", globalforceTime/nprocs + write(*,*) "Maximum force time on any processor is: ", maxForceTime + end if +#else + write(*,*) "Time spent in force loop is: ", forceTime +#endif + + + endif + +#endif + end subroutine do_force_loop subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot) @@ -725,7 +783,6 @@ contains call getElementProperty(atypes, me_j, "is_DP", is_DP_j) if ( is_DP_i .and. is_DP_j ) then - call do_dipole_pair(i, j, d, r, rijsq, pot, u_l, f, t, & do_pot, do_stress) if (FF_uses_RF .and. SimUsesRF()) then @@ -750,6 +807,7 @@ contains if (FF_uses_GB .and. SimUsesGB()) then + call getElementProperty(atypes, me_i, "is_GB", is_GB_i) call getElementProperty(atypes, me_j, "is_GB", is_GB_j) @@ -795,6 +853,7 @@ contains r = sqrt(rijsq) + #ifdef IS_MPI if (tagRow(i) .eq. tagColumn(j)) then write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j) @@ -809,7 +868,7 @@ contains me_j = atid(j) #endif - + if (FF_uses_EAM .and. SimUsesEAM()) then call getElementProperty(atypes, me_i, "is_EAM", is_EAM_i) call getElementProperty(atypes, me_j, "is_EAM", is_EAM_j) @@ -817,18 +876,19 @@ contains if ( is_EAM_i .and. is_EAM_j ) & call calc_EAM_prepair_rho(i, j, d, r, rijsq ) endif - end subroutine do_prepair + end subroutine do_prepair + subroutine do_preforce(nlocal,pot) integer :: nlocal real( kind = dp ) :: pot - if (FF_uses_EAM .and. SimUsesEAM()) then - call calc_EAM_preforce_Frho(nlocal,pot) - endif + if (FF_uses_EAM .and. SimUsesEAM()) then + call calc_EAM_preforce_Frho(nlocal,pot) + endif end subroutine do_preforce @@ -939,6 +999,15 @@ contains #endif + + if (FF_uses_EAM .and. SimUsesEAM()) then + call clean_EAM() + endif + + + + + rf = 0.0_dp tau_Temp = 0.0_dp virial_Temp = 0.0_dp @@ -1051,4 +1120,6 @@ end module do_Forces doesit = FF_uses_RF end function FF_RequiresPostpairCalc +!! This cleans componets of force arrays belonging only to fortran + end module do_Forces