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 439 by chuckv, Mon Mar 31 22:09:39 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.6 2003-03-31 22:09:39 chuckv Exp $, $Date: 2003-03-31 22:09:39 $, $Name: not supported by cvs2svn $, $Revision: 1.6 $
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 17 | Line 17 | module do_Forces
17    use dipole_dipole
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 27 | Line 30 | module do_Forces
30   #define __FORTRAN90
31   #include "fForceField.h"
32  
33 <  logical, save :: do_forces_initialized = .false.
33 >  logical, save :: do_forces_initialized = .false., haveRlist = .false.
34 >  logical, save :: havePolicies = .false.
35    logical, save :: FF_uses_LJ
36    logical, save :: FF_uses_sticky
37    logical, save :: FF_uses_dipoles
# Line 35 | Line 39 | module do_Forces
39    logical, save :: FF_uses_GB
40    logical, save :: FF_uses_EAM
41  
42 +  real(kind=dp), save :: rlist, rlistsq
43 +
44    public :: init_FF
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 )
59 +    
60 +    real(kind=dp) :: this_rlist
61 +
62 +    rlist = this_rlist
63 +    rlistsq = rlist * rlist
64 +    
65 +    haveRlist = .true.
66 +    if( havePolicies ) do_forces_initialized = .true.
67 +
68 +  end subroutine setRlistDF    
69 +
70    subroutine init_FF(LJMIXPOLICY, use_RF_c, thisStat)
71  
72      integer, intent(in) :: LJMIXPOLICY
# Line 87 | Line 114 | contains
114      !! check to make sure the FF_uses_RF setting makes sense
115      
116      if (FF_uses_dipoles) then
90       rrf = getRrf()
91       rt = getRt()      
92       call initialize_dipole(rrf, rt)
117         if (FF_uses_RF) then
118            dielect = getDielect()
119 <          call initialize_rf(rrf, rt, dielect)
119 >          call initialize_rf(dielect)
120         endif
121      else
122         if (FF_uses_RF) then          
# Line 100 | Line 124 | contains
124            thisStat = -1
125            return
126         endif
127 <    endif
127 >    endif
128  
129      if (FF_uses_LJ) then
130        
107       call getRcut(rcut)
108
131         select case (LJMIXPOLICY)
132         case (LB_MIXING_RULE)
133 <          call init_lj_FF(LB_MIXING_RULE, rcut, my_status)            
133 >          call init_lj_FF(LB_MIXING_RULE, my_status)            
134         case (EXPLICIT_MIXING_RULE)
135 <          call init_lj_FF(EXPLICIT_MIXING_RULE, rcut, my_status)
135 >          call init_lj_FF(EXPLICIT_MIXING_RULE, my_status)
136         case default
137            write(default_error,*) 'unknown LJ Mixing Policy!'
138            thisStat = -1
# Line 129 | 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 139 | Line 173 | contains
173      endif
174  
175      if (FF_uses_GB .and. FF_uses_LJ) then
176 +    endif
177 +    if (.not. do_forces_initialized) then
178 +       !! Create neighbor lists
179 +       call expandNeighborList(getNlocal(), my_status)
180 +       if (my_Status /= 0) then
181 +          write(default_error,*) "SimSetup: ExpandNeighborList returned error."
182 +          thisStat = -1
183 +          return
184 +       endif
185      endif
186 +    
187  
188 +    havePolicies = .true.
189 +    if( haveRlist ) do_forces_initialized = .true.
190  
145    do_forces_initialized = .true.    
146
191    end subroutine init_FF
192    
193  
# Line 168 | Line 212 | contains
212      logical :: do_pot
213      logical :: do_stress
214   #ifdef IS_MPI
215 <    real( kind = DP ) :: pot_local = 0.0_dp
215 >    real( kind = DP ) :: pot_local
216      integer :: nrow
217      integer :: ncol
218 +    integer :: nprocs
219   #endif
220      integer :: nlocal
221      integer :: natoms    
222      logical :: update_nlist  
223      integer :: i, j, jbeg, jend, jnab
224      integer :: nlist
225 <    real( kind = DP ) ::  rijsq, rlistsq, rcutsq, rlist, rcut
225 >    real( kind = DP ) ::  rijsq
226      real(kind=dp),dimension(3) :: d
227      real(kind=dp) :: rfpot, mu_i, virial
228      integer :: me_i
# Line 186 | Line 231 | contains
231      integer :: listerror, error
232      integer :: localError
233  
234 +    real(kind=dp) :: listSkin = 1.0  
235 +
236      !! initialize local variables  
237  
238   #ifdef IS_MPI
239 +    pot_local = 0.0_dp
240      nlocal = getNlocal()
241      nrow   = getNrow(plan_row)
242      ncol   = getNcol(plan_col)
# Line 197 | Line 245 | contains
245      natoms = nlocal
246   #endif
247  
200    call getRcut(rcut,rc2=rcutsq)
201    call getRlist(rlist,rlistsq)
202    
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 210 | 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 226 | 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, rcut, rlist, update_nlist)  
285 >       call checkNeighborList(nlocal, q, listSkin, update_nlist)  
286         !! if_mpi_gather_stuff_for_prepair
287         !! do_prepair_loop_if_needed
288         !! if_mpi_scatter_stuff_from_prepair
289         !! if_mpi_gather_stuff_from_prepair_to_main_loop
290 <    else
291 <       !! See if we need to update neighbor lists
292 <       call checkNeighborList(nlocal, q, rcut, rlist, update_nlist)  
290 >    
291 > !--------------------PREFORCE LOOP----------->>>>>>>>>>>>>>>>>>>>>>>>>>>
292 > #ifdef IS_MPI
293 >    
294 >    if (update_nlist) then
295 >      
296 >       !! save current configuration, construct neighbor list,
297 >       !! and calculate forces
298 >       call saveNeighborList(nlocal, q)
299 >      
300 >       neighborListSize = size(list)
301 >       nlist = 0      
302 >      
303 >       do i = 1, nrow
304 >          point(i) = nlist + 1
305 >          
306 >          prepair_inner: do j = 1, ncol
307 >            
308 >             if (skipThisPair(i,j)) cycle prepair_inner
309 >            
310 >             call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq)
311 >            
312 >             if (rijsq < rlistsq) then            
313 >                
314 >                nlist = nlist + 1
315 >                
316 >                if (nlist > neighborListSize) then
317 >                   call expandNeighborList(nlocal, listerror)
318 >                   if (listerror /= 0) then
319 >                      error = -1
320 >                      write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded."
321 >                      return
322 >                   end if
323 >                   neighborListSize = size(list)
324 >                endif
325 >                
326 >                list(nlist) = j
327 >                call do_prepair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot_local)                      
328 >             endif
329 >          enddo prepair_inner
330 >       enddo
331 >
332 >       point(nrow + 1) = nlist + 1
333 >      
334 >    else  !! (of update_check)
335 >
336 >       ! use the list to find the neighbors
337 >       do i = 1, nrow
338 >          JBEG = POINT(i)
339 >          JEND = POINT(i+1) - 1
340 >          ! check thiat molecule i has neighbors
341 >          if (jbeg .le. jend) then
342 >            
343 >             do jnab = jbeg, jend
344 >                j = list(jnab)
345 >
346 >                call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq)
347 >                call do_prepair(i, j, rijsq, d, do_pot, do_stress, &
348 >                     u_l, A, f, t, pot_local)
349 >
350 >             enddo
351 >          endif
352 >       enddo
353      endif
354      
355 < #ifdef IS_MPI
355 > #else
356      
357      if (update_nlist) then
358        
359 +       ! save current configuration, contruct neighbor list,
360 +       ! and calculate forces
361 +       call saveNeighborList(natoms, q)
362 +      
363 +       neighborListSize = size(list)
364 +  
365 +       nlist = 0
366 +
367 +       do i = 1, natoms-1
368 +          point(i) = nlist + 1
369 +          
370 +          prepair_inner: do j = i+1, natoms
371 +            
372 +             if (skipThisPair(i,j))  cycle prepair_inner
373 +                          
374 +             call get_interatomic_vector(q(:,i), q(:,j), d, rijsq)
375 +          
376 +
377 +             if (rijsq < rlistsq) then
378 +
379 +          
380 +                nlist = nlist + 1
381 +              
382 +                if (nlist > neighborListSize) then
383 +                   call expandNeighborList(natoms, listerror)
384 +                   if (listerror /= 0) then
385 +                      error = -1
386 +                      write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded."
387 +                      return
388 +                   end if
389 +                   neighborListSize = size(list)
390 +                endif
391 +                
392 +                list(nlist) = j
393 +                
394 +                call do_prepair(i, j, rijsq, d, do_pot, do_stress, &
395 +                        u_l, A, f, t, pot)
396 +                
397 +             endif
398 +          enddo prepair_inner
399 +       enddo
400 +      
401 +       point(natoms) = nlist + 1
402 +      
403 +    else !! (update)
404 +  
405 +       ! use the list to find the neighbors
406 +       do i = 1, natoms-1
407 +          JBEG = POINT(i)
408 +          JEND = POINT(i+1) - 1
409 +          ! check thiat molecule i has neighbors
410 +          if (jbeg .le. jend) then
411 +            
412 +             do jnab = jbeg, jend
413 +                j = list(jnab)
414 +
415 +                call get_interatomic_vector(q(:,i), q(:,j), d, rijsq)
416 +                call do_prepair(i, j, rijsq, d, do_pot, do_stress, &
417 +                     u_l, A, f, t, pot)
418 +
419 +             enddo
420 +          endif
421 +       enddo
422 +    endif    
423 + #endif
424 +    !! Do rest of preforce calculations
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)  
432 +    endif
433 +
434 +
435 +
436 +
437 +
438 + !---------------------------------MAIN Pair LOOP->>>>>>>>>>>>>>>>>>>>>>>>>>>>
439 +
440 +
441 +
442 +
443 +  
444 + #ifdef IS_MPI
445 +    
446 +    if (update_nlist) then
447         !! save current configuration, construct neighbor list,
448         !! and calculate forces
449 <       call saveNeighborList(q)
449 >       call saveNeighborList(nlocal, q)
450        
451         neighborListSize = size(list)
452         nlist = 0      
# Line 259 | Line 460 | contains
460              
461               call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq)
462              
463 <             if (rijsq <  rlistsq) then            
463 >             if (rijsq < rlistsq) then            
464                  
465                  nlist = nlist + 1
466                  
# Line 275 | Line 476 | contains
476                  
477                  list(nlist) = j
478                                  
479 <                if (rijsq <  rcutsq) then
480 <                   call do_pair(i, j, rijsq, d, do_pot, do_stress, &
481 <                        u_l, A, f, t,pot)
281 <                endif
479 >                call do_pair(i, j, rijsq, d, do_pot, do_stress, &
480 >                     u_l, A, f, t, pot_local)
481 >                
482               endif
483            enddo inner
484         enddo
# Line 299 | Line 499 | contains
499  
500                  call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq)
501                  call do_pair(i, j, rijsq, d, do_pot, do_stress, &
502 <                     u_l, A, f, t,pot)
502 >                     u_l, A, f, t, pot_local)
503  
504               enddo
505            endif
# Line 309 | 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(q)
515 >       call saveNeighborList(natoms, q)
516        
517         neighborListSize = size(list)
518    
# Line 328 | Line 528 | contains
528               call get_interatomic_vector(q(:,i), q(:,j), d, rijsq)
529            
530  
531 <             if (rijsq <  rlistsq) then
531 >             if (rijsq < rlistsq) then
532                  
533                  nlist = nlist + 1
534                
# Line 344 | Line 544 | contains
544                  
545                  list(nlist) = j
546                  
547 <                if (rijsq <  rcutsq) then
548 <                   call do_pair(i, j, rijsq, d, do_pot, do_stress, &
549 <                        u_l, A, f, t,pot)
350 <                endif
547 >                call do_pair(i, j, rijsq, d, do_pot, do_stress, &
548 >                        u_l, A, f, t, pot)
549 >                
550               endif
551            enddo inner
552         enddo
# Line 368 | Line 567 | contains
567  
568                  call get_interatomic_vector(q(:,i), q(:,j), d, rijsq)
569                  call do_pair(i, j, rijsq, d, do_pot, do_stress, &
570 <                     u_l, A, f, t,pot)
570 >                     u_l, A, f, t, pot)
571  
572               enddo
573            endif
# Line 378 | 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 472 | Line 678 | contains
678   #ifdef IS_MPI
679  
680      if (do_pot) then
681 <       pot = pot_local
681 >       pot = pot + pot_local
682         !! we assume the c code will do the allreduce to get the total potential
683         !! we could do it right here if we needed to...
684      endif
685  
686      if (do_stress) then
687 <       call mpi_allreduce(tau, tau_Temp,9,mpi_double_precision,mpi_sum, &
687 >      call mpi_allreduce(tau_Temp, tau, 9,mpi_double_precision,mpi_sum, &
688              mpi_comm_world,mpi_err)
689 <       call mpi_allreduce(virial, virial_Temp,1,mpi_double_precision,mpi_sum, &
689 >       call mpi_allreduce(virial_Temp, virial,1,mpi_double_precision,mpi_sum, &
690              mpi_comm_world,mpi_err)
691      endif
692  
# Line 492 | 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)
734 >  subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot)
735  
736      real( kind = dp ) :: pot
737 <    real( kind = dp ), dimension(:,:) :: u_l
738 <    real (kind=dp), dimension(:,:) :: A
739 <    real (kind=dp), dimension(:,:) :: f
740 <    real (kind=dp), dimension(:,:) :: t
737 >    real( kind = dp ), dimension(3,getNlocal()) :: u_l
738 >    real (kind=dp), dimension(9,getNlocal()) :: A
739 >    real (kind=dp), dimension(3,getNlocal()) :: f
740 >    real (kind=dp), dimension(3,getNlocal()) :: t
741  
742      logical, intent(inout) :: do_pot, do_stress
743      integer, intent(in) :: i, j
# Line 511 | Line 747 | contains
747      logical :: is_LJ_i, is_LJ_j
748      logical :: is_DP_i, is_DP_j
749      logical :: is_GB_i, is_GB_j
750 +    logical :: is_EAM_i,is_EAM_j
751      logical :: is_Sticky_i, is_Sticky_j
752      integer :: me_i, me_j
753  
754      r = sqrt(rijsq)
755  
756   #ifdef IS_MPI
757 +    if (tagRow(i) .eq. tagColumn(j)) then
758 +       write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j)
759 +    endif
760  
761      me_i = atid_row(i)
762      me_j = atid_col(j)
# Line 541 | 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
544          
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 566 | 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 575 | Line 815 | contains
815         endif
816      endif
817      
818 +
819 +  
820 +   if (FF_uses_EAM .and. SimUsesEAM()) then
821 +      call getElementProperty(atypes, me_i, "is_EAM", is_EAM_i)
822 +      call getElementProperty(atypes, me_j, "is_EAM", is_EAM_j)
823 +      
824 +      if ( is_EAM_i .and. is_EAM_j ) &
825 +           call do_eam_pair(i, j, d, r, rijsq, pot, f, do_pot, do_stress)
826 +   endif
827 +
828 +
829 +
830 +
831    end subroutine do_pair
832  
833  
834 +
835 +  subroutine do_prepair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot)
836 +   real( kind = dp ) :: pot
837 +   real( kind = dp ), dimension(3,getNlocal()) :: u_l
838 +   real (kind=dp), dimension(9,getNlocal()) :: A
839 +   real (kind=dp), dimension(3,getNlocal()) :: f
840 +   real (kind=dp), dimension(3,getNlocal()) :: t
841 +  
842 +   logical, intent(inout) :: do_pot, do_stress
843 +   integer, intent(in) :: i, j
844 +   real ( kind = dp ), intent(inout)    :: rijsq
845 +   real ( kind = dp )                :: r
846 +   real ( kind = dp ), intent(inout) :: d(3)
847 +  
848 +   logical :: is_EAM_i, is_EAM_j
849 +  
850 +   integer :: me_i, me_j
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)
858 +   endif
859 +  
860 +   me_i = atid_row(i)
861 +   me_j = atid_col(j)
862 +  
863 + #else
864 +  
865 +   me_i = atid(i)
866 +   me_j = atid(j)
867 +  
868 + #endif
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)
873 +      
874 +      if ( is_EAM_i .and. is_EAM_j ) &
875 +           call calc_EAM_prepair_rho(i, j, d, r, rijsq )
876 +   endif
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
890 +
891 +
892 +  end subroutine do_preforce
893 +  
894 +  
895    subroutine get_interatomic_vector(q_i, q_j, d, r_sq)
896      
897      real (kind = dp), dimension(3) :: q_i
898      real (kind = dp), dimension(3) :: q_j
899      real ( kind = dp ), intent(out) :: r_sq
900 <    real( kind = dp ) :: d(3)
901 <    real( kind = dp ) :: d_old(3)
902 <    d(1:3) = q_i(1:3) - q_j(1:3)
903 <    d_old = d
900 >    real( kind = dp ) :: d(3), scaled(3)
901 >    integer i
902 >
903 >    d(1:3) = q_j(1:3) - q_i(1:3)
904 >
905      ! Wrap back into periodic box if necessary
906      if ( SimUsesPBC() ) then
907        
908 <       d(1:3) = d(1:3) - box(1:3) * sign(1.0_dp,d(1:3)) * &
909 <            int(abs(d(1:3)/box(1:3)) + 0.5_dp)
908 >       if( .not.boxIsOrthorhombic ) then
909 >          ! calc the scaled coordinates.
910 >          
911 >          scaled = matmul(HmatInv, d)
912 >          
913 >          ! wrap the scaled coordinates
914 >
915 >          scaled = scaled  - anint(scaled)
916 >          
917 >
918 >          ! calc the wrapped real coordinates from the wrapped scaled
919 >          ! coordinates
920 >
921 >          d = matmul(Hmat,scaled)
922 >
923 >       else
924 >          ! calc the scaled coordinates.
925 >          
926 >          do i = 1, 3
927 >             scaled(i) = d(i) * HmatInv(i,i)
928 >            
929 >             ! wrap the scaled coordinates
930 >            
931 >             scaled(i) = scaled(i) - anint(scaled(i))
932 >            
933 >             ! calc the wrapped real coordinates from the wrapped scaled
934 >             ! coordinates
935 >
936 >             d(i) = scaled(i)*Hmat(i,i)
937 >          enddo
938 >       endif
939        
940      endif
941 +    
942      r_sq = dot_product(d,d)
943 <        
943 >    
944    end subroutine get_interatomic_vector
945 <
945 >  
946    subroutine check_initialization(error)
947      integer, intent(out) :: error
948      
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 651 | 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
657    
1012    end subroutine zero_work_arrays
1013    
1014    function skipThisPair(atom1, atom2) result(skip_it)
# Line 698 | Line 1052 | contains
1052   #else
1053      unique_id_2 = atom2
1054   #endif
1055 <    
1055 >
1056   #ifdef IS_MPI
1057      !! this situation should only arise in MPI simulations
1058      if (unique_id_1 == unique_id_2) then
# Line 708 | Line 1062 | contains
1062      
1063      !! this prevents us from doing the pair on multiple processors
1064      if (unique_id_1 < unique_id_2) then
1065 <       if (mod(unique_id_1 + unique_id_2,2) == 0) skip_it = .true.
1066 <       return
1065 >       if (mod(unique_id_1 + unique_id_2,2) == 0) then
1066 >          skip_it = .true.
1067 >          return
1068 >       endif
1069      else                
1070 <       if (mod(unique_id_1 + unique_id_2,2) == 1) skip_it = .true.
1071 <       return
1070 >       if (mod(unique_id_1 + unique_id_2,2) == 1) then
1071 >          skip_it = .true.
1072 >          return
1073 >       endif
1074      endif
1075   #endif
1076 <
1076 >
1077      !! the rest of these situations can happen in all simulations:
1078      do i = 1, nExcludes_global      
1079         if ((excludesGlobal(i) == unique_id_1) .or. &
# Line 724 | Line 1082 | contains
1082            return
1083         endif
1084      enddo
1085 <
1085 >
1086      do i = 1, nExcludes_local
1087         if (excludesLocal(1,i) == unique_id_1) then
1088            if (excludesLocal(2,i) == unique_id_2) then
# Line 760 | 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