--- trunk/OOPSE/libmdtools/calc_eam.F90 2003/08/07 00:47:33 669 +++ trunk/OOPSE/libmdtools/calc_eam.F90 2003/10/04 18:46:12 801 @@ -51,11 +51,11 @@ module eam !! Arrays for derivatives used in force calculation - real( kind = dp),save, dimension(:), allocatable :: frho - real( kind = dp),save, dimension(:), allocatable :: rho + real( kind = dp), dimension(:), allocatable :: frho + real( kind = dp), dimension(:), allocatable :: rho - real( kind = dp),save, dimension(:), allocatable :: dfrhodrho - real( kind = dp),save, dimension(:), allocatable :: d2frhodrhodrho + real( kind = dp), dimension(:), allocatable :: dfrhodrho + real( kind = dp), dimension(:), allocatable :: d2frhodrhodrho !! Arrays for MPI storage @@ -78,7 +78,7 @@ module eam end type EAMTypeList - type (eamTypeList) :: EAMList + type (eamTypeList), save :: EAMList !! standard eam stuff @@ -89,7 +89,7 @@ module eam public :: newEAMtype public :: calc_eam_prepair_rho public :: calc_eam_preforce_Frho - + public :: clean_EAM contains @@ -164,14 +164,15 @@ contains integer :: alloc_stat integer :: number_r, number_rho + + status = 0 if (EAMList%currentAddition == 0) then call handleError("init_EAM_FF","No members in EAMList") status = -1 return end if - - + do i = 1, EAMList%currentAddition ! Build array of r values @@ -233,15 +234,15 @@ contains ! do i = 1, EAMList%currentAddition ! EAMList%EAMParam(i)s%eam_atype_map(eam_atype(i)) = i ! end do - - !! Allocate arrays for force calculation - call allocateEAM(alloc_stat) - if (alloc_stat /= 0 ) then - status = -1 - return - endif - + + call allocateEAM(alloc_stat) + if (alloc_stat /= 0 ) then + write(*,*) "allocateEAM failed" + status = -1 + return + endif + end subroutine init_EAM_FF !! routine checks to see if array is allocated, deallocates array if allocated @@ -258,7 +259,7 @@ contains nlocal = getNlocal() - + status = 0 #ifdef IS_MPI nrow = getNrow(plan_row) ncol = getNcol(plan_col) @@ -365,6 +366,7 @@ contains subroutine clean_EAM() + ! clean non-IS_MPI first frho = 0.0_dp rho = 0.0_dp @@ -484,15 +486,10 @@ contains integer :: myid_atom2 ! check to see if we need to be cleaned at the start of a force loop - - if (cleanme) then - call clean_EAM - cleanme = .false. - end if - + #ifdef IS_MPI myid_atom1 = atid_Row(atom1) myid_atom2 = atid_Col(atom2) @@ -502,9 +499,9 @@ contains #endif if (r.lt.EAMList%EAMParams(myid_atom1)%eam_rcut) then - + call eam_splint(EAMList%EAMParams(myid_atom1)%eam_nr, & EAMList%EAMParams(myid_atom1)%eam_rvals, & EAMList%EAMParams(myid_atom1)%eam_rho_r, & @@ -518,6 +515,7 @@ contains #else rho(atom2) = rho(atom2) + rho_i_at_j #endif +! write(*,*) atom1,atom2,r,rho_i_at_j endif if (r.lt.EAMList%EAMParams(myid_atom2)%eam_rcut) then @@ -537,7 +535,6 @@ contains #endif endif - end subroutine calc_eam_prepair_rho @@ -554,10 +551,10 @@ contains integer :: atype1 integer :: me integer :: n_rho_points - ! reset clean forces to be true at top of calc rho. - cleanme = .true. + -!! Scatter the electron density from pre-pair calculation back to local atoms + cleanme = .true. + !! Scatter the electron density from pre-pair calculation back to local atoms #ifdef IS_MPI call scatter(rho_row,rho,plan_row,eam_err) if (eam_err /= 0 ) then @@ -595,13 +592,14 @@ contains end if - frho(i) = u - dfrhodrho(i) = u1 - d2frhodrhodrho(i) = u2 + frho(atom) = u + dfrhodrho(atom) = u1 + d2frhodrhodrho(atom) = u2 pot = pot + u + enddo - + #ifdef IS_MPI !! communicate f(rho) and derivatives back into row and column arrays @@ -632,6 +630,7 @@ contains endif #endif + end subroutine calc_eam_preforce_Frho @@ -664,11 +663,10 @@ contains integer :: mytype_atom1 integer :: mytype_atom2 - !Local Variables + ! write(*,*) "Frho: ", Frho(atom1) - phab = 0.0E0_DP dvpdr = 0.0E0_DP d2vpdrdr = 0.0E0_DP @@ -837,10 +835,7 @@ contains #endif if (molMembershipList(id1) .ne. molMembershipList(id2)) then - - - tau_Temp(1) = tau_Temp(1) - d(1) * fx tau_Temp(2) = tau_Temp(2) - d(1) * fy tau_Temp(3) = tau_Temp(3) - d(1) * fz