-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cgto.f90
2226 lines (1903 loc) · 56.9 KB
/
cgto.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
!
! rhOver - a FORTRAN program to determine magnetic anisotropy and related
! properties for dysprosium(III) single-ion magnets by semi-empirical approaches
! Copyright (C) 2014-2019 Michael Böhme <[email protected]>
!
! Permission is hereby granted, free of charge, to any person obtaining a copy
! of this software and associated documentation files (the "Software"), to deal
! in the Software without restriction, including without limitation the rights
! to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
! copies of the Software, and to permit persons to whom the Software is
! furnished to do so, subject to the following conditions:
!
! The above copyright notice and this permission notice shall be included in all
! copies or substantial portions of the Software.
!
! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
! SOFTWARE.
!
module data_mo
use global_c
implicit none
character(sMaxBuffer) :: FTitle
type t_atom
integer :: id
integer :: charge
logical :: skip
logical :: ghost
character(5) :: str
double precision :: x
double precision :: y
double precision :: z
double precision :: theta
double precision :: phi
double precision :: dist
double precision :: mulliken
double precision :: ccharge
end type t_atom
type(t_atom), dimension(iMaxAtoms) :: Atoms
integer :: NA = 0, NEl = 0
type t_cgto
integer :: id
integer :: atomid
integer :: shelltype
integer :: npgto
integer :: npgto_beg
integer :: n
integer :: subtype
double precision :: ox, oy, oz
logical :: deleted
double precision, allocatable, dimension(:,:) :: coeff
end type t_cgto
type(t_cgto), allocatable, dimension(:) :: CGTOs
integer :: NCGTO
type t_pgto
integer :: id
integer :: atomid
integer :: cgtoid
integer :: cgtonpgto
integer :: shelltype
integer :: subtype
integer :: subnum
integer :: n
double precision :: coeff, coeff_d, coeff_alpha
double precision :: ox, oy, oz
logical :: deleted
end type t_pgto
type(t_pgto), allocatable, dimension(:) :: PGTOs
type t_mo
integer :: id
integer :: motype
character(sMaxBuffer) :: name
double precision :: energy
double precision :: occup
double precision, allocatable, dimension(:) :: mocoeff
end type t_mo
type(t_mo), allocatable, dimension(:) :: MOs
integer :: NMO = 0
double precision, dimension(:,:), allocatable :: AtomsDistMat, AtomsDistMatSq
double precision, dimension(:,:), allocatable :: S_PGTO, S_CGTO, D_CGTO, O_CGTO12, DSMat, O_CGTO, O_CGTOT
double precision, dimension(:,:), allocatable :: DensPMat
double precision :: CSThresC, CSThresD, CSThresI
real :: TimerA, TimerB
end module
subroutine print_bs_info
use data_mo
implicit none
!
write(*,'(5X,A)') "> BASIS SET INFORMATION:"
write(*,*)
write(*,'(A35,I14)') "number of atoms: ", NA
write(*,'(A35,I14)') "primitive GTOs: ", NumPGTO
write(*,'(A35,I14)') "contracted GTOs: ", NumCGTO
write(*,*)
write(*,*)
end subroutine
subroutine check_ghost_atoms
use data_mo
implicit none
!
integer :: i, j, nGhosts
!
nGhosts = 0
do j = 1, NA
Atoms(j)%ghost = .TRUE.
do i = 1, NumCGTO
if ( CGTOs(i)%atomid .eq. j ) then
Atoms(j)%ghost = .FALSE.
exit
end if
end do
if ( Atoms(j)%ghost .eqv. .TRUE. ) then
nGhosts = nGhosts + 1
Atoms(j)%charge = 0d0
end if
end do
if ( nGhosts .gt. 0 ) then
write(*,'(A35,I14)') "ghost atom(s) found: ", nGhosts
end if
if ( ODelete4f .eqv. .TRUE. ) then
write(*,*) "> REMOVING 4f SHELL CONTRIBUTIONS (AS REQUESTED) ..."
write(*,*)
do j = 1, NumCGTO
if ( ( Atoms(CGTOs(j)%atomid)%dist .lt. 0.01d0 ) ) then
Atoms(CGTOs(j)%atomid)%ghost = .TRUE.
! delete 4f shell
if ( ( ODelete4f .eqv. .TRUE. ) .and. ( CGTOs(j)%shelltype .eq. 4 ) .and. ( CGTOs(j)%n .eq. 4 ) ) then
write(*,'(10X,A,I4,A)') " ... CGTO #", j, " has been removed!"
do i = 1, CGTOs(j)%npgto
CGTOs(j)%coeff(3,i) = 0d0
CGTOs(j)%coeff(2,i) = 0d0
CGTOs(j)%coeff(1,i) = 0d0
CGTOs(j)%deleted = .TRUE.
end do
do i = CGTOs(j)%npgto_beg, CGTOs(j)%npgto_beg + CGTOs(j)%npgto - 1
PGTOs(i)%coeff_alpha = 0d0
PGTOs(i)%coeff_d = 0d0
PGTOs(i)%coeff = 0d0
PGTOs(i)%deleted = .TRUE.
end do
end if
end if
end do
else if ( ODeleteAll .eqv. .TRUE. ) then
write(*,*) "> REMOVING ALL SHELLS FROM DY(III) CENTER (AS REQUESTED) ..."
write(*,*)
do j = 1, NumCGTO
if ( ( Atoms(CGTOs(j)%atomid)%dist .lt. 0.01d0 ) ) then
Atoms(CGTOs(j)%atomid)%ghost = .TRUE.
! delete shell
write(*,'(10X,A,I4,A)') " ... CGTO #", j, " has been removed!"
do i = 1, CGTOs(j)%npgto
CGTOs(j)%deleted = .TRUE.
end do
do i = CGTOs(j)%npgto_beg, CGTOs(j)%npgto_beg + CGTOs(j)%npgto - 1
PGTOs(i)%deleted = .TRUE.
end do
end if
end do
! else
! do j = 1, NumCGTO
! if ( ( Atoms(CGTOs(j)%atomid)%dist .lt. 0.01d0 ) ) then
!
! Atoms(CGTOs(j)%atomid)%ghost = .TRUE.
! end if
! end do
end if
if ( ( ODelete4f .eqv. .TRUE. ) .or. ( ODeleteAll .eqv. .TRUE. ) ) then
write(*,*)
write(*,*)
end if
end subroutine
subroutine read_molden_file(filename)
use data_mo
use global_c
implicit none
!
character (len=sMaxBuffer), intent(in) :: filename
character (len=sMaxBuffer) :: to_upper, to_upper_first
integer :: iost, iAtom, iBuffer, iPGTO, i, j, oshell, onshell, line = 0, mode = 0
double precision :: dBuffer, tdensity
character(len=sMaxBuffer) :: sBuffer, sBuffer2, sBuffer3, sShellType
logical :: SkipR = .FALSE.
!
tdensity = 0.d0
NCGTO = 0
write(*,'(/5X,3A/)',advance='no') "> READING MOLDEN FILE '", trim(filename), "' ..."
open(unit=uMolF, file=filename, action='read', status='old', iostat=iost)
if ( iost .ne. 0 ) then
write(*,*) "ERROR! Can't open molden file!"
stop
end if
! read file header
read(uMolF, '(A)') sBuffer
line = line + 1
sBuffer = to_upper(sBuffer)
if ( sBuffer .ne. "[MOLDEN FORMAT]" ) then
write(*,*)
write(*,*) "ERROR! This is not a molden file!"
close(uMolF)
stop
end if
do
if ( SkipR .eqv. .FALSE. ) then
line = line + 1
read(uMolF, '(A)',iostat=iost) sBuffer
else
SkipR = .FALSE.
end if
if ( iost .ne. 0 ) then
! end of file
exit
else
sBuffer = to_upper(sBuffer)
if ( len_trim(sBuffer) .ne. 0 ) then
if ( sBuffer .eq. "[TITLE]" ) then
line = line + 1
read(uMolF, '(A)', iostat=iost) FTitle
continue
else if ( sBuffer(1:7) .eq. "[ATOMS]" ) then
! TODO: check for AU keyword
mode = 1
do
line = line + 1
read(uMolF, '(A)',iostat=iost) sBuffer
if ( sBuffer(1:1) .ne. "[" ) then
NA = NA + 1
read(sBuffer, *) Atoms(NA)%str, Atoms(NA)%id, Atoms(NA)%charge, Atoms(NA)%x, Atoms(NA)%y, Atoms(NA)%z
Atoms(NA)%str = to_upper_first(Atoms(NA)%str)
Atoms(NA)%skip = .FALSE.
Atoms(NA)%ghost = .FALSE.
else
SkipR = .TRUE.
exit
end if
end do
continue
else if ( ( sBuffer .eq. "[5D]" ) .or. ( sBuffer .eq. "[7F]" ) .or. ( sBuffer .eq. "[9G]" ) ) then
write(*,*)
write(*,*) "ERROR! Keyword '", trim(sBuffer), "' found!"
write(*,*) "Only Cartesian basis functions are currently supported!"
close(uMolF)
stop
else if ( sBuffer .eq. "[STO]" ) then
write(*,*)
write(*,*) "ERROR! STO basis sets are not supported!"
close(uMolF)
stop
else if ( sBuffer .eq. "[GTO]" ) then
if ( mode .ne. 1 ) then
write(*,*)
write(*,*) "ERROR! Molden file is corrupt!"
close(uMolF)
stop
end if
mode = 2
allocate(CGTOs(iMaxCGTOs),stat=iost)
do
line = line + 1
read(uMolF, '(A)',iostat=iost) sBuffer
if ( len_trim(sBuffer) .ne. 0 ) then
if ( sBuffer(1:1) .ne. "[" ) then
read(sBuffer, *) iAtom, iBuffer
oshell = 0
onshell = 0
do
line = line + 1
read(uMolF, '(A)',iostat=iost) sBuffer
if ( len_trim(sBuffer) .ne. 0 ) then
NCGTO = NCGTO + 1
CGTOs(NCGTO)%atomid = iAtom
CGTOs(NCGTO)%ox = Atoms(iAtom)%x
CGTOs(NCGTO)%oy = Atoms(iAtom)%y
CGTOs(NCGTO)%oz = Atoms(iAtom)%z
CGTOs(NCGTO)%id = NCGTO
read(sBuffer, *) sShellType, iPGTO, dBuffer
sShellType = to_upper(sShellType)
select case ( sShellType )
case ( "S" )
NPGTO = NPGTO + 1
CGTOs(NCGTO)%shelltype = 1
case ( "P" )
NPGTO = NPGTO + 3
CGTOs(NCGTO)%shelltype = 2
case ( "D" )
NPGTO = NPGTO + 6
CGTOs(NCGTO)%shelltype = 3
case ( "F" )
NPGTO = NPGTO + 10
CGTOs(NCGTO)%shelltype = 4
case ( "G" )
NPGTO = NPGTO + 15
CGTOs(NCGTO)%shelltype = 5
case default
write(*,*)
write(*,*) "ERROR! Only shell types S, P, D, F, G are supported!"
close(uMolF)
stop
end select
if ( CGTOs(NCGTO)%shelltype .eq. oshell ) then
onshell = onshell + 1
else
oshell = CGTOs(NCGTO)%shelltype
onshell = CGTOs(NCGTO)%shelltype
end if
oshell = CGTOs(NCGTO)%shelltype
CGTOs(NCGTO)%n = onshell
CGTOs(NCGTO)%npgto = iPGTO
allocate(CGTOs(NCGTO)%coeff(3,iPGTO))
do i = 1, iPGTO
line = line + 1
read(uMolF, '(A)',iostat=iost) sBuffer
read(sBuffer,*) CGTOs(NCGTO)%coeff(1, i), CGTOs(NCGTO)%coeff(2, i)
select case ( CGTOs(NCGTO)%shelltype )
case ( 1 )
CGTOs(NCGTO)%coeff(3, i) = CGTOs(NCGTO)%coeff(2, i)
case ( 2 )
CGTOs(NCGTO)%coeff(3, i) = CGTOs(NCGTO)%coeff(2, i)
case ( 3 )
CGTOs(NCGTO)%coeff(3, i) = CGTOs(NCGTO)%coeff(2, i)
case ( 4 )
CGTOs(NCGTO)%coeff(3, i) = CGTOs(NCGTO)%coeff(2, i)
case ( 5 )
CGTOs(NCGTO)%coeff(3, i) = CGTOs(NCGTO)%coeff(2, i)
case default
write(*,*)
write(*,*) "ERROR! Unsupported shell type found!"
close(uMolF)
stop
end select
end do
else
exit
end if
end do
else
exit
end if
end if
end do
SkipR = .TRUE.
else if ( sBuffer .eq. "[MO]" ) then
if ( mode .ne. 2 ) then
write(*,*)
write(*,*) "ERROR! Molden file seems to be invalid!"
close(uMolF)
stop
end if
mode = 3
allocate(MOs(iMaxMOs))
do
line = line + 1
read(uMolF, '(A)',iostat=iost) sBuffer
if ( iost < 0 ) then
! end of file
exit
end if
if ( ( NMO .eq. 0 ) .and. ( OFNoTurbomole .eqv. .FALSE. ) ) then
if ( ( sBuffer .eq. " Sym= 1a") .and. ( OTurbomole .eqv. .FALSE. ) ) then
write(*,*)
write(*,*) " INFO: The loaded MOLDEN seems to be generated by TURBOMOLE/tm2molden."
write(*,*) " Correction factors to the d-, f-, and g-shells will automatically be applied."
write(*,*) " Use the 'NoTurbomole' keyword to turn off this automatic correction."
write(*,*)
OTurbomole = .TRUE.
end if
end if
if ( len_trim(sBuffer) .ne. 0 ) then
NMO = NMO + 1
sBuffer = adjustl(to_upper(sBuffer))
read(sBuffer, *) sBuffer2, sBuffer3
if ( sBuffer2 .ne. "SYM=" ) then
write(*,*)
write(*,*) "ERROR! Can't read MO parameter (1)!", sBuffer2
close(uMolF)
stop
end if
MOs(NMO)%id = NMO
MOs(NMO)%name = sBuffer3
line = line + 1
read(uMolF, '(A)') sBuffer
sBuffer = adjustl(to_upper(sBuffer))
read(sBuffer, *) sBuffer2, sBuffer3
if ( sBuffer2 .ne. "ENE=" ) then
write(*,*)
write(*,*) "ERROR! Can't read MO parameters (2)!"
close(uMolF)
stop
end if
read(sBuffer3, *) MOs(NMO)%energy
line = line + 1
read(uMolF, '(A)') sBuffer
sBuffer = adjustl(to_upper(sBuffer))
read(sBuffer, *) sBuffer2, sBuffer3
if ( sBuffer2 .ne. "SPIN=" ) then
write(*,*)
write(*,*) "ERROR! Can't read MO parameters (3)!"
close(uMolF)
stop
end if
if ( sBuffer3 .eq. "ALPHA" ) then
MOs(NMO)%motype = 1
else
MOs(NMO)%motype = 2
if ( OUHF .eqv. .FALSE. ) then
OUHF = .TRUE.
write(*,*)
write(*,'(7X,A)') "An UHF/UKS wave function was found!"
write(*,*)
end if
end if
line = line + 1
read(uMolF, '(A)') sBuffer
sBuffer = adjustl(to_upper(sBuffer))
read(sBuffer, *) sBuffer2, sBuffer3
if ( sBuffer2 .ne. "OCCUP=" ) then
write(*,*)
write(*,*) "ERROR! Can't read MO parameters (4)!"
close(uMolF)
stop
end if
read(sBuffer3, *) MOs(NMO)%occup
allocate(MOs(NMO)%mocoeff(NPGTO))
do i = 1, NPGTO
line = line + 1
read(uMolF, '(A)') sBuffer
read(sBuffer, *) iBuffer, dBuffer
if ( iBuffer .ne. i ) then
write(*,*)
write(*,*) "ERROR! Can't read MO parameters (5)!"
close(uMolF)
stop
end if
MOs(NMO)%mocoeff(i) = dBuffer
end do
!
else
! empty line
exit
end if
end do
else
write(*,*) "WARNING! Unknown keyword in Molden file found!"
write(*,*) sBuffer
close(uMolF)
stop
end if
end if
end if
end do
close(uMolF)
allocate(AtomsDistMat(NA,NA))
allocate(AtomsDistMatSq(NA,NA))
AtomsDistMat = 0d0
AtomsDistMatSq = 0d0
do i = 1, NA
do j = i + 1, NA
AtomsDistMatSq(i, j) = (Atoms(i)%x - Atoms(j)%x)**2 + (Atoms(i)%y - Atoms(j)%y)**2 + (Atoms(i)%z - Atoms(j)%z)**2
if ( AtomsDistMatSq(i, j) .lt. 1d-15 ) then
AtomsDistMatSq(i, j) = 0d0
end if
AtomsDistMatSq(j, i) = AtomsDistMatSq(i, j)
AtomsDistMat(i, j) = dsqrt( AtomsDistMatSq(i, j) )
AtomsDistMat(j, i) = AtomsDistMat(i, j)
end do
end do
TotalNuclearCharge = 0.0d0
do i = 1, NA
if ( Atoms(i)%ghost .eqv. .FALSE. ) then
TotalNuclearCharge = TotalNuclearCharge + Atoms(i)%charge
end if
end do
if ( CAtomID .gt. 0 ) then
EDyX = Atoms(CAtomID)%x
EDyY = Atoms(CAtomID)%y
EDyZ = Atoms(CAtomID)%z
end if
do i = 1, NA
Atoms(i)%dist = dsqrt( (EDyX - Atoms(i)%x )**2 + (EDyY - Atoms(i)%y )**2 + (EDyZ - Atoms(i)%z )**2 )
Atoms(i)%theta = dacos( (Atoms(i)%z-EDyZ) / Atoms(i)%dist )
Atoms(i)%phi = datan2( Atoms(i)%y-EDyY, Atoms(i)%x-EDyX )
end do
call write_done
end subroutine
function get_pgto_norm_factor(alpha, nx, ny, nz) result(res)
use data_mo
implicit none
!
double precision, intent(in) :: alpha
integer, intent(in) :: nx, ny, nz
integer :: n_fac
double precision :: res
!
res = (2d0*alpha/Pi)**(3d0/4d0) * &
dsqrt( (8d0*alpha)**(nx+ny+nz) * n_fac(nx) * n_fac(ny) * n_fac(nz) / &
( n_fac(2*nx) * n_fac(2*ny) * n_fac(2*nz) ) )
end function
subroutine reorder_cgtos
use data_mo
implicit none
!
integer :: i, j, k, l, m, n, nprim, ncont, nx, ny, nz, pgto_get_l
double precision :: get_pgto_norm_factor
!
nprim = 0
ncont = 0
! count contracted and primitive GTOs, cartesian only
do i = 1, NCGTO
select case ( CGTOs(i)%shelltype )
case ( 1 )
nprim = nprim + 1 * CGTOs(i)%npgto
ncont = ncont + 1
case ( 2 )
nprim = nprim + 3 * CGTOs(i)%npgto
ncont = ncont + 3
case ( 3 )
nprim = nprim + 6 * CGTOs(i)%npgto
ncont = ncont + 6
case ( 4 )
nprim = nprim + 10 * CGTOs(i)%npgto
ncont = ncont + 10
case ( 5 )
nprim = nprim + 15 * CGTOs(i)%npgto
ncont = ncont + 15
case default
write(*,*) "ERROR! Shell type not implemented!"
stop
end select
end do
NumPGTO = nprim
NumCGTO = ncont
if ( NumCGTO > iMaxCGTOs ) then
write(*,*) "ERROR! Too many CGTOs! Try to increase iMaxCGTOs!"
stop
end if
allocate(PGTOs(NumPGTO))
j = 0
n = 1
do i = 1, NumCGTO
select case ( CGTOs(i)%shelltype )
case ( 1 )
k = 1
case ( 2 )
k = 3
case ( 3 )
k = 6
case ( 4 )
k = 10
case ( 5 )
k = 15
case default
k = 0
end select
do l = 1, k
do m = 1, CGTOs(i)%npgto
j = j + 1
PGTOs(j)%id = j
PGTOs(j)%atomid = CGTOs(i)%atomid
PGTOs(j)%cgtoid = n
PGTOs(j)%shelltype = CGTOs(i)%shelltype
PGTOs(j)%ox = Atoms(CGTOs(i)%atomid)%x
PGTOs(j)%oy = Atoms(CGTOs(i)%atomid)%y
PGTOs(j)%oz = Atoms(CGTOs(i)%atomid)%z
PGTOs(j)%coeff_alpha = CGTOs(i)%coeff(1, m)
PGTOs(j)%coeff_d = CGTOs(i)%coeff(2, m)
PGTOs(j)%coeff = CGTOs(i)%coeff(2, m)
PGTOs(j)%cgtonpgto = CGTOs(i)%npgto
PGTOs(j)%subtype = l
PGTOs(j)%subnum = m
PGTOs(j)%n = CGTOs(i)%n
PGTOs(j)%deleted = .FALSE.
nx = pgto_get_l(PGTOs(j)%shelltype, PGTOs(j)%subtype, 1)
ny = pgto_get_l(PGTOs(j)%shelltype, PGTOs(j)%subtype, 2)
nz = pgto_get_l(PGTOs(j)%shelltype, PGTOs(j)%subtype, 3)
PGTOs(j)%coeff_d = PGTOs(j)%coeff_d * get_pgto_norm_factor(PGTOs(j)%coeff_alpha, nx, ny, nz)
! MOLDEN files from TURBOMOLE need a correction
if ( OTurbomole .eqv. .TRUE. ) then
select case ( PGTOs(j)%shelltype )
case ( 3 )
PGTOs(j)%coeff_d = PGTOs(j)%coeff_d * dsqrt(3d0)
case ( 4 )
PGTOs(j)%coeff_d = PGTOs(j)%coeff_d * dsqrt(15d0)
case ( 5 )
PGTOs(j)%coeff_d = PGTOs(j)%coeff_d * dsqrt(105d0)
end select
end if
end do
n = n + 1
end do
end do
do i = 1, NCGTO
deallocate(CGTOs(i)%coeff)
end do
deallocate(CGTOs)
allocate(CGTOs(NumCGTO))
do i = 1, NumCGTO
do j = 1, NumPGTO
if ( PGTOs(j)%cgtoid .eq. i ) then
CGTOs(i)%id = PGTOs(j)%cgtoid
CGTOs(i)%atomid = PGTOs(j)%atomid
CGTOs(i)%shelltype = PGTOs(j)%shelltype
CGTOs(i)%npgto = PGTOs(j)%cgtonpgto
CGTOs(i)%ox = PGTOs(j)%ox
CGTOs(i)%oy = PGTOs(j)%oy
CGTOs(i)%oz = PGTOs(j)%oz
CGTOs(i)%n = PGTOs(j)%n
CGTOs(i)%subtype = PGTOs(j)%subtype
if ( PGTOs(j)%subnum .eq. 1 ) then
CGTOs(i)%npgto_beg = j
end if
CGTOs(i)%deleted = .FALSE.
allocate(CGTOs(i)%coeff(3, CGTOs(i)%npgto))
exit
end if
end do
end do
do i = 1, NumPGTO
CGTOs(PGTOs(i)%cgtoid)%coeff(1, PGTOs(i)%subnum) = PGTOs(i)%coeff_alpha
CGTOs(PGTOs(i)%cgtoid)%coeff(2, PGTOs(i)%subnum) = PGTOs(i)%coeff
end do
end subroutine
subroutine print_pgto_info
use data_mo
implicit none
!
double precision :: res
integer :: i
character (len=1) :: stype
character (len=8) :: subtype
!
res = 0d0
i = 0
write(*,*) "PRIMITIVE GTO BASIS SET INFO:"
write(*,*)
write(*,'(8X,A)') "---------------------------------------------------------------------"
write(*,'(8X,A5,4A8,2A16)') "#", "CGTO", "ATOM", "SHELL", "TYPE", "ALPHA", "D"
write(*,'(8X,A)') "---------------------------------------------------------------------"
do while ( i .lt. NumPGTO )
i = i + 1
stype = "?"
subtype = " "
select case ( PGTOs(i)%shelltype )
case ( 1 )
stype = "s"
case ( 2 )
stype = "p"
select case ( PGTOs(i)%subtype )
case ( 1 )
subtype = "x"
case ( 2 )
subtype = "y"
case ( 3 )
subtype = "z"
case default
subtype = "?"
end select
case ( 3 )
stype = "d"
select case ( PGTOs(i)%subtype )
case ( 1 )
subtype = "xx"
case ( 2 )
subtype = "yy"
case ( 3 )
subtype = "zz"
case ( 4 )
subtype = "xy"
case ( 5 )
subtype = "xz"
case ( 6 )
subtype = "yz"
case default
subtype = "??"
end select
case ( 4 )
stype = "f"
select case ( PGTOs(i)%subtype )
case ( 1 )
subtype = "xxx"
case ( 2 )
subtype = "yyy"
case ( 3 )
subtype = "zzz"
case ( 4 )
subtype = "xyy"
case ( 5 )
subtype = "xxy"
case ( 6 )
subtype = "xxz"
case ( 7 )
subtype = "xzz"
case ( 8 )
subtype = "yzz"
case ( 9 )
subtype = "yyz"
case ( 10 )
subtype = "xyz"
case default
subtype = "???"
end select
case ( 5 )
stype = "g"
select case ( PGTOs(i)%subtype )
case ( 1 )
subtype = "xxxx"
case ( 2 )
subtype = "yyyy"
case ( 3 )
subtype = "zzzz"
case ( 4 )
subtype = "xxxy"
case ( 5 )
subtype = "xxxz"
case ( 6 )
subtype = "xyyy"
case ( 7 )
subtype = "yyyz"
case ( 8 )
subtype = "xzzz"
case ( 9 )
subtype = "yzzz"
case ( 10 )
subtype = "xxyy"
case ( 11 )
subtype = "xxzz"
case ( 12 )
subtype = "yyzz"
case ( 13 )
subtype = "xxyz"
case ( 14 )
subtype = "xyyz"
case ( 15 )
subtype = "xyzz"
case default
subtype = "????"
end select
case default
stype = "?"
end select
stype = adjustr(stype)
subtype = adjustr(subtype)
write(*,'(8X,I5,2I8,5X,I2,A1,A8,2F16.6)') i, PGTOs(i)%cgtoid, PGTOs(i)%atomid, PGTOs(i)%n, stype, subtype, PGTOs(i)%coeff_alpha, PGTOs(i)%coeff
end do
write(*,'(8X,A)') "---------------------------------------------------------------------"
write(*,*)
end subroutine
subroutine print_cgto_info
use data_mo
implicit none
!
double precision :: res
integer :: i
character (len=1) :: stype
character (len=8) :: subtype
!
res = 0d0
i = 0
write(*,*) "CONTRACTED GTO BASIS SET INFO:"
write(*,*)
write(*,'(48X,A)') "-----------------------------"
write(*,'(48X,A5,4A8,2A16)') "#", "ATOM", "SHELL", "TYPE"
write(*,'(48X,A)') "-----------------------------"
do while ( i .lt. NumCGTO )
i = i + 1
stype = "?"
subtype = " "
select case ( CGTOs(i)%shelltype )
case ( 1 )
stype = "s"
case ( 2 )
stype = "p"
select case ( CGTOs(i)%subtype )
case ( 1 )
subtype = "x"
case ( 2 )
subtype = "y"
case ( 3 )
subtype = "z"
case default
subtype = "?"
end select
case ( 3 )
stype = "d"
select case ( CGTOs(i)%subtype )
case ( 1 )
subtype = "xx"
case ( 2 )
subtype = "yy"
case ( 3 )
subtype = "zz"
case ( 4 )
subtype = "xy"
case ( 5 )
subtype = "xz"
case ( 6 )
subtype = "yz"
case default
subtype = "??"
end select
case ( 4 )
stype = "f"
select case ( CGTOs(i)%subtype )
case ( 1 )
subtype = "xxx"
case ( 2 )