-
Notifications
You must be signed in to change notification settings - Fork 0
/
BMATIN6.FORT10
1950 lines (1950 loc) · 65 KB
/
BMATIN6.FORT10
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
C BMATIN6 FINAL MODIFIED VERSION OF PULAY'S BMATIN PROGRAM
C***********************************************************************
C NOTICE OF PROGRAM MODIFICATION *
C***********************************************************************
c Moved to PSI distribution disk on 020389 - clj.
C***********************************************************************
C BY: TPH *
C DATE: DECEMBER 12, 1988 *
C REASON: CORRECT PROBLEM IN DISPLACEMENTS FOR TORSIONS. *
C***********************************************************************
C BY: TPH *
C DATE: SEPT 9, 1988 *
C REASON: CHANGE SCALING OF DISPLACEMENT TO HALVE 5 TIMES. DISP=TRUE *
C***********************************************************************
C BY: TPH *
C DATE: JUNE 13,1988 *
C REASON: PUT IN INVERSE BOND LENGTH AS A COORDINATE - INVR *
C***********************************************************************
C BY: TPH *
C DATE: JUNE 3,1988 *
C REASON: CHANGE SO THAT DUMMY ATOMS CAN BE USED FOR LINEAR BEND *
C DISPLACEMENTS. THE PROGRAM ZOOMS THE DUMMY ATOMS TO A *
C DISTANCE OF 1 BILLION SO THAT LIN1 AND LIN2 ARE EQUIVALENT *
C FOR LINEAR MOLECULES. *
C ALSO SCALE DISPLACEMENT ONCE IN GEOMETRY OPTIMIZATIONS *
C***********************************************************************
C BY: TPH *
C DATE: APRIL 25, 1988 *
C REASON: CHANGE SOME OF THE DEFAULTS. NO LONGER HAVE OLDF, OLDH, *
C AND EXFI. THE PROGRAM WILL READ THEM AND NOT CRASH. *
C NOUP AND NOEX MUST BE SPECIFIED TO SUPRESS HESSIAN UPDATE *
C AND READING IN FROM INP2, WHICH ARE NOW DEFAULT. *
C MURT MUST BE USED TO NOT HAVE POWELL OR BFGS UPDATES *
C***********************************************************************
C BY: TPH *
C DATE: APRIL 23, 1988 *
C REASON: CHANGE MACHB TO USE INTERNAL COORDINATES SPECIFICATION *
C THE SAME AS IN INTDER. (BEND,OUT,LIN1,LIN2) *
C***********************************************************************
C BY: TPH *
C DATE: FEBRUARY 26, 1988 *
C REASON: PUT PARTS BRIAN YATES CHANGED IN HIS VERSION, *
C KEEPING JON BAKER'S OPTEFC NEARLY THE SAME AS IN *
C GAUSSIAN82, AND USING AN INTERFACE CALLED EFC. *
C***********************************************************************
C BY: TPH *
C DATE: FEBRUARY 8, 1988 *
C REASON: PUT COMMENTS IN PROGRAM FIFTH, RENUMBER *
C INDICATING WHERE CHANGES IN THE NEAR FUTURE WILL BE MADE *
C***********************************************************************
C BY: TPH *
C DATE: OCTOBER 26, 1987 *
C REASON: PUT IN EIGENVECTOR FOLLOWING ROUTINE OF JON BAKER, *
C POWELL UPDATE OF THE HESSIAN, AND DIIS FOR GEOMETRY OPT. *
C BESSLER PREVIOUSLY PUT IN BFGS AND DAVIDON-FLETCHER-POWELL *
C UPDATES. FILE INP4 HAS INTERNAL FORCES PREVIOUS STEPS. *
C FILE INP3 HAS THE EIGENVECTOR FROM PREVIOUS STEP IN OPTEFC.*
C***********************************************************************
C***********************************************************************
C FUTURE NEEDS FOR BMAT: TAKE CARE OF DISCONTINUITY IN ANGULAR *
C COORDINATES (FOR NOW CHANGING ANGLE DEFINITIONS MAY HELP), *
C FIX GDIIS, PRINT RMS GRADIENT, *
C AUTOMATIC ROTATION SO THAT ONE COORDINATE IS AT ORIGIN *
C OR SYMMETRY PLANE PRESERVED ETC., *
C CALCULATION OF # OF TOTALLY SYMMETRIC MODES FOR WARNINGS *
C STEP LENGTH CONTROL FOR REGULAR BMAT *
C***********************************************************************
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER AI*80,WKEY1*4,WKEY2*4
INTEGER INP,IOUT,INP2,IPUN,IGMUP
COMMON /IOP/ IOP(50)
COMMON /GANZ/ NA,LOPT(26)
PARAMETER(INP=30,IOUT=31,INP2=32,IPUN=33,IGMUP=5)
PARAMETER(WKEY1='BMAT',WKEY2='STOP')
C....................................................................
C THIS IS WRITTEN SO THAT SEVERAL BMAT SECTIONS IN THE BMAT .
C INPUT FILE CAN BE RUN, SHOULD THE NEED ARISE .
C....................................................................
CALL NOUNFL
10 READ (INP,50) AI
IF (AI(1:4).NE.WKEY1) GO TO 40
WRITE(IOUT,60)
WRITE(IOUT,70) AI
DO 20 I=1,50
IOP(I)=0
20 CONTINUE
DO 30 I=1,26
LOPT(I)=0
30 CONTINUE
CALL FIFTH (INP,IOUT,INP2,IPUN,IGMUP)
GO TO 10
40 CONTINUE
50 FORMAT (A80)
60 FORMAT (9(8H********))
70 FORMAT (//,1X,A80)
END
C //////////////////////////////////////////////////////////
SUBROUTINE FIFTH(INP,IOUT,INP2,IPUN,IGMUP)
IMPLICIT REAL*8 (A-H,O-Z)
INTEGER INP,IOUT,INP2,IPUN,IGMUP
INTEGER P,Q,NR
CHARACTER WO*4,WK(26)*4,W1*2
INTEGER INDI(4,50),INDT(4)
LOGICAL WRIT,IFSTRE(50),SFIRST,DISP
REAL*8 NV,N2V,N3V
DIMENSION CCIN(4,50),CIN(4),CCC(75),ETA(4),ENERGY(4)
DIMENSION CI(9),AE(3),DUMX(10),DUMY(10),DUMZ(10)
DIMENSION SYMB(25)
DIMENSION LFLAG(4)
DIMENSION QQQ(69),FII(69)
DIMENSION WW(2)
DIMENSION L(69),M(69), KI(75), IA(25)
DIMENSION IFIX(20),IBOHR(40)
COMMON/MODOUT/VMODE(50)
COMMON /ENER/ TITLE(16)
COMMON /GANZ/ NA,LOPT(26)
COMMON /IO/ IIN,IIOUT,IINP2,IIPUN,IIGMUP
COMMON /IOP/ IOP(50)
COMMON/DISCON/SSS(100),SFIRST
COMMON /BMAT/ BL(1),C(4761),F(75),FI(69),CC(75)
&,XA(25),YA(25),ZA(25)
&,XM(75),XY(75),QQ1(75),QQ(69),B(75,69)
&,NV(75),HE(69,69),HN(69,69)
&,N2V(69),DV(69),N3V(69),GRC(69),GEC(69),A(4761),QD(69,69)
&,FD(69,69)
EQUIVALENCE (B(1,1),WW(1))
PARAMETER(ZERO=0.0D0,HALF=0.5D0,ONE=1.0D0,TWO=2.0D0)
PARAMETER(THREE=3.0D0,FOUR=4.0D0,FIVE=5.0D0,TEN=10.0D0)
PARAMETER(ANG=1.889726664D0,GDYN=8.2388575D0)
PARAMETER(FSUMT=1.0D-7,CRTTOL=1.0D-12,MXITER=40)
PARAMETER(RADC=57.29577951308D0)
DATA (WK(I),I=1,6)/'CARD','FMAT','DISP','OLDF','PUNC','PRIN'/
DATA (WK(I),I=7,12)/'ANGS','FIXC','FINT','FLT1','EXFI','BOHR'/
DATA (WK(I),I=13,18)/'FLT2','GDYN','OLDH','DEGR','DFLP','BFGS'/
DATA (WK(I),I=19,23)/'POWL','EIGF','DIIS','MODE','DUMB'/
DATA (WK(I),I=24,26)/'NOUP','NOEX','MURT'/
DATA XNIST/2HN=/
REWIND INP2
SFIRST=.TRUE.
DISP=.TRUE.
IIN=INP
IIOUT=IOUT
IINP2=INP2
IIPUN=IPUN
IIGMUP=IGMUP
IOP(5)=1
IX=INP
ISCALE=0
NDUM=0
NMAX=25
NCMAX=3*NMAX
NQMAX=NCMAX-6
LFLAG(1)=0
NFIX=0
C
C DIMENSION OF THE B MATRIX MUST CONFORM TO B(NCMAX,NQMAX)
C.................................................................
C READ IN INPUT OPTIONS .
C.................................................................
10 READ(INP,2000) WO,NR
DO 20 I=1,26
IF (WK(I).EQ.WO) GO TO 30
20 CONTINUE
BACKSPACE INP
GO TO 40
30 LOPT(I)=1
IF(I.EQ.1) NA=NR
IF (I.EQ.3) LOPT(3)=NR
IF (I.EQ.3.AND.LOPT(3).EQ.0) LOPT(3)=1
IF(I.EQ.8) THEN
NFIX=NFIX+1
IFIX(NFIX)=NR
END IF
IF(I.EQ.10) THEN
BACKSPACE INP
READ(INP,2020) WO,ETA(1),ETA(2),ETA(3),ETA(4)
WRITE(IOUT,2025) WO,ETA(1),ETA(2),ETA(3),ETA(4)
GO TO 10
END IF
IF(I.EQ.13) THEN
BACKSPACE INP
READ(INP,2030) WO,(ETA(K),ENERGY(K),K=1,3)
WRITE(IOUT,2035) WO,(ETA(K),ENERGY(K),K=1,3)
LOPT(10)=1
GO TO 10
END IF
IF(I.EQ.20) THEN
BACKSPACE INP
READ(INP,2040) WO,IOP(5),IOP(7),IOP(8),IOP(13),IOP(16),
& IOP(17),IOP(19),IOP(33),IOP(34)
WRITE(IOUT,2045) WO,IOP(5),IOP(7),IOP(8),IOP(13),IOP(16),
& IOP(17),IOP(19),IOP(33),IOP(34)
GO TO 10
END IF
IF(I.EQ.22) THEN
BACKSPACE INP
READ(INP,2050) WO,MODE1,MODE2
WRITE(IOUT,2055) WO,MODE1,MODE2
GO TO 10
END IF
IF(I.EQ.23) THEN
BACKSPACE INP
NDUM=NDUM+1
READ(INP,2060) WO,DUMX(NDUM),DUMY(NDUM),DUMZ(NDUM)
WRITE(IOUT,2065) WO,DUMX(NDUM),DUMY(NDUM),DUMZ(NDUM)
GO TO 10
END IF
WRITE(IOUT,2010) WO,NR
GO TO 10
C..................................................................
C CHECK THE NUMBER OF ITERATIONS .
C..................................................................
40 CONTINUE
READ(INP2,2070) NGEO,NUMIT
C..................................................................
C SET THE DEFAULTS HERE .
C..................................................................
IF(LOPT(3).GT.0.OR.LOPT(10).GT.0.OR.LOPT(13).GT.0) DISP=.FALSE.
IF(LOPT(10).GT.0) THEN
LOPT(15)=1
IF(LOPT(24).NE.0) LOPT(15)=0
ELSE
LOPT(4)=1
IF(LOPT(24).NE.0) LOPT(4)=0
ENDIF
IF(LOPT(25).GT.0) THEN
LOPT(11)=0
ELSE
LOPT(11)=1
ENDIF
IF(LOPT(17).EQ.0.AND.LOPT(18).EQ.0.AND.LOPT(19).EQ.0.AND.
& LOPT(26).EQ.0) THEN
IF(IOP(5).EQ.1) LOPT(18)=1
IF(IOP(5).EQ.0) LOPT(19)=1
ENDIF
C WRITE(IOUT,1234) (LOPT(I),I=1,26)
C1234 FORMAT(26I3)
C..................................................................
C TURN OFF HESSIAN UPDATING IN OPTEFC UNLESS BFGS WITH .
C POSITIVE DEFINITENESS IS GUARANTEED. .
C..................................................................
IF(LOPT(18).EQ.1 .AND. IOP(13).EQ.2) THEN
LOPT(24) = 1
ELSE
IOP(13) = -1
ENDIF
IF(LOPT(11).EQ.0.OR.NUMIT.LT.1) GO TO 60
C..................................................................
C CHECK THE NUMBER OF ATOMS IN INP2 IS EQUAL NA (EXFI OPTION) .
C..................................................................
DO 50 I=1,NA
READ(INP2,2080) W1
IF(W1.NE.'N=') THEN
WRITE(IOUT,2090) W1
RETURN
END IF
50 CONTINUE
60 CONTINUE
C..................................................................
C CHECK THAT NA IS NOT LARGER THAN NMAX .
C..................................................................
IF (NA.GT.0.AND.NA.LE.NMAX) GO TO 70
WRITE (IOUT,2100) NA
RETURN
70 CONTINUE
CTPH N=NA
IF (LOPT(1).NE.1) THEN
WRITE(IOUT,2105)
STOP
ENDIF
C..................................................................
C READ GEOMETRY IN FROM BMAT FILE .
C..................................................................
WRITE( IOUT,2110)
DO 90 I=1,NA
I3=3*I
READ(INP,2120) SYMB(I),IA(I),XA(I),YA(I),ZA(I),XM(I3)
C..................................................................
C DEFAULT MASS IS ONE .
C..................................................................
IF (XM(I3).EQ.ZERO) XM(I3)=ONE
IF (LOPT(7).EQ.1) GO TO 80
C..................................................................
C CONVERT BOHR TO ANGSTROMS .
C..................................................................
XA(I)=XA(I)/ANG
YA(I)=YA(I)/ANG
ZA(I)=ZA(I)/ANG
80 CONTINUE
C..................................................................
C CONVERT ANGSTROMS TO BOHR FOR PRINTING .
C..................................................................
XXWA=XA(I)*ANG
YYWA=YA(I)*ANG
ZZWA=ZA(I)*ANG
WRITE(IOUT,2130) I,IA(I),XXWA,YYWA,ZZWA,XM(I3)
C..................................................................
C PUT INVERSE MASS IN XM .
C..................................................................
XM(I3)=ONE/XM(I3)
XM(I3-1)=XM(I3)
XM(I3-2)=XM(I3)
90 CONTINUE
C..................................................................
NEK=3*NA
IF (LOPT(3).GT.0) GO TO 130
IF (LOPT(9).GT.0) GO TO 190
C..................................................................
C READ FORCES IN FROM BMAT FILE .
C..................................................................
READ (INP,2140) (F(I),I=1,NEK)
IF(LOPT(14).EQ.1) GO TO 110
C..................................................................
C CONVERT GRADIENTS IN ATOMIC UNITS TO FORCES IN MDYN .
C..................................................................
DO 100 I=1,NEK
F(I)=-F(I)*GDYN
100 CONTINUE
110 CONTINUE
WRITE(IOUT,2150)
WRITE(IOUT,2160) (F(I),I=1,NEK)
C..................................................................
C CHECK THAT FORCES ADD TO ZERO .
C..................................................................
XFQX=F(1)
DO 120 I=2,NEK
120 XFQX=XFQX+F(I)
IF(DABS(XFQX).GT.FSUMT) WRITE (IOUT,2170) XFQX
IF(LOPT(3).LE.0) GO TO 190
C..................................................................
C READ IN DISPLACEMENTS .
C..................................................................
130 CONTINUE
NDI=LOPT(3)
DO 140 I=1,NDI
140 READ (INP,2180) (INDI(J,I),CCIN(J,I),J=1,4)
IF(LOPT(12).NE.1) GO TO 190
C..................................................................
C CHANGE DISPLACEMENTS TO BOHR INSTEAD OF ANGSTROMS .
C..................................................................
NBOHR=0
IQ=0
KB=0
150 KB=KB+1
READ(INP,2190) WO,W1
IF(WO(1:1).NE.'K'.AND.WO.NE.' ') GO TO 160
IF(WO(1:1).EQ.'K')THEN
IQ=IQ+1
IF(W1.EQ.'ST')THEN
NBOHR=NBOHR+1
IBOHR(NBOHR)=IQ
END IF
END IF
GO TO 150
160 DO 170 I=1,KB
170 BACKSPACE INP
DO 180 K=1,NBOHR
DO 180 I=1,NDI
DO 180 J=1,4
IF(INDI(J,I).EQ.IBOHR(K))THEN
CCIN(J,I)=CCIN(J,I)/ANG
ELSE IF (LOPT(16).EQ.1) THEN
CCIN(J,I)=CCIN(J,I)/RADC
END IF
180 CONTINUE
C....................................................................
C PUT DUMMY ATOM COORDINATES IN XA,YA,ZA (NOT COMPLETELY TESTED).
C....................................................................
190 CONTINUE
NADT=NA
IF (LOPT(3) .NE. 0) THEN
NADT=NADT+NDUM
BILION = 1000000000.0D0
IF(NADT.GT.NMAX) STOP 'NA+NDUM GREATER THAN NMAX'
DO 200 I=1,NDUM
DUNORM = DSQRT(DUMX(I)**2 + DUMY(I)**2 + DUMZ(I)**2)
XA(NA+I)=DUMX(I)*BILION/DUNORM
YA(NA+I)=DUMY(I)*BILION/DUNORM
ZA(NA+I)=DUMZ(I)*BILION/DUNORM
NEK = NEK+3
200 CONTINUE
ENDIF
WRIT=.FALSE.
IF (LOPT(6).EQ.1) WRIT=.TRUE.
C....................................................................
C CHECK THE TYPE OF INTERNAL COORDINATE FOR OPTEFC CONVERSION .
C OF ANGSTROMS TO BOHRS .
C....................................................................
IQ=0
KB=0
205 KB=KB+1
READ(INP,2190) WO,W1
IF(WO(1:1).NE.'K' .AND. WO.NE.' ') GO TO 206
IF(WO(1:1).EQ.'K') THEN
IQ=IQ+1
IFSTRE(IQ) = W1.EQ.'ST'
ENDIF
GO TO 205
206 CONTINUE
DO 207 I=1,KB
BACKSPACE INP
207 CONTINUE
C....................................................................
C MAKE B MATRIX .
C....................................................................
CALL MACHB (NEK,B,NCMAX,NQMAX,XA,YA,ZA,QQ,NADT,IX,IOUT,NQ,WRIT,
1.FALSE.,NCARD)
IF(LOPT(5).EQ.0) GO TO 220
C....................................................................
C PUNCH B MATRIX .
C....................................................................
WRITE(IPUN,2200)
WRITE (IPUN,2210)
DO 210 I=1,NQ
WRITE (IPUN,2220) I
WRITE (IPUN,2230) (B(J,I),J=1,NEK)
210 CONTINUE
220 CONTINUE
C....................................................................
C INVERT B*M*B+ (SEE PULAY'S ARTICLE IN VOL 4, P 166) .
C....................................................................
I1=0
DO 240 I=1,NQ
DO 240 J=1,NQ
I1=I1+1
S=ZERO
DO 230 K=1,NEK
230 S=S+B(K,I)*B(K,J)*XM(K)
240 C(I1)=S
TOL=1.0D-8
CALL OSINV1 (C,NQ,D,TOL,L,M)
C....................................................................
WRITE (IOUT,2240) D
IF (LOPT(3).GT.0) GO TO 1150
C....................................................................
C FORM B*M*F .
C....................................................................
WRITE( IOUT,2250)
DO 260 I=1,NQ
T=ZERO
DO 250 J=1,NEK
250 T=T+B(J,I)*F(J)*XM(J)
260 CC(I)=T
C....................................................................
C FORM (B*M*B+)-1 * B*M*F = INTERNAL FORCES .
C....................................................................
IJ=0
DO 300 I=1,NQ
T=ZERO
IF(LOPT(9).GT.0) GO TO 280
DO 270 J=1,NQ
IJ=IJ+1
270 T=T+C(IJ)*CC(J)
FI(I)=T
280 IF(LOPT(9).LE.0) GO TO 290
C....................................................................
C READ IN INTERNAL FORCES INSTEAD .
C....................................................................
READ(INP,2140) FI(I)
NCARD=NCARD+1
290 CONTINUE
C....................................................................
C WRITE OUT COORDINATE NUMBER, INTERNAL COORDINATE AND FORCE .
C....................................................................
WRITE (IOUT,2260) I,QQ(I),FI(I)
QQQ(I)=QQ(I)
FII(I)=FI(I)
300 CONTINUE
C....................................................................
C PUNCH INTERNAL FORCES .
C....................................................................
WRITE(IPUN,2270) (FI(I),I=1,NQ)
IF(LOPT(10).GE.1.AND.LOPT(13).LT.1) WRITE(IOUT,2280)
IF(LOPT(13).GE.1) WRITE(IOUT,2290)
IF (LOPT(2).LT.1) GO TO 1530
C....................................................................
C READ INTERNAL FORCE CONSTANT MATRIX FROM BMAT FILE OR INP2 .
C....................................................................
IF(LOPT(10).GE.1) THEN
WRITE(IOUT,2300)
ELSE
WRITE(IOUT,2310)
END IF
IF(LOPT(11).GT.0.AND.NUMIT.GT.0) IX=INP2
DO 320 I=1,NQ
READ(IX,2270)(F(J),J=1,I)
WRITE (IOUT,2320) (F(J),J=1,I)
IF (LOPT(11).GT.0.AND.NUMIT.GT.0) GO TO 310
C....................................................................
C NCARD KEEPS TRACK OF HOW MANY CARDS IT TAKES IN BMAT FILE .
C TO READ IN THE FORCE CONSTANT MATRIX, FOR LATER USE .
C....................................................................
NCARD=NCARD+1+(I-1)/8
310 CONTINUE
C....................................................................
C PUT FORCE CONSTANT IN SQUARE MATRIX C, TAKE THE INVERSE .
C....................................................................
DO 320 J=1,I
IJ=(I-1)*NQ+J
JI=(J-1)*NQ+I
C(JI)=F(J)
C(IJ)=C(JI)
320 CONTINUE
IX=INP
CALL OSINV1 (C,NQ,D,1.0D-8,L,M)
IF(NUMIT.LT.1) GO TO 870
C....................................................................
C READ IN OLD INTERNAL COORDINATES, FORCES, AND DISPLACEMENTS .
C FROM INP2 OR INP .
CTPH INP2 SHOULD HAVE THIS WHETHER EXFI IS USED OR NOT .
C....................................................................
IF(LOPT(11).GT.0) IX=INP2
DO 340 I=1,NQ
READ(IX,2340) CC(I),F(I),GEC(I)
IF(LOPT(11).GT.0.AND.NUMIT.GT.0) GO TO 330
NCARD=NCARD+1
330 CONTINUE
340 CONTINUE
MODE= 0
IF(NUMIT.GT.0.AND.LOPT(11).GT.0) READ(INP2,2620) MODE
IX=INP
IF (LOPT(4).LT.1.AND.LOPT(15).LT.1) GO TO 870
C....................................................................
C UPDATE THE HESSIAN UNLESS IT IS THE FIRST OPTIMIZATION CYCLE .
C ALL UPDATES ARE THE POWELL UPDATE THE INVERSE HESSIAN .
C....................................................................
WRITE(IOUT,2330)
CTPH IF(LOPT(11).GT.0) IX=INP2
DO 345 I=1,NQ
WRITE (IOUT,2260) I,CC(I),F(I)
345 CONTINUE
CTPH IX=INP
C..................................................................
IF(LOPT(15).GE.1) GO TO 820
IF(LOPT(17) .EQ. 1) GOTO 420
IF(LOPT(18) .EQ. 1) GOTO 520
IF(LOPT(19) .EQ. 1) GOTO 620
C....................................................................
C MURTAGH-SARGENT UPDATE .
C....................................................................
WRITE(IOUT,2350)
DO 350 I=1,NQ
GRC(I)=-FI(I)+F(I)
350 CONTINUE
C 350 GEC(I)=QQ(I)-CC(I)
IJ=0
DO 360 I=1,NQ
DO 360 J=1,NQ
IJ=IJ+1
360 HE(I,J)=C(IJ)
DO 370 I=1,NQ
NV(I)=0.D0
DO 370 J=1,NQ
370 NV(I)=NV(I)+HE(I,J)*GRC(J)
DO 380 I=1,NQ
380 NV(I)=GEC(I)-NV(I)
DN=0.D0
DO 390 I=1,NQ
390 DN=DN+NV(I)*GRC(I)
DO 400 I=1,NQ
DO 400 J=1,NQ
400 HE(I,J)=HE(I,J)+NV(I)*NV(J)/DN
IJ=0
DO 410 I=1,NQ
DO 410 J=1,NQ
IJ=IJ+1
410 C(IJ)=HE(J,I)
GOTO 820
420 CONTINUE
C....................................................................
C DAVIDON-FLETCHER-POWELL (DFP) UPDATE .
C....................................................................
WRITE(IOUT,2360)
DO 430 I=1,NQ
GRC(I)=-FI(I)+F(I)
430 CONTINUE
C 430 GEC(I)=QQ(I)-CC(I)
IJ=0
DO 440 I=1,NQ
DO 440 J=1,NQ
IJ=IJ+1
440 HE(I,J)=C(IJ)
DN=0.D0
DO 450 I=1,NQ
450 DN=DN+GEC(I)*GRC(I)
DO 460 I=1,NQ
DO 460 J=1,NQ
460 HN(I,J)=GEC(I)*GEC(J)/DN
DO 470 I=1,NQ
DV(I)=0.D0
DO 470 J=1,NQ
470 DV(I)=DV(I)+HE(I,J)*GRC(J)
DN=0.D0
DO 480 I=1,NQ
480 DN=DN+GRC(I)*DV(I)
DO 490 I=1,NQ
N2V(I)=0.D0
DO 490 J=1,NQ
490 N2V(I)=N2V(I)+GRC(I)*HE(I,J)
DO 500 I=1,NQ
DO 500 J=1,NQ
500 HE(I,J)=HE(I,J)+HN(I,J)-DV(I)*N2V(J)/DN
IJ=0
DO 510 I=1,NQ
DO 510 J=1,NQ
IJ=IJ+1
510 C(IJ)=HE(I,J)
GOTO 820
520 CONTINUE
C....................................................................
C BFGS UPDATE .
C....................................................................
WRITE(IOUT,2370)
DO 530 I=1,NQ
GRC(I)=-FI(I)+F(I)
530 CONTINUE
C 530 GEC(I)=QQ(I)-CC(I)
IJ=0
DO 540 I=1,NQ
DO 540 J=1,NQ
IJ=IJ+1
540 HE(I,J)=C(IJ)
DN=0.D0
DO 550 I=1,NQ
550 DN=DN+GEC(I)*GRC(I)
DO 560 I=1,NQ
NV(I)=0.D0
DO 560 J=1,NQ
560 NV(I)=NV(I)+GRC(J)*HE(I,J)
SU=0.D0
DO 570 I=1,NQ
570 SU=SU+NV(I)*GRC(I)
SU=1.D0+SU/DN
DO 580 I=1,NQ
DO 580 J=1,NQ
580 HN(I,J)=HN(I,J)+SU/DN*GEC(I)*GEC(J)
DO 590 I=1,NQ
N2V(I)=0.D0
DO 590 J=1,NQ
590 N2V(I)=N2V(I)+GRC(J)*HE(I,J)
DO 600 I=1,NQ
DO 600 J=1,NQ
600 HE(I,J)=HE(I,J)+HN(I,J)-GEC(I)*N2V(J)/DN-NV(I)*GEC(J)/DN
IJ=0
DO 610 I=1,NQ
DO 610 J=1,NQ
IJ=IJ+1
610 C(IJ)=HE(I,J)
GO TO 820
620 CONTINUE
C......................................................................
C POWELL UPDATE (SYMMETRIC BROYDEN) .
C INVERT C TO REGAIN THE HESSIAN, UPDATE, THEN RESTORE THE INVERSE.
C......................................................................
CALL OSINV1 (C,NQ,D,1.0D-8,L,M)
WRITE(IOUT,2380)
IJ=0
DO 630 I=1,NQ
DO 630 J=1,NQ
IJ=IJ+1
630 HE(I,J)=C(IJ)
CTPH DO 640 I=1,NQ
CTPH GEC(I)=QQ(I)-CC(I)
C 640 CONTINUE
DO 660 I=1,NQ
N2V(I)=0.0D0
DO 650 J=1,NQ
N2V(I)=N2V(I)+HE(I,J)*GEC(J)
650 CONTINUE
GRC(I)=-FI(I)+F(I)-N2V(I)
660 CONTINUE
DN=0.D0
DO 670 I=1,NQ
670 DN=DN+GEC(I)*GEC(I)
SU=0.D0
DO 680 I=1,NQ
680 SU=SU+GEC(I)*GRC(I)
SU=SU/DN
DABSSU=DABS(SU)
C....................................................................
C YOU MAY NOT WANT TO DO THE UPDATE IF THE DISPLACEMENT IS SMALL.
C....................................................................
CTPH IF(DN.LT.0.000001D0) GO TO 700
DO 690 I=1,NQ
DO 690 J=1,I
TEMP=GEC(I)*GRC(J)+GEC(J)*GRC(I)-GEC(I)*SU*GEC(J)
HE(I,J)=HE(I,J)+TEMP/DN
HE(J,I)=HE(I,J)
690 CONTINUE
700 CONTINUE
IJ=0
DO 710 I=1,NQ
DO 710 J=1,NQ
IJ=IJ+1
710 C(IJ)=HE(I,J)
CALL OSINV1 (C,NQ,D,1.0E-8,L,M)
C....................................................................
C THE OPTIMALLY CONDITIONED UPDATE SHOULD GO HERE .
C....................................................................
820 IF(LOPT(4).GE.1) GO TO 870
C....................................................................
C UPDATE THE FLETCHER POWELL FORCE CONSTANTS .
C....................................................................
IJ=0
DO 840 I=1,NQ
S=ZERO
DO 830 J=1,NQ
IJ=IJ+1
830 S=S-C(IJ)*F(J)
840 CCC(I)=S
S=ZERO
S1=ZERO
DO 850 I=1,NQ
S=S-CC(I)*F(I)
850 S1=S1+CCC(I)*F(I)
IJ=0
DO 860 I=1,NQ
DO 860 J=1,NQ
IJ=IJ+1
860 C(IJ)=C(IJ)+CC(I)*CC(J)/S+CCC(I)*CCC(J)/S1
870 CONTINUE
C....................................................................
C CALCULATE THE NEW COORDINATES IN ONE OF THREE WAYS: .
C (A) EIGENVECTOR FOLLOWING (B) DIIS (C) NEWTON-RAPHSON .
C....................................................................
IF(LOPT(20).GE.1) THEN
C....................................................................
C (A) EIGENVECTOR FOLLOWING, EFC IS AN INTERFACE BETWEEN .
C BMATIN6 AND OPTEFC WRITTEN BY BRIAN YATES .
C THE HESSIAN IS NEEDED INSTEAD OF ITS INVERSE .
C....................................................................
CTPH MODE = 0
IF(LOPT(22).EQ.1 .AND. NUMIT.LT.1) THEN
IF(MODE1.EQ.1) MODE = MODE2
IF(MODE1.EQ.0) MODE = MODE2 + NQ
ENDIF
CALL OSINV1 (C,NQ,D,1.0D-8,L,M)
CALL EFC(NUMIT,NQ,F,QQ,FI,C,MODE,QQ1,IFSTRE,GEC)
CALL OSINV1 (C,NQ,D,1.0D-8,L,M)
ELSE
IF(LOPT(21).GT.0) NGEO=NGEO+1
IF(NGEO.GT.1.AND.LOPT(21).GT.0) THEN
C....................................................................
C (B) DIIS WITH THE POSSIBILITY OF UPDATING THE HESSIAN; THEREFORE .
C THE ERROR VECTORS MUST BE RECALCULATED FROM THE PREVIOUS AND .
C PRESENT GRADIENTS, USING THE NEW HESSIAN E = (H)-1*G .
C....................................................................
C....................................................................
C READ IN PAST COORDINATES AND GRADIENTS INTO QD AND FD .
C....................................................................
IF(NGEO.GE.NQ) NGEO = NQ-1
DO 880 J=1,NGEO-1
DO 880 I=1,NQ
READ(INP2,2390) QD(I,J),FD(I,J)
880 CONTINUE
M1=NGEO+1
MM1=NQ
MNQ=NMAX
DO 890 I=1,NQ
FD(I,NGEO)=FI(I)
QD(I,NGEO)=QQ(I)
890 CONTINUE
CALL GDIIS(MM1,NQMAX,M1,NQ,QD,FD,C,A,NV,N2V,QQ,FI,DV,XLAM,IER)
CTPH.................................................................
C EXTRAPOLATED COORDINATES AND FORCES IN QQ AND FI, THEN RELAX .
C PRINTING OF DIIS MATRIX FOR DEBUGGING, TO BE CHANGED LATER .
CTPH.................................................................
WRITE(IOUT,2401)
2401 FORMAT('INVERSE HESSIAN')
DO 901 I=1,NQ
J1=(I-1)*NQ+1
JN=(I-1)*NQ+I
WRITE(IOUT,2270) (C(J), J=J1,JN)
901 CONTINUE
WRITE(IOUT,2400)
DO 900 I=1,M1
J1=(I-1)*M1+1
JN=(I-1)*M1+I
WRITE(IOUT,2270) (A(J), J=J1,JN)
900 CONTINUE
IF (IER.EQ.0) GO TO 910
CTPH.................................................................
C ERROR SECTION, TO BE CHANGED LATER TO STOP PROGRAM .
CTPH.................................................................
WRITE(IOUT,2405)
RETURN
910 CONTINUE
C....................................................................
C PUT INTERNAL DISPLACEMENTS AND OLD INT. COORDINATES IN QQ1, QQ.
C....................................................................
CC DO 930 I=1,NQ
CC QQ1(I)=QQ(I)-QD(I,NGEO)
CC QQ(I)=QD(I,NGEO)
CC930 CONTINUE
WRITE(IOUT,2320) (QQ(I),I=1,NQ)
WRITE(IOUT,2320) (FI(I),I=1,NQ)
WRITE(IOUT,2410) (DV(I),I=1,NGEO)
WRITE(IOUT,2420) XLAM
ENDIF
C....................................................................
C (C) NEWTON RAPHSON STEP WHICH IS THE DEFAULT .
C....................................................................
IJ=0
DO 950 I=1,NQ
S=ZERO
DO 940 J=1,NQ
IJ=IJ+1
S=S+C(IJ)*FI(J)
940 CONTINUE
QQ1(I)=S
950 CONTINUE
ENDIF
C....................................................................
C CALCULATE FLAMBDA FOR FLETCHER PROCEDURE, PRINT NEW INTERNAL .
C COORDINATES AND DISPLACEMENTS, PUT DISPLACEMENTS IN GEC FOR .
C WRITING TO RESUL2 LATER .
C....................................................................
IF(LOPT(10).GE.1) THEN
WRITE(IOUT,2430)
ELSE
WRITE(IOUT,2440)
END IF
FLAMDA=0.0D0
DO 960 I=1,NQ
FLAMDA=FLAMDA+QQ1(I)*FII(I)
IF(NGEO.GT.1.AND.LOPT(21).GT.0) QQ1(I)=QQ(I)+QQ1(I)-QD(I,NGEO)
GEC(I)=QQ1(I)
CC(I)=GEC(I)
960 CONTINUE
C....................................................................
C SET CERTAIN DISPLACEMENTS TO ZERO (FIXC OPTION) .
C....................................................................
IF(NFIX.GT.0) THEN
DO 970 I=1,NFIX
CC(IFIX(I))=ZERO
QQ1(IFIX(I))=ZERO
GEC(IFIX(I))=ZERO
970 CONTINUE
ENDIF
DO 975 I=1,NQ
WRITE (IOUT,2260) I,QQ1(I),QQ(I)+QQ1(I)
975 CONTINUE
C....................................................................
C REGAIN THE HESSIAN FROM THE INVERSE .
C....................................................................
980 CALL OSINV1 (C,NQ,D,1.0E-8,L,M)
IF(LOPT(4).GT.0.OR.LOPT(15).GT.0) GO TO 1010
C....................................................................
C CHECK THE FORCE CONSTANTS TO SEE WHICH FORMAT TO USE, PRINT .
C IN FILE INP2 .
C....................................................................
REWIND INP2
JTRI=NQ*(NQ+1)/2
IBIG=0
DO 990 J=1,JTRI
IF(C(J).LE.-10.0D0.OR.C(J).GE.100.0D0) IBIG=1
990 CONTINUE
IJ=1
DO 1000 I=1,NQ
IJ1=IJ+I-1
IF(IBIG.EQ.1) THEN
WRITE(INP2,2320)(C(J),J=IJ,IJ1)
ELSE
WRITE(INP2,2450)(C(J),J=IJ,IJ1)
WRITE(IOUT,2450)(C(J),J=IJ,IJ1)
ENDIF
IJ=IJ+NQ
1000 CONTINUE
C....................................................................
IF(LOPT(10).GT.0) GO TO 1040
IF(LOPT(4).LT.1) GO TO 1210
C....................................................................
C CHECK THE FORCE CONSTANTS TO SEE WHICH FORMAT TO USE, PRINT .
C IN FILE IPUN,IOUT,INP2 .
C....................................................................
1010 IF(NUMIT.GT.0) WRITE(IOUT,2460)
REWIND INP2
JTRI=NQ*(NQ+1)/2
IBIG=0
DO 1020 J=1,JTRI
IF(C(J).LE.-10.0D0.OR.C(J).GE.100.0D0) IBIG=1
1020 CONTINUE
IJ=1
IF(LOPT(5).NE.0) WRITE(IPUN,2310)
DO 1030 I=1,NQ
IJ1=IJ+I-1
IF(IBIG.EQ.1) THEN
IF(NUMIT.GE.1.AND.LOPT(24).EQ.0) WRITE(IOUT,2320) (C(J),J=IJ,IJ1)
WRITE(INP2,2320)(C(J),J=IJ,IJ1)
IF (LOPT(5).GT.0) WRITE(IPUN,2320) (C(J),J=IJ,IJ1)
ELSE
IF(NUMIT.GE.1.AND.LOPT(24).EQ.0) WRITE(IOUT,2450) (C(J),J=IJ,IJ1)
WRITE(INP2,2450)(C(J),J=IJ,IJ1)
IF (LOPT(5).GT.0) WRITE(IPUN,2450) (C(J),J=IJ,IJ1)
ENDIF
IJ=IJ+NQ
1030 CONTINUE
IF(LOPT(4).GE.1) GO TO 1210
C....................................................................
C FIRST PART OF THE FLETCHER POWELL PROCEDURE (FLT1) .
C....................................................................
1040 DO 1050 I=1,NQ
1050 CCC(I)=QQ1(I)
IF(LOPT(13).EQ.1) GO TO 1080
IFLT=1
C....................................................................
C CHECK TO SEE IF LAST STEP ALONG FLETCHER-POWELL VECTOR IS MADE.
C....................................................................
1060 IF(ETA(IFLT).EQ.ZERO) GO TO 1450
DO 1070 I=1,NQ
QQ(I)=QQQ(I)
QQ1(I)=ETA(IFLT)*CCC(I)
1070 CC(I)=QQ1(I)
WRITE(IOUT,2470) ETA(IFLT)
GO TO 1210
C....................................................................
C SECOND PART OF THE FLETCHER POWELL PROCEDURE (FLT2) .
C....................................................................
1080 IJ=1
IF(ENERGY(3).GE.0.0D0) GO TO 1120
DO 1090 I=1,3
CI(IJ)=1
CI(IJ+1)=ETA(I)
CI(IJ+2)=ETA(I)**2
1090 IJ=IJ+3
CALL OSINV1(CI,3,D,1.0E-8,L,M)
IJ=0
DO 1110 I=1,3
S=ZERO
DO 1100 J=1,3
IJ=IJ+1
1100 S=S+CI(IJ)*ENERGY(J)
1110 AE(I)=S
ETA(4)=-AE(2)/(TWO*AE(3))
ENERGY(4)=ETA(4)*(ETA(4)*AE(3)+AE(2)) +AE(1)
GO TO 1130
1120 WRITE(IOUT,*) 'FLAMDA=',FLAMDA
FLAMDA=FLAMDA*ANG/GDYN
ELAMDA=(ENERGY(1)-ENERGY(2))/ETA(1)+FLAMDA
ETA(4)=FLAMDA*ETA(1)/(2.0D0*ELAMDA)
ENERGY(4)=ENERGY(2)-FLAMDA*ETA(4)/2.0D0
1130 IFLT=4
DO 1140 I=1,NQ
QQ(I)=QQQ(I)
QQ1(I)=ETA(IFLT)*CCC(I)
1140 CC(I)=QQ1(I)
WRITE(IOUT,2480) ENERGY(4)
WRITE(IOUT,2490) ETA(4)
GO TO 1210
1150 CONTINUE
C....................................................................
C WRITE OUT ORIGINAL INTERNAL COORDINATES, DISPLACEMENTS .
C FOR ONE DISTORTED GEOMETRY AT A TIME (DISP OPTION) .
C THE PROGRAM LOOPS BACK TO 1160 UNTIL II = # DISPLACEMENTS .
C....................................................................
WRITE(IOUT,2500)
WRITE(IOUT,2510) (QQ(J),J=1,NQ)
II=0
1160 II=II+1
DO 1170 J=1,4
INDT(J)=INDI(J,II)
1170 CIN(J)=CCIN(J,II)
WRITE(IOUT,2200)
WRITE(IOUT,2520) (INDT(J),CIN(J),J=1,4)
DO 1180 J=1,NQ
CC(J)=ZERO
1180 CONTINUE
DO 1190 J=1,4
J1=INDT(J)
IF (J1.LE.0) GO TO 1190
CC(J1) = CIN(J)
1190 CONTINUE
DO 1200 J=1,NQ
1200 QQ1(J)=CC(J)
GO TO 1250
C....................................................................
C MAKE B MATRIX, THEN (B*M*B+)-1 IN C .
C....................................................................
1210 DO 1220 I=1,NCARD
BACKSPACE INP
1220 CONTINUE
CALL MACHB(NEK,B,NCMAX,NQMAX,XA,YA,ZA,QQ,NADT,IX,IOUT,NQ,.FALSE.,
1 .FALSE.,NCARD)
I1=0
DO 1240 I=1,NQ
DO 1240 J=1,NQ
I1=I1+1
S=ZERO
DO 1230 K=1,NEK
1230 S=S+B(K,I)*B(K,J)*XM(K)
1240 C(I1)=S
CALL OSINV1(C,NQ,D,TOL,L,M)
1250 CONTINUE
C....................................................................
C NOW TRANSFORM THE INTERNAL DISPLACEMENTS TO CARTESIAN .
C DISPLACEMENTS BY DELTA X = (B*M*B+)-1 * B*M * (DELTA Q) .
C THIS IS THE SAME TRANSFORMATION USED TO CONVERT CARTESIAN .
C FORCES TO INTERNAL FORCES, AND CAN BE USED BECAUSE THE .
C DERIVATIVE WITH RESPECT TO A COORDINATE AND A COORDINATE ARE .
C CONTRAVARIANT .