diff --git a/src/main/json.F90 b/src/main/json.F90 index 263006637..e25aac0e6 100644 --- a/src/main/json.F90 +++ b/src/main/json.F90 @@ -59,13 +59,13 @@ ! "version": 6.1 ! } module xtb_main_json + use xtb_mctc_accuracy, only: wp implicit none private public :: main_xtb_json, write_json_gfnff_lists - public :: main_ptb_json - + public :: main_ptb_json, main_tblite_json contains subroutine main_xtb_json & @@ -585,7 +585,29 @@ subroutine write_json_gfnff_lists(n, etot, gnorm, topo, neigh, nlist, printTopo) call close_file(iunit) end subroutine write_json_gfnff_lists - + + !> wrapper for tblite-PTB JSON output + subroutine main_tblite_json & + (ijson, calc, energy, gradient, sigma) + +#if WITH_TBLITE + use tblite_output_ascii +#endif + use xtb_tblite_calculator, only : TTBLiteCalculator + + integer, intent(in) :: ijson + type(TTBLiteCalculator), intent(in) :: calc + real(wp), intent(in) :: energy + real(wp), intent(in) :: gradient(:,:) + real(wp), intent(in) :: sigma(:,:) + +#if WITH_TBLITE + call json_results(ijson, ' ', energy=energy, gradient=gradient, & + & sigma=sigma, energies=calc%results%energies) +#endif + + end subroutine main_tblite_json + !> wrapper for tblite-PTB JSON output subroutine main_ptb_json & (ijson, mol, wfx, calc, sccres, freqres) diff --git a/src/prog/main.F90 b/src/prog/main.F90 index 96465feb3..9b6976a26 100644 --- a/src/prog/main.F90 +++ b/src/prog/main.F90 @@ -77,7 +77,7 @@ module xtb_prog_main use xtb_xtb_gfn2 use xtb_main_setup use xtb_main_defaults, only: initDefaults - use xtb_main_json, only: main_xtb_json, write_json_gfnff_lists + use xtb_main_json, only: main_xtb_json, write_json_gfnff_lists, main_ptb_json, main_tblite_json use xtb_geoopt use xtb_metadynamic use xtb_biaspath @@ -97,8 +97,6 @@ module xtb_prog_main use xtb_ptb_calculator, only: TPTBCalculator use xtb_solv_cpx, only: TCpcmx use xtb_dipro, only: get_jab, jab_input - !> PTB related modules - use xtb_main_json, only: main_ptb_json implicit none private @@ -1020,12 +1018,19 @@ subroutine xtbMain(env, argParser) end if if (set%pr_json) then - select type (calc) + select type (calc) type is (TxTBCalculator) call open_file(ich, 'xtbout.json', 'w') call main_xtb_json(ich, & mol, chk%wfn, calc%basis, res, fres) call close_file(ich) + + type is (TTBLiteCalculator) + call open_file(ich, 'tblite.json', 'w') + call main_tblite_json(ich, & + calc, etot, g, sigma) + call close_file(ich) + type is (TPTBCalculator) call open_file(ich, 'xtbout.json', 'w') call main_ptb_json(ich, & @@ -1033,19 +1038,19 @@ subroutine xtbMain(env, argParser) call close_file(ich) end select end if + if (printTopo%any()) then select type (calc) type is (TGFFCalculator) call write_json_gfnff_lists(mol%n, res%e_total, res%gnorm, calc%topo, calc%neigh, chk%nlist, printTopo) end select end if - if ((set%runtyp == p_run_opt) .or. (set%runtyp == p_run_ohess) .or. & - (set%runtyp == p_run_omd) .or. (set%runtyp == p_run_screen) .or. & - (set%runtyp == p_run_metaopt) .or. (set%runtyp == p_run_bhess)) then + + if (anyopt) then call main_geometry(iprop, mol) end if - if ((set%runtyp == p_run_hess) .or. (set%runtyp == p_run_ohess) .or. (set%runtyp == p_run_bhess)) then + if (anyhess) then call generic_header(iprop, 'Frequency Printout', 49, 10) call main_freq(iprop, mol, chk%wfn, fres) end if @@ -1058,9 +1063,7 @@ subroutine xtbMain(env, argParser) end if end if - if ((set%runtyp == p_run_opt) .or. (set%runtyp == p_run_ohess) .or. & - (set%runtyp == p_run_omd) .or. (set%runtyp == p_run_screen) .or. & - (set%runtyp == p_run_metaopt) .or. (set%runtyp == p_run_bhess)) then + if ( anyopt .or. (set%runtyp == p_run_bhess) ) then call generateFileName(tmpname, 'xtbopt', extension, mol%ftype) write (env%unit, '(/,a,1x,a,/)') & "optimized geometry written to:", tmpname diff --git a/src/tblite/calculator.F90 b/src/tblite/calculator.F90 index ff45b96a3..7507cd459 100644 --- a/src/tblite/calculator.F90 +++ b/src/tblite/calculator.F90 @@ -40,6 +40,7 @@ module xtb_tblite_calculator use tblite_xtb_ipea1, only : new_ipea1_calculator, export_ipea1_param use tblite_xtb_singlepoint, only : xtb_singlepoint use tblite_data_spin, only : get_spin_constant + use tblite_results, only : results_type #endif use xtb_mctc_accuracy, only : wp use xtb_type_calculator, only : TCalculator @@ -89,6 +90,8 @@ module xtb_tblite_calculator type(xtb_calculator) :: tblite !> Perform a spin-polarized calculation logical :: spin_polarized = .false. + !> results + type(results_type) :: results #endif contains !> Perform calculator for a singlepoint @@ -284,7 +287,7 @@ subroutine singlepoint(self, env, mol, chk, printlevel, restart, & call get_qat_from_qsh(self%tblite%bas, chk%tblite%qsh, chk%tblite%qat) call xtb_singlepoint(ctx, struc, self%tblite, chk%tblite, self%accuracy, & - & energy, gradient, sigma, printlevel) + & energy, gradient, sigma, printlevel,self%results) if (ctx%failed()) then do while(ctx%failed()) call ctx%get_error(error)