4 |
|
|
5 |
|
!! @author Charles F. Vardeman II |
6 |
|
!! @author Matthew Meineke |
7 |
< |
!! @version $Id: do_Forces.F90,v 1.25 2003-07-24 19:57:35 chuckv Exp $, $Date: 2003-07-24 19:57:35 $, $Name: not supported by cvs2svn $, $Revision: 1.25 $ |
7 |
> |
!! @version $Id: do_Forces.F90,v 1.40 2003-12-19 20:36:35 mmeineke Exp $, $Date: 2003-12-19 20:36:35 $, $Name: not supported by cvs2svn $, $Revision: 1.40 $ |
8 |
|
|
9 |
|
module do_Forces |
10 |
|
use force_globals |
19 |
|
use gb_pair |
20 |
|
use vector_class |
21 |
|
use eam |
22 |
+ |
use status |
23 |
|
#ifdef IS_MPI |
24 |
|
use mpiSimulation |
25 |
|
#endif |
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 |
+ |
integer :: nLoops |
53 |
+ |
#endif |
54 |
+ |
|
55 |
|
contains |
56 |
|
|
57 |
|
subroutine setRlistDF( this_rlist ) |
150 |
|
return |
151 |
|
end if |
152 |
|
endif |
153 |
+ |
|
154 |
+ |
|
155 |
+ |
if (FF_uses_EAM) then |
156 |
+ |
call init_EAM_FF(my_status) |
157 |
+ |
if (my_status /= 0) then |
158 |
+ |
write(*,*) "init_EAM_FF returned a bad status" |
159 |
+ |
thisStat = -1 |
160 |
+ |
return |
161 |
+ |
end if |
162 |
+ |
endif |
163 |
+ |
|
164 |
+ |
|
165 |
|
|
166 |
|
if (FF_uses_GB) then |
167 |
|
call check_gb_pair_FF(my_status) |
182 |
|
return |
183 |
|
endif |
184 |
|
endif |
185 |
+ |
|
186 |
|
|
187 |
|
havePolicies = .true. |
188 |
|
if( haveRlist ) do_forces_initialized = .true. |
189 |
< |
|
189 |
> |
|
190 |
|
end subroutine init_FF |
191 |
|
|
192 |
|
|
214 |
|
real( kind = DP ) :: pot_local |
215 |
|
integer :: nrow |
216 |
|
integer :: ncol |
217 |
+ |
integer :: nprocs |
218 |
|
#endif |
219 |
|
integer :: nlocal |
220 |
|
integer :: natoms |
230 |
|
integer :: listerror, error |
231 |
|
integer :: localError |
232 |
|
|
233 |
< |
real(kind=dp) :: listSkin = 1.0 |
212 |
< |
|
233 |
> |
real(kind=dp) :: listSkin = 1.0 |
234 |
|
|
235 |
|
!! initialize local variables |
236 |
|
|
243 |
|
nlocal = getNlocal() |
244 |
|
natoms = nlocal |
245 |
|
#endif |
246 |
< |
|
246 |
> |
|
247 |
|
call check_initialization(localError) |
248 |
|
if ( localError .ne. 0 ) then |
249 |
+ |
call handleError("do_force_loop","Not Initialized") |
250 |
|
error = -1 |
251 |
|
return |
252 |
|
end if |
255 |
|
do_pot = do_pot_c |
256 |
|
do_stress = do_stress_c |
257 |
|
|
258 |
+ |
|
259 |
|
! Gather all information needed by all force loops: |
260 |
|
|
261 |
|
#ifdef IS_MPI |
272 |
|
endif |
273 |
|
|
274 |
|
#endif |
275 |
< |
|
275 |
> |
|
276 |
> |
!! Begin force loop timing: |
277 |
> |
#ifdef PROFILE |
278 |
> |
call cpu_time(forceTimeInitial) |
279 |
> |
nloops = nloops + 1 |
280 |
> |
#endif |
281 |
> |
|
282 |
|
if (FF_RequiresPrepairCalc() .and. SimRequiresPrepairCalc()) then |
283 |
|
!! See if we need to update neighbor lists |
284 |
|
call checkNeighborList(nlocal, q, listSkin, update_nlist) |
286 |
|
!! do_prepair_loop_if_needed |
287 |
|
!! if_mpi_scatter_stuff_from_prepair |
288 |
|
!! if_mpi_gather_stuff_from_prepair_to_main_loop |
289 |
< |
|
289 |
> |
|
290 |
|
!--------------------PREFORCE LOOP----------->>>>>>>>>>>>>>>>>>>>>>>>>>> |
291 |
|
#ifdef IS_MPI |
292 |
|
|
362 |
|
neighborListSize = size(list) |
363 |
|
|
364 |
|
nlist = 0 |
365 |
< |
|
365 |
> |
|
366 |
|
do i = 1, natoms-1 |
367 |
|
point(i) = nlist + 1 |
368 |
|
|
374 |
|
|
375 |
|
|
376 |
|
if (rijsq < rlistsq) then |
377 |
< |
|
377 |
> |
|
378 |
> |
|
379 |
|
nlist = nlist + 1 |
380 |
|
|
381 |
|
if (nlist > neighborListSize) then |
400 |
|
point(natoms) = nlist + 1 |
401 |
|
|
402 |
|
else !! (update) |
403 |
< |
|
403 |
> |
|
404 |
|
! use the list to find the neighbors |
405 |
|
do i = 1, natoms-1 |
406 |
|
JBEG = POINT(i) |
421 |
|
endif |
422 |
|
#endif |
423 |
|
!! Do rest of preforce calculations |
424 |
< |
call do_preforce(nlocal,pot) |
424 |
> |
!! do necessary preforce calculations |
425 |
> |
call do_preforce(nlocal,pot) |
426 |
> |
! we have already updated the neighbor list set it to false... |
427 |
> |
update_nlist = .false. |
428 |
|
else |
429 |
|
!! See if we need to update neighbor lists for non pre-pair |
430 |
|
call checkNeighborList(nlocal, q, listSkin, update_nlist) |
443 |
|
#ifdef IS_MPI |
444 |
|
|
445 |
|
if (update_nlist) then |
413 |
– |
|
446 |
|
!! save current configuration, construct neighbor list, |
447 |
|
!! and calculate forces |
448 |
|
call saveNeighborList(nlocal, q) |
508 |
|
#else |
509 |
|
|
510 |
|
if (update_nlist) then |
511 |
< |
|
511 |
> |
|
512 |
|
! save current configuration, contruct neighbor list, |
513 |
|
! and calculate forces |
514 |
|
call saveNeighborList(natoms, q) |
576 |
|
#endif |
577 |
|
|
578 |
|
! phew, done with main loop. |
579 |
< |
|
579 |
> |
|
580 |
> |
!! Do timing |
581 |
> |
#ifdef PROFILE |
582 |
> |
call cpu_time(forceTimeFinal) |
583 |
> |
forceTime = forceTime + forceTimeFinal - forceTimeInitial |
584 |
> |
#endif |
585 |
> |
|
586 |
> |
|
587 |
|
#ifdef IS_MPI |
588 |
|
!!distribute forces |
589 |
|
|
695 |
|
tau = tau_Temp |
696 |
|
virial = virial_Temp |
697 |
|
endif |
698 |
< |
|
698 |
> |
|
699 |
|
#endif |
700 |
|
|
701 |
+ |
|
702 |
+ |
|
703 |
|
end subroutine do_force_loop |
704 |
|
|
705 |
|
subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot) |
752 |
|
call getElementProperty(atypes, me_j, "is_DP", is_DP_j) |
753 |
|
|
754 |
|
if ( is_DP_i .and. is_DP_j ) then |
714 |
– |
|
755 |
|
call do_dipole_pair(i, j, d, r, rijsq, pot, u_l, f, t, & |
756 |
|
do_pot, do_stress) |
757 |
|
if (FF_uses_RF .and. SimUsesRF()) then |
776 |
|
|
777 |
|
if (FF_uses_GB .and. SimUsesGB()) then |
778 |
|
|
779 |
+ |
|
780 |
|
call getElementProperty(atypes, me_i, "is_GB", is_GB_i) |
781 |
|
call getElementProperty(atypes, me_j, "is_GB", is_GB_j) |
782 |
|
|
822 |
|
|
823 |
|
r = sqrt(rijsq) |
824 |
|
|
825 |
+ |
|
826 |
|
#ifdef IS_MPI |
827 |
|
if (tagRow(i) .eq. tagColumn(j)) then |
828 |
|
write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j) |
837 |
|
me_j = atid(j) |
838 |
|
|
839 |
|
#endif |
840 |
< |
|
840 |
> |
|
841 |
|
if (FF_uses_EAM .and. SimUsesEAM()) then |
842 |
|
call getElementProperty(atypes, me_i, "is_EAM", is_EAM_i) |
843 |
|
call getElementProperty(atypes, me_j, "is_EAM", is_EAM_j) |
845 |
|
if ( is_EAM_i .and. is_EAM_j ) & |
846 |
|
call calc_EAM_prepair_rho(i, j, d, r, rijsq ) |
847 |
|
endif |
848 |
< |
end subroutine do_prepair |
848 |
> |
|
849 |
> |
end subroutine do_prepair |
850 |
|
|
851 |
|
|
852 |
|
|
855 |
|
integer :: nlocal |
856 |
|
real( kind = dp ) :: pot |
857 |
|
|
858 |
< |
if (FF_uses_EAM .and. SimUsesEAM()) then |
859 |
< |
call calc_EAM_preforce_Frho(nlocal,pot) |
860 |
< |
endif |
858 |
> |
if (FF_uses_EAM .and. SimUsesEAM()) then |
859 |
> |
call calc_EAM_preforce_Frho(nlocal,pot) |
860 |
> |
endif |
861 |
|
|
862 |
|
|
863 |
|
end subroutine do_preforce |
920 |
|
error = 0 |
921 |
|
! Make sure we are properly initialized. |
922 |
|
if (.not. do_forces_initialized) then |
923 |
+ |
write(*,*) "Forces not initialized" |
924 |
|
error = -1 |
925 |
|
return |
926 |
|
endif |
968 |
|
|
969 |
|
#endif |
970 |
|
|
971 |
+ |
|
972 |
+ |
if (FF_uses_EAM .and. SimUsesEAM()) then |
973 |
+ |
call clean_EAM() |
974 |
+ |
endif |
975 |
+ |
|
976 |
+ |
|
977 |
+ |
|
978 |
+ |
|
979 |
+ |
|
980 |
|
rf = 0.0_dp |
981 |
|
tau_Temp = 0.0_dp |
982 |
|
virial_Temp = 0.0_dp |
1089 |
|
doesit = FF_uses_RF |
1090 |
|
end function FF_RequiresPostpairCalc |
1091 |
|
|
1092 |
+ |
#ifdef PROFILE |
1093 |
+ |
function getforcetime() result(totalforcetime) |
1094 |
+ |
real(kind=dp) :: totalforcetime |
1095 |
+ |
totalforcetime = forcetime |
1096 |
+ |
end function getforcetime |
1097 |
+ |
#endif |
1098 |
+ |
|
1099 |
+ |
!! This cleans componets of force arrays belonging only to fortran |
1100 |
+ |
|
1101 |
|
end module do_Forces |