1
1
! This file is part of s-dftd3.
2
- ! SPDX-Identifier: LGLP -3.0-or-later
2
+ ! SPDX-Identifier: LGPL -3.0-or-later
3
3
!
4
4
! s-dftd3 is free software: you can redistribute it and/or modify it under
5
5
! the terms of the GNU Lesser General Public License as published by
@@ -20,12 +20,14 @@ program dftd3_main
20
20
use mctc_io
21
21
use dftd3
22
22
use dftd3_output
23
+ use dftd3_utils
23
24
implicit none
24
25
character (len=* ), parameter :: prog_name = " s-dftd3"
25
26
26
27
type :: d3_config
27
- logical :: json = .true .
28
+ logical :: json = .false .
28
29
character (len= :), allocatable :: json_output
30
+ logical :: wrap = .true.
29
31
logical :: tmer = .true.
30
32
logical :: properties = .false.
31
33
logical :: atm = .false.
@@ -49,37 +51,64 @@ program dftd3_main
49
51
character (len= :), allocatable :: method
50
52
type (zero_damping_param), allocatable :: zparam
51
53
type (rational_damping_param), allocatable :: rparam
54
+ real (wp), allocatable :: s9
52
55
integer :: stat, unit
53
56
logical :: echo, exist
54
57
55
58
call get_arguments(input, input_format, config, method, inp, echo, error)
56
59
if (allocated (error)) then
57
- write (error_unit, ' (a)' ) error% message
60
+ write (error_unit, ' ("[Error]", 1x, a)' ) error% message
58
61
error stop
59
62
end if
60
63
64
+ if (config% verbosity > 1 ) then
65
+ call header(output_unit)
66
+ end if
67
+
61
68
if (input == " -" ) then
62
69
if (.not. allocated (input_format)) input_format = filetype% xyz
63
70
call read_structure(mol, input_unit, input_format, error)
64
71
else
65
72
call read_structure(mol, input, error, input_format)
66
73
end if
67
74
if (allocated (error)) then
68
- write (error_unit, ' (a)' ) error% message
75
+ write (error_unit, ' ("[Error]", 1x, a)' ) error% message
69
76
error stop
70
77
end if
78
+ if (config% wrap) then
79
+ call wrap_to_central_cell(mol% xyz, mol% lattice, mol% periodic)
80
+ end if
71
81
82
+ if (config% atm) s9 = inp% s9
72
83
if (config% zero) then
84
+ if (.not. config% has_param) then
85
+ call get_zero_damping_param(inp, method, error, s9)
86
+ if (allocated (error)) then
87
+ write (error_unit, ' ("[Error]", 1x, a)' ) error% message
88
+ error stop
89
+ end if
90
+ end if
73
91
allocate (zparam)
74
92
call new_zero_damping(zparam, inp, mol% num)
75
93
call move_alloc(zparam, param)
76
94
end if
77
95
if (config% rational) then
96
+ if (.not. config% has_param) then
97
+ call get_rational_damping_param(inp, method, error, s9)
98
+ if (allocated (error)) then
99
+ write (error_unit, ' ("[Error]", 1x, a)' ) error% message
100
+ error stop
101
+ end if
102
+ end if
78
103
allocate (rparam)
79
104
call new_rational_damping(rparam, inp, mol% num)
80
105
call move_alloc(rparam, param)
81
106
end if
82
107
108
+ if (allocated (param) .and. config% verbosity > 0 ) then
109
+ call ascii_damping_param(output_unit, param, method)
110
+ end if
111
+
83
112
if (config% grad) then
84
113
allocate (gradient(3 , mol% nat))
85
114
end if
@@ -186,6 +215,19 @@ subroutine property_calc(unit, mol, disp, verbosity)
186
215
end subroutine property_calc
187
216
188
217
218
+ subroutine header (unit )
219
+ integer , intent (in ) :: unit
220
+ character (len= :), allocatable :: version_string
221
+
222
+ call get_dftd3_version(string= version_string)
223
+ write (unit, ' (a)' ) &
224
+ " -----------------------------------" , &
225
+ " s i m p l e D F T - D 3 v" // version_string, &
226
+ " -----------------------------------" , " "
227
+
228
+ end subroutine header
229
+
230
+
189
231
subroutine help (unit )
190
232
integer , intent (in ) :: unit
191
233
@@ -195,21 +237,20 @@ subroutine help(unit)
195
237
write (unit, ' (a)' ) &
196
238
" " , &
197
239
" Takes an geometry input to calculate the D3 dispersion correction." , &
198
- " Periodic calculations are performed automatically for periodic input formats" , &
240
+ " Periodic calculations are performed automatically for periodic input formats. " , &
199
241
" Specify the functional to select the correct parameters." , &
200
242
" "
201
243
202
244
write (unit, ' (2x, a, t25, a)' ) &
203
245
" -i, --input <format>" , " Hint for the format of the input file" , &
204
- " --func <method>" , " Specify functional to use" , &
205
- " --bj" , " Use rational (Becke-Johnson) damping function" , &
246
+ " --bj <method>" , " Use rational (Becke-Johnson) damping function" , &
206
247
" --bj-param <list>" , " Specify parameters for rational damping," , &
207
248
" " , " expected order is s6, s8, a1, a2 (requires four arguments)" , &
208
- " --zero" , " Use zero (Chai-Head-Gordon) damping function" , &
209
- " --zero-param <list>" , " Specify functional to use ," , &
249
+ " --zero <method> " , " Use zero (Chai-Head-Gordon) damping function" , &
250
+ " --zero-param <list>" , " Specify parameters for zero damping ," , &
210
251
" " , " expected order is s6, s8, rs6 (requires three arguments)" , &
211
- " --atm" , " Use ATM three-body dispersion, " , &
212
- " --atm-scale <s9>" , " Use scaled ATM three-body dispersion, " , &
252
+ " --atm" , " Use ATM three-body dispersion" , &
253
+ " --atm-scale <s9>" , " Use scaled ATM three-body dispersion" , &
213
254
" --noedisp" , " Disable writing of dispersion energy to .EDISP file" , &
214
255
" --json [file]" , " Dump results to JSON output (default: dftd3.json)" , &
215
256
" --grad" , " Request gradient evaluation" , &
@@ -340,7 +381,11 @@ subroutine get_arguments(input, input_format, config, method, inp, echo, error)
340
381
call move_alloc(arg, input)
341
382
cycle
342
383
end if
343
- call fatal_error(error, " Too many positional arguments present" )
384
+ if (arg(1 :1 ) == " -" ) then
385
+ call fatal_error(error, " Unknown argument encountered: '" // arg// " '" )
386
+ else
387
+ call fatal_error(error, " Too many positional arguments present" )
388
+ end if
344
389
exit
345
390
case (" -i" , " --input" )
346
391
iarg = iarg + 1
@@ -352,6 +397,7 @@ subroutine get_arguments(input, input_format, config, method, inp, echo, error)
352
397
input_format = get_filetype(" ." // arg)
353
398
case (" --json" )
354
399
config% json = .true.
400
+ config% json_output = " dftd3.json"
355
401
iarg = iarg + 1
356
402
call get_argument(iarg, arg)
357
403
if (allocated (arg)) then
@@ -360,13 +406,13 @@ subroutine get_arguments(input, input_format, config, method, inp, echo, error)
360
406
cycle
361
407
end if
362
408
call move_alloc(arg, config% json_output)
363
- else
364
- config% json_output = " dftd3.json"
365
409
end if
366
410
case (" --property" )
367
411
config% properties = .true.
368
412
case (" --noedisp" )
369
413
config% tmer = .false.
414
+ case (" --nowrap" )
415
+ config% wrap = .false.
370
416
case (" --grad" )
371
417
config% grad = .true.
372
418
case (" --atm" )
@@ -377,6 +423,15 @@ subroutine get_arguments(input, input_format, config, method, inp, echo, error)
377
423
call get_argument_as_real(iarg, inp% s9, error)
378
424
if (allocated (error)) exit
379
425
config% atm = .true.
426
+ case (" --zero" )
427
+ config% zero = .true.
428
+ iarg = iarg + 1
429
+ call get_argument(iarg, arg)
430
+ if (.not. allocated (arg)) then
431
+ call fatal_error(error, " Missing argument for method" )
432
+ exit
433
+ end if
434
+ call move_alloc(arg, method)
380
435
case (" --zero-param" )
381
436
config% zero = .true.
382
437
config% has_param = .true.
@@ -389,6 +444,15 @@ subroutine get_arguments(input, input_format, config, method, inp, echo, error)
389
444
iarg = iarg + 1
390
445
call get_argument_as_real(iarg, inp% rs6, error)
391
446
if (allocated (error)) exit
447
+ case (" --bj" )
448
+ config% rational = .true.
449
+ iarg = iarg + 1
450
+ call get_argument(iarg, arg)
451
+ if (.not. allocated (arg)) then
452
+ call fatal_error(error, " Missing argument for method" )
453
+ exit
454
+ end if
455
+ call move_alloc(arg, method)
392
456
case (" --bj-param" )
393
457
config% rational = .true.
394
458
config% has_param = .true.
@@ -404,16 +468,9 @@ subroutine get_arguments(input, input_format, config, method, inp, echo, error)
404
468
iarg = iarg + 1
405
469
call get_argument_as_real(iarg, inp% a2, error)
406
470
if (allocated (error)) exit
407
- case (" --func" )
408
- iarg = iarg + 1
409
- call get_argument(iarg, arg)
410
- if (.not. allocated (arg)) then
411
- call fatal_error(error, " Missing argument for method" )
412
- exit
413
- end if
414
- call move_alloc(arg, method)
415
471
end select
416
472
end do
473
+ if (allocated (error)) return
417
474
418
475
if (.not. config% has_param .and. .not. allocated (method)) then
419
476
config% properties = .true.
0 commit comments