-
Notifications
You must be signed in to change notification settings - Fork 137
/
set_module.f90
2319 lines (2167 loc) · 74.2 KB
/
set_module.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
! This file is part of xtb.
!
! Copyright (C) 2017-2019 Stefan Grimme
!
! xtb is free software: you can redistribute it and/or modify it under
! the terms of the GNU Lesser General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! xtb is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU Lesser General Public License for more details.
!
! You should have received a copy of the GNU Lesser General Public License
! along with xtb. If not, see <https://www.gnu.org/licenses/>.
!! ========================================================================
! * WELCOME TO THE C O N T R O L & I N P U T MODULE IN XTB *
!! ------------------------------------------------------------------------
! I use a singleton pattern for our input parser to ensure that you cannot
! override your input data, therefore it is strictly necessary to follow a
! strict hierachy on input sources. We decided that command arguments have
! the highest priority, than follows the various input files and finally a
! global configuration file is read in. The program structure is set up in
! exactly that way, so this module has to behave like a singleton. Fortran
! provides the save keyword, which is used in each set subroutine for this
! purpose.
!! ------------------------------------------------------------------------
! The syntax is:
!> # logical instructions require a single statement
!> $fit
!> $samerand
!> # special logicals are chrg and spin
!> $chrg <int>
!> $spin <int>
!> # data instructons are opened by a keyword, which by default has no effect
!> $gfn
!> version=<int>
!> d4=<bool>
!> $scc
!> temp=<real>
!> broydamp=<real>
!> ...
!> $end # this is optional
! unknown instructions are ignored and can be used to store additional info
! that does not affect the outcome of the calculation
!
! generally we distinguish between, ints, bools and reals. List's of arbitrary
! combinations those can be archived by the `parse' subroutine from the MCTC lib.
! Be carefully when reading arrays of unknown size, because you cannot backspace
! on the input file. Multiline input is also not supported, but we have
! arbitrary long lines to compensate for this.
!
! To implement a new feature start by adding the variables to the header of
! setparam.f90 (here), think about what you are doing, this module is integrated
! in almost every important unit of xtb, so be careful when chosing variable
! names (dum, nat, xyz and i usually bad ideas). You should use verbose names.
!
! Next step is to define a default and add the printout in `write_set', add
! the necessary information about the feature in the man page of `xcontrol'
! and a short description in the manual. SERIOUSLY, do this first.
! For all features that are incompatible with the singleton nature of `setparam'
! use `constrain_param' and read the introduction there carefully.
!
! Now you can add the necessary line in the `readflags' loop of `rdcontrol'
! and define your own set subroutine here. If you add an option to an existing
! instruction just add the case in the appropriate and set subroutine and
! use a saved logical to guard it (I called them set<int>).
!
! If you have any questions on this module, feel free to ask me or another dev
! SAW: ehlert@thch.uni-bonn.de
!
module set_module
use iso_fortran_env, only : wp => real64
use readin, only : mirror_line,get_value
use setparam
implicit none
private :: wp,mirror_line,get_value
character,private,parameter :: flag = '$'
character,private,parameter :: colon = ':'
character,private,parameter :: space = ' '
character,private,parameter :: equal = '='
character,private,parameter :: hash = '#'
character,private,parameter :: dot = '.'
character,private,parameter :: comma = ','
character(len=*),private,parameter :: flag_end = flag//'end'
! Using allocatable arrays of dynamic length strings is only possible
! with a lot of hacks, so we use good'ol fixed size stack arrays.
! Let's choose something different from 42 that is not dividable by 10... ;)
! Happy debugging!
integer,private,parameter :: p_str_length = 48
integer,private,parameter :: p_arg_length = 24
public
contains
subroutine write_set(ictrl)
implicit none
integer,intent(in) :: ictrl
! write the coord file, charge and spin information first
write(ictrl,'(a,"chrg",1x,i0)') flag,ichrg
write(ictrl,'(a,"spin",1x,i0)') flag,nalphabeta
! was the fit-flag set?
if (fit) write(ictrl,'(a,"fit")') flag
if (samerand) write(ictrl,'(a,"samerand")') flag
call write_set_gfn(ictrl)
call write_set_scc(ictrl)
call write_set_opt(ictrl)
call write_set_thermo(ictrl)
call write_set_md(ictrl)
call write_set_siman(ictrl)
call write_set_hess(ictrl)
call write_set_gbsa(ictrl)
call write_set_modef(ictrl)
call write_set_cube(ictrl)
call write_set_symmetry(ictrl)
call write_set_embedding(ictrl)
call write_set_write(ictrl)
call write_set_external(ictrl)
call write_set_stm(ictrl)
call write_set_path(ictrl)
call write_set_split(ictrl)
call write_set_wall(ictrl)
call write_set_fix(ictrl)
call write_set_constrain(ictrl)
call write_set_scan(ictrl)
call write_set_metadyn(ictrl)
call write_set_reactor(ictrl)
end subroutine write_set
! write *all* informations contained in the setcommon to xcontrol
subroutine write_set_gfn(ictrl)
use readin, only : bool2int,bool2string
implicit none
integer,intent(in) :: ictrl
write(ictrl,'(a,"gfn")') flag
write(ictrl,'(3x,"method=",i0)') gfn_method
! select case(gfn_method)
! case(p_method_gfn0xtb); write(ictrl,'(3x,"method=gfn0-xtb")')
! case(p_method_gfn1xtb); write(ictrl,'(3x,"method=gfn1-xtb")')
! case(p_method_gfn2xtb); write(ictrl,'(3x,"method=gfn2-xtb")')
! end select
if (gfn_method.gt.2) &
write(ictrl,'(3x,"d4=",a)') bool2string(newdisp)
write(ictrl,'(3x,"scc=",a)') bool2string(solve_scc)
write(ictrl,'(3x,"periodic=",a)') bool2string(periodic)
end subroutine write_set_gfn
subroutine write_set_scc(ictrl)
implicit none
integer,intent(in) :: ictrl
write(ictrl,'(a,"scc")') flag
write(ictrl,'(3x,"maxiterations=",i0)') maxscciter
write(ictrl,'(3x,"temp=",g0)') eTemp
write(ictrl,'(3x,"broydamp=",g0)') broydamp
end subroutine write_set_scc
subroutine write_set_opt(ictrl)
use readin, only : bool2int,bool2string
implicit none
integer,intent(in) :: ictrl
write(ictrl,'(a,"opt")') flag
write(ictrl,'(3x,"engine=")',advance='no')
select case(opt_engine)
case default; write(ictrl,'("unknown")')
case(p_engine_rf); write(ictrl,'("rf")')
case(p_engine_lbfgs); write(ictrl,'("lbfgs")')
case(p_engine_inertial); write(ictrl,'("inertial")')
end select
if (allocated(opt_outfile)) &
write(ictrl,'(3x,"output=",a)') opt_outfile
if (allocated(opt_logfile)) &
write(ictrl,'(3x,"logfile=",a)') opt_logfile
write(ictrl,'(3x,"optlevel=",a)') int2optlevel(optset%optlev)
write(ictrl,'(3x,"microcycle=",i0)') optset%micro_opt
write(ictrl,'(3x,"maxcycle=",i0)') optset%maxoptcycle
write(ictrl,'(3x,"maxdispl=",g0)') optset%maxdispl_opt
write(ictrl,'(3x,"hlow=",g0)') optset%hlow_opt
write(ictrl,'(3x,"hessian=")',advance='no')
select case(mhset%model)
case default; write(ictrl,'("lindh-d2")')
case(p_modh_unit); write(ictrl,'("unit")')
case(p_modh_old); write(ictrl,'("old")')
case(p_modh_lindh); write(ictrl,'("lindh")')
case(p_modh_lindh_d2); write(ictrl,'("lindh-d2")')
case(p_modh_swart); write(ictrl,'("swart")')
end select
write(ictrl,'(3x,"s6=",g0)') mhset%s6
write(ictrl,'(3x,"kstretch=",g0)') mhset%kr
write(ictrl,'(3x,"kbend =",g0)') mhset%kf
write(ictrl,'(3x,"ktorsion=",g0)') mhset%kt
write(ictrl,'(3x,"koutofp =",g0)') mhset%ko
write(ictrl,'(3x,"kvdw =",g0)') mhset%kd
write(ictrl,'(3x,"kes =",g0)') mhset%kq
write(ictrl,'(3x,"rcut =",g0)') sqrt(mhset%rcut)
write(ictrl,'(3x,"ts=",i0)') bool2int(tsopt)
write(ictrl,'(3x,"tsroot=",i0)') tsroot
write(ictrl,'(3x,"exact rf=",g0)') bool2string(optset%exact_rf)
end subroutine write_set_opt
subroutine write_set_thermo(ictrl)
implicit none
integer,intent(in) :: ictrl
integer :: i,idum
write(ictrl,'(a,"thermo")') flag
if (thermotemp(idum+1).ne.0.0_wp) idum = size(thermotemp,1)
write(ictrl,'(3x,"temp=")',advance='no')
! now we print all but the last argument to avoid a trailing comma
do i = 1, nthermo-1
write(ictrl,'(g0,",")',advance='no') thermotemp(i)
enddo
write(ictrl,'(g0)') thermotemp(nthermo)
write(ictrl,'(3x,"sthr=",g0)') thermo_sthr
end subroutine write_set_thermo
subroutine write_set_md(ictrl)
use readin, only : bool2int,bool2string
implicit none
integer,intent(in) :: ictrl
write(ictrl,'(a,"md")') flag
write(ictrl,'(3x,"temp=",g0)') temp_md
write(ictrl,'(3x,"time=",g0)') time_md
write(ictrl,'(3x,"dump=",g0)') dump_md2
write(ictrl,'(3x,"velo=",i0)') bool2int(velodump)
write(ictrl,'(3x,"nvt=",i0)') bool2int(nvt_md)
write(ictrl,'(3x,"skip=",g0)') skip_md
write(ictrl,'(3x,"step=",g0)') tstep_md
write(ictrl,'(3x,"hmass=",i0)') md_hmass
write(ictrl,'(3x,"shake=",i0)') shake_mode
write(ictrl,'(3x,"sccacc=",g0)') accu_md
end subroutine write_set_md
subroutine write_set_siman(ictrl)
use readin, only : bool2int,bool2string
implicit none
integer,intent(in) :: ictrl
write(ictrl,'(a,"siman")') flag
write(ictrl,'(3x,"dump=",g0)') dump_md
write(ictrl,'(3x,"n=",i0)') ntemp_siman
write(ictrl,'(3x,"ewin=",g0)') ewin_conf
write(ictrl,'(3x,"temp=",g0)') Tend_siman
write(ictrl,'(3x,"enan=",i0)') bool2int(enan_siman)
write(ictrl,'(3x,"check=",i0)') bool2int(.not.check_rmsd)
end subroutine write_set_siman
subroutine write_set_hess(ictrl)
implicit none
integer,intent(in) :: ictrl
write(ictrl,'(a,"hess")') flag
write(ictrl,'(3x,"sccacc=",g0)') accu_hess
write(ictrl,'(3x,"step=",g0)') step_hess
end subroutine write_set_hess
subroutine write_set_gbsa(ictrl)
use gbobc, only: lgbsa,ionst,ion_rad
implicit none
integer,intent(in) :: ictrl
if (lgbsa) then
write(ictrl,'(a,"gbsa")') flag
if (allocated(solvent)) write(ictrl,'(3x,"solvent=",a)') solvent
write(ictrl,'(3x,"ion_st=",g0)') ionst
write(ictrl,'(3x,"ion_rad=",g0)') ion_rad
write(ictrl,'(3x,"gbsagrid=")',advance='no')
select case(ngrida)
case(p_angsa_normal); write(ictrl,'(a)') "normal"
case(p_angsa_tight); write(ictrl,'(a)') "tight"
case(p_angsa_verytight);write(ictrl,'(a)') "verytight"
case(p_angsa_extreme); write(ictrl,'(a)') "extreme"
case default; write(ictrl,'(i0)') ngrida
end select
endif
end subroutine write_set_gbsa
subroutine write_set_modef(ictrl)
implicit none
integer,intent(in) :: ictrl
write(ictrl,'(a,"modef")') flag
write(ictrl,'(3x,"n=",i0)') mode_nscan
write(ictrl,'(3x,"step=",g0)') mode_step
write(ictrl,'(3x,"updat=",g0)') mode_updat
write(ictrl,'(3x,"local=",i0)') mode_local
write(ictrl,'(3x,"vthr=",g0)') mode_vthr
write(ictrl,'(3x,"prj=",g0)') mode_prj
write(ictrl,'(3x,"mode=",g0)') mode_follow
end subroutine write_set_modef
subroutine write_set_cube(ictrl)
implicit none
integer,intent(in) :: ictrl
write(ictrl,'(a,"cube")') flag
write(ictrl,'(3x,"step=",g0)') cube_step
write(ictrl,'(3x,"pthr=",g0)') cube_pthr
end subroutine write_set_cube
subroutine write_set_symmetry(ictrl)
implicit none
integer,intent(in) :: ictrl
write(ictrl,'(a,"symmetry")') flag
write(ictrl,'(3x,"desy=",g0)') desy
write(ictrl,'(3x,"maxat=",i0)') maxatdesy
end subroutine write_set_symmetry
subroutine write_set_embedding(ictrl)
use readin, only : bool2int,bool2string
implicit none
integer,intent(in) :: ictrl
write(ictrl,'(a,"embedding")') flag
write(ictrl,'(3x,"at=",i0)') pcem_dummyatom
write(ictrl,'(3x,"es=",a)') bool2string(pcem_l_es)
!write(ictrl,'(3x,"aes=",a)') bool2string(pcem_l_aes)
!write(ictrl,'(3x,"disp=",a)') bool2string(pcem_l_disp)
!write(ictrl,'(3x,"dipm=",a)') bool2string(pcem_l_dipm)
!write(ictrl,'(3x,"qp=",a)') bool2string(pcem_l_qp)
!write(ictrl,'(3x,"cn=",a)') bool2string(pcem_l_cn)
!write(ictrl,'(3x,"atm=",a)') bool2string(pcem_l_atm)
end subroutine write_set_embedding
subroutine write_set_write(ictrl)
use readin, only : bool2int,bool2string
implicit none
integer,intent(in) :: ictrl
write(ictrl,'(a,"write")') flag
if (allocated(property_file)) &
write(ictrl,'(3x,"output file=",a)') property_file
write(ictrl,'(3x,"esp=",a)') bool2string(pr_esp)
if (allocated(esp_gridfile)) write(ictrl,'(3x,"gridfile=",a)') esp_gridfile
write(ictrl,'(3x,"mos=",a)') bool2string(pr_molden_input)
write(ictrl,'(3x,"gbw=",a)') bool2string(pr_gbw)
write(ictrl,'(3x,"tm mos=",a)') bool2string(pr_tmmos)
write(ictrl,'(3x,"tm basis=",a)') bool2string(pr_tmbas)
write(ictrl,'(3x,"lmo=",a)') bool2string(pr_lmo)
write(ictrl,'(3x,"density=",a)') bool2string(pr_density)
write(ictrl,'(3x,"spin population=",a)') bool2string(pr_spin_population)
write(ictrl,'(3x,"spin density=",a)') bool2string(pr_spin_density)
write(ictrl,'(3x,"fod=",a)') bool2string(pr_fod)
write(ictrl,'(3x,"fod population=",a)') bool2string(pr_fod_pop)
write(ictrl,'(3x,"wiberg=",a)') bool2string(pr_wiberg)
write(ictrl,'(3x,"wbo fragments=",a)') bool2string(pr_wbofrag)
write(ictrl,'(3x,"dipole=",a)') bool2string(pr_dipole)
write(ictrl,'(3x,"charges=",a)') bool2string(pr_charges)
write(ictrl,'(3x,"mulliken=",a)') bool2string(pr_mulliken)
write(ictrl,'(3x,"orbital energies=",a)') bool2string(pr_eig)
write(ictrl,'(3x,"inertia=",a)') bool2string(pr_moments)
write(ictrl,'(3x,"distances=",a)') bool2string(pr_distances)
write(ictrl,'(3x,"angles=",a)') bool2string(pr_angles)
write(ictrl,'(3x,"torsions=",a)') bool2string(pr_torsions)
write(ictrl,'(3x,"final struct=",a)') bool2string(pr_finalstruct)
write(ictrl,'(3x,"geosum=",a)') bool2string(pr_geosum)
write(ictrl,'(3x,"stm=",a)') bool2string(pr_stm)
write(ictrl,'(3x,"modef=",a)') bool2string(pr_modef)
write(ictrl,'(3x,"gbsa=",a)') bool2string(pr_gbsa)
end subroutine write_set_write
subroutine write_set_external(ictrl)
implicit none
integer,intent(in) :: ictrl
write(ictrl,'(a,"external")') flag
if (allocated(ext_orca%path)) &
write(ictrl,'(3x,"orca bin=",a)') ext_orca%executable
if (allocated(ext_orca%input_string)) &
write(ictrl,'(3x,"orca input line=",a)') ext_orca%input_string
if (allocated(ext_orca%input_file)) &
write(ictrl,'(3x,"orca input file=",a)') ext_orca%input_file
if (allocated(ext_mopac%path)) &
write(ictrl,'(3x,"mopac bin=",a)') ext_mopac%executable
if (allocated(ext_mopac%input_string)) &
write(ictrl,'(3x,"mopac input=",a)') ext_mopac%input_string
if (allocated(ext_mopac%input_file)) &
write(ictrl,'(3x,"mopac file=",a)') ext_mopac%input_file
if (allocated(ext_turbo%path)) &
write(ictrl,'(3x,"turbodir=",a)') ext_turbo%path
end subroutine write_set_external
subroutine write_set_stm(ictrl)
implicit none
integer,intent(in) :: ictrl
if (.not.pr_stm) return
write(ictrl,'(a,"stm")') flag
write(ictrl,'(3x,"broadening=",g0,1x,"#",1x,a)') stm_alp,"in eV"
write(ictrl,'(3x,"current=",g0,1x,"#")') stm_targ
write(ictrl,'(3x,"grid=",g0,1x,"#",1x,a)') stm_grid,"in au"
write(ictrl,'(3x,"thr=",g0)') stm_thr
write(ictrl,'(3x,"potential=",g0,1x,"#",1x,a)') stm_pot,"in V"
end subroutine write_set_stm
subroutine write_set_path(ictrl)
use tbdef_atomlist
implicit none
integer,intent(in) :: ictrl
type(tb_atomlist) :: atl
character(len=:), allocatable :: string
integer :: i
write(ictrl,'(a,"path")') flag
write(ictrl,'(3x,"nrun=",i0)') pathset%nrun
write(ictrl,'(3x,"nopt=",i0)') pathset%nopt
write(ictrl,'(3x,"anopt=",i0)') pathset%anopt
write(ictrl,'(3x,"kpush=",g0)') pathset%kpush
write(ictrl,'(3x,"kpull=",g0)') pathset%kpull
write(ictrl,'(3x,"alp=",g0)') pathset%alp
if (allocated(pathset%fname)) &
write(ictrl,'(3x,"product=",a)') pathset%fname
if (pathset%nat > 0) then
call atl%new(pathset%atoms(:pathset%nat))
call atl%to_string(string)
write(ictrl,'(3x,"atoms:",1x,a)') string
endif
end subroutine write_set_path
subroutine write_set_reactor(ictrl)
use tbdef_atomlist
implicit none
integer,intent(in) :: ictrl
type(tb_atomlist) :: atl
character(len=:), allocatable :: string
integer :: i
write(ictrl,'(a,"reactor")') flag
write(ictrl,'(3x,"max=",i0)') reactset%nmax
write(ictrl,'(3x,"density=",g0,1x,"# in kg/L")') &
reactset%dens
write(ictrl,'(3x,"kpush=",g0)') reactset%kpush
write(ictrl,'(3x,"alp=",g0)') reactset%alp
if (reactset%nat > 0) then
call atl%new(reactset%atoms(:reactset%nat))
call atl%to_string(string)
write(ictrl,'(3x,"atoms:",1x,a)') string
endif
end subroutine write_set_reactor
subroutine write_set_constrain(ictrl)
use scanparam
use splitparam
use mctc_econv, only : autoaa
use mctc_constants, only : pi
implicit none
integer, intent(in) :: ictrl
integer :: i,idum
if (nconstr.eq.0) return
write(ictrl,'(a,"constrain")') flag
write(ictrl,'(3x,"force constant=",g0)') fcconstr
do i = 1, nconstr
! instead of simply saving the kind of constraint while reading,
! we used some really obvious integer code system depending on
! the number of elements in the atconstr-Array.
! Expected to break at some point, add a FIXME and wait for complaints...
idum = atconstr(1,i)
if (atconstr(2,i).gt.0) idum = 1
if (atconstr(3,i).gt.0) idum = 2
if (atconstr(4,i).gt.0) idum = 3
select case(idum)
case default ! this is bad, we don't want this to happen
call raise('E','This is an internal error, please report this!',1)
case(-2)
write(ictrl,'(3x,"center:",1x,g0,1x,i0,1x,"# force constant")') &
valconstr(i),iatf1
case(-1)
write(ictrl,'(3x,"z:",1x,g0,1x,"# in Ångström")') &
valconstr(i)*autoaa
case(0)
write(ictrl,'(3x,"cma:",1x,g0,1x,"# in Ångström")') &
valconstr(i)*autoaa
case(1)
write(ictrl,'(3x,"distance:",1x,2(i0,",",1x),g0,1x,"# in Ångström")') &
atconstr(1,i),atconstr(2,i),valconstr(i)*autoaa
case(2)
write(ictrl,'(3x,"angle:",1x,3(i0,",",1x),g0,1x,"# in Degree")') &
atconstr(1,i),atconstr(2,i),atconstr(3,i),valconstr(i)*180.0_wp/pi
case(3)
write(ictrl,'(3x,"dihedral:",1x,4(i0,",",1x),g0,1x,"# in Degree")') &
atconstr(1,i),atconstr(2,i),atconstr(3,i),atconstr(4,i), &
valconstr(i)*180.0_wp/pi
end select
enddo
end subroutine write_set_constrain
subroutine write_set_scan(ictrl)
use scanparam
use mctc_econv, only : autoaa
use mctc_constants, only : pi
implicit none
integer, intent(in) :: ictrl
integer :: i,idum
if (nscan.eq.0) return
write(ictrl,'(a,"scan")') flag
select case(scan_mode)
case default ! this should never happen...
call raise('E','This is an internal error, please report this!',1)
case(p_scan_sequential)
write(ictrl,'(3x,"mode=sequential")')
case(p_scan_concerted)
write(ictrl,'(3x,"mode=concerted")')
end select
do i = 1, nscan
! instead of simply saving the kind of constraint while reading,
! we used some really obvious integer code system depending on
! the number of elements in the atconstr-Array.
! Expected to break at some point, add a FIXME and wait for complaints...
idum = atconstr(1,i)
if (atconstr(2,i).gt.0) idum = 1
if (atconstr(3,i).gt.0) idum = 2
if (atconstr(4,i).gt.0) idum = 3
if (idum.le.1) then
write(ictrl,'(3x,i0,":",1x,2(g0,",",1x),i0,1x,"# in Ångström")') &
scan_list(i)%iconstr,scan_list(i)%valscan(1)*autoaa, &
scan_list(i)%valscan(scan_list(i)%nscan)*autoaa,scan_list(i)%nscan
else
write(ictrl,'(3x,i0,":",1x,2(g0,",",1x),i0,1x,"# in Degree")') &
scan_list(i)%iconstr,scan_list(i)%valscan(1)*180.0_wp/pi, &
scan_list(i)%valscan(scan_list(i)%nscan)*180.0_wp/pi,scan_list(i)%nscan
endif
enddo
end subroutine write_set_scan
subroutine write_set_fix(ictrl)
use tbdef_atomlist
use fixparam
implicit none
integer, intent(in) :: ictrl
type(tb_atomlist) :: atl
character(len=:), allocatable :: string
integer :: i
if (fixset%n.eq.0 .and. freezeset%n.eq.0) return
write(ictrl,'(a,"fix")') flag
if (fixset%n > 0) then
call atl%new(fixset%atoms(:fixset%n))
call atl%to_string(string)
write(ictrl,'(3x,"atoms:",1x,a)') string
endif
write(ictrl,'(3x,"freeze frequency=",g0,1x,"# in atomic units")') freezeset%fc
if (freezeset%n > 0) then
call atl%new(freezeset%atoms(:freezeset%n))
call atl%to_string(string)
write(ictrl,'(3x,"freeze:",1x,a)') string
endif
end subroutine write_set_fix
subroutine write_set_split(ictrl)
use tbdef_atomlist
use splitparam
implicit none
integer, intent(in) :: ictrl
type(tb_atomlist) :: atl
character(len=:), allocatable :: string
integer :: i
if ((iatf1.eq.0).and.(iatf2.eq.0)) return
write(ictrl,'(a,"split")') flag
do i = 1, maxval(splitlist)
call atl%new
call atl%add(splitlist.eq.i)
call atl%to_string(string)
write(ictrl,'(3x,"fragment:",1x,i0,",",a)') i, string
enddo
end subroutine write_set_split
subroutine write_set_wall(ictrl)
use sphereparam
implicit none
integer, intent(in) :: ictrl
integer :: i,j,nlist
write(ictrl,'(a,"wall")') flag
write(ictrl,'(3x,"potential=")',advance='no')
if (spherepot_type.eq.p_type_polynomial) then
write(ictrl,'(a)') 'polynomial'
else
write(ictrl,'(a)') 'logfermi'
endif
write(ictrl,'(3x,"alpha=",i0)') sphere_alpha
write(ictrl,'(3x,"beta=",g0)') sphere_beta
write(ictrl,'(3x,"temp=",g0)') sphere_temp
write(ictrl,'(3x,"autoscale=",g0)') sphere_autoscale
write(ictrl,'(3x,"axisshift=",g0)') sphere_shift
if (number_walls.eq.0) return
do i = 1, number_walls
if (all(abs(wpot(i)%radius-wpot(i)%radius(1)).lt.1e-6_wp)) then
write(ictrl,'(3x,"sphere:",1x,g0,",",1x)',advance='no') &
wpot(i)%radius(1)
else
write(ictrl,'(3x,"ellipsoid:",1x,3(g0,",",1x))',advance='no') &
wpot(i)%radius
endif
if (allocated(wpot(i)%list)) then
nlist = size(wpot(i)%list,1)
do j = 1, nlist-1
write(ictrl,'(i0,",",1x)',advance='no') wpot(i)%list(j)
enddo
write(ictrl,'(i0,1x,"# radius in Bohr")') wpot(i)%list(nlist)
else
write(ictrl,'("all # radius in Bohr")')
endif
enddo
end subroutine write_set_wall
subroutine write_set_metadyn(ictrl)
use tbdef_atomlist
use fixparam
implicit none
integer, intent(in) :: ictrl
type(tb_atomlist) :: atl
character(len=:), allocatable :: string
integer :: i
if (metaset%maxsave.eq.0) return
write(ictrl,'(a,"metadyn")') flag
write(ictrl,'(3x,"save=",i0)') metaset%maxsave
write(ictrl,'(3x,"factor=",1x,g0)') metaset%global_factor
if (any((metaset%factor - metaset%global_factor).ne.0.0_wp)) then
do i = 1, metaset%maxsave
if ((metaset%factor(i) - metaset%global_factor).ne.0.0_wp) then
write(ictrl,'(3x,"modify factor:",1x,i0,",",1x,g0)') &
i,metaset%factor(i)
endif
enddo
endif
if (allocated(metaset%fname)) write(ictrl,'(3x,"coord=",a)') metaset%fname
if (metaset%nat > 0) then
call atl%new(metaset%atoms(:metaset%nat))
call atl%to_string(string)
write(ictrl,'(3x,"atoms:",1x,a)') string
endif
end subroutine write_set_metadyn
subroutine open_set(ictrl,fname)
use mctc_timings, only : prtimestring
implicit none
integer,intent(out) :: ictrl
character(len=*),intent(in) :: fname
character(len=:),allocatable :: buffer
logical :: exist
integer :: i
call open_file(ictrl,fname,'w')
! write the command line which has called this program
call get_command(length=i)
allocate(character(len=i) :: buffer)
call get_command(buffer)
write(ictrl,'(a,"cmd",x,a)') flag,buffer
! write the date when this program was started, use timings for this job
write(ictrl,'(a,"date",x,a)') flag,prtimestring('S')
end subroutine open_set
subroutine close_set(ictrl)
integer,intent(in) :: ictrl
write(ictrl,'("'//flag_end//'")')
call close_file(ictrl)
end subroutine close_set
subroutine rdcontrol(fname,copy_file)
use iso_fortran_env, only : output_unit,iostat_end
use readin, only : find_new_name
use splitparam, only : maxfrag
use scanparam, only : maxconstr,maxscan
use sphereparam, only : maxwalls
implicit none
character(len=*),intent(in) :: fname
character(len=:),allocatable :: line
character(len=:),allocatable :: key
character(len=:),allocatable :: val
character(len=:),allocatable :: newname
logical,intent(in),optional :: copy_file
integer :: i
integer :: id
integer :: ic
integer :: ie
integer :: ncount
integer :: copy
integer :: err
logical :: exist
logical :: do_copy
if (present(copy_file)) then
do_copy=copy_file
else
do_copy=.false.
endif
call open_file(id,fname,'r')
if (id.eq.-1) then
call raise('S',"could not find '"//fname//"'",1)
return
endif
if (do_copy) then
newname = find_new_name(fname)
! newunit would be nice to have here, but it would always open to a
! negative number, currently I'm checking for a negative number in
! in mirror_line to avoid copying to another unit, so I go with unit 41
call open_file(copy,newname,'w')
else
copy = -1 ! deactivate copy in mirror_line
endif
! read first line before the readloop starts, I have to do this
! to avoid using backspace on id (dammit Turbomole format)
call mirror_line(id,copy,line,err)
readflags: do
! check if there is a $ in the *first* column
if (index(line,flag).eq.1) then
select case(line(2:))
! logical
case('fit' ); call set_fit; call mirror_line(id,copy,line,err)
case('samerand'); call set_samerand; call mirror_line(id,copy,line,err)
case('cma' ); call set_cma; call mirror_line(id,copy,line,err)
! data
case('cube' ); call rdblock(set_cube, line,id,copy,err,ncount)
case('write' ); call rdblock(set_write, line,id,copy,err,ncount)
case('gfn' ); call rdblock(set_gfn, line,id,copy,err,ncount)
case('scc' ); call rdblock(set_scc, line,id,copy,err,ncount)
case('opt' ); call rdblock(set_opt, line,id,copy,err,ncount)
case('hess' ); call rdblock(set_hess, line,id,copy,err,ncount)
case('md' ); call rdblock(set_md, line,id,copy,err,ncount)
case('siman' ); call rdblock(set_siman, line,id,copy,err,ncount)
case('modef' ); call rdblock(set_modef, line,id,copy,err,ncount)
case('gbsa' ); call rdblock(set_gbsa, line,id,copy,err,ncount)
case('embedding'); call rdblock(set_pcem, line,id,copy,err,ncount)
case('thermo' ); call rdblock(set_thermo, line,id,copy,err,ncount)
case('external' ); call rdblock(set_external,line,id,copy,err,ncount)
case('symmetry' ); call rdblock(set_symmetry,line,id,copy,err,ncount)
case('metadyn' ); call rdblock(set_metadyn, line,id,copy,err,ncount)
case('path' ); call rdblock(set_path, line,id,copy,err,ncount)
case('reactor' ); call rdblock(set_reactor, line,id,copy,err,ncount)
case('stm' ); call rdblock(set_stm, line,id,copy,err,ncount)
! data + user data which is read later, but we start counting here
case('fix' ); call rdblock(set_fix, line,id,copy,err,ncount)
case('wall' ); call rdblock(set_wall, line,id,copy,err,ncount)
maxwalls = maxwalls + ncount
case('scan' ); call rdblock(set_scan, line,id,copy,err,ncount)
maxscan = maxscan + ncount
maxconstr = maxconstr + ncount ! better save than sorry
case('constrain'); call rdblock(set_constr, line,id,copy,err,ncount)
maxconstr = maxconstr + ncount
case('split' ); call rdblock(set_split, line,id,copy,err,ncount)
maxfrag = maxfrag + ncount
! legacy
case('set' ); call rdsetbl(set_legacy,line,id,copy,err)
case default ! unknown keyword -> ignore, we don't raise them
! except for chrg and spin which you actually can set here
! read them here because select case might not catch them that easy
if (index(line(2:),'chrg').eq.1) call set_chrg(line(7:))
if (index(line(2:),'spin').eq.1) call set_spin(line(7:))
! get a new line
call mirror_line(id,copy,line,err)
end select
else ! not a keyword -> ignore
call mirror_line(id,copy,line,err)
endif
! check for end of file, which I will tolerate as alternative to $end
if (err.eq.iostat_end) exit readflags
! if (index(line,flag_end).ne.0) exit readflags ! compatibility reasons
enddo readflags
if (do_copy) call close_file(copy)
call close_file(id)
end subroutine rdcontrol
subroutine rdsetbl(handler,line,id,copy,err)
use iso_fortran_env, only : iostat_end
implicit none
interface
subroutine handler(key,val)
character(len=*),intent(in) :: key
character(len=*),intent(in) :: val
end subroutine handler
end interface
integer,intent(in) :: id
integer,intent(in) :: copy
external :: handler
integer,intent(out) :: err
character(len=:),allocatable,intent(out) :: line
character(len=:),allocatable :: key
character(len=:),allocatable :: val
integer :: ie
call raise('S','set-blocks will become obsolete in xtb 6.0 and newer',1)
do
call mirror_line(id,copy,line,err)
if (err.eq.iostat_end) exit
if (index(line,flag).ne.0) exit
! find the first space
ie = index(line,space)
if ((line.eq.'').or.(ie.eq.0)) cycle
key = trim(line(:ie-1))
val = trim(adjustl(line(ie+1:)))
call handler(key,val)
enddo
end subroutine rdsetbl
subroutine rdblock(handler,line,id,copy,err,ncount)
use iso_fortran_env, only : iostat_end
implicit none
interface
subroutine handler(key,val)
character(len=*),intent(in) :: key
character(len=*),intent(in) :: val
end subroutine handler
end interface
integer,intent(in) :: id
integer,intent(in) :: copy
external :: handler
integer,intent(out) :: err
integer,intent(out) :: ncount
character(len=:),allocatable,intent(out) :: line
character(len=:),allocatable :: key
character(len=:),allocatable :: val
integer :: ie
ncount = 0
do
call mirror_line(id,copy,line,err)
if (err.eq.iostat_end) return
if (index(line,flag).ne.0) return
! find the equal sign
ie = index(line,equal)
if (line.eq.'') cycle ! skip empty lines
ncount = ncount + 1 ! but count non-empty lines first
if (ie.eq.0) cycle
key = trim(line(:ie-1))
val = trim(adjustl(line(ie+1:)))
call handler(key,val)
enddo
end subroutine rdblock
subroutine set_exttyp(typ)
implicit none
character(len=*),intent(in) :: typ
logical,save :: set = .true.
if (.not.set) return
select case(typ)
case default ! do nothing
call raise('S',typ//' is no valid exttyp (internal error)',1)
case('vtb')
mode_extrun = p_ext_vtb
case('eht')
mode_extrun = p_ext_eht
case('xtb')
mode_extrun = p_ext_xtb
case('qmdff')
mode_extrun = p_ext_qmdff
case('orca')
mode_extrun = p_ext_orca
case('turbomole')
mode_extrun = p_ext_turbomole
extcode = 1
extmode = 1
case('mopac')
mode_extrun = p_ext_mopac
end select
set = .false.
end subroutine set_exttyp
subroutine set_geopref(typ)
implicit none
character(len=*),intent(in) :: typ
logical,save :: set = .true.
if (.not.set) return
select case(typ)
case default ! do nothing
call raise('S',typ//' is no valid geometry format (internal error)',1)
case('sdf')
geometry_inputfile = p_geo_sdf
case('xmol','xyz')
geometry_inputfile = p_geo_xmol
case('coord','tm','turbomole')
geometry_inputfile = p_geo_coord
case('vasp','poscar')
geometry_inputfile = p_geo_poscar
end select
set = .false.
end subroutine set_geopref
subroutine set_runtyp(typ)
implicit none
character(len=*),intent(in) :: typ
logical,save :: set = .true.
if (.not.set) then
call raise('S','Runtyp already set and locked, please use a composite runtyp instead.',1)
return
endif
select case(typ)
case default ! do nothing
call raise('E',typ//' is no valid runtyp (internal error)',1)
case('nox')
runtyp = p_run_nox
case('stda')
runtyp = p_run_stda
case('scc')
runtyp = p_run_scc
case('grad')
runtyp = p_run_grad
case('opt','optts')
runtyp = p_run_opt
case('hess')
runtyp = p_run_hess
case('ohess')
runtyp = p_run_ohess
case('md')
runtyp = p_run_md
case('omd')
runtyp = p_run_omd
case('siman')
runtyp = p_run_siman
case('path')
runtyp = p_run_path
case('screen')
runtyp = p_run_screen
case('gmd')
runtyp = p_run_gmd
case('modef')
runtyp = p_run_modef
case('mdopt')
runtyp = p_run_mdopt
case('metaopt')
runtyp = p_run_metaopt
case('reactor')
runtyp = p_run_reactor
case('vip')
runtyp = p_run_vip
case('vea')
runtyp = p_run_vea
case('vipea')
runtyp = p_run_vipea
case('vomega')
runtyp = p_run_vomega
case('vfukui')
runtyp = p_run_vfukui
end select
set = .false.
end subroutine set_runtyp
subroutine set_fit
implicit none
fit = .true.
end subroutine set_fit
subroutine set_cma
implicit none
do_cma_trafo = .true.
end subroutine set_cma
subroutine set_enso_mode
implicit none
enso_mode = .true.
end subroutine set_enso_mode
subroutine set_samerand