-
Notifications
You must be signed in to change notification settings - Fork 5
/
frendly.f
2378 lines (1777 loc) · 68.3 KB
/
frendly.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
c Copyright (c) 1990 by James A. D. Connolly, Institute for Mineralogy and
c Petrography, Swiss Federal Insitute of Technology, CH-8092 Zurich,
c SWITZERLAND. All rights reserved.
c Please do not distribute this source.
c------------------------------------------------------------------------
c FRENDLY - a thermodynamic calculator for petrologic problems.
c------------------------------------------------------------------------
program FRNDLY
implicit none
include 'perplex_parameters.h'
logical nonlin, readyn
character uname*8, rxny*1, opname*100
integer i, j, k, l, idiag, ier, iord
double precision coef(0:10)
double precision gcpd
external gcpd, readyn
double precision props,psys,psys1,pgeo,pgeo1
common/ cxt22 /props(i8,k5),psys(i8),psys1(i8),pgeo(i8),pgeo1(i8)
integer ifct,idfl
common/ cst208 /ifct,idfl
double precision v,tr,pr,r,ps
common/ cst5 /v(l2),tr,pr,r,ps
integer ipot,jv,iv
common/ cst24 /ipot,jv(l2),iv(l2)
double precision vmax,vmin,dv
common/ cst9 /vmax(l2),vmin(l2),dv(l2)
integer inc,jpot
common/ cst101 /inc(l2),jpot
integer iam
common/ cst4 /iam
save idiag
c-----------------------------------------------------------------------
c iam flag indicates the Perple_X program
iam = 5
c perplexwrap.f flags
getInput = .true.
sWarn = .false.
c version info
call vrsion (6)
c assign data files
call fopen2 (2,opname)
c read options
opname = 'perplex_option.dat'
call redop1 (.false.,opname)
c override T_melt option
nopt(20) = 0d0
c flag to indicate whether a plot file is open
idiag = 0
c harass the user for no reason
write (*,1040)
read (*,'(a)') uname
if (uname.eq.' ') uname = ' Nimrod '
write (*,1050) uname
if (.not.readyn()) then
write (*,1060) uname
stop
end if
do
write (*,1030)
c read icopt, default icopt = 2.
call rdnumb (r,0d0,icopt,2,.false.)
if (icopt.eq.4) exit
call jnput2 (rxny,uname)
nonlin = .false.
if (icopt.eq.1) then
c calculating equilibrium properties for a
c reaction:
c select variables and set up plot file:
if (idiag.eq.0) call setplt (.false.,nonlin,coef,iord)
idiag = 1
do
call eqrxn
write (*,1070)
read (*,'(a)') rxny
if (rxny.ne.'y'.and.rxny.ne.'Y') exit
call jnput2 (rxny,uname)
end do
else if (icopt.eq.2) then
c calculating properties at arbitrary conditions:
write (*,1180)
if (readyn()) then
c tabulated properties
write (*,1190)
if (readyn()) then
c non-linear 1d table
nonlin = .true.
call setplt (.true.,nonlin,coef,iord)
else
c linear 1d or 2d table
call setplt (.true.,nonlin,coef,iord)
end if
do k = 1, inc(iv(3))
v(iv(3)) = vmin(iv(3)) + dfloat(k-1)*dv(iv(3))
do j = 1, inc(iv(2))
v(iv(2)) = vmin(iv(2)) + dfloat(j-1)*dv(iv(2))
do i = 1, inc(iv(1))
v(iv(1)) = vmin(iv(1)) + dfloat(i-1)*dv(iv(1))
if (nonlin) then
v(iv(2)) = 0d0
do l = 0, iord
v(iv(2)) = v(iv(2)) + coef(l)*v(iv(1))**l
end do
end if
call calphp
call outphp (.true.)
end do
end do
end do
close (n4)
write (*,1120)
cycle
else
do
c interactively entered conditions
write (*,1100)
read (*,*,iostat=ier) v(1),v(2)
if (ier.ne.0) then
call rerr
cycle
end if
if (v(1).eq.0d0) exit
if (ifct.gt.0) then
do
write (*,1110)
read (*,*,iostat=ier) v(3)
if (ier.eq.0) exit
call rerr
end do
end if
call calphp
call outphp (.false.)
write (*,1090)
if (readyn()) call change
end do
end if
else if (icopt.eq.5) then
c special file output
do
write (*,*) 'Enter P-T file name '
read (*,*) opname
open (666,file=opname,status='old',iostat=ier)
if (ier.ne.0) cycle
exit
end do
do
write (*,*) 'Enter output file name '
read (*,*) opname
open (667,file=opname,status='new',iostat=ier)
if (ier.ne.0) cycle
exit
end do
do
read (666,*,iostat=ier) v(1), v(2)
if (ier.ne.0) exit
write (667,'(3(g14.6,1x))') gcpd(1,.false.), v(1), v(2)
end do
close (666)
close (667)
else if (icopt.eq.3) then
c create a new data base entry
call nentry
end if
end do
write (*,1130) uname
if (idiag.eq.1) write (n4,1010) 1,1,1,1,1,0,0,0,0,1d0,0,0
1000 format (80(g14.7,1x))
1010 format (9(1x,i1),/,f3.1,/,2(1x,i1))
1030 format (/,'Choose from the following options:',
* //,2x,'1 - equilibrium coordinates for a reaction.',
* /,2x,'2 - [default] thermodynamic properties for a phase or',
* ' reaction relative to',/,6x,'the reference state.',
* /,2x,'3 - create new thermodynamic data file entries.',
* /,2x,'4 - quit.',
* //,'With options 1-2 you may also modify',
* ' thermodynamic data, the modified data',/,'can then',
* ' be stored as a new entry in the thermodynamic data',
* ' file.',/)
1040 format (/,'Hi! I am a user freindly program.',/,
* 'What is your name? ')
1050 format (/,'Hi ',a,'!, I like you and I hope we have fun!',/,
* 'Can you say "therm-o-dy-nam-ics" (y/n)?')
1060 format (/,'Weeell ', a,' why dont you go read Gibbs and try me',
* ' again later?')
1070 format ('Calculate a different equilibrium (y/n)?')
1090 format ('Modify or output thermodynamic parameters (y/n)? ')
1100 format ('Enter P(bars) and T(K) [zeroes to quit]:')
1110 format ('Enter X(CO2/O) in fluid phase:')
1120 format (/,'The table has been written.',/)
1130 format (/,'Have a nice day ',a,'!',/)
1180 format ('Write a properties table (Y/N)?')
1190 format ('Compute properties along a path (Y/N)?')
end
subroutine chptx
c----------------------------------------------------------------------
implicit none
include 'perplex_parameters.h'
integer ier, i, j
double precision delv
common/ cst63 /delv(l2)
double precision v,tr,pr,r,ps
common/ cst5 /v(l2),tr,pr,r,ps
double precision vmax,vmin,dv
common/ cst9 /vmax(l2),vmin(l2),dv(l2)
integer ipot,jv,iv
common/ cst24 /ipot,jv(l2),iv(l2)
write (*,1020)
do i = 1, ipot
j = iv(i)
do
write (*,1000) vname(j),vmin(j),vmax(j)
read (*,*,iostat=ier) vmin(j),vmax(j)
if (j.eq.3.and.vmin(j).lt.0d0.or.j.eq.3.and.vmax(j).gt.1d0
* .or.j.ne.3.and.vmin(j).ge.vmax(j).or.ier.ne.0) then
write (*,1010)
cycle
end if
exit
end do
v(j) = vmin(j)
delv(j) = vmax(j) - vmin(j)
dv(j) = delv(j) / 4d1
end do
call concrt
1000 format (/,'Enter new min/max values for ',a,' (',
* 'old values were ',g12.5,',',g12.5,')',/)
1010 format (/,'Try again.',/)
1020 format (/,'This option does not change plot limits!'
* ,'To do this, modify default plot options',
* /,'while running PSVDRAW.',/)
end
subroutine eqrxn
c------------------------------------------------------------------------
implicit none
include 'perplex_parameters.h'
integer i
double precision v,tr,pr,r,ps
common/ cst5 /v(l2),tr,pr,r,ps
double precision vmax,vmin,dv
common/ cst9 /vmax(l2),vmin(l2),dv(l2)
integer ipot,jv,iv
common/ cst24 /ipot,jv(l2),iv(l2)
integer inc,jpot
common/ cst101 /inc(l2),jpot
c------------------------------------------------------------------------
c search for an equilibrium point
c on the x-y coordinate frame.
do i = 1, inc(iv(3))
v(iv(3)) = vmin(iv(3)) + dfloat(i-1)*dv(iv(3))
call newhld
end do
end
subroutine setplt (table,nonlin,coef,iord)
c----------------------------------------------------------------------
c select variables for a plot or table
c----------------------------------------------------------------------
implicit none
include 'perplex_parameters.h'
character n4name*100, title*100, text*200
integer i,j,ier,ic,ix,iord
logical table, nonlin, readyn
character*14 tags(27)
double precision coef(0:10)
external readyn
integer inc,jpot
common/ cst101 /inc(l2),jpot
double precision delv
common/ cst63 /delv(l2)
double precision vmax,vmin,dv
common/ cst9 /vmax(l2),vmin(l2),dv(l2)
integer ipot,jv,iv
common/ cst24 /ipot,jv(l2),iv(l2)
integer io3,io4,io9
common/ cst41 /io3,io4,io9
logical oned
common/ cst82 /oned
save tags
data tags/ 'g(J/mol) ','h(J/mol) ','log10[Keq] ',
*'s(J/mol/K) ','cp(J/mol/K) ','v(J/mol/bar) ','alpha(1/K) ',
*'beta(1/bar) ','N(g/mol) ','rho(kg/m3) ','Gruneisen_T ',
*'Ks(bar) ','KsT(bar/K) ','KsP ','Gs(bar) ',
*'GsT(bar/K) ','GsP ',
*'v0(km/s) ','v0T(km/s/K) ','v0P(km/s/bar)',
*'vp(km/s) ','vpT(km/s/K) ','vpP(km/s/bar)','vs(km/s) ',
*'vsT(km/s/K) ','vsP(km/s/bar)','cp/cv '/
c----------------------------------------------------------------------
do i = 1, l2
iv(i) = i
vmin(i) = 0d0
vmax(i) = vmin(i)
dv(i) = 1d0
inc(i) = 1
end do
oned = .false.
c query for 1d table
if (table) then
if (nonlin) then
oned = .true.
else
write (*,1110)
if (readyn()) oned = .true.
end if
end if
do
c select the x variable (iv(1)):
if (oned) then
write (*,1120)
else
write (*,2130)
end if
write (*,2140) (j,vname(iv(j)), j = 1, ipot)
write (*,*)
read (*,*,iostat=ier) ic
if (ier.eq.0) exit
call rerr
end do
ix = iv(1)
iv(1) = iv(ic)
iv(ic) = ix
c get x variable limits and increment
do
if (table) then
write (*,1000) vname(iv(1))
read (*,*,iostat=ier) vmin(iv(1)),vmax(iv(1)),dv(iv(1))
else
write (*,2150) vname(iv(1))
read (*,*,iostat=ier) vmin(iv(1)),vmax(iv(1))
end if
if (ier.eq.0) exit
call rerr
end do
if (oned.and.nonlin) then
c select the dependent variable
jpot = ipot
if (ipot.eq.3) then
do
write (*,1030)
write (*,2140) (j,vname(iv(j)), j = 2, ipot)
write (*,*)
read (*,*,iostat=ier) ic
if (ier.eq.0) exit
call rerr
end do
else
ic = 2
end if
ix = iv(2)
iv(2) = iv(ic)
iv(ic) = ix
vmax(iv(2)) = vmin(iv(2))
if (ipot.eq.3) then
c specify the value for the 3rd variable
write (*,2180) vname(iv(3))
read (*,*,iostat=ier) vmin(iv(3))
vmax(iv(3)) = vmin(iv(3))
end if
c get the path function
write (*,1040) vname(iv(2)),vname(iv(1))
read (*,*) iord
do i = 0, iord
write (*,1050) i
read (*,*) coef(i)
end do
write (text,1070) vname(iv(2)),
* (coef(i),vname(iv(1)),i,i=0,iord)
call unblnk (text)
write (*,1070) text
else if (oned) then
c specify the sectioning variables
jpot = ipot
do i = 2, ipot
do
write (*,2180) vname(iv(i))
read (*,*,iostat=ier) vmin(iv(i))
if (ier.eq.0) exit
call rerr
end do
vmax(iv(i)) = vmin(iv(i))
end do
else
c specify the additional variables
jpot = 2
if (ipot.eq.3) then
do
write (*,2110)
write (*,2140) (j,vname(iv(j)), j = 2, ipot)
write (*,*)
read (*,*,iostat=ier) ic
if (ier.eq.0) exit
call rerr
end do
else
ic = 2
end if
ix = iv(2)
iv(2) = iv(ic)
iv(ic) = ix
do
if (table) then
write (*,1000) vname(iv(2))
read (*,*,iostat=ier) vmin(iv(2)),vmax(iv(2)),dv(iv(2))
else
write (*,2150) vname(iv(2))
read (*,*,iostat=ier) vmin(iv(2)),vmax(iv(2))
end if
if (ier.eq.0) exit
call rerr
end do
c third variable?
if (ipot.eq.3) then
if (table) then
write (*,1010) vname(iv(3))
if (readyn()) then
c setting jpot = 3 will cause plotting programs
c to crash.
jpot = 3
write (*,1000) vname(iv(3))
read (*,*,iostat=ier) vmin(iv(3)),vmax(iv(3)),
* dv(iv(3))
end if
else
write (*,2160) vname(iv(3))
if (readyn()) then
jpot = 3
do
write (*,2150) vname(iv(3))
read (*,*,iostat=ier) vmin(iv(3)),vmax(iv(3))
if (ier.eq.0) exit
call rerr
end do
do
write (*,1060)
read (*,*,iostat=ier) inc(iv(3))
if (ier.eq.0) exit
call rerr
end do
if (inc(iv(3)).lt.1) inc(iv(3)) = 1
end if
end if
c set third variable if unused:
if (jpot.eq.2) then
do
write (*,2180) vname(iv(3))
read (*,*,iostat=ier) vmin(iv(3))
if (ier.eq.0) exit
call rerr
end do
vmax(iv(3)) = vmin(iv(3))
dv(iv(3)) = 0d0
inc(iv(3)) = 1
end if
end if
end if
c increments or counters:
if (table) then
do i = 1, jpot
inc(iv(i)) = idint(dabs(vmax(iv(i))-vmin(iv(i)))/dv(iv(i)))
* + 1
end do
else
do i = 1, jpot
inc(iv(i)) = 100
delv(iv(i)) = vmax(iv(i))-vmin(iv(i))
dv(iv(i)) = delv(iv(i)) / dfloat(inc(iv(i)))
end do
c set convergence criteria for univeq:
call concrt
c plot file output?
write (*,1020)
if (readyn()) then
io4 = 0
else
io4 = 1
end if
end if
c setup output files:
if (table.or.io4.eq.0) then
c query output file name
write (*,1080)
c readrt loads the root into prject
call readrt
if (table) then
call mertxt (n4name,prject,'.tab',0)
else
call mertxt (n4name,prject,'.plt',0)
end if
open (n4,file=n4name)
c plot blurb
if (oned) then
call plblrb (4)
else if (table) then
call plblrb (1)
else
call plblrb (2)
end if
c query for title
write (*,'(/,a)') 'Enter calculation title:'
read (*,'(a)') title
end if
c write file headers
if (table) then
c terminal info on variables
c write (*,1090)
c write (*,'(80(a14,1x))') (vname(iv(i)),i=1,jpot),tags
c write version flag
write (n4,'(a,/,a)') '|6.6.6',title
write (n4,*) jpot
do i = 1, jpot
write (n4,*) vname(iv(i))
write (n4,*) vmin(iv(i))
write (n4,*) dv(iv(i))
write (n4,*) inc(iv(i))
end do
write (n4,*) 27+jpot
write (n4,'(80(a14,1x))') (vname(iv(i)),i=1,jpot),tags
else if (io4.eq.0) then
write (n4,*) 1
write (n4,*) 0, 0, 0
write (n4,*) 0, 0, 0, 0, 0, 0
write (n4,'(a)') title,' ',' ',' '
write (n4,*) ipot,(iv(i),i=1,ipot),1,2
write (n4,'(a)') '0 0 0 0. 0. 0. 0. 0.'
write (n4,'(6(g11.5,1x))') (vmax(iv(i)),vmin(iv(i)),i=1,ipot)
write (n4,'(a)') (vname(iv(i)),i=1,ipot)
end if
1000 format ('Enter minimum, maximum, and increment for ',a,':')
1010 format (/,'Make the table also a function of ',a,' (y/n)?',//,
* 'WARNING: if you answer yes, then the resulting 3d table ',
* 'cannot be plotted ',/,
* 'with current Perple_X programs or scripts.',/)
1020 format (/,'Generate a plot file (y/n)?')
1030 format (/,'Select the dependent path variable:',/)
1040 format (/,'Profile must be described by the function',/,a,
* ' = Sum ( c(i) * ',a,' ^i, i = 0..n)',/,'Enter n (<10)')
1050 format (/,'Enter c(',i2,')')
1060 format (/,'Enter number of sections:')
1070 format (a,'=',5('+(',g12.6,')','*',a,'^',i1))
1080 format (/,'Enter the output file name [without the ',
* '.plt/.tab suffix, default is my_project]:')
1090 format (/,'Table columns will be:',/)
1100 format (/,'Your polynomial is:',/,a)
1110 format (/,'Make a 1-dimensional (e.g., isobaric) table (y/n)?')
1120 format (/,'Select the independent (x) variable:',/)
2130 format (/,'Select the first independent (x) variable:',/)
2140 format (10x,i1,' - ',a)
2150 format (/,'Enter minimum and maximum values for ',a,':')
2110 format (/,'Select the second independent (y) variable:',/)
2180 format (/,'Specify the value for: ',a)
2160 format (/,'Calculate multiple sections as a function of ',a,
* ' (y/n)?')
end
subroutine newhld
c-----------------------------------------------------------------------
implicit none
include 'perplex_parameters.h'
logical readyn
integer ivi,ivd,ier,igo
double precision div
external readyn
double precision v,tr,pr,r,ps
common/ cst5 /v(l2),tr,pr,r,ps
double precision vmax,vmin,dv
common/ cst9 /vmax(l2),vmin(l2),dv(l2)
integer ipot,jv,iv1,iv2,iv3,iv4,iv5
common/ cst24 /ipot,jv(l2),iv1,iv2,iv3,iv4,iv5
c-----------------------------------------------------------------------
c initialization:
c ifuk = 0
10 write (*,1160)
write (*,1170) vname(iv1),vname(iv2)
c write potential variable sectioning
c constraints:
if (ipot.gt.2) write (*,1180) vname(iv3), v(iv3)
c set starting values for search
v(iv1)=vmin(iv1)
v(iv2)=vmin(iv2)
c test stability along an edge of the
c diagrams coordinate frame:
call search (ivi,ivd,div,ier)
if (ier.eq.1) then
write (*,1010)
goto 20
end if
call trace (ivd,ivi,div,igo)
c this would permit continuation of the
c search on failures from trace if iste
c were not initialized in search (but here).
c if (igo.eq.1.and.ifuk.eq.0) then
c ifuk = 1
c goto 30
c else if (igo.eq.1.and.ifuk.eq.1) then
c write (*,1030)
c end if
20 write (*,1040)
if (readyn()) then
call chptx
goto 10
end if
write (*,1020)
if (.not.readyn()) return
call change
goto 10
1010 format (/,'Equilibrium is not in specified',
* ' coordinate frame.',/)
1020 format (/,'Modify data and',
* ' recalculate the equilibrium (y/n)? ')
1040 format (/,'Change PTX limits (y/n)?',/)
1160 format (/,'-------------------------------------------------'
* ,'---------------',/)
1170 format ('The ',a,'-',a,' loci of the univariant field'
* ,' follows:')
1180 format ('(subject to the constraint ',a,'=',g12.6,')',/)
99 end
subroutine search (ivi,ivd,div,ier)
c-----------------------------------------------------------------------
implicit none
include 'perplex_parameters.h'
integer ivi,ivd,ier,i
double precision div,ddv,gval,gst
double precision a,b
integer ipvt,idv,iophi,idphi,iiphi,iflg1
common/ cst23 /a(k8,k8),b(k8),ipvt(k8),idv(k8),
* iophi,idphi,iiphi,iflg1
integer ipot,jv,iv1,iv2,iv3,iv4,iv5
common/ cst24 /ipot,jv(l2),iv1,iv2,iv3,iv4,iv5
double precision vmax,vmin,dv
common/ cst9 /vmax(l2),vmin(l2),dv(l2)
double precision v,tr,pr,r,ps
common/ cst5 /v(l2),tr,pr,r,ps
c-----------------------------------------------------------------------
c initialization
ier = 0
v(iv1) = vmin(iv1)
v(iv2) = vmin(iv2)
call grxn (gst)
do i = 1, 4
c set default dependent and independent
c variables and increments for each edge
c to be searched.
if (i.eq.1) then
c traverse 1.
ivi = iv2
ivd = iv1
ddv = dv(ivd)
div = dv(ivi)
v(ivi) = vmin(ivi)
else if (i.eq.2) then
c traverse 2.
ivi = iv1
ivd = iv2
ddv = dv(ivd)
div = -dv(ivi)
v(ivi) = vmax(ivi)
else if (i.eq.3) then
c traverse 3.
ivi = iv2
ivd = iv1
ddv = -dv(ivd)
div = -dv(ivi)
v(ivi) = vmax(ivi)
else if (i.eq.4) then
c traverse 4.
ivi = iv1
ivd = iv2
ddv = -dv(ivd)
div = dv(ivi)
v(ivi) = vmin(ivi)
end if
do
c begin search:
v(ivd) = v(ivd) + ddv
c out of range?:
if (i.le.2) then
if (v(ivd).gt.vmax(ivd)) v(ivd) = vmax(ivd)
else
if (v(ivd).lt.vmin(ivd)) v(ivd) = vmin(ivd)
end if
c calculate phase energies:
call grxn (gval)
if (gval*gst.lt.0d0) return
c check if search is in range:
if (i.le.2) then
if (v(ivd).ge.vmax(ivd)) exit
else
if (v(ivd).le.vmin(ivd)) exit
end if
end do
c next traverse.
end do
c set this ier flag to indicate
c the reaction wasn't found
ier=1
c done:
end
subroutine trace (iovd,iovi,odiv,igo)
c----------------------------------------------------------------------
implicit none
include 'perplex_parameters.h'
integer iovd,iovi,ivd,igo,ier,jer,icter,ird,ivi
double precision odiv,div
double precision v,tr,pr,r,ps
common/ cst5 /v(l2),tr,pr,r,ps
integer ipt2
double precision ptx
common/ cst32 /ptx(l5),ipt2
c-----------------------------------------------------------------------
ivi = iovi
ivd = iovd
igo = 0
50 call univeq (ivd,ier)
c if univeq fails on a bounding edge
c write error message and return:
goto (9000,9000),ier
c set the increment for the iv
div = odiv
c initialize counters
ipt2 = 0
icter = 0
c assign the 1st point
call assptx
c follow the equilibrium
60 call sfol1 (ivd,ivi,ier,div)
c sfol1 returns ier=1
goto (70,70),ier
ivi = iovi
ivd = iovd
goto 9999
70 call switch (div,ivi,ivd,jer)
goto (75),jer
icter=icter+1
if (icter.lt.4) goto 60
75 call warn (10, v(ivi), igo, 'TRACE')