-
Notifications
You must be signed in to change notification settings - Fork 61
dftd4_load_rational_damping third arg uneffective #333
Description
I found that for dftd4_load_rational_damping function, if the third argument (mdb in C, atm in Fortran) is false, s9 will still be set to 1.0. Could you help check whether this is a bug?
Traceback
-
C-API Layer (
include/dftd4.h):
The function signature isdftd4_load_rational_damping(..., bool mdb). -
Fortran API Layer (
src/dftd4/api.f90):
The C function callsload_rational_damping_api.function load_rational_damping_api(verror, charptr, atm) ... logical(c_bool), value, intent(in) :: atm real(wp), allocatable :: s9 ... if (atm) s9 = 1.0_wp call get_rational_damping(method, tmp, s9)
If
atm(the third argument) isfalse, the variables9remains unallocated. -
Parameter Retrieval (
src/dftd4/param.f90):
Theget_rational_dampinginterface callsget_rational_damping_name, which callsget_rational_damping_id.
Sinces9was unallocated in the caller, it is treated as not present in the optional arguments chain.In
get_rational_damping_id:mbd = .true. if (present(s9)) mbd = abs(s9) > epsilon(s9)
Because
s9is not present,mbddefaults to.true.. This triggers the call toget_d4eeq_bjatm_parameter. -
Default Value Assignment:
Insideget_d4eeq_bjatm_parameter, the helper functiondftd_paramis called withouts9.pure function dftd_param(..., s9) ... s9_ = 1.0_wp if (present(s9)) s9_ = s9
Since
s9is missing, it defaults to 1.0.