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 887 by mmeineke, Fri Dec 19 17:25:00 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.39 2003-12-19 17:25:00 mmeineke Exp $, $Date: 2003-12-19 17:25:00 $, $Name: not supported by cvs2svn $, $Revision: 1.39 $
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 +  public :: getforcetime
50 +  real, save :: forceTime = 0
51 +  real :: forceTimeInitial, forceTimeFinal
52 + #endif
53 +
54   contains
55  
56    subroutine setRlistDF( this_rlist )
# Line 141 | Line 149 | contains
149            return
150         end if
151      endif
152 +
153 +
154 +    if (FF_uses_EAM) then
155 +         call init_EAM_FF(my_status)
156 +       if (my_status /= 0) then
157 +          write(*,*) "init_EAM_FF returned a bad status"
158 +          thisStat = -1
159 +          return
160 +       end if
161 +    endif
162 +
163 +
164      
165      if (FF_uses_GB) then
166         call check_gb_pair_FF(my_status)
# Line 161 | Line 181 | contains
181            return
182         endif
183      endif
184 +    
185  
186      havePolicies = .true.
187      if( haveRlist ) do_forces_initialized = .true.
188 <    
188 >
189    end subroutine init_FF
190    
191  
# Line 192 | Line 213 | contains
213      real( kind = DP ) :: pot_local
214      integer :: nrow
215      integer :: ncol
216 +    integer :: nprocs
217   #endif
218      integer :: nlocal
219      integer :: natoms    
# Line 207 | Line 229 | contains
229      integer :: listerror, error
230      integer :: localError
231  
232 <    real(kind=dp) :: listSkin = 1.0
211 <    
232 >    real(kind=dp) :: listSkin = 1.0  
233  
234      !! initialize local variables  
235  
# Line 221 | Line 242 | contains
242      nlocal = getNlocal()
243      natoms = nlocal
244   #endif
245 <  
245 >
246      call check_initialization(localError)
247      if ( localError .ne. 0 ) then
248 +       call handleError("do_force_loop","Not Initialized")
249         error = -1
250         return
251      end if
# Line 232 | Line 254 | contains
254      do_pot = do_pot_c
255      do_stress = do_stress_c
256  
257 +
258      ! Gather all information needed by all force loops:
259      
260   #ifdef IS_MPI    
# Line 248 | Line 271 | contains
271      endif
272      
273   #endif
274 <    
274 >
275 > !! Begin force loop timing:
276 > #ifdef PROFILE
277 >    call cpu_time(forceTimeInitial)
278 >    nloops = nloops + 1
279 > #endif
280 >  
281      if (FF_RequiresPrepairCalc() .and. SimRequiresPrepairCalc()) then
282         !! See if we need to update neighbor lists
283         call checkNeighborList(nlocal, q, listSkin, update_nlist)  
# Line 256 | Line 285 | contains
285         !! do_prepair_loop_if_needed
286         !! if_mpi_scatter_stuff_from_prepair
287         !! if_mpi_gather_stuff_from_prepair_to_main_loop
288 <
288 >    
289   !--------------------PREFORCE LOOP----------->>>>>>>>>>>>>>>>>>>>>>>>>>>
290   #ifdef IS_MPI
291      
# Line 332 | Line 361 | contains
361         neighborListSize = size(list)
362    
363         nlist = 0
364 <      
364 >
365         do i = 1, natoms-1
366            point(i) = nlist + 1
367            
# Line 344 | Line 373 | contains
373            
374  
375               if (rijsq < rlistsq) then
376 <                
376 >
377 >          
378                  nlist = nlist + 1
379                
380                  if (nlist > neighborListSize) then
# Line 369 | Line 399 | contains
399         point(natoms) = nlist + 1
400        
401      else !! (update)
402 <      
402 >  
403         ! use the list to find the neighbors
404         do i = 1, natoms-1
405            JBEG = POINT(i)
# Line 390 | Line 420 | contains
420      endif    
421   #endif
422      !! Do rest of preforce calculations
423 <   call do_preforce(nlocal,pot)
423 >    !! do necessary preforce calculations  
424 >    call do_preforce(nlocal,pot)
425 >   ! we have already updated the neighbor list set it to false...
426 >   update_nlist = .false.
427      else
428         !! See if we need to update neighbor lists for non pre-pair
429         call checkNeighborList(nlocal, q, listSkin, update_nlist)  
# Line 409 | Line 442 | contains
442   #ifdef IS_MPI
443      
444      if (update_nlist) then
412      
445         !! save current configuration, construct neighbor list,
446         !! and calculate forces
447         call saveNeighborList(nlocal, q)
# Line 475 | Line 507 | contains
507   #else
508      
509      if (update_nlist) then
510 <      
510 >
511         ! save current configuration, contruct neighbor list,
512         ! and calculate forces
513         call saveNeighborList(natoms, q)
# Line 543 | Line 575 | contains
575   #endif
576      
577      ! phew, done with main loop.
578 <    
578 >
579 > !! Do timing
580 > #ifdef PROFILE
581 >    call cpu_time(forceTimeFinal)
582 >    forceTime = forceTime + forceTimeFinal - forceTimeInitial
583 > #endif
584 >
585 >
586   #ifdef IS_MPI
587      !!distribute forces
588    
# Line 655 | Line 694 | contains
694         tau = tau_Temp
695         virial = virial_Temp
696      endif
697 <
697 >    
698   #endif
699      
700 +    
701 +    
702    end subroutine do_force_loop
703  
704    subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot)
# Line 710 | Line 751 | contains
751         call getElementProperty(atypes, me_j, "is_DP", is_DP_j)
752        
753         if ( is_DP_i .and. is_DP_j ) then
713          
754            call do_dipole_pair(i, j, d, r, rijsq, pot, u_l, f, t, &
755                 do_pot, do_stress)
756            if (FF_uses_RF .and. SimUsesRF()) then
# Line 735 | Line 775 | contains
775  
776      if (FF_uses_GB .and. SimUsesGB()) then
777  
778 +
779         call getElementProperty(atypes, me_i, "is_GB", is_GB_i)
780         call getElementProperty(atypes, me_j, "is_GB", is_GB_j)
781        
# Line 780 | Line 821 | contains
821    
822     r = sqrt(rijsq)
823    
824 +
825   #ifdef IS_MPI
826     if (tagRow(i) .eq. tagColumn(j)) then
827        write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j)
# Line 794 | Line 836 | contains
836     me_j = atid(j)
837    
838   #endif
839 <  
839 >    
840     if (FF_uses_EAM .and. SimUsesEAM()) then
841        call getElementProperty(atypes, me_i, "is_EAM", is_EAM_i)
842        call getElementProperty(atypes, me_j, "is_EAM", is_EAM_j)
# Line 802 | Line 844 | contains
844        if ( is_EAM_i .and. is_EAM_j ) &
845             call calc_EAM_prepair_rho(i, j, d, r, rijsq )
846     endif
847 <  end subroutine do_prepair
847 >
848 > end subroutine do_prepair
849  
850  
851  
# Line 811 | Line 854 | contains
854      integer :: nlocal
855      real( kind = dp ) :: pot
856  
857 <   if (FF_uses_EAM .and. SimUsesEAM()) then
858 <      call calc_EAM_preforce_Frho(nlocal,pot)
859 <   endif
857 >    if (FF_uses_EAM .and. SimUsesEAM()) then
858 >       call calc_EAM_preforce_Frho(nlocal,pot)
859 >    endif
860  
861  
862    end subroutine do_preforce
# Line 876 | Line 919 | contains
919      error = 0
920      ! Make sure we are properly initialized.
921      if (.not. do_forces_initialized) then
922 +       write(*,*) "Forces not initialized"
923         error = -1
924         return
925      endif
# Line 923 | Line 967 | contains
967  
968   #endif
969  
970 +
971 +    if (FF_uses_EAM .and. SimUsesEAM()) then
972 +       call clean_EAM()
973 +    endif
974 +
975 +
976 +
977 +
978 +
979      rf = 0.0_dp
980      tau_Temp = 0.0_dp
981      virial_Temp = 0.0_dp
# Line 1035 | Line 1088 | end module do_Forces
1088      doesit = FF_uses_RF
1089    end function FF_RequiresPostpairCalc
1090    
1091 + #ifdef PROFILE
1092 +  function getforcetime() return(totalforcetime)
1093 +    real(kind=dp) :: totalforcetime
1094 +    totalforcetime = forcetime
1095 +  end function getforcetime
1096 + #endif
1097 +
1098 + !! This cleans componets of force arrays belonging only to fortran
1099 +
1100   end module do_Forces

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines