-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgencl77.f
2441 lines (2312 loc) · 72.5 KB
/
gencl77.f
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
!
!
! G E N C L
! =========
!
! ------------------------------------------------------------------
PROGRAM GENCLF
!
! C O P Y R I G H T -- 1994
!
! By C. Froese Fischer
! Bin Liu
! Vanderbilt University
! Nashville, TN 37235 USA
!
! Written: May, 1983
!
! Computer Physics Communications, Vol. 64, 406--416 (1991).
!
! Modified By G. Gaigalas for f-shells (1997)
!
! Cleaned up and checked by J. Grumer (2015) by hand and by using
! the PlusFORT routine SPAG. This was done to simplify translation
! to f90
!
! ------------------------------------------------------------------
!
!
! This program computes all possible couplings for each member of
! the reference set, generates all unique, possible configurations
! and their couplings from the active set, and for each replacement,
! generates configurations and their couplings, then outputs the
! configurations and couplings with given final term(s).
! Input : (Interactive)
! i) Header ;
! ii) List of closed shells ;
! iii) The "reference" set ;
! iv) The "active" set ;
! v) Replacements from the reference set ;
! Virtual Set if Replacement is 's' or 'd' or 'sd'
! vi) Final Term
! Output :
! i ) Header ;
! ii) List of closed shells ;
! iii) Configurations (FORMAT(8(1X,A3,'(',I2,')'))
! and their couplings (FORMAT(15(1X,A3))
! I/O allocation
! FILE1(.) : Configurations by Active Set (internal file)
! FILE2(.) : Configurations by Replacement (internal file)
! FILE3(.) : couplings (internal file)
! 6 : Terminal output
! 7 : File CLIST
! FBETA(1,.) : Information of Beta2 (internal file )
! FBETA(2,.) : Information of Beta3 (internal file )
! FBETA(3,.) : Information of Beta4 (internal file )
! FBETA(4,.) : Information of Beta5 (internal file )
! FBETA(5,.) : Information of Beta6 (internal file )
! FBETA(6,.) : Information of Beta7 (internal file )
! FBETA(7,.) : Information of Beta8 (internal file )
!
!
! ---------------------------------------------------------------------
! M A I N P R O G R A M
! ---------------------------------------------------------------------
!
IMPLICIT NONE
!
! PARAMETER definitions
!
INTEGER NELS, NSHEL, NCOUPL, NCFG, NSCOUP
PARAMETER (NELS=21,NSHEL=8,NCOUPL=2*NSHEL-1,NCFG=10000,
& NSCOUP=10000)
!
! COMMON variables
!
CHARACTER*60 ACT, REF(NELS), REPL(NELS)
INTEGER CONST, M, MA, MAXFINAL, MINFINAL, ML, MR, MS(NELS), NF,
& NFTM, NQ, NR, NREF, ORD0, ORD9, ORDLA, ORDLZ, ORDUA,
& ORDUZ, PARITYVAL, Q(NELS), Q1, Q10, Q11, Q12, Q13, Q14,
& Q15, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QL(NELS), QR(NELS),
& QS(NELS,NELS), RL(NELS)
CHARACTER*3 EL(NELS), ELA(NELS), ELL(NELS), ELR(NELS), ELS(NELS)
CHARACTER*8 FBETA(7,NSCOUP)
CHARACTER*32 FILE1(NCFG), FILE3(NSCOUP)
CHARACTER*40 FILE2(NCFG)
CHARACTER*2 FTM(NELS)
CHARACTER*72 HEADER, SHELLS, VIRTUL
COMMON NF, NR, NFTM, MAXFINAL, MINFINAL, PARITYVAL, CONST, NQ
COMMON /BLK0 / ORDLA, ORDLZ, ORDUA, ORDUZ, ORD0, ORD9
COMMON /BLK1 / HEADER, SHELLS, ACT, VIRTUL
COMMON /BLK2 / REF, REPL, FTM
COMMON /BLK3 / EL, ELL, ELR, ELS, ELA
COMMON /BLK4 / Q, QL, ML, QR, MR, M, QS, MS, MA, RL, NREF, Q1,
& Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12,
& Q13, Q14, Q15
COMMON /FILES / FBETA, FILE1, FILE2, FILE3
!
! Local variables
!
CHARACTER CH1
CHARACTER*2 CH2
CHARACTER*3 CH3, COUPLE(NCOUPL), ELB(NELS), ELC(NELS), ELV(NELS)
INTEGER DFLAG, F(NELS), H(NELS), I, IFLAG, ITYPE, J, K, L, LEFT,
& LL1, LL2, LLMAX, LLMIN, LMAX, LMIN, LVIR, MINQ1, MV, N,
& N1, N2, NC, NL, NREPL, NVIR, PL, QA(NELS), QB(NELS),
& RIGHT, SFLAG, VL(NELS)
CHARACTER*24 FILENAME
CHARACTER*60 FINALS(NELS), STRL, STRR
INTEGER ICTOI, LVAL
DOUBLE PRECISION S, SUMQ
CHARACTER*72 TEMP
EXTERNAL CONFIG, COUPLD, DECOMP, DEL, HELP, ICTOI, INPUT, LVAL,
& PRINT_COUPLINGS, REPLAC, STRSH, VPAIR
!
!
!**************
! Declaration of variable for the input data
!
! HEADER = header of output
! SHELLS = Closed Shells
! REF = Reference set
! ACT = Active Set
! REPL = Replacement
! VIRTUL = Virtual Set
! FTM = Final Term (NELS)
!
FILENAME = 'cfg.inp'
!**************
! Obtain ASCII value for the bound of character and digit
!
ORDLA = ICHAR('a')
ORDLZ = ICHAR('z')
ORDUA = ICHAR('A')
ORDUZ = ICHAR('Z')
ORD0 = ICHAR('0')
ORD9 = ICHAR('9')
NQ = 0
IFLAG = 0
SFLAG = 0
DFLAG = 0
!***************
! Disply for the beginning of the program
!
WRITE (0,*)
WRITE (0,*)
WRITE (0,*)
&' -----------------------------------------------------------'
WRITE (0,*)
WRITE (0,*) ' You are under the program GENCL'
WRITE (0,*) ' which GENerates a Configuration List'
WRITE (0,*)
WRITE (0,*)
WRITE (0,*)
&' Type H (Help) to obtain information about the input format '
WRITE (0,*)
WRITE (0,*) ' Type <RETURN> if you already know '
WRITE (0,*)
WRITE (0,*)
& ' --------------------------------------------------------'
WRITE (0,*)
!**************
! If the user needs to obtain information about input format,
! call subroutine HELP .
!
READ (5,'(A)') STRL
I = INDEX(STRL,'H')
J = INDEX(STRL,'h')
IF ( I.NE.0 .OR. J.NE.0 ) CALL HELP
!**********************************************************************
! READ AND ANALYSIS THE INPUT DATA
!
!
! Input Header
!
100 WRITE (0,99001)
99001 FORMAT (T13,'Header ? ')
READ (5,'(A)') HEADER
CH1 = CH3(2:2) ! CHECK THIS! IS CH3 DEFINED?
!
!**************
! Input Closed Shell, check if it satisfies the FORMAT(18(1X,A3))
!
200 WRITE (0,99002)
99002 FORMAT (' Closed Shells ? ')
READ (5,'(A)') TEMP
I = INDEX(TEMP,'B')
J = INDEX(TEMP,'b')
IF ( I.NE.0 .OR. J.NE.0 ) GO TO 100
N = 2
SHELLS = ' '
300 IF ( INDEX(TEMP,' ').GT.2 ) THEN
CALL DEL(TEMP)
J = ICHAR(TEMP(1:1))
IF ( J.LT.ORD0 .OR. J.GT.ORD9 ) THEN
WRITE (0,*) ' INPUT ERROR !'
GO TO 200
END IF
SHELLS(N:N+2) = TEMP(:3)
N = N + 4
CALL STRSH(TEMP,4)
GO TO 300
END IF
!**************
! Input Reference Set, and check the input error
!
! LEFT = position of the first '(' in the string
! RIGHT = position of the first ')' in the string
! SUMQ = total number of Q(i) for each configuration
! NL = Total quantum number for each reference set
! CONST = Total number of Qi for the first reference set
! PARITYVAL = Parity for the first reference set
!
!
400 WRITE (0,99003)
99003 FORMAT (' Reference Set ? ')
CALL INPUT(NELS,NREF,REF,IFLAG,SFLAG,DFLAG,*200,*400)
DO I = 1, NREF
SUMQ = 0
NL = 0
TEMP = REF(I)
450 IF ( TEMP(1:5).NE.' ' ) THEN
CALL DEL(TEMP)
!
! Error if the input has unmatched parenthesis
!
LEFT = INDEX(TEMP,'(')
RIGHT = INDEX(TEMP(:7),')')
IF ( LEFT.EQ.0 .OR. RIGHT.EQ.0 ) THEN
WRITE (0,*) ' Unmatched parenthesis!',
& ' Please input again .'
GO TO 400
END IF
!
! Error if number of electron is more than FULL
!
CH3 = TEMP(LEFT+1:RIGHT-1)
N = ICTOI(CH3)
L = LVAL(TEMP(2:2))
IF ( N.GT.L*4+2 ) THEN
WRITE (0,*)
& ' Number of electrons in a shell is more than FULL !'
GO TO 400
END IF
SUMQ = SUMQ + N
NL = NL + N*L
CALL STRSH(TEMP,RIGHT+1)
GO TO 450
END IF
!**************
! The first Reference Set is defined as the standard value
!
IF ( I.EQ.1 ) THEN
CONST = INT(SUMQ)
PARITYVAL = MOD(NL,2)
ELSE
!
! Error if members of the reference set have different
! electron numbers or parity
IF ( INT(SUMQ).NE.CONST ) THEN
WRITE (0,*) ' Total number of electrons is wrong!'
GO TO 400
END IF
IF ( MOD(NL,2).NE.PARITYVAL ) THEN
WRITE (0,*) ' Parity is wrong!'
GO TO 400
END IF
END IF
END DO
!******************
! Input Active Set
!
500 WRITE (0,99004)
99004 FORMAT (' Active Set ? ')
READ (5,'(A)') ACT
I = INDEX(ACT,'B')
J = INDEX(ACT,'b')
IF ( I.NE.0 .OR. J.NE.0 ) GO TO 400
IF ( ACT.NE.' ' ) THEN
WRITE (0,99005)
99005 FORMAT ('Type of set generation ?')
READ *, ITYPE
END IF
!*******************
! Input Replacement
!
600 WRITE (0,99006)
99006 FORMAT (' Replacements ? ')
IFLAG = 1
CALL INPUT(NELS,NREPL,REPL,IFLAG,SFLAG,DFLAG,*500,*1000)
!*******************
! If Replacement = S or D or SD, input Virtual Set
!
! ELV = Electron label for virtual set
! MV = Number of electron for Virtual Set
! VL = Parity for each Qi in Virtual Set
!
IF ( SFLAG.EQ.0 .AND. DFLAG.EQ.0 ) GO TO 1000
WRITE (0,99007)
99007 FORMAT (' Virtual Set ? ')
READ (5,'(A)') VIRTUL
TEMP = VIRTUL
J = INDEX(TEMP,' ')
TEMP(J:J) = ','
MV = 0
!
! Decompose the input of Virtual Set
!
700 IF ( TEMP(:5).NE.' ' ) THEN
MV = MV + 1
IF ( MV.GT.(NELS) ) THEN
WRITE (0,*) ' Virtual set too large: MAX=', NELS
STOP
END IF
CALL DEL(TEMP)
J = INDEX(TEMP,',')
VL(MV) = MOD(LVAL(TEMP(2:2)),2)
!
! Convert the input of uppercase to lowercase and assign value
! ELVi
N = ICHAR(TEMP(2:2))
IF ( N.GE.ORDUA .AND. N.LE.ORDUZ ) TEMP(2:2)
& = CHAR(N-ORDUA+ORDLA)
ELV(MV) = TEMP(:J-1)
CALL STRSH(TEMP,J+1)
GO TO 700
END IF
800 WRITE (0,99008)
99008 FORMAT (' From which shell ? ')
READ (5,'(A)') TEMP
I = INDEX(TEMP,'B')
J = INDEX(TEMP,'b')
IF ( I.NE.0 .OR. J.NE.0 ) GO TO 600
CALL DEL(TEMP)
NVIR = ICHAR(TEMP(1:1)) - ORD0
IF ( NVIR.LT.1 .OR. NVIR.GT.9 ) THEN
WRITE (0,*) ' Please input digit for the shell position!'
GO TO 800
END IF
900 WRITE (0,99009)
99009 FORMAT (' To which shell ? ')
READ (5,'(A)') TEMP
I = INDEX(TEMP,'B')
J = INDEX(TEMP,'b')
IF ( I.NE.0 .OR. J.NE.0 ) GO TO 600
CALL DEL(TEMP)
LVIR = ICHAR(TEMP(:1)) - ORD0
IF ( LVIR.LT.0 .OR. LVIR.GT.9 ) THEN
WRITE (0,*) ' Please input digit for the shell position!'
GO TO 900
END IF
!******************
! Input Final Terms
!
! NFTM = Number of input for final term
!
1000 WRITE (0,99010)
99010 FORMAT (' Final Terms ? ')
IFLAG = 0
CALL INPUT(NELS,NFTM,FINALS,IFLAG,SFLAG,DFLAG,*600,*1100)
DO I = 1, NFTM
CH2 = FINALS(I)(:2)
!
! Conver the input of lowercase to uppercase
!
N = ICHAR(CH2(2:2))
IF ( N.GE.ORDLA .AND. N.LE.ORDLZ ) CH2(2:2)
& = CHAR(N-ORDLA+ORDUA)
FTM(I) = CH2
END DO
!**********************************************************************
! Open the file for CI.LST
!
1100 OPEN (7,FILE=FILENAME,STATUS='UNKNOWN')
!**********************************************************************
! PRINT OUT ALL INPUT DATA OF THE USER
!
WRITE (6,99011)
99011 FORMAT (///////T5,'*************** I N P U T',
& ' D A T A **********'///)
WRITE (6,99012) HEADER
99012 FORMAT (T5,' Header : ',A60/)
WRITE (6,99013) SHELLS
99013 FORMAT (T5,' Closed shell : ',A60/)
WRITE (6,99014) REF(1)
99014 FORMAT (T5,' Reference Set : ',A60/)
DO I = 2, NREF
WRITE (6,99033) I, REF(I)
END DO
WRITE (6,99015) ACT
99015 FORMAT (T5,' Active Set : ',A60/)
WRITE (6,99016) REPL(1)
99016 FORMAT (T5,' Replacements : ',A60/)
IF ( SFLAG.NE.0 .OR. DFLAG.NE.0 ) THEN
WRITE (6,99017) VIRTUL
99017 FORMAT (T5,' Virtual Set : ',A72/)
WRITE (6,*) ' From which shell : ',
& CHAR(NVIR+ORD0)
WRITE (6,*)
WRITE (6,*) ' To which shell : ',
& CHAR(LVIR+ORD0)
WRITE (6,*)
END IF
DO I = 2, NREPL
WRITE (6,99033) I, REPL(I)
END DO
WRITE (6,99018) FINALS(1)
99018 FORMAT (T5,' Final Terms : ',A60/)
DO I = 2, NFTM
WRITE (6,99033) I, FINALS(I)
END DO
WRITE (7,99019) HEADER
99019 FORMAT (' ',A60)
WRITE (7,'(1X,A72)') SHELLS
!**********************************************************************
! PROCESS THE REFERENCE SET
!
! M = Maximin number of ELi for reference set
! ELS = Storage of ELi for different Reference Set
! QS = Storage of Qi for each Reference Set
! MS = Storage of M for each Reference Set
! STRL = Temporary string
!
!
DO NF = 1, NREF
M = 0
TEMP = REF(NF)
DO I = 1, NELS
!**************
! Decompose the input for Reference Set
!
IF ( TEMP(:5).EQ.' ' ) THEN
Q(I) = 0
EXIT
END IF
CALL DEL(TEMP)
LEFT = INDEX(TEMP,'(')
RIGHT = INDEX(TEMP,')')
M = M + 1
!**************
! Convert the input of uppercase to lowercase, and assign
! initial values for ELi and Qi
!
CH3 = TEMP(:LEFT-1)
N = ICHAR(CH3(2:2))
IF ( N.GE.ORDUA .AND. N.LE.ORDUZ ) CH3(2:2)
& = CHAR(N-ORDUA+ORDLA)
EL(M) = CH3
CH3 = TEMP(LEFT+1:RIGHT-1)
Q(M) = ICTOI(CH3)
CALL STRSH(TEMP,RIGHT+1)
END DO
DO J = 1, NELS
QS(J,NF) = 0
END DO
!**************
! Add new electrons to the first configuration
!
IF ( NF.EQ.1 ) THEN
DO J = 1, M
ELS(J) = EL(J)
QS(J,NF) = Q(J)
END DO
MS(NF) = M
ELSE
DO J = 1, M
N = MS(1)
DO I = 1, N
IF ( EL(J).EQ.ELS(I) ) THEN
QS(I,NF) = Q(J)
GO TO 1120
END IF
END DO
N = N + 1
IF ( N.GT.NELS ) THEN
WRITE (0,*) ' Too many shells in reference set: MAX=',
& NELS
STOP
END IF
MS(1) = N
ELS(N) = EL(J)
QS(N,NF) = Q(J)
1120 END DO
MS(NF) = N
END IF
!***************
! Generate all couplings for the reference set
! MAX = -5 means the first time to call subroutine COUPLD
!
K = 0
DO I = 1, M
IF ( Q(I).NE.0 ) THEN
K = K + 1
ELB(K) = EL(I)
QB(K) = Q(I)
END IF
END DO
MAXFINAL = -5
CALL COUPLD(ELB,QB,K,ELC,NC,*1700)
IF ( NC.NE.0 ) THEN
WRITE (6,99020)
99020 FORMAT (//
&' GENERATE ALL COUPLINGS FOR EACH MEMBER OF THE REFERENCE SE
&T'//)
CALL PRINT_COUPLINGS(ELC,QB,K,NC,1)
END IF
!**************
! Compute max and min value for the finals.
! Rule : MAXFINAL = 2*|S+L| , MINFINAL = 2*|S-L|
!
IF ( NF.EQ.1 ) THEN
MAXFINAL = 0
MINFINAL = 100
DO I = 1, NC
N = 2*K - 1
READ (FILE3(I),99021) (COUPLE(J),J=1,N)
99021 FORMAT (9(A3))
CH3 = COUPLE(N)(1:1)
CH1 = COUPLE(N)(2:2)
S = (ICTOI(CH3)-1)/2.
L = LVAL(CH1)
LMIN = 2*ABS(S-L)
LMAX = 2*ABS(S+L)
IF ( LMIN.LT.MINFINAL ) MINFINAL = LMIN
IF ( LMAX.GT.MAXFINAL ) MAXFINAL = LMAX
END DO
END IF
END DO
IF ( ACT(:5).EQ.' ' ) GO TO 1500
!**********************************************************************
! PROCESS THE ACTIVE SET
!
! The member of the input is limited to NELS .
!
! NQ = Number of configurations
! ELA = ELi for Active Set
! QA = Qi for Active Set
! MA = Number of ELi for Active Set
! RL = L-value for each shell
! F = Full value for each shell
!
MA = 0
TEMP = ACT
!**************
! Decompose the input of Active Set, Conver the input of uppercase
! to lowercase, assign values to ELA,QA,RL,F .
!
1200 IF ( MA.LT.NELS ) THEN
IF ( TEMP(1:5).EQ.' ' ) GO TO 1300
CALL DEL(TEMP)
MA = MA + 1
N = ICHAR(TEMP(2:2))
IF ( N.GE.ORDUA .AND. N.LE.ORDUZ ) TEMP(2:2)
& = CHAR(N-ORDUA+ORDLA)
ELA(MA) = TEMP(:2)
RL(MA) = LVAL(TEMP(2:2))
IF ( RL(MA).GT.3 ) THEN
F(MA) = 2
ELSE
F(MA) = MIN0(CONST,4*RL(MA)+2)
END IF
CALL STRSH(TEMP,4)
GO TO 1200
ELSE
WRITE (0,*) 'Too many electrons in the active set: MAX= 15'
STOP
END IF
!***************
! NELS is maximun value of active electrons
!
1300 DO I = MA + 1, NELS
F(I) = 0
END DO
!**************
! Generate other possible configurations from the given set
! F(I) is the maximum allowed number of electrons
! H(I) is the number of unassigned electrons or ``holes''
!
1400 IF ( ITYPE.EQ.0 ) THEN
MINQ1 = 0
ELSE IF ( ITYPE.EQ.1 ) THEN
MINQ1 = MAX0(MIN0(F(1),CONST)-1,0)
ELSE IF ( ITYPE.EQ.2 ) THEN
MINQ1 = MAX0(MIN0(F(1),CONST)-2,0)
ELSE IF ( ITYPE.EQ.3 ) THEN
MINQ1 = MAX0(MIN0(F(1),CONST)-3,0)
ELSE
WRITE (0,*) ' Unknown type: Re-enter'
READ *, ITYPE
GO TO 1400
END IF
DO Q1 = MIN0(F(1),CONST), MINQ1, -1
H(1) = MAX0(0,CONST-Q1)
DO Q2 = MIN0(F(2),H(1)), 0, -1
H(2) = MAX0(0,H(1)-Q2)
DO Q3 = MIN0(F(3),H(2)), 0, -1
H(3) = MAX0(0,H(2)-Q3)
DO Q4 = MIN0(F(4),H(3)), 0, -1
H(4) = MAX0(0,H(3)-Q4)
DO Q5 = MIN0(F(5),H(4)), 0, -1
H(5) = MAX0(0,H(4)-Q5)
DO Q6 = MIN0(F(6),H(5)), 0, -1
H(6) = MAX0(0,H(5)-Q6)
DO Q7 = MIN0(F(7),H(6)), 0, -1
H(7) = MAX0(0,H(6)-Q7)
DO Q8 = MIN0(F(8),H(7)), 0, -1
H(8) = MAX0(0,H(7)-Q8)
DO Q9 = MIN0(F(9),H(8)), 0, -1
H(9) = MAX0(0,H(8)-Q9)
DO Q10 = MIN0(F(10),H(9)), 0, -1
H(10) = MAX0(0,H(9)-Q10)
DO Q11 = MIN0(F(11),H(10)), 0, -1
H(11) = MAX0(0,H(10)-Q11)
DO Q12 = MIN0(F(12),H(11)), 0, -1
H(12) = MAX0(0,H(11)-Q12)
DO Q13 = MIN0(F(13),H(12)), 0,
& -1
H(13) = MAX0(0,H(12)-Q13)
DO Q14 = MIN0(F(14),H(13)), 0,
& -1
H(14) = MAX0(0,H(13)-Q14)
IF ( H(14).LE.F(15) ) THEN
Q15 = H(14)
CALL CONFIG
END IF
END DO
END DO
END DO
END DO
END DO
END DO
END DO
END DO
END DO
END DO
END DO
END DO
END DO
END DO
!**************
! Print Header of the output file
!
IF ( NQ.EQ.0 ) GO TO 1500
WRITE (6,99022)
99022 FORMAT (//
&' GENERATE ALL POSSIBLE CONFIGURATIONS FROM THE ACTIVE SET'
&//)
J = INDEX(HEADER,' ')
WRITE (6,99023) HEADER(1:J)
99023 FORMAT (' '/T10,'------------- ',A,' --------'/)
WRITE (6,99024) SHELLS
99024 FORMAT (' Closed Shells : ',A60/)
WRITE (6,99025) ACT
99025 FORMAT (' Active Set : ',A60/)
!**************
! Print all configurations generated from Active Set
!
WRITE (6,*) ' Configurations :'
DO I = 1, NQ
READ (FILE1(I),99034) (QA(J),J=1,MA)
IF ( ELA(1)(1:1).EQ.' ' ) THEN
N = 27
ELSE
N = 28
END IF
K = 0
DO J = 1, MA
IF ( QA(J).NE.0 .OR. MA.EQ.2 ) THEN
K = K + 1
ELB(K) = ELA(J)
QB(K) = QA(J)
END IF
END DO
WRITE (6,99026) (ELB(J),QB(J),J=1,K)
99026 FORMAT (T28,8(1X,A3,'(',I2,')'))
END DO
!***************
! For each new configuration, generate all possible couplings
!
N1 = 0
N2 = 0
DO I = 1, NQ
READ (FILE1(I),99034) (QA(J),J=1,MA)
!**************
! Omit ELA(i) if corresponding QA(i)=0
!
K = 0
DO J = 1, MA
IF ( QA(J).NE.0 .OR. MA.EQ.2 ) THEN
K = K + 1
ELB(K) = ELA(J)
QB(K) = QA(J)
END IF
END DO
!***************
! Omit configurations which have more than 8 shells
!
IF ( K.LE.8 ) THEN
CALL COUPLD(ELB,QB,K,ELC,NC,*1700)
IF ( NC.GT.0 ) THEN
WRITE (6,99027)
99027 FORMAT (//' LIST THE COUPLINGS FOR EACH',
& ' CONFIGURATION GENERATED BY THE ACTIVE SET'//)
CALL PRINT_COUPLINGS(ELC,QB,K,NC,2)
ELSE
N2 = N2 + 1
END IF
ELSE
N1 = N1 + 1
END IF
END DO
IF ( N1.NE.0 ) PRINT 99028, N1
99028 FORMAT (T5,'Too many occuplied shells --- ',I3,
& ' configuration omitted!')
IF ( N2.NE.0 ) PRINT 99029, N2
99029 FORMAT (T5,'No final term as your selection for ',I3,
& ' Active set!')
IF ( NREPL.EQ.0 ) GO TO 1700
!**********************************************************************
! PROCESS THE REPACEMENTS
!
! STRL : String of the left side of '='
! STRR = String of the right side of '='
!
1500 IF ( SFLAG.NE.0 .OR. DFLAG.NE.0 ) GO TO 1600
N1 = 0
DO NR = 1, NREPL
STRR = REPL(NR)
J = INDEX(STRR,'=')
STRL = STRR(1:J-1)
CALL STRSH(STRR,J+1)
!**************
! Decompose the substring on the left of ''=''
!
! ELL = Old value of ELi to be replaced
! QL = Old value of Qi to be replaced
! ML = Number of Old value of ELi to be replaced
!
CALL DEL(STRL)
CALL DECOMP(STRL,ELL,QL,ML)
!**************
! Decompose the substring on the right of ''=''
!
! ELR = New value of ELi
! QR = New vaRue of Qi
! MR = Number of the new value of ELi
!
CALL DEL(STRR)
CALL DECOMP(STRR,ELR,QR,MR)
!**************
! For each Replacement, replace all Reference Sets
!
DO NF = 1, NREF
M = MS(NF)
IF ( M.LT.ML ) CYCLE
DO I = 1, M
EL(I) = ELS(I)
Q(I) = QS(I,NF)
END DO
CALL REPLAC(ELB,QB,K,*1550)
CALL COUPLD(ELB,QB,K,ELC,NC,*1700)
IF ( NC.GT.0 ) THEN
WRITE (6,99030)
99030 FORMAT (//' FOR EACH REPLACEMENT, GENERATE',
& ' CONFIGURATIONS AND COUPLINGS FOR THE REFERENCE SET'
& //)
CALL PRINT_COUPLINGS(ELC,QB,K,NC,3)
ELSE
N1 = N1 + 1
END IF
1550 END DO
END DO
IF ( N1.NE.0 ) WRITE (0,99031) N1
99031 FORMAT (T5,'No Final Term as selected for ',I3,' Replacements!')
GO TO 1700
!**********************************************************************
! PROCESS THE VIRTUAL SET
!
! RL = Parity of ELi of Reference Set
! VL = Parity of ELi of Virtual Set
!
!
1600 DO NF = 1, NREF
!**************
! Set the initial values of Reference Set
!
M = MS(NF)
DO I = 1, NELS
CH3 = ELS(I)
EL(I) = CH3
ELB(I) = CH3
Q(I) = QS(I,NF)
QB(I) = Q(I)
RL(I) = MOD(LVAL(CH3(2:2)),2)
END DO
IF ( SFLAG.EQ.0 .AND. DFLAG.NE.0 ) GO TO 1650
!**************
! Preparation for the Single Replacement
!
QL(1) = 1
ML = 1
QR(1) = 1
MR = 1
DO I = NVIR, LVIR
IF ( Q(I).EQ.0 ) CYCLE
ELL(1) = EL(I)
IF ( RL(I).GT.0 ) THEN
N = 1
ELSE
N = 0
END IF
DO J = 1, MV
!**************
! Replace Qi of Reference Set which has the same parity
! with Qj of Virtual Set
!
IF ( VL(J).EQ.N ) THEN
ELR(1) = ELV(J)
CALL REPLAC(ELB,QB,K,*1620)
CALL COUPLD(ELB,QB,K,ELC,NC,*1700)
IF ( NC.GT.0 ) THEN
WRITE (6,99032)
99032 FORMAT (//' FOR VIRTUAL SET, ',
& 'GENERATE CONFIGURATION AND COUPLINGS FOR S-REPLACEMENT'
& //)
NR = NELS
TEMP = ELL(1)//' = '//ELR(1)
CALL DEL(TEMP)
REPL(NR) = TEMP
CALL PRINT_COUPLINGS(ELC,QB,K,NC,4)
END IF
END IF
1620 END DO
END DO
!*************
! Rreplace pairs of Q(i) and Q(j) by Double Virtual Set
!
! PL = Pairty for the pair Qi and Qj in Reference Set
!
1650 IF ( DFLAG.EQ.0 ) EXIT
ML = 2
QL(1) = 1
QL(2) = 1
DO I = NVIR, LVIR - 1
ELL(1) = EL(I)
LL1 = LVAL(ELL(1)(2:2))
DO J = I + 1, M
IF ( Q(I).EQ.0 .OR. Q(J).EQ.0 ) CYCLE
ELL(2) = EL(J)
LL2 = LVAL(ELL(2)(2:2))
TEMP = ELL(1)//'.'//ELL(2)//' = '
LLMIN = IABS(LL1-LL2)
LLMAX = LL1 + LL2
PL = MOD(LLMAX,2)
CALL VPAIR(ELV,MV,PL,LLMIN,LLMAX,TEMP,*1700)
END DO
END DO
!**************
! Replace pairs of (Qi)=2 by Double Virtual Set
!
ML = 1
QL(1) = 2
DO I = NVIR, LVIR
IF ( Q(I).GT.1 ) THEN
ELL(1) = EL(I)
LL1 = LVAL(ELL(1)(2:2))
LLMIN = 0
LLMAX = LL1 + LL1
TEMP = ELL(1)//'(2) = '
PL = MOD(LLMAX,2)
CALL VPAIR(ELV,MV,PL,LLMIN,LLMAX,TEMP,*1700)
END IF
END DO
END DO
!**********************************************************************
! THE END OF THE PROGRAM
!
1700 WRITE (7,'(A1)') '*'
CLOSE (7)
WRITE (0,*)
WRITE (0,*) ' OK !'
WRITE (0,*) ' List of configurations and their couplings'
WRITE (0,*) ' is in the file ', FILENAME
99033 FORMAT (T29,I2,' : ',A60/)
99034 FORMAT (21(I2))
END PROGRAM GENCLF
!
!
! S U B R O U T I N E S
! =====================
!
!
! ----------------------------------------------------------------------
! SUBROUTINE C O N F I G
! ----------------------------------------------------------------------
!
! Examine if the new configuration has the same
! electron number and parity .
!
SUBROUTINE CONFIG
IMPLICIT NONE
!
! PARAMETER definitions
!
INTEGER NELS, NCFG, NSCOUP
PARAMETER (NELS=21,NCFG=10000,NSCOUP=10000)
!
! COMMON variables
!
INTEGER CONST, M, MA, MAXFINAL, MINFINAL, ML, MR, MS(NELS), NF,
& NFTM, NQ, NR, NREF, PARITYVAL, Q(NELS), Q1, Q10, Q11, Q12,
& Q13, Q14, Q15, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA(NELS),
& QL(NELS), QR(NELS), QS(NELS,NELS), RL(NELS)
CHARACTER*3 EL(NELS), ELA(NELS), ELL(NELS), ELR(NELS), ELS(NELS)
CHARACTER*8 FBETA(7,NSCOUP)
CHARACTER*32 FILE1(NCFG), FILE3(NSCOUP)
CHARACTER*40 FILE2(NCFG)
COMMON NF, NR, NFTM, MAXFINAL, MINFINAL, PARITYVAL, CONST, NQ
COMMON /BLK3 / EL, ELL, ELR, ELS, ELA
COMMON /BLK4 / Q, QL, ML, QR, MR, M, QS, MS, MA, RL, NREF, Q1,
& Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12,
& Q13, Q14, Q15
COMMON /FILES / FBETA, FILE1, FILE2, FILE3
!
! Local variables
!
CHARACTER*3 CH3
INTEGER I, IQ, J, K, N, NEWP
!
!
EQUIVALENCE (Q1,QA(1))
EQUIVALENCE (Q2,QA(2))
EQUIVALENCE (Q3,QA(3))
EQUIVALENCE (Q4,QA(4))
EQUIVALENCE (Q5,QA(5))
EQUIVALENCE (Q6,QA(6))
EQUIVALENCE (Q7,QA(7))
EQUIVALENCE (Q8,QA(8))
EQUIVALENCE (Q9,QA(9))
EQUIVALENCE (Q10,QA(10))
EQUIVALENCE (Q11,QA(11))
EQUIVALENCE (Q12,QA(12))
EQUIVALENCE (Q13,QA(13))
EQUIVALENCE (Q14,QA(14))
EQUIVALENCE (Q15,QA(15))