-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpmz_rev1.f
More file actions
1689 lines (1613 loc) · 48.3 KB
/
Copy pathpmz_rev1.f
File metadata and controls
1689 lines (1613 loc) · 48.3 KB
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
#define TR(arg) trim(adjustl(arg))
program pmz
implicit none
integer*4 MENDELEV
parameter (MENDELEV=89)
character*80 s80,ts,sdalbas
character*20 s20
character*1 sgn,axis
character*20 i2str,coord
logical lex,lcp2k,lcastep,qdim,ldalton,lvstep,lschk,only_double,
1 no_zero,nochk
real*8,allocatable:: r(:,:),s(:,:),w(:),steps(:)
real*8 step,x,y,z,dx,dy,step1,step2,
1dz,drmax,wcm,ucm,dd1,dd2,xf,yf,zf,o11i,o12i,o13i,o22i,
2o23i,o33i,dist,dd,dqs
integer*4,allocatable::ig(:),iqlist(:),nl(:)
integer*4 i,j,nat,idiff,ic,ix,ist,io,
1ii,im,ndiff,nm,nmd,jm,jx,jst,nparallel,npart,iparallel,is,ie,
1ip1,ia1,ia2,nn,ico1,ico2,ip2,iy,istart,jb1,jb2,
1ndiff1,ndiff2,ib,jb,jo,fistart,n,io_start,at
double precision, parameter :: cm_2_au=4.556431403d-6
double precision, parameter :: amu_2_au=1822.89d0
double precision, parameter :: amu_2_kg=1.6605402E-27
double precision, parameter :: ang_2_au=1.8897259886d0
double precision, parameter :: c_au=1.37036d2
double precision, parameter :: hbar=1.054571628d-34
double precision, parameter :: c=299792458
double precision, parameter :: pi=4.0d0*atan(1.0d0)
CHARACTER*2 sy(MENDELEV)
data sy/' H','He','Li','Be',' B',' C',' N',' O',' F','Ne',
3'Na','Mg','Al','Si',' P',' S','Cl','Ar',
4' K','Ca','Sc','Ti',' V','Cr','Mn','Fe','Co','Ni','Cu','Zn',
4 'Ga','Ge','As','Se','Br','Kr',
5'Rb','Sr',' Y','Zr','Nb','Mo','Tc','Ru','Rh','Pd','Ag','Cd',
5 'In','Sn','Sb','Te',' I','Xe',
6'Cs','Ba','La',
6 'Ce','Pr','Nd','Pm','Sm','Eu','Gd','Tb','Dy','Ho',
6 'Er','Tm','Yb','Lu',
6'Hf','Ta',' W','Re','Os','Ir','Pt','Au','Hg',
6 'Tl','Pb','Bi','Po','At','Rn',
7'Fr','Ra','Ac'/
character*7 round(2)
character*1 r3(3)
character*10 s10
character*1 xyz(3)
character*4 key,k2,tsn
data round/ 'forward',' back'/
data r3/'-',' ','+'/
data xyz/'x','y','z'/
character*80 tso
write(6,6000)
6000 format(' Preparation of inputs using coordinate differentiations'
1 ,/,/, ' Input: FILE.X - geometry',/,
2 ' G.TXT - gaussian input head',/,
3 ' CM.TXT - charge, multiplicity',/,
4 ' AFTER.TXT - after coordinate options',/,
5 ' CP2K.TXT - CP2K input head',/,/,
4 ' CP2KAFTER.TXT - after coordinate options',/,
6 ' Output: FILE.INP - Gaussian Input',/,
7 ' (CP2K directory for CP2K)',/)
c
open(7,file='FILE.X')
read(7,80)s80
80 format(a80)
read(7,*)nat
n=3*nat
allocate(r(3,nat),s(n,n),w(n),steps(n),ig(nat),iqlist(n),nl(n))
do 1 i=1,nat
1 read(7,*)ig(i),(r(j,i),j=1,3)
close(7)
write(6,*)nat,' atoms'
inquire(file='CP2K.TXT',exist=lcp2k)
if(lcp2k)CALL system('mkdir CP2K')
inquire(file='CASTEP.TXT',exist=lcastep)
if(lcastep)then
CALL system('mkdir CASTEP')
call setcage(o11i,o12i,o13i,o22i,o23i,o33i)
endif
inquire(file='PMZ.PAR',exist=lex)
lvstep=.false.
c separate (differently-named) checkpoint files:
lschk=.false.
nochk=.false.
step=0.05d0
qdim=.false.
dist=0.0d0
idiff=2
ic=0
nparallel=0
nmd=0
ldalton=.false.
only_double=.false.
sdalbas='cc-pVDZ'
if(lex)then
open(7,file='PMZ.PAR')
72 read(7,700)key
700 format(a4)
if(key.eq.'NO00')read(7,*)no_zero
if(key.eq.'STEP')read(7,*)step
if(key.eq.'QDIM')read(7,*)qdim
if(key.eq.'PARA')read(7,*)nparallel
if(key.eq.'DONL')read(7,*)only_double !Do only double steps d/dq_i^2, no cross terms like d/dq_i.dq_j
if(key.eq.'DIST')read(7,*)dist
if(key.eq.'IDIF')read(7,*)idiff
if(key.eq.'DALB')read(7,*)sdalbas
if(key.eq.'DALT')read(7,*)ldalton
if(key.eq.'VSTE')read(7,*)lvstep
if(key.eq.'LSCH')read(7,*)lschk
if(key.eq.'NOCH')read(7,*)nochk
if(key(1:2).eq.'IC')read(7,*)ic
if(key(1:3).eq.'NMD')then
read(7,*)nmd
do 4 i=1,nmd
4 read(7,*)iqlist(i)
endif
if(key(1:3).eq.'END')goto 71
backspace 7
read(7,700)k2
if(k2.eq.key)then
write(6,700)k2
call report('unknown option')
endif
goto 72
71 close(7)
else
c 'Step (A) and degree (1,2,3) of the differentiation:
step=0.05d0
idiff=2
c 'cartesian or normal mode (0,1):'
ic=0
endif
if(no_zero)then
io_start=1
else
io_start=0
end if
c idiff = 1 one-step diff
c 2 two-step diff (forward and back)
c 3 one-step in two coordinates
c 4 two-steps in two coordinates
c 5 <not used>
c 6 each atom two-step in x,y and z
c 8 two-step, ordered by coordinate (x1+,x1-,y1+,y1-, etc)
c in relaxed normal modes
c 88 as 8, for two coordinates
c 22 two-step, ordered by coordinate (x1+,x1-,y1+,y1-, etc)
c 44 two-step, two coordinate, ordered by coordinate
c (x+y+,x+y-,x-y+,x-y-,...), DIST keyword applied
c 100 each atom coordinate/mode differentiated N-times,
c N is defined in file N.LST, single differentiation
c 200 each atom coordinate/mode differentiated N-times,
c N is defined in file N.LST, double differentiation
c
c QDIM - use the dimensionless normal mode coordinates
c
c VSTEP-variable step for each mode read as third column in N.LST,
c for idif ? 100.
c
if(ldalton)CALL system('mkdir DALTON')
if(ic.eq.1)then
write(6,*)'Normal mode differentiation'
call loads(s,nat,w,nm)
if(nmd.eq.0)then
nmd=nm
do 5 i=1,nm
5 iqlist(i)=i
endif
write(6,*)nmd,' modes to differentiate'
do 6 i=1,nmd
6 write(6,600)i,iqlist(i),w(iqlist(i))
600 format(i4,i4,f8.1,' cm-1')
else
write(6,*)'Cartesian mode differentiation'
endif
c 0000000000000000000000000000000000000000000000000000000
if(idiff.eq.0)then
io=0
open(8,file='FILE.INP')
call wgtxt(lschk,io)
if(lcp2k)then
write(ts,500)io
istart=fistart(ts)
CALL system('mkdir CP2K/'//ts(istart:len(ts)))
open(88,file='CP2K/'//ts(istart:len(ts))//'/c.inp')
open(89,file='CP2K/'//ts(istart:len(ts))//'/t.inp')
call wgtxt2
endif
write(ts,500)io
istart=fistart(ts)
if(lcastep)then
CALL system('mkdir CASTEP/'//ts(istart:len(ts)))
open(98,file='CASTEP/'//ts(istart:len(ts))//'/c.cell')
open(99,file='CASTEP/'//ts(istart:len(ts))//'/t.inp')
call wgtxt3
endif
if(ldalton)then
open(79,file='DALTON/'//ts(istart:len(ts))//'.INP')
write(79,791)
791 format('BASIS')
write(79,7911)(sdalbas(ii:ii),ii=fistart(sdalbas),len(sdalbas))
7911 format(80a1)
endif
write(8,*)
write(8,80)s80
write(6,3003)
write(8,3003)
if(lcp2k)write(89,3003)
if(lcastep)write(99,3003)
if(ldalton)then
write(79,3003)
write(79,3003)
write(tsn,'(i4)')nat
tso='AtomTypes='
1//tsn(fistart(tsn):len(tsn))//' Angstroms Nosymmetry'
write(79,7911)(tso(ii:ii),ii=fistart(tso),len(tso))
endif
write(8,*)
call wcmtxt
do 13333 ii=1,nat
x=r(1,ii)
y=r(2,ii)
z=r(3,ii)
if(lcp2k)write(88,8011)sy(ig(ii)),x,y,z
if(lcastep)then
xf=x*o11i+y*o12i+z*o13i
yf= y*o22i+z*o23i
zf= z*o33i
write(98,8012)sy(ig(ii)),xf,yf,zf
endif
if(ldalton)then
if(ig(ii).lt.10)then
write(79,3019)real(ig(ii)),ig(ii),x,y,z
3019 format('Charge=',f3.1,' Atoms=1',/,i1,3f12.6)
else
write(79,3020)real(ig(ii)),ig(ii),x,y,z
3020 format('Charge=',f4.1,' Atoms=1',/,i2,3f12.6)
endif
endif
13333 write(8,801)ig(ii),x,y,z
call wafter
write(8,*)
if(lcastep)then
call wafter3
close(98)
close(99)
endif
if(lcp2k)then
call wafter2
close(88)
close(89)
endif
if(ldalton)close(79)
close(8)
write(6,*)1,' structure'
stop
endif
c 00000000000000000000000000000000000000000000000000000000000
c 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2
if(idiff.eq.1.or.idiff.eq.2)then
ist=1
i=1
ix=0
im=0
if(ic.eq.1)then
ndiff=nmd*idiff
else
ndiff=n*idiff
endif
do 2 io=0,ndiff
if(io==0)then
s20='equilibrium geometry'
else
if(io>ndiff/2)then
sgn='-'
else
sgn='+'
end if
if(ic==0)then
if(io>ndiff/2)then
at=(io-ndiff/2-1)/3+1
else
at=(io-1)/3+1
end if
s20=i2str(at)
if(mod(io,3)==1)then
axis='x'
else if(mod(io,3)==2)then
axis='y'
else
axis='z'
end if
write(coord,'(a1,a,a1,a1)')'r',TR(s20),axis,sgn
else
write(coord,'(a1,a,a1)')'q',TR(s20),sgn
end if
s20=coord
end if
if(no_zero.and.io==0)cycle
if(io.gt.0)then
if(ic.eq.0)then
ix=ix+1
if(ix.gt.3)then
ix=1
i=i+1
if(i.gt.nat)then
i=1
ist=ist+1
endif
endif
else
im=im+1
if(im.gt.nmd)then
ist=ist+1
im=1
endif
endif
endif
open(8,file='FILE.INP')
if(io.gt.io_start)write(8,802)
802 format('--link1--')
call wgtxt(lschk,io)
write(ts,500)io
500 format(i80)
istart=fistart(ts)
if(lcp2k)then
CALL system('mkdir CP2K/'//ts(istart:len(ts)))
open(88,file='CP2K/'//ts(istart:len(ts))//'/c.inp')
open(89,file='CP2K/'//ts(istart:len(ts))//'/t.inp')
call wgtxt2
endif
if(lcastep)then
CALL system('mkdir CASTEP/'//ts(istart:len(ts)))
open(98,file='CASTEP/'//ts(istart:len(ts))//'/c.cell')
open(99,file='CASTEP/'//ts(istart:len(ts))//'/t.inp')
call wgtxt3
endif
if(ldalton)then
open(79,file='DALTON/'//ts(istart:len(ts))//'.INP')
write(79,791)
write(79,7911)(sdalbas(ii:ii),ii=fistart(sdalbas),len(sdalbas))
endif
if(io.gt.0 .and. .not. lschk .and. .not. nochk)write(8,803)
803 format('guess=checkpoint')
write(8,*)
if(io>0)write(8,'(a20)')s20
if(io.eq.0)then
write(6,3003)
3003 format('equilibrium geometry')
write(8,3003)
if(lcp2k)write(89,3003)
if(lcastep)write(99,3003)
if(ldalton)then
write(79,3003)
write(79,3003)
write(tsn,'(i4)')nat
tso='AtomTypes='
1//tsn(fistart(tsn):len(tsn))//' Angstroms Nosymmetry'
write(79,7911)(tso(ii:ii),ii=fistart(tso),len(tso))
endif
else
if(ic.eq.0)then
write(6,3004)round(ist),i,ix
3004 format(a7,', atom ',i4,', coord ',i2)
if(lcp2k)write(89,3004)round(ist),i,ix
if(lcastep)write(99,3004)round(ist),i,ix
if(ldalton)then
write(79,3004)round(ist),i,ix
write(79,3004)round(ist),i,ix
write(tsn,'(i4)')nat
tso='AtomTypes='
1//tsn(fistart(tsn):len(tsn))//' Angstroms Nosymmetry'
write(79,7911)(tso(ii:ii),ii=fistart(tso),len(tso))
endif
else
wcm=w(iqlist(im))
write(6,3005)round(ist),im,iqlist(im),wcm
3005 format(a7,', mode ',i4,', (',i3,')',f8.1,' cm-1')
write(8,3005)round(ist),im,iqlist(im),wcm
if(lcp2k)write(89,3005)round(ist),im,iqlist(im),wcm
if(lcastep)write(99,3005)round(ist),im,iqlist(im),wcm
if(ldalton)then
write(79,3005)round(ist),im,iqlist(im),wcm
write(79,3005)round(ist),im,iqlist(im),wcm
write(tsn,'(i4)')nat
tso='AtomTypes='
1//tsn(fistart(tsn):len(tsn))//' Angstroms Nosymmetry'
write(79,7911)(tso(ii:ii),ii=fistart(tso),len(tso))
endif
endif
endif
write(8,*)
call wcmtxt
drmax=0.0d0
do 3 ii=1,nat
x=r(1,ii)
y=r(2,ii)
z=r(3,ii)
if(io.gt.0)then
if(ic.eq.0)then
if(ii.eq.i)then
if(ix.eq.1)x=x+(3.0d0-2.0d0*dble(ist))*step
if(ix.eq.2)y=y+(3.0d0-2.0d0*dble(ist))*step
if(ix.eq.3)z=z+(3.0d0-2.0d0*dble(ist))*step
endif
else
if(qdim)then
C dqs=step*dsqrt(1.0d3/wcm)
c Conversion of s-matrix from amu^-1/2 to au^-1/2, dimensionless normal modes definition in atomic units and then conversion to angstrom
c https://doi.org/10.1021/acs.jctc.3c01223
C dqs=(1d0/sqrt(amu_2_au))*1d0/sqrt(2d0*pi*c_au*wcm*cm_2_au)
C 1 *step/ang_2_au
C dqs=1d0/sqrt(2d0*pi*c_au*wcm*cm_2_au)
C 1 *step/ang_2_au
dqs=sqrt(hbar/(2d0*pi*c*wcm*100))
1 *step/sqrt(amu_2_kg)*1d10
else
dqs=step
endif
dx=s((ii-1)*3+1,iqlist(im))*dqs*(3.0d0-2.0d0*dble(ist))
dy=s((ii-1)*3+2,iqlist(im))*dqs*(3.0d0-2.0d0*dble(ist))
dz=s((ii-1)*3+3,iqlist(im))*dqs*(3.0d0-2.0d0*dble(ist))
x=x+dx
y=y+dy
z=z+dz
if(dabs(dx).gt.drmax)drmax=dabs(dx)
if(dabs(dy).gt.drmax)drmax=dabs(dy)
if(dabs(dz).gt.drmax)drmax=dabs(dz)
endif
endif
if(lcp2k)then
write(88,8011)sy(ig(ii)),x,y,z
8011 format(1x,a2,1x,3f20.10)
endif
if(lcastep)then
xf=x*o11i+y*o12i+z*o13i
yf= y*o22i+z*o23i
zf= z*o33i
write(98,8012)sy(ig(ii)),xf,yf,zf
8012 format(1x,a2,3f21.16)
endif
if(ldalton)write(79,3019)real(ig(ii)),ig(ii),x,y,z
3 write(8,801)ig(ii),x,y,z
if(ic.eq.1)write(6,6003)drmax
6003 format('drmax = ',f12.6,' A')
801 format(i3,3f12.6)
call wafter
write(8,*)
if(lcastep)then
call wafter3
close(98)
close(99)
endif
if(lcp2k)then
call wafter2
close(88)
close(89)
endif
if(ldalton)close(79)
2 continue
close(8)
write(6,*)io,' structures'
stop
endif
c 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2
c 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4
if(idiff.eq.3.or.idiff.eq.4)then
write(6,*)' True double differentiation'
if(ic.eq.1)then
ndiff=((idiff-2) *nmd)**2
else
ndiff=((idiff-2)*n)**2
endif
ist=1
jst=1
i=1
j=1
ix=0
jx=1
im=0
jm=1
do 7 io=0,ndiff
if(no_zero.and.io==0)cycle
if(io.gt.0)then
if(ic.eq.0)then
ix=ix+1
if(ix.gt.3)then
ix=1
i=i+1
if(i.gt.nat)then
i=1
jx=jx+1
if(jx.gt.3)then
jx=1
j=j+1
if(j.gt.nat)then
j=1
ist=ist+1
if(ist.gt.2)then
ist=1
jst=jst+1
endif
endif
endif
endif
endif
else
im=im+1
if(im.gt.nmd)then
im=1
jm=jm+1
if(jm.gt.nmd)then
jm=1
ist=ist+1
if(ist.gt.2)then
ist=1
jst=jst+1
endif
endif
endif
endif
endif
if(only_double.and.im/=jm.and.io.gt.0)cycle
if(only_double .and. ist/=jst)cycle
open(8,file='FILE.INP')
if(io.gt.io_start)write(8,802)
call wgtxt(lschk,io)
if(io.gt.0 .and. .not. nochk)write(8,803)
write(8,*)
write(8,80)s80
if(io.eq.0)then
write(6,3003)
write(8,3003)
else
if(ic.eq.0)then
write(6,3414)round(ist),i,ix,round(jst),j,jx
write(8,3414)round(ist),i,ix,round(jst),j,jx
3414 format(2(a7,', atom',i5,', coord ',i2,1x))
else
wcm=w(iqlist(im))
ucm=w(iqlist(jm))
write(6,3415)round(ist),im,iqlist(im),wcm,round(jst),
1 jm,iqlist(jm),ucm
write(8,3415)round(ist),im,iqlist(im),wcm,round(jst),
1 jm,iqlist(jm),ucm
3415 format(2(a7,', mode ',i4,', (',i3,')',f8.1,' cm-1 '))
endif
endif
write(8,*)
call wcmtxt
drmax=0.0d0
do 8 ii=1,nat
x=r(1,ii)
y=r(2,ii)
z=r(3,ii)
if(io.gt.0)then
if(ic.eq.0)then
if(ii.eq.i)then
if(ix.eq.1)x=x+(3.0d0-2.0d0*dble(ist))*step
if(ix.eq.2)y=y+(3.0d0-2.0d0*dble(ist))*step
if(ix.eq.3)z=z+(3.0d0-2.0d0*dble(ist))*step
endif
if(ii.eq.j)then
if(jx.eq.1)x=x+(3.0d0-2.0d0*dble(jst))*step
if(jx.eq.2)y=y+(3.0d0-2.0d0*dble(jst))*step
if(jx.eq.3)z=z+(3.0d0-2.0d0*dble(jst))*step
endif
else
if(qdim)then
C dqs=step*dsqrt(1.0d3/wcm)
c Conversion of s-matrix from amu^-1/2 to au^-1/2, dimensionless normal modes definition in atomic units and then conversion to angstrom
c https://doi.org/10.1021/acs.jctc.3c01223
C dqs=(1d0/sqrt(amu_2_au))*1d0/sqrt(2d0*pi*c_au*wcm*cm_2_au)
C 1 *step/ang_2_au
dqs=1d0/sqrt(2d0*pi*c_au*wcm*cm_2_au)
1 *step/ang_2_au
else
dqs=step
endif
dx=s((ii-1)*3+1,iqlist(im))*dqs*(3.0d0-2.0d0*dble(ist))
1 +s((ii-1)*3+1,iqlist(jm))*dqs*(3.0d0-2.0d0*dble(jst))
dy=s((ii-1)*3+2,iqlist(im))*dqs*(3.0d0-2.0d0*dble(ist))
1 +s((ii-1)*3+2,iqlist(jm))*dqs*(3.0d0-2.0d0*dble(jst))
dz=s((ii-1)*3+3,iqlist(im))*dqs*(3.0d0-2.0d0*dble(ist))
1 +s((ii-1)*3+3,iqlist(jm))*dqs*(3.0d0-2.0d0*dble(jst))
x=x+dx
y=y+dy
z=z+dz
if(dabs(dx).gt.drmax)drmax=dabs(dx)
if(dabs(dy).gt.drmax)drmax=dabs(dy)
if(dabs(dz).gt.drmax)drmax=dabs(dz)
endif
endif
8 write(8,801)ig(ii),x,y,z
if(ic.eq.1)write(6,6003)drmax
call wafter
write(8,*)
7 continue
close(8)
write(6,*)io,' structures'
stop
endif
c 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4
c 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
if(idiff.eq.6)then
write(6,*)' Two-atom quartic force field'
if(ic.eq.1)call report('Cartesian coordinates allowed only')
ndiff=36*nat
if(nparallel.gt.1)then
npart=ndiff/nparallel
else
npart=ndiff
endif
iparallel=1
if(nparallel.gt.1)then
write(s10,1010)iparallel
1010 format(i10)
do 101 is=1,10
101 if(s10(is:is).ne.' ')goto 102
102 do 103 ie=10,1,-1
103 if(s10(ie:ie).ne.' ')goto 104
104 write(6,*)'FILE.36.'//s10(is:ie)//'.INP opened'
open(8,file='FILE.36.'//s10(is:ie)//'.INP')
else
open(8,file='FILE.36.INP')
endif
c number of atoms
i=1
c coordinate
ix=1
jx=1
c direction:
ist=0
jst=1
do 9 io=0,ndiff
if(io.gt.0)then
if(io.gt.0)then
ist=ist+1
if(ist.gt.2)then
ist=1
jst=jst+1
if(jst.gt.2)then
jst=1
ix=ix+1
if(ix.gt.3)then
ix=1
jx=jx+1
if(jx.gt.3)then
jx=1
i=i+1
endif
endif
endif
endif
endif
endif
if(nparallel.gt.1)then
if(mod(io,npart).eq.0.and.
1 iparallel.lt.nparallel.and.io.gt.0)then
write(6,*)'FILE.36.'//s10(is:ie)//'.INP closed'
close(8)
iparallel=iparallel+1
write(s10,1010)iparallel
do 201 is=1,10
201 if(s10(is:is).ne.' ')goto 202
202 do 203 ie=10,1,-1
203 if(s10(ie:ie).ne.' ')goto 204
204 open(8,file='FILE.36.'//s10(is:ie)//'.INP')
write(6,*)'FILE.36.'//s10(is:ie)//'.INP opened'
call wgtxt(lschk,io)
else
if(io.gt.0)write(8,802)
call wgtxt(lschk,io)
if(io.gt.0 .and. .not. nochk)write(8,803)
endif
else
if(io.gt.0)write(8,802)
call wgtxt(lschk,io)
if(io.gt.0 .and. .not. nochk)write(8,803)
endif
write(8,*)
write(8,80)s80
if(io.eq.0)then
write(6,3003)
write(8,3003)
else
write(6,3016)io,i,xyz(ix),round(ist),xyz(jx),round(jst)
write(8,3016)io,i,xyz(ix),round(ist),xyz(jx),round(jst)
3016 format(i5,1h:,' atom',i5,2(', ',a1,' ',a7))
endif
write(8,*)
call wcmtxt
do 10 ii=1,nat
x=r(1,ii)
y=r(2,ii)
z=r(3,ii)
if(io.gt.0)then
if(ii.eq.i)then
if(ix.eq.1)x=x+(3.0d0-2.0d0*dble(ist))*step
if(ix.eq.2)y=y+(3.0d0-2.0d0*dble(ist))*step
if(ix.eq.3)z=z+(3.0d0-2.0d0*dble(ist))*step
if(jx.eq.1)x=x+(3.0d0-2.0d0*dble(jst))*step
if(jx.eq.2)y=y+(3.0d0-2.0d0*dble(jst))*step
if(jx.eq.3)z=z+(3.0d0-2.0d0*dble(jst))*step
endif
endif
10 write(8,801)ig(ii),x,y,z
call wafter
write(8,*)
9 continue
close(8)
write(6,*)io,' structures'
stop
endif
c 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
c 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
if(idiff.eq.8.or.idiff.eq.88)then
c relaxed normal mode coordinates
open(91,file='g_opt')
CALL system('mkdir diff')
nn=0
c zero geometry:
write(ts,500)nn
istart=fistart(ts)
CALL system('mkdir diff/'//ts(istart:len(ts)))
open(8,file='diff/'//ts(istart:len(ts))//'/FREE.INP')
call wgtxtfres(8,'FREE.TXT')
close(8)
open(81,file='diff/'//ts(istart:len(ts))//'/G98.INP')
call wgtxtfres(81,'G98.TXT')
write(81,*)
write(81,80)s80
write(81,3003)
write(6,3003)
write(81,*)
call wcmtxtn(81)
if(lcp2k)then
open(88,file='diff/'//ts(istart:len(ts))//'/c.inp')
call wgtxt2
endif
if(lcastep)then
open(88,file='diff/'//ts(istart:len(ts))//'/c.cell')
call wgtxt3
endif
do 1004 ii=1,nat
x=r(1,ii)
y=r(2,ii)
z=r(3,ii)
if(lcp2k)then
write(88,8011)sy(ig(ii)),x,y,z
endif
if(lcastep)then
xf=x*o11i+y*o12i+z*o13i
yf= y*o22i+z*o23i
zf= z*o33i
write(98,8012)sy(ig(ii)),xf,yf,zf
endif
1004 write(81,801)ig(ii),x,y,z
call waftern(81)
write(81,*)
close(81)
open(89,file='diff/'//ts(istart:len(ts))//'/t.inp')
write(89,3003)
close(89)
if(lcastep)then
call wafter3
close(98)
close(99)
endif
if(lcp2k)then
call wafter2
close(88)
close(89)
endif
write(91,*)'cd diff/'//ts(istart:len(ts))
write(91,*)'g09 G98.INP G98.OUT'
write(91,*)'g09 FREE.INP FREE.OUT'
write(91,*)'cd ../..'
write(91,*)'cat diff/'//ts(istart:len(ts))//'/FREE.OUT > G.OUT'
c coordinate cycles:
if(ic.eq.1)then
ndiff=nmd
else
ndiff=n
endif
c first coordinate
do 3006 io=1,ndiff
if(ic.eq.0)then
i=(io+2)/3
ix=io-3*(i-1)
endif
c first coordinate back,0,forward
do 3006 ib=-1,1
ist=ib+2
if(idiff.eq.8)then
ndiff1=1
ndiff2=1
jb1=0
jb2=0
else
ndiff1=io
ndiff2=ndiff
jb1=-1
jb2=1
endif
c second coordinate
do 3006 jo=ndiff1,ndiff2
dd=0.0d0
if(ic.eq.0)then
j=(jo+2)/3
dd=
1 dsqrt((r(1,i)-r(1,j))**2+(r(2,i)-r(2,j))**2+(r(3,i)-r(3,j))**2)
jx=jo-3*(j-1)
endif
c second coordinate back,0,forward
do 3006 jb=jb1,jb2
c skip for too distant atoms:
if(ic.eq.0.and.dist.ne.0.0d0.and.dd.gt.dd)goto 33333
c skip equilibrium:
if(ib.eq.0.and.idiff.eq.8)goto 33333
c eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
jst=jb+2
nn=nn+1
write(ts,500)nn
istart=fistart(ts)
CALL system('mkdir diff/'//ts(istart:len(ts)))
open(8,file='diff/'//ts(istart:len(ts))//'/FREE.INP')
call wgtxtfres(8,'FREE.TXT')
close(8)
open(81,file='diff/'//ts(istart:len(ts))//'/G98.INP')
call wgtxtfres(81,'G98.TXT')
open(89,file='diff/'//ts(istart:len(ts))//'/t.inp')
if(lcp2k)then
open(88,file='diff/'//ts(istart:len(ts))//'/c.inp')
call wgtxt2
endif
if(lcastep)then
open(98,file='diff/'//ts(istart:len(ts))//'/c.cell')
call wgtxt3
endif
write(81,*)
write(81,80)s80
if(idiff.eq.8)then
if(ic.eq.0)then
write(6,3304)i,xyz(ix),r3(ist)
write(81,3304)i,xyz(ix),r3(ist)
write(89,3304)i,xyz(ix),r3(ist)
else
wcm=w(iqlist(io))
write(6,3305)io,r3(ist),iqlist(io),wcm
write(81,3305)io,r3(ist),iqlist(io),wcm
write(89,3305)io,r3(ist),iqlist(io),wcm
endif
else
if(ic.eq.0)then
write(6,3314)i,xyz(ix),r3(ist),j,xyz(jx),r3(jst)
write(81,3314)i,xyz(ix),r3(ist),j,xyz(jx),r3(jst)
write(89,3314)i,xyz(ix),r3(ist),j,xyz(jx),
1 r3(jst)
else
wcm=w(iqlist(io))
ucm=w(iqlist(jo))
write(6,3315)io,r3(ist),jo,r3(jst),
1 iqlist(io),wcm,iqlist(jo),ucm
write(81,3315)io,r3(ist),jo,r3(jst),
1 iqlist(io),wcm,iqlist(jo),ucm
write(89,3315)io,r3(ist),jo,r3(jst),
1 iqlist(io),wcm,iqlist(jo),ucm
endif
endif
write(81,*)
call wcmtxtn(81)
drmax=0.0d0
do 3009 ii=1,nat
x=r(1,ii)
y=r(2,ii)
z=r(3,ii)
if(ic.eq.0)then
if(ii.eq.i)then
if(ix.eq.1)x=x+dble(ib)*step
if(ix.eq.2)y=y+dble(ib)*step
if(ix.eq.3)z=z+dble(ib)*step
endif
if(ii.eq.j)then
if(jx.eq.1)x=x+dble(jb)*step
if(jx.eq.2)y=y+dble(jb)*step
if(jx.eq.3)z=z+dble(jb)*step
endif
else
dx=s((ii-1)*3+1,iqlist(io))*step*dble(ib)
1 +s((ii-1)*3+1,iqlist(jo))*step*dble(jb)
dy=s((ii-1)*3+2,iqlist(io))*step*dble(ib)
1 +s((ii-1)*3+2,iqlist(jo))*step*dble(jb)
dz=s((ii-1)*3+3,iqlist(io))*step*dble(ib)
1 +s((ii-1)*3+3,iqlist(jo))*step*dble(jb)
x=x+dx
y=y+dy
z=z+dz
if(dabs(dx).gt.drmax)drmax=dabs(dx)
if(dabs(dy).gt.drmax)drmax=dabs(dy)
if(dabs(dz).gt.drmax)drmax=dabs(dz)
endif
if(lcp2k)write(88,8011)sy(ig(ii)),x,y,z
if(lcastep)then
xf=x*o11i+y*o12i+z*o13i
yf= y*o22i+z*o23i
zf= z*o33i
write(98,8012)sy(ig(ii)),xf,yf,zf
endif
3009 write(81,801)ig(ii),x,y,z
if(ic.eq.1)write(6,6003)drmax
call waftern(81)
write(81,*)
if(lcastep)then
call wafter3
close(98)
endif
if(lcp2k)then
call wafter2
close(88)
endif
c eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
close(81)
close(89)
open(89,file='diff/'//ts(istart:len(ts))//'/Q.OPT')
call wgtxtfres(89,'Q.TXT')
write(89,8902)iqlist(io)
8902 format('modes fixed',/,'1',/,i4,/,
1 'hessian update',/,'f',/,
1 's-matrix',/,'F.INP',/,'cartesian update',/,'f',/,'end')
close(89)
write(91,*)'cd diff/'//ts(istart:len(ts))
write(91,*)'cp ../../F.INP .'
write(91,*)'cp ../../FTRY.INP .'
write(91,*)'runopt'
write(91,*)'g09 FREE.INP FREE.OUT'
write(91,*)'cd ../..'
write(91,*)'cat diff/'//ts(istart:len(ts))//'/FREE.OUT >> G.OUT'
33333 continue
3006 continue
close(91)
write(6,*)nn+1,' structures'
stop
endif
c 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
c 22 44 22 44 22 44 22 44 22 44 22 44 22 44 22 44 22 44 22 44