Skip to content

Commit

Permalink
Run autoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Oct 31, 2023
1 parent 544a46b commit e604927
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 75 deletions.
2 changes: 1 addition & 1 deletion src/abin.F90
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ program abin
write (stdout, *) ''

! LZ warning for too many states
if (ipimd == 5 .and. (nsinglet_lz > 2 .or. ntriplet_lz > 2 )) then
if (ipimd == 5 .and. (nsinglet_lz > 2 .or. ntriplet_lz > 2)) then
write (*, *) 'WARNING: LZ was derived for a two-state problem. More states might cause unphysical behavior.'
write (stdout, *) ''
end if
Expand Down
4 changes: 2 additions & 2 deletions src/cmdline.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ subroutine get_cmdline(chinput, chcoords, chveloc, &
use mod_error, only: fatal_error
use mod_utils, only: file_exists_or_exit
character(len=*), intent(inout) :: chinput, chcoords, chveloc
character(len=*), intent(inout) :: tc_server_name ! TeraChem MPI interface
character(len=*), intent(inout) :: tcpb_input_file ! TeraChem protobuf interface
character(len=*), intent(inout) :: tc_server_name ! TeraChem MPI interface
character(len=*), intent(inout) :: tcpb_input_file ! TeraChem protobuf interface
character(len=*), intent(inout) :: tcpb_host
integer, intent(inout) :: tcpb_port
character(len=len(chinput)) :: arg
Expand Down
46 changes: 23 additions & 23 deletions src/force_tcpb.F90
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ subroutine initialize_tcpb(natqm, at_names, tc_port, tc_host, tc_file)
if (status == 0) then
write (stdout, *) "Successfully connected to TeraChem server."
else if (status == 1) then
call fatal_error(__FILE__, __LINE__, &
& "Connection to TeraChem TCPB server failed! Is it running?")
call fatal_error(__FILE__, __LINE__, &
& "Connection to TeraChem TCPB server failed! Is it running?")
else if (status == 2) then
call fatal_error(__FILE__, __LINE__, &
& "Connection to TeraChem server succeed, but the "&
& //" server is not available!")
call fatal_error(__FILE__, __LINE__, &
& "Connection to TeraChem server succeed, but the "&
& //" server is not available!")
else
call fatal_error(__FILE__, __LINE__, &
& "Could not connect to TCPB server. Is it running?")
call fatal_error(__FILE__, __LINE__, &
& "Could not connect to TCPB server. Is it running?")
end if

! Setup TeraChem
Expand All @@ -113,16 +113,16 @@ subroutine initialize_tcpb(natqm, at_names, tc_port, tc_host, tc_file)
#endif
status = 0
if (status == 0) then
write (*,*) "TeraChem setup completed with success."
write (*, *) "TeraChem setup completed with success."
else if (status == 1) then
call fatal_error(__FILE__, __LINE__, &
& "TCPB: No options read from TeraChem input file or mismatch in the input options!")
call fatal_error(__FILE__, __LINE__, &
& "TCPB: No options read from TeraChem input file or mismatch in the input options!")
else if (status == 2) then
call fatal_error(__FILE__, __LINE__, &
& "TCPB: Failed to setup TeraChem.")
call fatal_error(__FILE__, __LINE__, &
& "TCPB: Failed to setup TeraChem.")
else
call fatal_error(__FILE__, __LINE__, &
& "TCPB: Status on tc_setup function is not recognized!")
call fatal_error(__FILE__, __LINE__, &
& "TCPB: Status on tc_setup function is not recognized!")
end if
end subroutine initialize_tcpb

Expand Down Expand Up @@ -151,20 +151,20 @@ subroutine force_tcpb(x, y, z, fx, fy, fz, eclas, walkmax)

allocate (qmcharges(natqm))
allocate (qmcoords(3 * natqm))
allocate (qmgrad(3* natqm))
allocate (qmgrad(3 * natqm))

qmgrad = 0.0D0
mmgrad = 0.0D0
mmcoords = 0.0D0
mmcharges= 0.0D0
qmcharges= 0.0D0
mmcharges = 0.0D0
qmcharges = 0.0D0

do iw = 1, walkmax

do iat = 1, natqm
qmcoords(3*iat - 2) = x(iat, iw)
qmcoords(3*iat - 1) = y(iat, iw)
qmcoords(3*iat) = z(iat, iw)
qmcoords(3 * iat - 2) = x(iat, iw)
qmcoords(3 * iat - 1) = y(iat, iw)
qmcoords(3 * iat) = z(iat, iw)
end do

status = -1
Expand All @@ -186,9 +186,9 @@ subroutine force_tcpb(x, y, z, fx, fy, fz, eclas, walkmax)
end if

do iat = 1, natqm
fx(iat, iw) = -qmgrad(3*iat - 2)
fy(iat, iw) = -qmgrad(3*iat - 1)
fz(iat, iw) = -qmgrad(3*iat)
fx(iat, iw) = -qmgrad(3 * iat - 2)
fy(iat, iw) = -qmgrad(3 * iat - 1)
fz(iat, iw) = -qmgrad(3 * iat)
end do

! ONIOM was not yet tested!!
Expand Down
2 changes: 1 addition & 1 deletion src/force_terash.F90
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ subroutine receive_terash(fx, fy, fz, eclas, tc_comm)
call check_recv_count(status, nstate * nstate, MPI_DOUBLE_PRECISION)

! Should change the following according to what is done in TeraChem
if (oldwfn /= 0 .and. ipimd /= 5) then
if (oldwfn /= 0 .and. ipimd /= 5) then
i = Check_CIVector(CIvecs, CIvecs_old, civec, nstate)
end if

Expand Down
8 changes: 4 additions & 4 deletions src/fortran_interfaces.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
! Some functions are currently outside of modules due to
! circular dependencies.
module mod_interfaces
use, intrinsic :: iso_c_binding, only: c_int, c_int32_t
use, intrinsic :: iso_c_binding, only: C_INT, C_INT32_T
use mod_const, only: DP
public
interface
Expand Down Expand Up @@ -58,9 +58,9 @@ end subroutine omp_set_num_threads
! https://cyber.dabamos.de/programming/modernfortran/sleep.html
! int usleep(useconds_t useconds)
function usleep(useconds) bind(c, name='usleep')
import :: c_int, c_int32_t
integer(kind=c_int32_t), value :: useconds
integer(kind=c_int) :: usleep
import :: C_INT, C_INT32_T
integer(kind=C_INT32_T), value :: useconds
integer(kind=C_INT) :: usleep
end function usleep

end interface
Expand Down
76 changes: 38 additions & 38 deletions src/landau_zener.F90
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,23 @@ subroutine lz_init(pot)
end subroutine lz_init

subroutine lz_init_terash()
use mod_general, only: natom
use mod_sh, only: en_array, tocalc, nacx, nacy, nacz

nstate = nstate_lz !Needed in init_terash
inac = 2 !Turns off couplings calculation

!Based on sh_init() routine, sharing most of the functions
!TODO: Break dependence - separation of MPI interface needed
allocate (en_array(nstate_lz))
allocate (nacx(natom, nstate_lz, nstate_lz))
allocate (nacy(natom, nstate_lz, nstate_lz))
allocate (nacz(natom, nstate_lz, nstate_lz))
allocate (tocalc(nstate, nstate))
en_array = 0.0D0
tocalc = 0
tocalc(istate_lz, istate_lz) = 1
call set_current_state(istate_lz)
use mod_general, only: natom
use mod_sh, only: en_array, tocalc, nacx, nacy, nacz

nstate = nstate_lz !Needed in init_terash
inac = 2 !Turns off couplings calculation

!Based on sh_init() routine, sharing most of the functions
!TODO: Break dependence - separation of MPI interface needed
allocate (en_array(nstate_lz))
allocate (nacx(natom, nstate_lz, nstate_lz))
allocate (nacy(natom, nstate_lz, nstate_lz))
allocate (nacz(natom, nstate_lz, nstate_lz))
allocate (tocalc(nstate, nstate))
en_array = 0.0D0
tocalc = 0
tocalc(istate_lz, istate_lz) = 1
call set_current_state(istate_lz)
end subroutine lz_init_terash

!LZ singlets hop
Expand Down Expand Up @@ -176,9 +176,9 @@ subroutine lz_hop(x, y, z, vx, vy, vz, fxc, fyc, fzc, amt, dt, eclas, chpot)
end if

do ist1 = ibeg, iend
if (ist1 == ist) cycle
if (ist1 == ist) cycle
! only closest states are considered for hopping
if (ist1 > (ist + 1) .or. ist1 < (ist - 1)) cycle
if (ist1 > (ist + 1) .or. ist1 < (ist - 1)) cycle

do ihist = 1, 4
en_diff(ihist) = abs(en_array_lz(ist, ihist) - en_array_lz(ist1, ihist))
Expand All @@ -204,31 +204,31 @@ subroutine lz_hop(x, y, z, vx, vy, vz, fxc, fyc, fzc, amt, dt, eclas, chpot)
! only for significant probabilities, for tiny probabilities this does not make sense
! e.g. for parallel states (the whole LZ does not make sense for this case)
if (prob(ist1) > 0.01) then
! Calculating backward second derivative formula. We are not using the newest energy
! but the previous three. Discontinuity would not affect this formula.
second_der_back = ((en_diff(2) - 2 * en_diff(3) + en_diff(4)) / dt**2)
! We have central and backward second derivative formulas and compare them.
! If the change is too large, we either almost hit the CI or we have discontinuity.
der_check = abs((second_der - second_der_back) / second_der)
! If they differ by more then 130%, we have aa unphysical change of curvature --> certain discontinuity.
if (der_check > 1.3) then
write (stdout,*) "ERROR: Change of curvature --> discontinuity in PES!"
write (stdout,*) "Probability set to 0!"
prob(ist1) = 0.0D0
! 30% threshold was set empirically and should capture most discontinuities
! yet it can also be a conical intersection. Thus, we just issue an warning
! and let the user to evaluate on his own.
else if (der_check > 0.3) then
write (stdout,*) "WARNING: Possible discontinuity in PES! Check PES.dat!"
end if
end if
! Calculating backward second derivative formula. We are not using the newest energy
! but the previous three. Discontinuity would not affect this formula.
second_der_back = ((en_diff(2) - 2 * en_diff(3) + en_diff(4)) / dt**2)
! We have central and backward second derivative formulas and compare them.
! If the change is too large, we either almost hit the CI or we have discontinuity.
der_check = abs((second_der - second_der_back) / second_der)
! If they differ by more then 130%, we have aa unphysical change of curvature --> certain discontinuity.
if (der_check > 1.3) then
write (stdout, *) "ERROR: Change of curvature --> discontinuity in PES!"
write (stdout, *) "Probability set to 0!"
prob(ist1) = 0.0D0
! 30% threshold was set empirically and should capture most discontinuities
! yet it can also be a conical intersection. Thus, we just issue an warning
! and let the user to evaluate on his own.
else if (der_check > 0.3) then
write (stdout, *) "WARNING: Possible discontinuity in PES! Check PES.dat!"
end if
end if

end if
end do

! LZ warning
if (sum(prob) > 1) then
write (stdout, *) "WARNING: Sum of hopping probabilities > 1. Breakdown of LZ assumptions"
write (stdout, *) "WARNING: Sum of hopping probabilities > 1. Breakdown of LZ assumptions"
end if

!Hop?
Expand Down
2 changes: 1 addition & 1 deletion src/surfacehop.F90
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ subroutine try_hop_nacme_rescale(vx, vy, vz, instate, outstate, eclas)
a_temp = 0.5D0 * a_temp
c_temp = b_temp**2 + 4 * a_temp * (en_array(instate) - en_array(outstate))

if (a_temp <= 0.0D0 ) then
if (a_temp <= 0.0D0) then
write (stdout, *) 'WARNING: NACME vector is zero, rescaling velocities isotropically along the velocity vector'
call try_hop_simple_rescale(vx, vy, vz, instate, outstate, eclas)
return
Expand Down
2 changes: 1 addition & 1 deletion src/tera_mpi_api.F90
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ subroutine finalize_terachem(abin_error_code)

do itera = 1, nteraservers

if (.not.communication_established(itera)) cycle
if (.not. communication_established(itera)) cycle

write (stdout, '(A,I0)') 'Shutting down TeraChem server id = ', itera

Expand Down
8 changes: 4 additions & 4 deletions src/utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,13 @@ subroutine int_switch(i, varname)
end subroutine int_switch

subroutine milisleep(milisec)
use, intrinsic :: iso_c_binding, only: c_int, c_int32_t
use, intrinsic :: iso_c_binding, only: C_INT, C_INT32_T
use mod_interfaces, only: usleep
integer :: milisec
integer(kind=c_int32_t) :: usec
integer(kind=c_int) :: c_err
integer(kind=C_INT32_T) :: usec
integer(kind=C_INT) :: c_err

usec = int(milisec * 1000, c_int32_t)
usec = int(milisec * 1000, C_INT32_T)
! TODO: Based on usleep(2) manpage, we probably should not sleep more than a second
c_err = usleep(usec)
if (c_err /= 0) then
Expand Down

0 comments on commit e604927

Please sign in to comment.