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

writing updated coord AND xtbopt.xyz during external driver optimization (including nicer printout) #828

Merged
merged 11 commits into from
Aug 18, 2023
18 changes: 16 additions & 2 deletions src/extern/driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
module xtb_extern_driver
use xtb_mctc_accuracy, only: wp
use xtb_mctc_io, only: stdout
use xtb_mctc_filetypes, only: fileType
use xtb_mctc_filetypes, only: fileType, generateFileName
use xtb_mctc_symbols, only: toSymbol
use xtb_type_calculator, only: TCalculator
use xtb_type_data, only: scc_results
Expand Down Expand Up @@ -104,6 +104,8 @@ subroutine singlepoint(self, env, mol, chk, printlevel, restart, &
'(9x,"::",1x,a,f23.12,1x,a,1x,"::")'
real(wp) :: xyz_cached(3, mol%n)
integer :: err
character(len=:),allocatable :: extension
character(len=:),allocatable :: tmpname

call mol%update

Expand All @@ -117,11 +119,22 @@ subroutine singlepoint(self, env, mol, chk, printlevel, restart, &
!$omp critical (turbo_lock)
inquire (file='gradient', exist=exist)
if (exist) then
! ### only TM output is supported for now ###
call rdtm(env,mol%n, .true., energy, gradient, xyz_cached)
cache = all(abs(xyz_cached - mol%xyz) < 1.e-10_wp)
end if
if (.not. cache) then
call wrtm(mol%n, mol%at, mol%xyz)
call generateFileName(tmpname, 'xtbopt', extension, mol%ftype)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use xtbopt for the final optimized structure, but this routine can be called from a single point or hessian calculation. Better use a more neutral filename here.

write(env%unit,'(/,a,1x,a,/)') &
"updated geometry written to:",tmpname
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This output should be guarded by printlevel > 0

call open_file(ich,tmpname,'w')
if (exist) then
awvwgk marked this conversation as resolved.
Show resolved Hide resolved
call writeMolecule(mol, ich, format=mol%ftype, energy=energy, &
& gnorm=norm2(gradient))
else
call writeMolecule(mol, ich, format=mol%ftype)
end if
call close_file(ich)

write (env%unit, '(72("="))')
write (env%unit, '(1x,"*",1x,a)') &
Expand All @@ -135,6 +148,7 @@ subroutine singlepoint(self, env, mol, chk, printlevel, restart, &
end if
write (env%unit, '(72("="))')

! ### only TM output is supported for now ###
call rdtm(env,mol%n, .true., energy, gradient, xyz_cached)
end if
!$omp end critical (turbo_lock)
Expand Down