Skip to content

Commit

Permalink
Add citation as optional argument
Browse files Browse the repository at this point in the history
  • Loading branch information
awvwgk committed Sep 29, 2024
1 parent d6c2e73 commit 56b37f8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
16 changes: 8 additions & 8 deletions app/driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ subroutine run_driver(config, error)
character(len=:), allocatable :: output
integer :: stat, unit, idx
logical :: exist
type(citation_type) :: citation
type(citation_type) :: citation, param_citation

if (config%verbosity > 1) then
call header(output_unit)
Expand Down Expand Up @@ -97,7 +97,7 @@ subroutine run_driver(config, error)
if (allocated(config%db)) then
call from_db(param, config%db, config%method, "zero", error)
else
call get_zero_damping(inp, config%method, error, s9)
call get_zero_damping(inp, config%method, error, s9, param_citation)
end if
if (allocated(error)) return
end if
Expand All @@ -116,7 +116,7 @@ subroutine run_driver(config, error)
if (allocated(config%db)) then
call from_db(param, config%db, config%method, "zerom", error)
else
call get_mzero_damping(inp, config%method, error, s9)
call get_mzero_damping(inp, config%method, error, s9, param_citation)
end if
if (allocated(error)) return
end if
Expand All @@ -140,13 +140,13 @@ subroutine run_driver(config, error)
if (allocated(config%db)) then
call from_db(param, config%db, config%method, "bjm", error)
else
call get_mrational_damping(inp, config%method, error, s9)
call get_mrational_damping(inp, config%method, error, s9, param_citation)
end if
else
if (allocated(config%db)) then
call from_db(param, config%db, config%method, "bj", error)
else
call get_rational_damping(inp, config%method, error, s9)
call get_rational_damping(inp, config%method, error, s9, param_citation)
end if
end if
if (allocated(error)) return
Expand All @@ -166,7 +166,7 @@ subroutine run_driver(config, error)
if (allocated(config%db)) then
call from_db(param, config%db, config%method, "op", error)
else
call get_optimizedpower_damping(inp, config%method, error, s9)
call get_optimizedpower_damping(inp, config%method, error, s9, param_citation)
end if
if (allocated(error)) return
end if
Expand Down Expand Up @@ -278,11 +278,11 @@ subroutine run_driver(config, error)

if (config%citation) then
open(file=config%citation_output, newunit=unit)
if (.not.same_citation(citation, inp%citation)) then
if (.not.same_citation(citation, param_citation)) then
call format_bibtex(output, citation)
if (allocated(output)) write(unit, '(a)') output
end if
call format_bibtex(output, inp%citation)
call format_bibtex(output, param_citation)
if (allocated(output)) write(unit, '(a)') output
close(unit)
if (config%verbosity > 0) then
Expand Down
36 changes: 25 additions & 11 deletions src/dftd3/param.f90
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ module dftd3_param
real(wp) :: a2 = 5.0_wp
real(wp) :: alp = 14.0_wp
real(wp) :: bet = 0.0_wp
type(citation_type) :: citation
end type d3_param


Expand Down Expand Up @@ -290,7 +289,7 @@ function get_method_id(method) result(id)
end function get_method_id


subroutine get_rational_damping(param, method, error, s9)
subroutine get_rational_damping(param, method, error, s9, citation)

!> Loaded parameter record
type(d3_param), intent(out) :: param
Expand All @@ -301,6 +300,9 @@ subroutine get_rational_damping(param, method, error, s9)
!> Overwrite s9
real(wp), intent(in), optional :: s9

!> Citation information
type(citation_type), intent(out), optional :: citation

!> Error handling
type(error_type), allocatable, intent(out) :: error

Expand Down Expand Up @@ -775,7 +777,7 @@ subroutine get_rational_damping(param, method, error, s9)
end select

if (.not.allocated(doi)) doi = doi_dftd3_bj
param%citation = get_citation(doi)
citation = get_citation(doi)

if (present(s9)) then
param%s9 = s9
Expand All @@ -784,7 +786,7 @@ subroutine get_rational_damping(param, method, error, s9)
end subroutine get_rational_damping


subroutine get_zero_damping(param, method, error, s9)
subroutine get_zero_damping(param, method, error, s9, citation)

!> Loaded parameter record
type(d3_param), intent(out) :: param
Expand All @@ -795,6 +797,9 @@ subroutine get_zero_damping(param, method, error, s9)
!> Overwrite s9
real(wp), intent(in), optional :: s9

!> Citation information
type(citation_type), intent(out), optional :: citation

!> Error handling
type(error_type), allocatable, intent(out) :: error

Expand Down Expand Up @@ -1055,7 +1060,7 @@ subroutine get_zero_damping(param, method, error, s9)
end select

if (.not.allocated(doi)) doi = doi_dftd3_0
param%citation = get_citation(doi)
citation = get_citation(doi)

if (present(s9)) then
param%s9 = s9
Expand All @@ -1064,7 +1069,7 @@ subroutine get_zero_damping(param, method, error, s9)
end subroutine get_zero_damping


subroutine get_mrational_damping(param, method, error, s9)
subroutine get_mrational_damping(param, method, error, s9,citation)

!> Loaded parameter record
type(d3_param), intent(out) :: param
Expand All @@ -1075,6 +1080,9 @@ subroutine get_mrational_damping(param, method, error, s9)
!> Overwrite s9
real(wp), intent(in), optional :: s9

!> Citation information
type(citation_type), intent(out), optional :: citation

!> Error handling
type(error_type), allocatable, intent(out) :: error

Expand All @@ -1100,7 +1108,7 @@ subroutine get_mrational_damping(param, method, error, s9)
param = d3_param(a1=0.563761_wp, s8=0.906564_wp, a2=3.593680_wp)
end select

param%citation = get_citation(doi_dftd3_m)
citation = get_citation(doi_dftd3_m)

if (present(s9)) then
param%s9 = s9
Expand All @@ -1109,7 +1117,7 @@ subroutine get_mrational_damping(param, method, error, s9)
end subroutine get_mrational_damping


subroutine get_mzero_damping(param, method, error, s9)
subroutine get_mzero_damping(param, method, error, s9, citation)

!> Loaded parameter record
type(d3_param), intent(out) :: param
Expand All @@ -1120,6 +1128,9 @@ subroutine get_mzero_damping(param, method, error, s9)
!> Overwrite s9
real(wp), intent(in), optional :: s9

!> Citation information
type(citation_type), intent(out), optional :: citation

!> Error handling
type(error_type), allocatable, intent(out) :: error

Expand All @@ -1145,7 +1156,7 @@ subroutine get_mzero_damping(param, method, error, s9)
param = d3_param(rs6=1.366361_wp, s8=1.280619_wp, bet=0.003160_wp)
end select

param%citation = get_citation(doi_dftd3_m)
citation = get_citation(doi_dftd3_m)

if (present(s9)) then
param%s9 = s9
Expand All @@ -1154,7 +1165,7 @@ subroutine get_mzero_damping(param, method, error, s9)
end subroutine get_mzero_damping


subroutine get_optimizedpower_damping(param, method, error, s9)
subroutine get_optimizedpower_damping(param, method, error, s9, citation)

!> Loaded parameter record
type(d3_param), intent(out) :: param
Expand All @@ -1165,6 +1176,9 @@ subroutine get_optimizedpower_damping(param, method, error, s9)
!> Overwrite s9
real(wp), intent(in), optional :: s9

!> Citation information
type(citation_type), intent(out), optional :: citation

!> Error handling
type(error_type), allocatable, intent(out) :: error

Expand Down Expand Up @@ -1202,7 +1216,7 @@ subroutine get_optimizedpower_damping(param, method, error, s9)
param = d3_param(s6=1.0_wp, s8=1.69464_wp, a1=0.650_wp, a2=4.75_wp, bet=0.0_wp)
end select

param%citation = get_citation(doi_dftd3_op)
citation = get_citation(doi_dftd3_op)

if (present(s9)) then
param%s9 = s9
Expand Down

0 comments on commit 56b37f8

Please sign in to comment.