Skip to content
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
16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,19 @@ jobs:
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit checks
run: pre-commit run -a
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/PlasmaFAIR/fortitude-pre-commit
rev: v0.9.0
hooks:
- id: fortitude
args: ["--fix", "--preview"]
8 changes: 4 additions & 4 deletions app/argument.f90
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ recursive subroutine get_response_file(self, resp, stat)
return
end if

open(file=resp, unit=unit, iostat=info, status='old', action='read')
open(file=resp, unit=unit, iostat=info, status="old", action="read")
do while(info == 0)
call getline(unit, arg, info)
if (info /= 0) exit
Expand Down Expand Up @@ -216,7 +216,7 @@ subroutine getline(unit, line, iostat, iomsg)

allocate(character(len=0) :: line)
do
read(unit, '(a)', advance='no', iostat=stat, iomsg=msg, size=size) &
read(unit, "(a)", advance="no", iostat=stat, iomsg=msg, size=size) &
& buffer
if (stat > 0) exit
line = line // buffer(:size)
Expand Down Expand Up @@ -330,12 +330,12 @@ subroutine get_default_argument(idx, arg)
call get_command_argument(idx, length=length, status=stat)
if (stat /= 0) then
return
endif
end if

allocate(character(len=length) :: arg, stat=stat)
if (stat /= 0) then
return
endif
end if

if (length > 0) then
call get_command_argument(idx, arg, status=stat)
Expand Down
12 changes: 6 additions & 6 deletions app/cli.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

module dftd3_app_cli
use, intrinsic :: iso_fortran_env, only : output_unit
use mctc_env, only : wp, error_type, fatal_error
use mctc_io, only : structure_type, read_structure, filetype, get_filetype
use dftd3, only : d3_param
use dftd3_app_argument, only : argument_list, len
use dftd3_app_help, only : prog_name, header, help_text, run_help_text, param_help_text, &
& gcp_help_text, version
use mctc_env, only : wp, error_type, fatal_error
use mctc_io, only : structure_type, read_structure, filetype, get_filetype
implicit none
private

Expand Down Expand Up @@ -232,7 +232,7 @@ subroutine get_arguments(config, error)
if (allocated(error)) return

if (.not.allocated(config)) then
write(output_unit, '(a)') help_text
write(output_unit, "(a)") help_text
call fatal_error(error, "Insufficient arguments provided")
return
end if
Expand Down Expand Up @@ -570,7 +570,7 @@ subroutine get_run_arguments(config, list, start, error)

if (.not.allocated(config%input)) then
if (.not.allocated(error)) then
write(output_unit, '(a)') run_help_text
write(output_unit, "(a)") run_help_text
call fatal_error(error, "Insufficient arguments provided")
end if
end if
Expand Down Expand Up @@ -649,7 +649,7 @@ subroutine get_param_arguments(config, list, start, error)

if (.not.allocated(config%input)) then
if (.not.allocated(error)) then
write(output_unit, '(a)') param_help_text
write(output_unit, "(a)") param_help_text
call fatal_error(error, "Insufficient arguments provided")
end if
end if
Expand Down Expand Up @@ -758,7 +758,7 @@ subroutine get_gcp_arguments(config, list, start, error)

if (.not.allocated(config%input)) then
if (.not.allocated(error)) then
write(output_unit, '(a)') gcp_help_text
write(output_unit, "(a)") gcp_help_text
call fatal_error(error, "Insufficient arguments provided")
end if
end if
Expand Down
60 changes: 31 additions & 29 deletions app/driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

module dftd3_app_driver
use, intrinsic :: iso_fortran_env, only : output_unit, input_unit
use mctc_env, only : wp, error_type, fatal_error
use mctc_io, only : structure_type, read_structure, filetype, get_filetype
use dftd3, only : damping_param, d3_param, d3_model, &
& get_dispersion, get_zero_damping, zero_damping_param, new_zero_damping, &
& get_rational_damping, rational_damping_param, new_rational_damping, &
Expand All @@ -27,18 +25,20 @@ module dftd3_app_driver
& get_cso_damping, cso_damping_param, new_cso_damping, &
& new_d3_model, get_pairwise_dispersion, &
& realspace_cutoff, get_lattice_points, get_coordination_number
use dftd3_app_cli, only : app_config, run_config, param_config, gcp_config, get_arguments
use dftd3_app_help, only : header
use dftd3_app_toml, only : param_database
use dftd3_citation, only : format_bibtex, is_citation_present, citation_type, &
& get_citation, doi_dftd3_0, doi_dftd3_bj, doi_dftd3_m, doi_dftd3_op, &
& doi_dftd3_cso, doi_joss, same_citation
use dftd3_gcp, only : gcp_param, get_gcp_param, get_geometric_counterpoise
use dftd3_output, only : ascii_damping_param, ascii_atomic_radii, &
& ascii_atomic_references, ascii_system_properties, ascii_energy_atom, &
& ascii_results, ascii_pairwise, tagged_result, json_results, &
& turbomole_gradient, turbomole_gradlatt, ascii_gcp_param
use dftd3_utils, only : wrap_to_central_cell
use dftd3_citation, only : format_bibtex, is_citation_present, citation_type, &
& get_citation, doi_dftd3_0, doi_dftd3_bj, doi_dftd3_m, doi_dftd3_op, &
& doi_dftd3_cso, doi_joss, same_citation
use dftd3_app_help, only : header
use dftd3_app_cli, only : app_config, run_config, param_config, gcp_config, get_arguments
use dftd3_app_toml, only : param_database
use mctc_env, only : wp, error_type, fatal_error
use mctc_io, only : structure_type, read_structure, filetype, get_filetype
implicit none
private

Expand Down Expand Up @@ -213,10 +213,12 @@ subroutine run_driver(config, error)
end if

if (config%verbosity > 0) then
if (allocated(param)) &
call ascii_damping_param(output_unit, param, config%method)
if (config%gcp) &
call ascii_gcp_param(output_unit, mol, gcp)
if (allocated(param)) then
call ascii_damping_param(output_unit, param, config%method)
end if
if (config%gcp) then
call ascii_gcp_param(output_unit, mol, gcp)
end if
end if

if (allocated(param)) then
Expand Down Expand Up @@ -272,7 +274,7 @@ subroutine run_driver(config, error)
& pairwise_energy2=pair_disp2, pairwise_energy3=pair_disp3, param=param)
close(unit)
if (config%verbosity > 0) then
write(output_unit, '(a)') &
write(output_unit, "(a)") &
& "[Info] JSON dump of results written to '"//config%json_output//"'"
end if
end if
Expand All @@ -282,16 +284,16 @@ subroutine run_driver(config, error)
if (config%citation) then
open(file=config%citation_output, newunit=unit)
call format_bibtex(output, get_citation(doi_joss))
if (allocated(output)) write(unit, '(a)') output
if (allocated(output)) write(unit, "(a)") output
if (.not.same_citation(citation, param_citation)) then
call format_bibtex(output, citation)
if (allocated(output)) write(unit, '(a)') output
if (allocated(output)) write(unit, "(a)") output
end if
call format_bibtex(output, param_citation)
if (allocated(output)) write(unit, '(a)') output
if (allocated(output)) write(unit, "(a)") output
close(unit)
if (config%verbosity > 0) then
write(output_unit, '(a)') &
write(output_unit, "(a)") &
& "[Info] Citation information written to '"//config%citation_output//"'"
end if
end if
Expand All @@ -317,9 +319,9 @@ subroutine property_calc(unit, mol, disp, verbosity)

if (verbosity > 1) then
call ascii_atomic_radii(unit, mol, disp)
write(unit, '(a)')
write(unit, "(a)")
call ascii_atomic_references(unit, mol, disp)
write(unit, '(a)')
write(unit, "(a)")
end if

mref = maxval(disp%ref)
Expand All @@ -331,7 +333,7 @@ subroutine property_calc(unit, mol, disp, verbosity)

if (verbosity > 0) then
call ascii_system_properties(unit, mol, disp, cn, c6)
write(unit, '(a)')
write(unit, "(a)")
end if

end subroutine property_calc
Expand All @@ -354,7 +356,7 @@ subroutine param_driver(config, error)
end if
call ascii_damping_param(output_unit, param, config%method)
else
write(output_unit, '(a, *(1x, g0))') "[Info] Found", size(db%records), &
write(output_unit, "(a, *(1x, g0))") "[Info] Found", size(db%records), &
"damping parameters in '"//config%input//"'"
end if

Expand Down Expand Up @@ -446,7 +448,7 @@ subroutine gcp_driver(config, error)
call json_results(unit, " ", energy=energy, gradient=gradient, sigma=sigma)
close(unit)
if (config%verbosity > 0) then
write(output_unit, '(a)') &
write(output_unit, "(a)") &
& "[Info] JSON dump of results written to '"//config%json_output//"'"
end if
end if
Expand All @@ -470,10 +472,10 @@ subroutine tmer_writer(filename, energy, label, verbosity)

if (verbosity > 0) then
if (verbosity > 1) then
write(output_unit, '(a)') "[Info] Writing "//label//" energy to '"//filename//"'"
write(output_unit, "(a)") "[Info] Writing "//label//" energy to '"//filename//"'"
end if
open(file=filename, newunit=unit)
write(unit, '(f24.14)') energy
write(unit, "(f24.14)") energy
close(unit)
end if
end subroutine tmer_writer
Expand Down Expand Up @@ -504,7 +506,7 @@ subroutine results_writer(filename, energy, gradient, sigma, label, verbosity)
call tagged_result(unit, energy, gradient, sigma)
close(unit)
if (verbosity > 0) then
write(output_unit, '(a)') "[Info] "//label//" results written to '"//filename//"'"
write(output_unit, "(a)") "[Info] "//label//" results written to '"//filename//"'"
end if
end subroutine results_writer

Expand Down Expand Up @@ -537,10 +539,10 @@ subroutine turbomole_writer(mol, energy, gradient, sigma, verbosity, label)
call turbomole_gradient(mol, "gradient", energy, gradient, stat)
if (verbosity > 0) then
if (stat == 0) then
write(output_unit, '(a)') &
write(output_unit, "(a)") &
& "[Info] "//label//" gradient added to Turbomole gradient file"
else
write(output_unit, '(a)') &
write(output_unit, "(a)") &
& "[Warn] Could not add to Turbomole gradient file"
end if
end if
Expand All @@ -550,10 +552,10 @@ subroutine turbomole_writer(mol, energy, gradient, sigma, verbosity, label)
call turbomole_gradlatt(mol, "gradlatt", energy, sigma, stat)
if (verbosity > 0) then
if (stat == 0) then
write(output_unit, '(a)') &
write(output_unit, "(a)") &
& "[Info] "//label//" virial added to Turbomole gradlatt file"
else
write(output_unit, '(a)') &
write(output_unit, "(a)") &
& "[Warn] Could not add to Turbomole gradlatt file"
end if
end if
Expand Down
6 changes: 3 additions & 3 deletions app/help.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module dftd3_app_help

character(len=*), parameter :: prog_name = "s-dftd3"

character(len=*), parameter :: nl = new_line('a')
character(len=*), parameter :: nl = new_line("a")

character(len=*), parameter :: run_options_text = &
"-i,--input <format> Hint for the format of the input file"//nl//&
Expand Down Expand Up @@ -161,7 +161,7 @@ subroutine header(unit)
character(len=:), allocatable :: version_string

call get_dftd3_version(string=version_string)
write(unit, '(a)') &
write(unit, "(a)") &
"-----------------------------------", &
" s i m p l e D F T - D 3 v"// version_string, &
"-----------------------------------", ""
Expand All @@ -174,7 +174,7 @@ subroutine version(unit)
character(len=:), allocatable :: version_string

call get_dftd3_version(string=version_string)
write(unit, '(a, *(1x, a))') &
write(unit, "(a, *(1x, a))") &
& prog_name, "version", version_string

end subroutine version
Expand Down
4 changes: 2 additions & 2 deletions app/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

program dftd3_main
use, intrinsic :: iso_fortran_env, only : output_unit, error_unit
use mctc_env, only : error_type
use dftd3_app_cli, only : app_config, get_arguments
use dftd3_app_driver, only : app_driver
use mctc_env, only : error_type
implicit none
class(app_config), allocatable :: config
type(error_type), allocatable :: error
Expand All @@ -43,7 +43,7 @@ end subroutine sys_exit

if (allocated(error)) then
if (error%stat == 0) then
write(output_unit, '(a)') error%message
write(output_unit, "(a)") error%message
call sys_exit(0)
else
write(error_unit, '("[Error]", 1x, a)') error%message
Expand Down
2 changes: 1 addition & 1 deletion app/toml.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

!> Implementation of a parameter database for damping parameters
module dftd3_app_toml
use mctc_env, only : error_type, fatal_error
use dftd3, only : d3_param, damping_param, rational_damping_param, new_rational_damping, &
& zero_damping_param, new_zero_damping, mzero_damping_param, new_mzero_damping, &
& optimizedpower_damping_param, new_optimizedpower_damping, &
& cso_damping_param, new_cso_damping
use mctc_env, only : error_type, fatal_error
use tomlf, only : toml_table, toml_array, toml_key, toml_error, toml_parse, &
& get_value, len
implicit none
Expand Down
10 changes: 5 additions & 5 deletions doc/guide/minimal-example/energy.f90
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
program test_simple_d3
use, intrinsic :: iso_fortran_env, only : r8 => real64
use mctc_env, only: error_type
use mctc_io, only: structure_type, new
use dftd3, only: d3_model, d3_param, rational_damping_param, get_rational_damping, &
& new_rational_damping, new_d3_model, get_dispersion, realspace_cutoff
use mctc_env, only: error_type
use mctc_io, only: structure_type, new
implicit none

character(len=:), allocatable :: method
Expand All @@ -17,7 +17,7 @@ program test_simple_d3
type(d3_param) :: inp
type(rational_damping_param) :: param

method = 'PBE0'
method = "PBE0"
num = [6, 1, 1, 1, 1]
xyz = reshape([ & ! coordinates in Bohr
& 0.0000000_r8, -0.0000000_r8, 0.0000000_r8, &
Expand All @@ -30,13 +30,13 @@ program test_simple_d3

call get_rational_damping(inp, method, error, s9=1.0_r8)
if (allocated(error)) then
print '(2a)', "Error: ", error%message
print "(2a)", "Error: ", error%message
return
end if
call new_rational_damping(param, inp)
call new_d3_model(disp, mol)

call get_dispersion(mol, disp, param, realspace_cutoff(), energy)
print '(3a, f13.10, a)', 'Dispersion energy for ', method, '-D3(BJ) is ', energy, ' Hartree'
print "(3a, f13.10, a)", "Dispersion energy for ", method, "-D3(BJ) is ", energy, " Hartree"

end program test_simple_d3
Loading
Loading