-
Notifications
You must be signed in to change notification settings - Fork 0
/
qm2_read_nm_and_alloc.F90
1679 lines (1500 loc) · 66.1 KB
/
qm2_read_nm_and_alloc.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
! <compile=optimized>
#include "copyright.h"
#include "../include/assert.fh"
#include "../include/dprec.fh"
#ifdef SQM
module sqm_qmmm_read_and_alloc
#else
module qmmm_read_and_alloc
#endif
!+++++++++++++++++++++++++++++++++++++++++++++
!This subroutine reads the QMMM namelist
!and also calls allocation routines
!for QMMM based on natom.
!
!Author:
! Ross Walker (SDSC)
!+++++++++++++++++++++++++++++++++++++++++++++
private
public :: read_qmmm_nm_and_alloc
contains
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!+ Reads the qmmm namelist and calls the qmmm memory allocation routines
#ifdef SQM
subroutine read_qmmm_nm_and_alloc( natom_inout, igb, atnum, maxcyc, &
grms_tol, ntpr, ncharge_in, excharge, chgatnum )
#else
subroutine read_qmmm_nm_and_alloc( igb, ih, ix, x, cut, use_pme, ntb, qmstep, &
isabfqm, abfqmcharge, read_file, options)
#endif
use findmask
use constants, only : RETIRED_INPUT_OPTION, MAX_QUANTUM_ATOMS
#ifdef SQM
#ifdef OPENMP
use qmmm_module, only : qmmm_struct, qm2_struct, qmmm_nml, &
validate_qm_atoms, qmsort, &
allocate_qmmm, get_atomic_number, &
qmmm_opnq, qmmm_input_options, qmmm_omp
#else
use qmmm_module, only : qmmm_struct, qm2_struct, qmmm_nml, &
validate_qm_atoms, qmsort, &
allocate_qmmm, get_atomic_number, &
qmmm_opnq, qmmm_input_options
#endif
#else
#ifdef OPENMP
use qmmm_module, only : qmmm_struct, qm2_struct, qmmm_nml, &
validate_qm_atoms, qmsort, &
allocate_qmmm, get_atomic_number, qmmm_div, &
qmmm_opnq, qmmm_vsolv, qmmm_input_options, &
qmmm_omp
#else
use qmmm_module, only : qmmm_struct, qm2_struct, qmmm_nml, &
validate_qm_atoms, qmsort, &
allocate_qmmm, get_atomic_number, qmmm_div, &
qmmm_opnq, qmmm_vsolv, qmmm_input_options
#endif
use qmmm_vsolv_module, only : read_vsolv_nml
#endif
use qmmm_qmtheorymodule
use ElementOrbitalIndex, only : numberElements
use ParameterReader, only : ReadParameterFile
implicit none
!Passed in
integer :: igb !Value of igb from cntrl namelist
#ifdef SQM
integer use_pme, ntb
integer, intent(inout) :: natom_inout
integer, intent(in) :: atnum(*)
integer, intent(out) :: maxcyc, ntpr
_REAL_, intent(out) :: grms_tol
_REAL_, intent(in) :: excharge(*)
integer, intent(in) :: chgatnum(*)
integer, intent(in) :: ncharge_in
#else
character(len=4) ih(*)
integer, intent(in) :: ix(*)
_REAL_, intent(in) :: x(*)
_REAL_, intent(in) :: cut !MM-MM cutoff in angstroms
integer, intent(in) :: use_pme, ntb
integer, intent(in) :: qmstep
integer, intent(in) :: isabfqm(*)
integer, intent(in) :: abfqmcharge
logical, intent(in) :: read_file ! because the present intrinsic on "options" does not seem to work
type(qmmm_input_options), intent(in), optional :: options
#endif
!local
_REAL_ :: qmcut ! local copied to qmmm_nml%qmcut - specified cutoff to use for QM-MM electrostatics.
! Default = same as regular MM cutoff.
_REAL_ :: lnk_dis ! Distance from the QM atom to place link atom.
!A value of <0.0 means the link atom gets placed on the MM link pair atom's coordinates
!on every MD step.
_REAL_ :: scfconv ! local copied to qmmm_nml%scfconv - Convergence criteria for SCF routine. Default = 1.0D-8.
! Minimum (tightest criteria) = 1.0D-16
!+TJG 01/26/2010
_REAL_ :: errconv ! Convergence criteria for maximum value in the error matrix FP-PF
integer :: ndiis_matrices ! Maximum number of matrices used in a diis extrapolation
integer :: ndiis_attempts ! The initial number of diis tokens... the number of iterations
! that diis extrapolations will be attempted before giving up on diis
!-TJG 01/26/2010
_REAL_ :: pseudo_diag_criteria !Criteria - maximum change in density matrix between successive SCF iterations
!in which to allow pseudo diagonalisation. Default = 0.05.
integer :: lnk_atomic_no !Atomic number of link atom
integer :: lnk_method !controls how QM-MM valence terms are dealt with.
integer :: qmgb ! local copied to qmmm_nml%qmgb - flag for type of GB do with QM region
integer :: qmtheory ! deprecated flag for level of theory to use for QM region
integer :: qmcharge ! local copied to qmmm_nml%qmcharge - value of charge on QM system
integer :: corecharge
integer :: buffercharge
integer :: spin ! local copied to qmmm_nml%spin - spin state of system
integer :: i,j ! temporary counter for local loops
integer :: ifind
integer :: qmqmdx ! local copied to qmmm_nml%qmqm_analyt - 1 = analytical, 2 = numerical QM-QM derivatives in qm2
integer :: verbosity ! local copied to qmmm_nml%verbosity - Controls amount of info about QM part of calc that is printed (0=Def)
integer :: tight_p_conv ! local copied to qmmm_nml%tight_p_conv - Controls convergence of density matrix. 0 (Def) = 0.05*sqrt(SCFCRT)
! 1 = Converged both Energy and Density to SCFCONV
integer :: printcharges !Local copied to qmmm_nml%printcharges as a logical. 1 = true - print mulliken and cm1a and cm2a charges
!on every step. 0 = false = don't print charges. Default = 0 (.false.)
integer :: printdipole !Local copied to qmmm_nml%printdipole as an integer 1 = QM dipole moment, 2 = QM + MM dipole moment, (0=Def)
integer :: print_eigenvalues !Local copied to qmmm_nml%print_eigenvalues, 0 = no printing, 1 = at end of run (default), 2 = each SCF cycle, 3 = each SCF iteration
integer :: peptide_corr !Local copied to the logical qmmm_nml%peptide_corr
!Add MM correction to peptide linkages 0 = No (Default), 1 = Yes.
integer :: itrmax !Local copied to qmmm_nml%itrmax - Maximum number of scf cycles to run
!before assuming convergence has failed (default = 1000)
integer :: printbondorders !Local copied to qmmm_nml%printbondorders as a logical.
! 1 = true - print bondorders at the end of the
! calculation. 0 = false = dont print bondorders. Default = 0 (.false.)
integer :: qmshake !Local copied to qmmm_nml%qmshake - shake QM atoms if ntc>1?
integer :: qmmmrij_incore !Flag to store rij between qm-mm pairs and related equations in memory.
!1 (default) = store in memory. 0 = calc on fly.
integer :: qmqm_erep_incore !Flag to store QM-QM 1 electron repulsion integrals in memory or to calculate
!them on the fly. Only available with QM-QM analytical derivatives.
!1 (default) = store in memory. 0 = calc on fly.
integer :: pseudo_diag !Whether to allow pseudo diagonalisations to be done when possible in SCF.
!0 (default) = Always do full diagonalisations.
!1 = do pseudo diagonalisations when possible.
integer :: qm_ewald !0 (default) do only regular QM-MM interaction in periodic calculations.
!1 do ewald based periodic QM-MM interactions.
!2 do ewald based periodic QM-MM but with the QM image charges
! fixed at the previous steps mulliken charges during the SCF.
integer :: qm_pme !0 use regular Ewald for doing QM-MM interactions when qm_ewald>0.
!1 (default) use PME to do the reciprocal sum.
integer :: kmaxqx, kmaxqy, kmaxqz !Maximum K space vectors
integer :: ksqmaxq !Maximum K squared values for spherical cutoff in k space.
_REAL_ :: kappa ! the ewald coefficient for QM region ewald calculations
integer :: writepdb
integer :: qmmm_int !QM-MM interaction method
integer :: adjust_q
integer :: diag_routine !Controls diagonalization routine to use in SCF.
#ifdef OPENMP
integer :: qmmm_omp_max_threads !Maximum number of openmp threads to use for parallel QMMM routines
#endif
integer :: density_predict !Controls prediction of density matrix for next SCF step.
integer :: fock_predict !Controls prediction of Fock matrix for next SCF step.
integer :: vsolv ! = 0 by default, = 1 for simple vsolv QM/MM, = 2 for adaptive QM/MM with vsolv
_REAL_ :: fockp_d1 !prefactor for fock matrix prediction.
_REAL_ :: fockp_d2 !prefactor for fock matrix prediction.
_REAL_ :: fockp_d3 !prefactor for fock matrix prediction.
_REAL_ :: fockp_d4 !prefactor for fock matrix prediction.
_REAL_ :: damp ! AWG SCF damping
_REAL_ :: vshift ! AWG SCF level shift parameter
logical :: mdin_qmmm=.false.
logical :: do_not_print
integer :: idc
integer :: divpb
!! (GMS)
_REAL_ :: chg_lambda ! Charge scaling factor for free energy calculation
!! DFTB options
integer :: dftb_maxiter ! Max # of iterations before resetting Broyden (default: 70 ) ==> qmmm_nml%dftb_maxiter
integer :: dftb_disper ! Use dispersion? (default: 0 = false) ==> qmmm_nml%dftb_disper
integer :: dftb_chg ! DFTB CM3 charges (default: 0 = Mulliken, 1 = CM3) ==> qmmm_nml%dftb_chg
_REAL_ :: dftb_telec ! Electronic temperature, in Kelvins. (Default = 0.0K) ==> qmmm_nml%dftb_telec
_REAL_ :: dftb_telec_step ! Telec step size for convergence accelerator (Default = 0.0K) ==> qmmm_nml%dftb_telec_step
character(Len=256) :: dftb_3rd_order ! 3rd order SCC-DFTB (default: 'NONE'== No third order)
! 'PA' == Do 3rd order, Proton Affinities parameterization
! 'PR' == Phosphate reactions parameterization
! 'READ' == read the parameters from a user-specified file (TO IMPLEMENT)
character(len=256) :: dftb_slko_path
_REAL_ :: r_switch_lo !Lower bound of the QM/MM switching function
_REAL_ :: r_switch_hi !Upper bound of the QM/MM switching function
integer :: qmmm_switch !0 Turn off QM/MM switching function
!1 Turn on QM/MM switching function
integer :: abfqmmm
integer :: hot_spot
_REAL_ :: r_core_in
_REAL_ :: r_core_out
_REAL_ :: r_qm_in
_REAL_ :: r_qm_out
_REAL_ :: r_buffer_in
_REAL_ :: r_buffer_out
character(len=256) :: cut_bond_list_file
character(len=256) :: oxidation_number_list_file
integer :: mom_cons_type
integer :: mom_cons_region
integer :: fix_atom_list
integer :: solvent_atom_number
integer :: selection_type
integer :: center_type
integer :: initial_selection_type
integer :: max_bonds_per_atom
integer :: n_max_recursive
_REAL_ :: min_heavy_mass
_REAL_ :: gamma_ln_qm
character(len=256) :: read_idrst_file
character(len=256) :: write_idrst_file
integer :: ntwidrst
character(len=256) :: pdb_file
integer :: ntwpdb
#include "../include/memory.h"
!Apparently you can't use a pointer in a namelist :-( Therefore
!we need a local scratch array that will be big enough that
!the iqmatoms list never exceeds it
integer :: iqmatoms( MAX_QUANTUM_ATOMS )
integer :: core_iqmatoms( MAX_QUANTUM_ATOMS )
integer :: buffer_iqmatoms( MAX_QUANTUM_ATOMS )
character(len=8192) :: qmmask
character(len=8192) :: coremask
character(len=8192) :: buffermask
integer :: qm_subsetatoms( natom )
integer :: core_subsetatoms( natom )
integer :: buffer_subsetatoms( natom )
integer :: center_subsetatoms( natom )
character(len=8192) :: ext_qmmask_subset
character(len=8192) :: ext_coremask_subset
character(len=8192) :: ext_buffermask_subset
character(len=8192) :: centermask
character(len=12) :: qm_theory
!Options=PM3,AM1,MNDO,PDDG-PM3,PM3PDDG,PDDG-MNDO,PDDGMNDO,
! PM3-CARB1,PM3CARB1,DFTB,SCC-DFTB,RM1,PM6,PM3-ZnB,PM3-MAIS
! EXTERNAL (for external programs like ADF/GAMESS/TeraChem)
#ifndef SQM
integer, dimension(:), pointer :: isqm
#endif
integer :: ier=0
character(len=80) :: parameter_file
logical :: qxd
namelist /qmmm/ qmcut, iqmatoms,qmmask,qmgb,qm_theory, qmtheory, &
qmcharge, qmqmdx, verbosity, tight_p_conv, scfconv, &
errconv,ndiis_matrices,ndiis_attempts, &
parameter_file, qxd,&
printcharges, printdipole, print_eigenvalues, peptide_corr, itrmax, qmshake, &
qmqm_erep_incore, qmmmrij_incore, &
lnk_dis, lnk_atomic_no, lnk_method, spin, pseudo_diag, &
pseudo_diag_criteria, &
qm_ewald, qm_pme, kmaxqx, kmaxqy, kmaxqz, ksqmaxq, kappa, &
writepdb, qmmm_int, adjust_q, diag_routine, &
density_predict, fock_predict, &
fockp_d1, fockp_d2, fockp_d3, fockp_d4, idc, divpb, &
dftb_maxiter, dftb_disper, dftb_3rd_order, dftb_slko_path, dftb_chg, &
dftb_telec, dftb_telec_step, printbondorders, &
qmmm_switch, r_switch_lo, r_switch_hi, damp, vshift, &
#ifdef OPENMP
qmmm_omp_max_threads, &
#endif
#ifdef SQM
maxcyc, ntpr, grms_tol, &
#endif
chg_lambda, vsolv, &
abfqmmm, r_core_in, r_core_out, r_buffer_in, r_buffer_out, &
r_qm_in, r_qm_out, coremask, buffermask, &
cut_bond_list_file, oxidation_number_list_file, &
mom_cons_type, mom_cons_region, &
fix_atom_list, solvent_atom_number, &
selection_type, center_type, initial_selection_type, &
corecharge, buffercharge, &
max_bonds_per_atom, n_max_recursive, min_heavy_mass, &
gamma_ln_qm, &
read_idrst_file, ntwidrst, write_idrst_file, ntwpdb, pdb_file, &
ext_qmmask_subset, ext_coremask_subset, ext_buffermask_subset, &
centermask, hot_spot
!Setup defaults
#ifdef SQM
qmcut = 9999.d0
use_pme = 0
ntb = 0
maxcyc = 9999
grms_tol = 0.02
ntpr=10
do_not_print = .false.
#else
do_not_print = .not. read_file
qmcut = cut
#endif
lnk_dis=1.09d0 !Methyl C-H distance
lnk_atomic_no=1 !Hydrogen
lnk_method=1 !treat MMLink as being MM atom.
qmgb = 2 !Gets set to zero if igb==6 or igb==0.
qm_theory = ''
qmtheory = RETIRED_INPUT_OPTION
qmcharge = 0
corecharge = 0
buffercharge = 0
spin = 1
qmqmdx = 1
verbosity = 0
parameter_file=''
qxd=.false.
!+TJG 01/26/2010
#ifdef SQM
! defaults for stand-alone (geom. opt.) code:
! dac: for now, just use the same values as in the non-stand-alone
! code, but these should be updated once we figure out the best
! values for geometry optimization
tight_p_conv = 0
scfconv = 1.0D-8
errconv = 1.0d-1
ndiis_matrices = 6
ndiis_attempts = 0
#else
! defaults for MD is off:
tight_p_conv = 0
scfconv = 1.0D-8
errconv = 1.0D-1
ndiis_matrices = 6
ndiis_attempts = 0
#endif
!-TJG 01/26/2010
printcharges = 0
printbondorders = 0
printdipole = 0
print_eigenvalues = 1
peptide_corr = 0
itrmax = 1000
qmshake = 1
qmmask=''
coremask=''
buffermask=''
iqmatoms(1:MAX_QUANTUM_ATOMS) = 0
core_iqmatoms(1:MAX_QUANTUM_ATOMS) = 0
buffer_iqmatoms(1:MAX_QUANTUM_ATOMS) = 0
ext_qmmask_subset=''
ext_coremask_subset=''
ext_buffermask_subset=''
centermask=''
qm_subsetatoms(1:natom) = 0
core_subsetatoms(1:natom) = 0
buffer_subsetatoms(1:natom) = 0
center_subsetatoms(1:natom) = 0
qmmmrij_incore = 1
qmqm_erep_incore = 1
pseudo_diag = 1
pseudo_diag_criteria = 0.05d0
qm_ewald=1 !Default is to do QMEwald, with varying charges, if ntb=0 or use_pme=0 then this will get turned off
qm_pme = 1 !use pme for QM-MM
kmaxqx=8; kmaxqy=8; kmaxqz=8 !Maximum K space vectors
kappa=-1.0
ksqmaxq=100 !Maximum K squared values for spherical cutoff in k space.
writepdb = 0 !Set to 1 to write a pdb on the first step with just the QM region in it.
qmmm_int = 1 !Default, do full interaction without extra Gaussian terms for PM3 / AM1 etc.
adjust_q = 2 !Default adjust q over all atoms.
diag_routine = 0 !Select optimum diag routine based on timings
#ifdef OPENMP
qmmm_omp_max_threads = 1 !Use just 1 openmp thread by default.
#endif
density_predict = 0 !Use density matrix from previous MD step.
fock_predict = 0 !Do not attempt to predict the Fock matrix.
fockp_d1 = 2.4d0
fockp_d2 = -1.2d0
fockp_d3 = -0.8d0
fockp_d4 = 0.6d0
damp = 1.0
vshift = 0.0
idc = 0
divpb = 0
vsolv = 0 ! by default do not use simple vsolv QM/MM or adaptive QM/MM based on vsolv
qmmm_switch = 0 !Use QM/MM switching function
r_switch_hi = qmcut !Set the default value to be equal to qmcut
r_switch_lo = r_switch_hi - 2.0D0 !Set the default value to be 2 Angstrom shorter than r_switch_hi
!DFTB
dftb_maxiter = 70
dftb_disper = 0
dftb_chg = 0
dftb_telec = 0.0d0
dftb_telec_step = 0.0d0
chg_lambda = 1.0d0
dftb_3rd_order = 'NONE'
dftb_slko_path = ''
!ABFQMMM
abfqmmm = 0
hot_spot = 0
r_core_in = 0
r_core_out = 0
r_qm_in = 0
r_qm_out = 0
r_buffer_in = 0
r_buffer_out = 0
cut_bond_list_file = ''
oxidation_number_list_file = ''
mom_cons_type = 1
mom_cons_region = 1
fix_atom_list = 0
solvent_atom_number = 3
selection_type = 1
center_type = 1
initial_selection_type = 0
max_bonds_per_atom = 4
n_max_recursive = 10000
min_heavy_mass = 4.0
gamma_ln_qm = 0.0d0
read_idrst_file = ''
write_idrst_file = 'abfqmmm.idrst'
ntwidrst = 0
pdb_file = 'abfqmmm.pdb'
ntwpdb = 0
!Read qmmm namelist
#ifndef SQM
if (.not. read_file) then
! If we were passed input options, use those instead of trying to read
! them from a file
qmcut = options%qmcut
lnk_dis = options%lnk_dis
lnk_atomic_no = options%lnk_atomic_no
lnk_method = options%lnk_method
qmgb = options%qmgb
qm_theory = options%qm_theory
qmcharge = options%qmcharge
corecharge = options%corecharge
buffercharge = options%buffercharge
spin = options%spin
qmqmdx = options%qmqmdx
verbosity = options%verbosity
scfconv = options%scfconv
errconv = options%errconv
ndiis_matrices = options%ndiis_matrices
ndiis_attempts = options%ndiis_attempts
printcharges = options%printcharges
printbondorders = options%printbondorders
printdipole = options%printdipole
print_eigenvalues = options%print_eigenvalues
peptide_corr = options%peptide_corr
itrmax = options%itrmax
qmshake = options%qmshake
qmmask = options%qmmask
coremask = options%coremask
buffermask = options%buffermask
iqmatoms(1:MAX_QUANTUM_ATOMS) = options%iqmatoms(1:MAX_QUANTUM_ATOMS)
core_iqmatoms(1:MAX_QUANTUM_ATOMS) = options%core_iqmatoms(1:MAX_QUANTUM_ATOMS)
buffer_iqmatoms(1:MAX_QUANTUM_ATOMS) = options%buffer_iqmatoms(1:MAX_QUANTUM_ATOMS)
centermask = options%centermask
qmmmrij_incore = options%qmmmrij_incore
qmqm_erep_incore = options%qmqm_erep_incore
pseudo_diag = options%pseudo_diag
pseudo_diag_criteria = options%pseudo_diag_criteria
qm_ewald = options%qm_ewald
qm_pme = options%qm_pme
kmaxqx = options%kmaxqx
kmaxqy = options%kmaxqy
kmaxqz = options%kmaxqz
kappa = options%kappa
ksqmaxq = options%ksqmaxq
qmmm_int = options%qmmm_int
adjust_q = options%adjust_q
diag_routine = options%diag_routine
density_predict = options%density_predict
fock_predict = options%fock_predict
fockp_d1 = options%fockp_d1
fockp_d2 = options%fockp_d2
fockp_d3 = options%fockp_d3
fockp_d4 = options%fockp_d4
damp = options%damp
vshift = options%vshift
vsolv = options%vsolv
qmmm_switch = options%qmmm_switch
r_switch_hi = options%r_switch_hi
r_switch_lo = options%r_switch_lo
dftb_maxiter = options%dftb_maxiter
dftb_disper = options%dftb_disper
dftb_chg = options%dftb_chg
dftb_telec = options%dftb_telec
dftb_telec_step = options%dftb_telec_step
dftb_3rd_order = options%dftb_3rd_order
dftb_slko_path = options%dftb_slko_path
abfqmmm = options%abfqmmm
hot_spot = options%hot_spot
min_heavy_mass = options%min_heavy_mass
tight_p_conv = options%tight_p_conv
else
#endif
rewind 5
call nmlsrc('qmmm',5,ifind)
if (ifind /= 0) mdin_qmmm=.true.
!Read qmmm namelist
rewind 5
if ( mdin_qmmm ) then
read(5,nml=qmmm)
else
write(6, '(1x,a,/)') 'Could not find qmmm namelist'
call mexit(6,1)
endif
#ifndef SQM
end if
#endif
call CheckRetiredQmTheoryInputOption(qmtheory)
call set(qmmm_nml%qmtheory, qm_theory)
! Read-in the user-defined parameter file (TL -- Rutgers, 2011)
call ReadParameterFile(parameter_file)
! turn on OPNQ if necessary
qmmm_opnq%useOPNQ=qxd
#ifdef SQM
! Disable EXTERN in SQM since
! it does not make sense for SQM to be calling the external ADF interface.
if (qmmm_nml%qmtheory%EXTERN) then
call sander_bomb('read_qmmm_namelist','External interface is not supported in SQM.', &
'(qm_theory = ''EXTERN'')')
end if
if (qmmm_nml%qmtheory%SEBOMD) then
call sander_bomb('read_qmmm_namelist','SEBOMD interface is not supported in SQM.', &
'(qm_theory = ''SEBOMD'')')
end if
if (ncharge_in > 0) then ! we have external charge
if (maxcyc > 0) then
! external charge calculation is not supported in gradient minimization
call sander_bomb('read_qmmm_namelist','maxcyc > 0 but external charge found.', &
'external charge calculation is for single point energy calculations only.')
end if
natom = natom_inout + ncharge_in
qmmm_struct%nquant = natom_inout
qmmm_struct%nlink = 0
qmmm_struct%nquant_nlink = natom_inout
qmmm_struct%qm_mm_pairs = ncharge_in
do i=1,natom_inout
iqmatoms(i) = i
end do
!update natom_inout with the number of external charges
natom_inout = natom
else
natom = natom_inout
qmmm_struct%nquant = natom
qmmm_struct%nlink = 0
qmmm_struct%nquant_nlink = natom
do i=1,natom
iqmatoms(i) = i
end do
end if
!natom = natom_in
!qmmm_struct%nquant = natom
!qmmm_struct%nlink = 0
!qmmm_struct%nquant_nlink = natom
!do i=1,natom
! iqmatoms(i) = i
!end do
#else
if (qmmm_nml%qmtheory%SEBOMD) then
qmmm_struct%nquant = 0
else
if( (qmmask /= '') .or. (coremask /= '') ) then ! get the quantum atoms from the mask
if(abfqmmm == 1 .and. qmmm_struct%abfqmmm /= 1 &
.and. .not. do_not_print) then
write(6,'(a)') ''
write(6,'(/80("-")/" ADAPTIVE BUFFERED FORCE QM/MM",/80("-")/)')
if(hot_spot == 1) then
write(6,'(a)') ''
write(6,'(/80("-")/" HOT SPOT IS ACTIVE ",/80("-")/)')
end if
end if
if(qmmm_struct%abfqmmm /= 1 .and. .not. do_not_print) then
if(abfqmmm == 1) then
write(6,'(a)') ''
write(6,'(a)') '------------------------'
write(6,'(a)') 'Specification of regions'
write(6,'(a)') '------------------------'
write(6,'(a)') ''
write(6,'(a)') 'QM atoms:'
write(6,'(a)') '---------'
write(6,'(a)') ''
if(qmmask /= '') then
write(6,'(a)') 'INFO: loading the quantum atoms as groups'
else
write(6,'(a)') 'INFO: quantum atoms for adaptive QM/MM are not defined'
write(6,'(a)') 'INFO: core atoms will be used in reduced calculation'
end if
else
write(6,'(a)') 'LOADING THE QUANTUM ATOMS AS GROUPS'
end if
end if
allocate(isqm( natom ), stat=ier)
REQUIRE(ier==0)
call atommask(natom, nres, 0, ih(m04), ih(m06), &
ix(i02), ih(m02), x(lcrd), qmmask, isqm )
if(abfqmmm == 1 .and. qmstep == 0) then
if(r_core_in == 0) then
qmmm_struct%r_core_in = r_core_out
else
qmmm_struct%r_core_in = r_core_in
end if
if(r_core_out <= r_core_in) then
qmmm_struct%r_core_out = r_core_in
else
qmmm_struct%r_core_out = r_core_out
end if
if(r_qm_in == 0) then
qmmm_struct%r_qm_in = r_qm_out
else
qmmm_struct%r_qm_in = r_qm_in
end if
if(r_qm_out <= r_qm_in) then
qmmm_struct%r_qm_out = r_qm_in
else
qmmm_struct%r_qm_out = r_qm_out
end if
if(r_buffer_in == 0) then
qmmm_struct%r_buffer_in = r_buffer_out
else
qmmm_struct%r_buffer_in = r_buffer_in
end if
if(r_buffer_out <= r_buffer_in) then
qmmm_struct%r_buffer_out = r_buffer_in
else
qmmm_struct%r_buffer_out = r_buffer_out
end if
qmmm_struct%cut_bond_list_file = cut_bond_list_file
qmmm_struct%oxidation_number_list_file = oxidation_number_list_file
qmmm_struct%mom_cons_type = mom_cons_type
qmmm_struct%mom_cons_region = mom_cons_region
qmmm_struct%fix_atom_list = fix_atom_list
qmmm_struct%solvent_atom_number = solvent_atom_number
qmmm_struct%selection_type = selection_type
qmmm_struct%center_type = center_type
qmmm_struct%initial_selection_type = initial_selection_type
qmmm_struct%max_bonds_per_atom = max_bonds_per_atom
qmmm_struct%n_max_recursive = n_max_recursive
qmmm_struct%min_heavy_mass = min_heavy_mass
qmmm_struct%gamma_ln_qm = gamma_ln_qm
qmmm_struct%read_idrst_file = read_idrst_file
qmmm_struct%write_idrst_file = write_idrst_file
qmmm_struct%ntwidrst = ntwidrst
qmmm_struct%pdb_file = pdb_file
qmmm_struct%ntwpdb = ntwpdb
end if
if (qmstep /= 0) isqm(1:natom) = isabfqm(1:natom)
qmmm_struct%nquant = sum(isqm(1:natom))
if( (qmmm_struct%abfqmmm /= 1) .and. (qmmask /= '') .and. &
.not. do_not_print) then
write(6,'(a,a,a,i5,a)') ' Mask ', qmmask(1:len_trim(qmmask)), &
' matches ',qmmm_struct%nquant,' atoms'
end if
if(abfqmmm == 1 .and. qmmm_struct%abfqmmm /= 1) then
if (.not. do_not_print) &
write(6,'(a,i2)') ' qm-charge: ', qmcharge
qmmm_nml%qmcharge = qmcharge
end if
j = 0
do i=1,natom
if( isqm(i)>0 ) then
j = j+1
iqmatoms(j) = i
end if
end do
if(abfqmmm == 1 .and. qmmm_struct%abfqmmm /= 1) then
if( ext_qmmask_subset /= '' ) then
if (.not. do_not_print) then
write(6,'(a)') 'INFO: qm subset was specified for the extended qm region'
write(6,'(a)') 'INFO: loading qm subset atoms'
end if
call atommask(natom, nres, 0, ih(m04), ih(m06), &
ix(i02), ih(m02), x(lcrd), ext_qmmask_subset, isqm )
qmmm_struct%qm_nsubset = sum(isqm(1:natom))
if (.not. do_not_print) &
write(6,'(a,a,a,i5,a)') ' Mask ', trim(ext_qmmask_subset), &
' matches ',qmmm_struct%qm_nsubset,' atoms'
if(qmmm_struct%qm_nsubset == 0 .and. .not. do_not_print) then
write(6,'(a)') 'INFO: qm subset is an empty set => &
&all atoms can be in extended qm region'
end if
j = 0
do i=1,natom
if( isqm(i)>0 ) then
j = j+1
qm_subsetatoms(j) = i
end if
end do
else
if (.not. do_not_print) &
write(6,'(a)') 'INFO: qm subset was not specified for the &
&extended qm region'
qmmm_struct%qm_nsubset = 0
end if
if (.not. do_not_print) then
write(6,'(a)') ''
write(6,'(a)') 'CORE atoms:'
write(6,'(a)') '-----------'
write(6,'(a)') ''
end if
if( coremask /= '' ) then
if (.not. do_not_print) &
write(6,'(a)') 'INFO: loading the core atoms for adaptive QM/MM'
call atommask(natom, nres, 0, ih(m04), ih(m06), &
ix(i02), ih(m02), x(lcrd), coremask, isqm )
qmmm_struct%core_nquant = sum(isqm(1:natom))
if (.not. do_not_print) &
write(6,'(3a,i5,a)') ' Mask ', trim(coremask), ' matches ',&
qmmm_struct%core_nquant,' atoms'
j = 0
do i=1,natom
if( isqm(i)>0 ) then
j = j+1
core_iqmatoms(j) = i
end if
end do
else
if (.not. do_not_print) then
write(6,'(a)') 'INFO: core atoms for adaptive QM/MM are not defined'
write(6,'(a)') 'INFO: reduced calculation will be full MM calculation'
write(6,'(a)') 'INFO: using FF parameters from topology file'
end if
qmmm_struct%core_nquant = 0
end if
write(6,'(a,i2)') ' core-charge: ', corecharge
qmmm_nml%corecharge = corecharge
if( ext_coremask_subset /= '' ) then
if (.not. do_not_print) then
write(6,'(a)') 'INFO: core subset was specified for the extended core region'
write(6,'(a)') 'INFO: loading core subset atoms'
end if
call atommask(natom, nres, 0, ih(m04), ih(m06), &
ix(i02), ih(m02), x(lcrd), ext_coremask_subset, isqm )
qmmm_struct%core_nsubset = sum(isqm(1:natom))
if (.not. do_not_print) &
write(6,'(3a,i5,a)') ' Mask ', trim(ext_coremask_subset), &
' matches ',qmmm_struct%core_nsubset,' atoms'
if(qmmm_struct%core_nsubset == 0 .and. .not. do_not_print) then
write(6,'(a)') 'INFO: core subset is an empty set => &
&all atoms can be in extended core region'
end if
j = 0
do i=1,natom
if( isqm(i)>0 ) then
j = j+1
core_subsetatoms(j) = i
end if
end do
else
if (.not. do_not_print) &
write(6,'(a)') 'INFO: core subset was not specified for the &
&extended core region'
qmmm_struct%core_nsubset = 0
end if
if (.not. do_not_print) then
write(6,'(a)') ''
write(6,'(a)') 'BUFFER atoms:'
write(6,'(a)') '-------------'
write(6,'(a)') ''
end if
if( buffermask /= '' ) then
if (.not. do_not_print) &
write(6,'(a)')'INFO: loading the buffer atoms for adaptive QM/MM'
call atommask(natom, nres, 0, ih(m04), ih(m06), &
ix(i02), ih(m02), x(lcrd), buffermask, isqm )
qmmm_struct%buffer_nquant = sum(isqm(1:natom))
if (.not. do_not_print) &
write(6,'(3a,i5,a)') ' Mask ', trim(buffermask), &
' matches ',qmmm_struct%buffer_nquant,' atoms'
j = 0
do i=1,natom
if( isqm(i)>0 ) then
j = j+1
buffer_iqmatoms(j) = i
end if
end do
else
if (.not. do_not_print) &
write(6,'(a)') 'INFO: buffer atoms for adaptive QM/MM are not defined'
if(qmmm_struct%r_buffer_out == 0 .and. .not. do_not_print) then
write(6,'(a)') 'WARNING: buffer radius was set to zero and no buffer atoms were given'
write(6,'(a)') ' this may lead to unconverged QM forces'
end if
qmmm_struct%buffer_nquant = 0
end if
if (.not. do_not_print) &
write(6,'(a,i2)') ' buffer-charge: ', buffercharge
qmmm_nml%buffercharge = buffercharge
if( ext_buffermask_subset /= '' ) then
if (.not. do_not_print) then
write(6,'(a)') 'INFO: buffer subset was specified for the &
&extended buffer region'
write(6,'(a)') 'INFO: loading buffer subset atoms'
end if
call atommask(natom, nres, 0, ih(m04), ih(m06), &
ix(i02), ih(m02), x(lcrd), ext_buffermask_subset, isqm )
qmmm_struct%buffer_nsubset = sum(isqm(1:natom))
if (.not. do_not_print) &
write(6,'(3a,i5,a)') ' Mask ', trim(ext_buffermask_subset), &
' matches ',qmmm_struct%buffer_nsubset,' atoms'
if(qmmm_struct%buffer_nsubset == 0 .and. .not. do_not_print) then
write(6,'(a)') 'INFO: buffer subset is an empty set => all atoms can be in extended buffer region'
end if
j = 0
do i=1,natom
if( isqm(i)>0 ) then
j = j+1
buffer_subsetatoms(j) = i
end if
end do
else
if (.not. do_not_print) &
write(6,'(a)') 'INFO: buffer subset was not specified for &
&the extended buffer region'
qmmm_struct%buffer_nsubset = 0
end if
if (.not. do_not_print) then
write(6,'(a)') ''
write(6,'(a)') 'CENTER atoms:'
write(6,'(a)') '-------------'
write(6,'(a)') ''
end if
if(centermask /= '') then
if (.not. do_not_print) then
write(6,'(a)') 'INFO: center atom list was specified'
write(6,'(a)') 'INFO: loading the center atoms for adaptive QM/MM'
end if
call atommask(natom, nres, 0, ih(m04), ih(m06), &
ix(i02), ih(m02), x(lcrd), centermask, isqm )
qmmm_struct%center_nsubset = sum(isqm(1:natom))
if (.not. do_not_print) &
write(6,'(3a,i5,a)') ' Mask ', trim(centermask), &
' matches ',qmmm_struct%center_nsubset,' atoms'
if(qmmm_struct%center_nsubset == 0 .and. .not. do_not_print) then
if(qmmm_struct%core_nquant > 0) then
write(6,'(a)') 'INFO: center atom list is an empty set => &
¢er atom list = user defined core list'
else
write(6,'(a)') 'INFO: center atom list is an empty set => &
¢er atom list = user defined qm list'
end if
end if
j = 0
do i=1,natom
if( isqm(i)>0 ) then
j = j+1
center_subsetatoms(j) = i
end if
end do
else
if(qmmm_struct%core_nquant > 0 .and. .not. do_not_print) then
write(6,'(a)') 'INFO: center atom list is not defined => &
¢er atom list = user defined core list'
else if (.not. do_not_print) then
write(6,'(a)') 'INFO: center atom list is not defined => &
¢er atom list = user defined qm list'
end if
qmmm_struct%center_nsubset = 0
end if
end if ! (qmmask /= '' .or. (coremask /= '')
if(abfqmmm == 1) qmmm_struct%abfqmmm = 1
if(abfqmmm == 1 .and. hot_spot == 1) then
qmmm_struct%hot_spot = 1
end if
deallocate(isqm, stat=ier)
REQUIRE(ier==0)
else ! get the count from the input iqmatoms array
do i = 1,MAX_QUANTUM_ATOMS
if( iqmatoms(i) == 0 ) exit
end do
qmmm_struct%nquant = i-1
end if
end if ! (qmmm_nml%qmtheory%SEBOMD)
if(abfqmmm == 1) then
if(qmstep == 0) then
if(qmmm_struct%nquant > 0) then
call validate_qm_atoms(iqmatoms,qmmm_struct%nquant,natom)
call int_legal_range('QMMM: (number of qm atoms) ', &
qmmm_struct%nquant, 1, MAX_QUANTUM_ATOMS )
call qmsort(iqmatoms)
allocate(qmmm_struct%iqmatoms(qmmm_struct%nquant))
do i = 1, qmmm_struct%nquant
qmmm_struct%iqmatoms(i)=iqmatoms(i)
end do
end if
if(qmmm_struct%qm_nsubset > 0) then
call validate_qm_atoms(qm_subsetatoms,qmmm_struct%qm_nsubset,natom)
call int_legal_range('QMMM: (number of qm subset atoms) ', &
qmmm_struct%qm_nsubset, 1, natom )
call qmsort(qm_subsetatoms)
allocate(qmmm_struct%qm_subsetatoms(qmmm_struct%qm_nsubset))
do i = 1, qmmm_struct%qm_nsubset
qmmm_struct%qm_subsetatoms(i)=qm_subsetatoms(i)
end do
end if
if(qmmm_struct%core_nquant > 0) then
call validate_qm_atoms(core_iqmatoms,qmmm_struct%core_nquant,natom)
call int_legal_range('QMMM: (number of core atoms) ', &
qmmm_struct%core_nquant, 1, max_quantum_atoms )
allocate(qmmm_struct%core_iqmatoms(qmmm_struct%core_nquant))