Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reformat files relevant for PTB PR with fprettify #964

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
610 changes: 303 additions & 307 deletions src/freq/io.f90

Large diffs are not rendered by default.

806 changes: 403 additions & 403 deletions src/main/json.f90

Large diffs are not rendered by default.

2,445 changes: 1,221 additions & 1,224 deletions src/main/property.F90

Large diffs are not rendered by default.

332 changes: 164 additions & 168 deletions src/main/setup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,211 +17,207 @@

!> TODO
module xtb_main_setup
use xtb_mctc_accuracy, only : wp
use xtb_solv_input, only : TSolvInput
use xtb_solv_model, only : init
use xtb_extern_orca, only : TOrcaCalculator, newOrcaCalculator
use xtb_extern_mopac, only : TMopacCalculator, newMopacCalculator
use xtb_extern_turbomole, only : TTMCalculator, newTMCalculator
use xtb_extern_driver, only : TDriverCalculator, newDriverCalculator
use xtb_tblite_calculator, only : TTBLiteCalculator, TTBLiteInput, newTBLiteCalculator
use xtb_type_calculator, only : TCalculator
use xtb_type_environment, only : TEnvironment
use xtb_type_molecule, only : TMolecule
use xtb_type_restart, only : TRestart
use xtb_type_wavefunction, only : TWavefunction
use xtb_xtb_calculator, only : TxTBCalculator, newXTBcalculator, newWavefunction
use xtb_gfnff_calculator, only : TGFFCalculator, newGFFCalculator
use xtb_iff_calculator, only : TIFFCalculator, newIFFCalculator
use xtb_iff_data, only : TIFFData
use xtb_oniom, only : TOniomCalculator, newOniomCalculator, oniom_input
use xtb_mctc_accuracy, only: wp
use xtb_solv_input, only: TSolvInput
use xtb_solv_model, only: init
use xtb_extern_orca, only: TOrcaCalculator, newOrcaCalculator
use xtb_extern_mopac, only: TMopacCalculator, newMopacCalculator
use xtb_extern_turbomole, only: TTMCalculator, newTMCalculator
use xtb_extern_driver, only: TDriverCalculator, newDriverCalculator
use xtb_tblite_calculator, only: TTBLiteCalculator, TTBLiteInput, newTBLiteCalculator
use xtb_type_calculator, only: TCalculator
use xtb_type_environment, only: TEnvironment
use xtb_type_molecule, only: TMolecule
use xtb_type_restart, only: TRestart
use xtb_type_wavefunction, only: TWavefunction
use xtb_xtb_calculator, only: TxTBCalculator, newXTBcalculator, newWavefunction
use xtb_gfnff_calculator, only: TGFFCalculator, newGFFCalculator
use xtb_iff_calculator, only: TIFFCalculator, newIFFCalculator
use xtb_iff_data, only: TIFFData
use xtb_oniom, only: TOniomCalculator, newOniomCalculator, oniom_input
use xtb_setparam
implicit none
private

public :: newCalculator, newWavefunction, addSolvationModel
public :: newXTBCalculator


contains

subroutine newCalculator(env, mol, calc, fname, restart, accuracy, input, iff_data, tblite_input)

subroutine newCalculator(env, mol, calc, fname, restart, accuracy, input, iff_data, tblite_input)
character(len=*), parameter :: source = 'main_setup_newCalculator'

character(len=*), parameter :: source = 'main_setup_newCalculator'
type(TEnvironment), intent(inout) :: env

type(TEnvironment), intent(inout) :: env
type(TMolecule), intent(in) :: mol

type(TMolecule), intent(in) :: mol
class(TCalculator), allocatable, intent(out) :: calc

class(TCalculator), allocatable, intent(out) :: calc
character(len=*), intent(in) :: fname

character(len=*), intent(in) :: fname
logical, intent(in) :: restart

logical, intent(in) :: restart
real(wp), intent(in) :: accuracy

real(wp), intent(in) :: accuracy
type(oniom_input), intent(in), optional :: input

type(oniom_input), intent(in), optional :: input
type(TIFFData), intent(in), optional, allocatable :: iff_data

type(TIFFData), intent(in), optional, allocatable :: iff_data
!> Input for TBLite calculator
type(TTBLiteInput), intent(in), optional :: tblite_input

!> Input for TBLite calculator
type(TTBLiteInput), intent(in), optional :: tblite_input
type(TxTBCalculator), allocatable :: xtb
type(TTBLiteCalculator), allocatable :: tblite
type(TGFFCalculator), allocatable :: gfnff
type(TIFFCalculator), allocatable :: iff
type(TOrcaCalculator), allocatable :: orca
type(TMopacCalculator), allocatable :: mopac
type(TTMCalculator), allocatable :: turbo
type(TOniomCalculator), allocatable :: oniom
type(TDriverCalculator), allocatable :: driver

type(TxTBCalculator), allocatable :: xtb
type(TTBLiteCalculator), allocatable :: tblite
type(TGFFCalculator), allocatable :: gfnff
type(TIFFCalculator), allocatable :: iff
type(TOrcaCalculator), allocatable :: orca
type(TMopacCalculator), allocatable :: mopac
type(TTMCalculator), allocatable :: turbo
type(TOniomCalculator), allocatable :: oniom
type(TDriverCalculator), allocatable :: driver

logical :: exitRun

select case(set%mode_extrun)
case default
call env%error("Unknown calculator type", source)

case(p_ext_oniom)
if (.not.present(input)) then
call env%error("ONIOM calculator requires input", source)
return
end if
allocate(oniom)
call newOniomCalculator(oniom, env, mol, input)
call move_alloc(oniom, calc)

case(p_ext_eht, p_ext_xtb)
allocate(xtb)

call newXTBCalculator(env, mol, xtb, fname, set%gfn_method, accuracy)

call env%check(exitRun)
if (exitRun) then
call env%error("Could not construct new calculator", source)
return
end if
logical :: exitRun

call move_alloc(xtb, calc)
case(p_ext_tblite)
if (.not.present(tblite_input)) then
call env%error("TBLite calculator requires input", source)
return
end if
allocate(tblite)
select case (set%mode_extrun)
case default
call env%error("Unknown calculator type", source)

call newTBLiteCalculator(env, mol, tblite, tblite_input)
case (p_ext_oniom)
if (.not. present(input)) then
call env%error("ONIOM calculator requires input", source)
return
end if
allocate (oniom)
call newOniomCalculator(oniom, env, mol, input)
call move_alloc(oniom, calc)

call env%check(exitRun)
if (exitRun) then
call env%error("Could not construct new calculator", source)
return
end if
case (p_ext_eht, p_ext_xtb)
allocate (xtb)

call move_alloc(tblite, calc)
case(p_ext_gfnff)
allocate(gfnff)
call newXTBCalculator(env, mol, xtb, fname, set%gfn_method, accuracy)

call newGFFCalculator(env, mol, gfnff, fname, restart)
call env%check(exitRun)
if (exitRun) then
call env%error("Could not construct new calculator", source)
return
end if

call env%check(exitRun)
if (exitRun) then
call env%error("Could not construct new calculator", source)
return
end if
call move_alloc(xtb, calc)
case (p_ext_tblite)
if (.not. present(tblite_input)) then
call env%error("TBLite calculator requires input", source)
return
end if
allocate (tblite)

call move_alloc(gfnff, calc)
case(p_ext_mcgfnff)
allocate(gfnff)
call newTBLiteCalculator(env, mol, tblite, tblite_input)

call newGFFCalculator(env, mol, gfnff, fname, restart, 4) ! mcgfnff2023 version
call env%check(exitRun)
if (exitRun) then
call env%error("Could not construct new calculator", source)
return
end if

call env%check(exitRun)
if (exitRun) then
call env%error("Could not construct new calculator", source)
return
end if
call move_alloc(tblite, calc)
case (p_ext_gfnff)
allocate (gfnff)

call move_alloc(gfnff, calc)
case(p_ext_iff)
if (.not.present(iff_data)) then
call env%error("IFF calculator requires input", source)
return
end if
allocate(iff)
call newGFFCalculator(env, mol, gfnff, fname, restart)

if (.not. allocated(iff_data)) then
call env%error("IFF Data not present for Calculator", source)
end if

call newIFFCalculator(env, mol, iff_data, iff)
call env%check(exitRun)
if (exitRun) then
call env%error("Could not construct new calculator", source)
return
end if

call env%check(exitRun)
if (exitRun) then
call env%error("Could not construct new calculator", source)
return
end if
call move_alloc(gfnff, calc)
case (p_ext_mcgfnff)
allocate (gfnff)

call newGFFCalculator(env, mol, gfnff, fname, restart, 4) ! mcgfnff2023 version

call env%check(exitRun)
if (exitRun) then
call env%error("Could not construct new calculator", source)
return
end if

call move_alloc(iff, calc)

! ORCA => https://orcaforum.kofo.mpg.de/app.php/portal !
case(p_ext_orca)
allocate(orca)
call newOrcaCalculator(orca, env, set%ext_orca)
call move_alloc(orca, calc)
case(p_ext_mopac)
allocate(mopac)
call newMopacCalculator(mopac, env, set%ext_mopac)
call move_alloc(mopac, calc)

case(p_ext_turbomole)
allocate(turbo)
call newTMCalculator(turbo, set%extcode, set%extmode)
call move_alloc(turbo, calc)

case(p_ext_driver)
allocate(driver)
call newDriverCalculator(driver, env, set%ext_driver)
call move_alloc(driver, calc)
end select

end subroutine newCalculator



subroutine addSolvationModel(env, calc, input)
type(TEnvironment), intent(inout) :: env
class(TCalculator), intent(inout) :: calc
type(TSolvInput), intent(in) :: input
integer :: level

level = 0
select type(calc)
type is(TxTBCalculator)
level = calc%xtbData%level
type is(TOniomCalculator)
select type(xtb => calc%real_low)
type is(TxTBCalculator)
level = xtb%xtbData%level
call move_alloc(gfnff, calc)
case (p_ext_iff)
if (.not. present(iff_data)) then
call env%error("IFF calculator requires input", source)
return
end if
allocate (iff)

if (.not. allocated(iff_data)) then
call env%error("IFF Data not present for Calculator", source)
end if

call newIFFCalculator(env, mol, iff_data, iff)

call env%check(exitRun)
if (exitRun) then
call env%error("Could not construct new calculator", source)
return
end if

call move_alloc(iff, calc)

! ORCA => https://orcaforum.kofo.mpg.de/app.php/portal !
case (p_ext_orca)
allocate (orca)
call newOrcaCalculator(orca, env, set%ext_orca)
call move_alloc(orca, calc)

case (p_ext_mopac)
allocate (mopac)
call newMopacCalculator(mopac, env, set%ext_mopac)
call move_alloc(mopac, calc)

case (p_ext_turbomole)
allocate (turbo)
call newTMCalculator(turbo, set%extcode, set%extmode)
call move_alloc(turbo, calc)

case (p_ext_driver)
allocate (driver)
call newDriverCalculator(driver, env, set%ext_driver)
call move_alloc(driver, calc)
end select
end select

if (allocated(input%solvent)) then
calc%lSolv = input%solvent /= 'none' .and. input%solvent /= 'gas' &
& .and. input%solvent /= 'vac'
else
calc%lSolv = .false.
end if
end subroutine newCalculator

subroutine addSolvationModel(env, calc, input)
type(TEnvironment), intent(inout) :: env
class(TCalculator), intent(inout) :: calc
type(TSolvInput), intent(in) :: input
integer :: level

level = 0
select type (calc)
type is (TxTBCalculator)
level = calc%xtbData%level
type is (TOniomCalculator)
select type (xtb => calc%real_low)
type is (TxTBCalculator)
level = xtb%xtbData%level
end select
end select

if (allocated(input%solvent)) then
calc%lSolv = input%solvent /= 'none' .and. input%solvent /= 'gas' &
& .and. input%solvent /= 'vac'
else
calc%lSolv = .false.
end if

if (calc%lSolv) then
allocate(calc%solvation)
call init(calc%solvation, env, input, level)
endif
if (calc%lSolv) then
allocate (calc%solvation)
call init(calc%solvation, env, input, level)
end if

end subroutine addSolvationModel
end subroutine addSolvationModel

end module xtb_main_setup
Loading
Loading