forked from MethodicalAcceleratorDesign/MAD-X
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.f90
executable file
·1982 lines (1792 loc) · 66.1 KB
/
util.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module math_constfi ! 2015-Aug-06 Ghislain
implicit none
public
!--- Definition of useful mathematical constants
double precision, parameter :: zero=0d0, one=1d0, two=2d0, three=3d0, four=4d0, five=5d0
double precision, parameter :: six=6d0, seven=7d0, eight=8d0, nine=9d0, ten=10d0
double precision, parameter :: eleven=11d0, twelve=12d0, thirteen=13d0, fourteen=14d0, fifteen=15d0
double precision, parameter :: sixteen=16d0, seventeen=17d0, eighteen=18d0, nineteen=19d0, twenty=20d0
double precision, parameter :: half=0.5d0, quarter=0.25d0
double precision, parameter :: ten3m=1d-3, ten6m=1d-6, ten9m=1d-9
double precision, parameter :: ten3p=1d3, ten6p=1d6, ten9p=1d9
double precision, parameter :: pi = 3.141592653589793238462643383279502884197169399375105820974944d0
double precision, parameter :: twopi = two*pi
double precision, parameter :: degrad = 180d0/pi, raddeg = pi/180d0
double precision, parameter :: e = 2.718281828459045235360287471352662497757247093699959574966967d0
end module math_constfi
module phys_constfi
use math_constfi, only : pi
implicit none
public
!--- Definition of physical constants
! sources :
! J. Beringer et al. (Particle Data Group), Phys. Rev. D86, 010001 (2012). = PDG 2012
! K.A. Olive et al. (Particle Data Group), Chin. Phys. C, 38, 090001 (2014). = PDG 2014
double precision, parameter :: clight = 299792458d0 ! Speed of light in vacuum [m/s]
double precision, parameter :: qelect = 1.6021766208d-19 ! Elementary charge [A*s]
double precision, parameter :: hbar = 6.582119514e-25 ! Reduced Plack's constant [GeV*s]
double precision, parameter :: amu0 = 4d-7 * pi ! Permeability of vacuum [V*s/A*m]
! Rest Mass [GeV]
double precision, parameter :: emass = 0.5109989461d-3 ! GeV CODATA 2014
double precision, parameter :: pmass = 0.9382720813 ! GeV CODATA 2014
double precision, parameter :: nmass = 0.9314940954 ! GeV CODATA 2014
double precision, parameter :: mumass = 0.1056583745 ! GeV CODATA 2014
! Classical radius [m]
double precision, parameter :: erad = 2.8179403227d-15
double precision, parameter :: prad = erad*emass/pmass
end module phys_constfi
module matrices
! useful matrices: Identity EYE(6,6) and Symplectic JMAT(6.6) and SMAT(2,2)
implicit none
double precision, parameter :: EYE(6,6)=reshape((/1d0,0d0,0d0,0d0,0d0,0d0,&
0d0,1d0,0d0,0d0,0d0,0d0,&
0d0,0d0,1d0,0d0,0d0,0d0,&
0d0,0d0,0d0,1d0,0d0,0d0,&
0d0,0d0,0d0,0d0,1d0,0d0,&
0d0,0d0,0d0,0d0,0d0,1d0 /), shape(EYE))
double precision, parameter :: JMAT(6,6)=reshape((/0d0,1d0,0d0,0d0,0d0,0d0, &
-1d0,0d0,0d0,0d0,0d0,0d0, &
0d0,0d0,0d0,1d0,0d0,0d0, &
0d0,0d0,-1d0,0d0,0d0,0d0, &
0d0,0d0,0d0,0d0,0d0,1d0, &
0d0,0d0,0d0,0d0,-1d0,0d0 /), shape(JMAT))
double precision, parameter :: JMATINV(6,6) = -JMAT
double precision, parameter :: JMATT(6,6) = -JMAT
double precision, parameter :: SMAT(2,2)=reshape((/0d0,1d0, &
-1d0,0d0 /), shape(SMAT))
double precision, parameter :: SMATINV(2,2) = -SMAT
double precision, parameter :: SMATT(2,2) = -SMAT
double precision, parameter :: symp_thrd = 1d-12 !, symp_thrd_orbit = 1d-10 ! threshold during closed orbit search
end module matrices
module code_constfi
implicit none
public
!--- Definition of mad8 codes in a more readable format
integer, parameter :: code_drift = 1
integer, parameter :: code_rbend = 2
integer, parameter :: code_sbend = 3
integer, parameter :: code_matrix = 4
integer, parameter :: code_quadrupole = 5
integer, parameter :: code_sextupole = 6
integer, parameter :: code_octupole = 7
integer, parameter :: code_multipole = 8
integer, parameter :: code_solenoid = 9
integer, parameter :: code_rfcavity = 10
integer, parameter :: code_elseparator = 11
integer, parameter :: code_srotation = 12
integer, parameter :: code_yrotation = 13
integer, parameter :: code_hkicker = 14
integer, parameter :: code_kicker = 15
integer, parameter :: code_vkicker = 16
integer, parameter :: code_hmonitor = 17
integer, parameter :: code_monitor = 18
integer, parameter :: code_vmonitor = 19
integer, parameter :: code_ecollimator = 20
integer, parameter :: code_rcollimator = 21
integer, parameter :: code_beambeam = 22
! code 23 is free
integer, parameter :: code_instrument = 24
integer, parameter :: code_marker = 25
! code 26 is free
integer, parameter :: code_twcavity = 27
! code 28 is free
integer, parameter :: code_wire = 29
integer, parameter :: code_slmonitor = 30
integer, parameter :: code_blmonitor = 31
integer, parameter :: code_imonitor = 32
integer, parameter :: code_dipedge = 33
integer, parameter :: code_xrotation = 34
integer, parameter :: code_changeref = 35
integer, parameter :: code_translation = 36
integer, parameter :: code_crabcavity = 37
integer, parameter :: code_placeholder = 38
integer, parameter :: code_tkicker = 39
integer, parameter :: code_hacdipole = 40
integer, parameter :: code_vacdipole = 41
integer, parameter :: code_nllens = 42
integer, parameter :: code_rfmultipole = 43
integer, parameter :: code_collimator = 44
integer, parameter :: code_changerefp0 = 45
integer, parameter :: code_sixmarker = 46
end module code_constfi
module aperture_enums
implicit none
public
integer, parameter :: ap_circle = 0
integer, parameter :: ap_ellipse = 1
integer, parameter :: ap_rectangle = 2
integer, parameter :: ap_lhcscreen = 3
integer, parameter :: ap_rectcircle = 4
integer, parameter :: ap_rectellipse = 5
integer, parameter :: ap_racetrack = 6
integer, parameter :: ap_octagon = 7
integer, parameter :: ap_custom = 8
integer, parameter :: ap_notset = 9
integer, parameter :: ap_custom_inter = 10
end module aperture_enums
module track_enums
implicit none
public
integer, parameter :: enum_other_bv = 1
integer, parameter :: enum_lrad = 2
integer, parameter :: enum_noise = 3
integer, parameter :: enum_angle = 4
integer, parameter :: enum_time_var = 5
integer, parameter :: enum_sinkick = 6
integer, parameter :: enum_kick = 7
integer, parameter :: enum_chkick = 8
integer, parameter :: enum_cvkick = 9
integer, parameter :: enum_hkick = 10
integer, parameter :: enum_vkick = 11
integer, parameter :: total_enums = 11
end module track_enums
module Inf_NaN_Detection
!! Inf_NaN_Detection module
!! Copyright(c) 2003, Lahey Computer Systems, Inc.
!! Copies of this source code, or standalone compiled files
!! derived from this source may not be sold without permission
!! from Lahey Computers Systems. All or part of this module may be
!! freely incorporated into executable programs which are offered
!! for sale. Otherwise, distribution of all or part of this file is
!! permitted, provided this copyright notice and header are included.
!! This module exposes four elemental functions:
!!
!! isnan(x) - test for a "not a number" value
!!
!! isinf(x) - test for either a positive or negative "infinite" value
!!
!! isposinf(x) - test for a positive "infinite" value
!!
!! isneginf(x) - test for a negative "infinite" value
!!
!! Each function accepts a single or double precision real argument, and
!! returns a true or false value to indicate the presence of the value
!! being tested for. If the argument is array valued, the function returns
!! a conformable logical array, suitable for use with the ANY function, or
!! as a logical mask.
!!
!! Each function operates by transferring the bit pattern from a real
!! variable to an integer container. Unless testing for + or - infinity,
!! the sign bit is cleared to zero. The value is exclusive ORed with
!! the value being tested for. The integer result of the IEOR function is
!! converted to a logical result by comparing it to zero.
!!
implicit none
private
public :: isnan, isinf, isposinf, isneginf, sp, dp
! Order set-up
integer, parameter :: sp=kind(1.e0)
integer, parameter :: dp=selected_real_kind(2*precision(1.e0))
! Kind numbers for single and double precision integer containers
integer, parameter :: Single = selected_int_kind(precision(1.e0))
integer, parameter :: Double = selected_int_kind(2*precision(1.e0))
!VK20070611: The below lines are not accepted by NAG-compiler with <Makefile_nag>
! Single precision IEEE values
integer(Single), parameter :: sNaN = Z"7FC00000"
integer(Single), parameter :: sPosInf = Z"7F800000"
integer(Single), parameter :: sNegInf = Z"FF800000"
! Double precision IEEE values
integer(Double), parameter :: dNaN = Z"7FF8000000000000"
integer(Double), parameter :: dPosInf = Z"7FF0000000000000"
integer(Double), parameter :: dNegInf = Z"FFF0000000000000"
! Locatation of single and double precision sign bit (Intel)
! Subtract one because bit numbering starts at zero
integer, parameter :: SPSB = bit_size(sNaN) - 1
integer, parameter :: DPSB = bit_size(dNaN) - 1
interface isnan
module procedure sisnan
module procedure disnan
end interface isnan
interface isinf
module procedure sisinf
module procedure disinf
end interface isinf
interface isposinf
module procedure sisposinf
module procedure disposinf
end interface isposinf
interface isneginf
module procedure sisneginf
module procedure disneginf
end interface isneginf
contains
! Single precision test for NaN
elemental function sisnan(x) result(res)
implicit none
real(sp), intent(in) :: x
logical :: res
res = ieor(ibclr(transfer(x,sNan),SPSB), sNaN) == 0
end function sisnan
! Double precision test for NaN
!DEC$ ATTRIBUTES FORCEINLINE :: disnan
elemental function disnan(d) result(res)
implicit none
real(dp), intent(in) :: d
logical :: res
res = ieor(ibclr(transfer(d,dNaN),DPSB), dNaN) == 0
end function disnan
! Single precision test for Inf
elemental function sisinf(x) result(res)
implicit none
real(sp), intent(in) :: x
logical :: res
res = ieor(ibclr(transfer(x,sPosInf),SPSB), sPosInf) == 0
end function sisinf
! Double precision test for Inf
elemental function disinf(d) result(res)
implicit none
real(dp), intent(in) :: d
logical :: res
res = ieor(ibclr(transfer(d,dPosInf),DPSB), dPosInf) == 0
end function disinf
! Single precision test for +Inf
elemental function sisposinf(x) result(res)
implicit none
real(sp), intent(in) :: x
logical :: res
res = ieor(transfer(x,sPosInf), sPosInf) == 0
end function sisposinf
! Double precision test for +Inf
elemental function disposinf(d) result(res)
implicit none
real(dp), intent(in) :: d
logical :: res
res = ieor(transfer(d,dPosInf), dPosInf) == 0
end function disposinf
! Single precision test for -Inf
elemental function sisneginf(x) result(res)
implicit none
real(sp), intent(in) :: x
logical :: res
res = ieor(transfer(x,sNegInf), sNegInf) == 0
end function sisneginf
! Double precision test for -Inf
elemental function disneginf(d) result(res)
implicit none
real(dp), intent(in) :: d
logical :: res
res = ieor(transfer(d,dNegInf), dNegInf) == 0
end function disneginf
end module Inf_NaN_Detection
module bbfi
implicit none
public
integer, parameter :: bbd_max=100000
integer :: bbd_loc(bbd_max)=0, bbd_cnt=0, bbd_flag=0, bbd_pos=0
double precision :: bb_kick(2,bbd_max)=0.d0
double precision, parameter :: explim=150.0d0 ! if x > explim, exp(-x) is outside machine limits.
end module bbfi
module deltrafi
implicit none
public
logical :: radiate=.false., damp=.false., quantum=.false., fastune=.false.
double precision :: deltax=0.d0
end module deltrafi
module dyntabfi
implicit none
public
double precision :: dynapfrac=0.d0, dktrturns=0.d0
double precision :: xend=0.d0, pxend=0.d0, yend=0.d0, pyend=0.d0, tend=0.d0, ptend=0.d0
!double precision :: smear=0.d0, yapunov=0.d0
double precision :: smear=0.d0, lyapunov=0.d0
end module dyntabfi
module wmaxmin0fi
implicit none
public
double precision :: wxmax=0.d0, wymax=0.d0, wxymax=0.d0
double precision :: wxmin=1.d20, wymin=1.d20, wxymin=1.d20
end module wmaxmin0fi
module tunesfi
implicit none
public
double precision :: x0=0.d0, y0=0.d0, tunx=0.d0, tuny=0.d0, dtune=0.d0
end module tunesfi
module twiss0fi
implicit none
public
!integer, parameter :: align_max=14, fundim=74
!IT increase fundim to 110 to fit in sigma matrices 6x6
integer, parameter :: align_max=14, fundim=110
end module twiss0fi
module twissafi
implicit none
public
character(len=48) :: table_name=' ', sectorTableName=' '
logical :: match_is_on=.false.
end module twissafi
module twisslfi
implicit none
public
logical :: centre=.false., first
logical :: rmatrix=.false., sectormap=.false., ripken=.false.
logical :: mode_flip=.false.
logical :: ele_body=.false.
end module twisslfi
module twisscfi
use twiss0fi
implicit none
public
double precision :: opt_fun0(fundim)=0.d0, opt_fun(fundim)=0.d0
double precision :: disp(6)=0.d0, ddisp(6)=0.d0
double precision :: rmat(2,2)=0.d0
double precision :: sigmat(6,6)=0.d0
double precision :: betx=0.d0, alfx=0.d0, amux=0.d0, cosmux=0.d0, sinmux=0.d0, qx=0.d0
double precision :: bety=0.d0, alfy=0.d0, amuy=0.d0, cosmuy=0.d0, sinmuy=0.d0, qy=0.d0
double precision :: bxmax=0.d0, dxmax=0.d0, bymax=0.d0, dymax=0.d0
double precision :: xcomax=0.d0, ycomax=0.d0, sigxco=0.d0, sigyco=0.d0
double precision :: sigdx=0.d0, sigdy=0.d0
double precision :: wgt=0.d0, suml=0.d0, circ=0.d0, eta=0.d0, alfa=0.d0, gamtr=0.d0
double precision :: wx=0.d0, phix=0.d0, dmux=0.d0, xix=0.d0, wy=0.d0, phiy=0.d0, dmuy=0.d0, xiy=0.d0
double precision :: synch_1=0.d0, synch_2=0.d0, synch_3=0.d0, synch_4=0.d0, synch_5=0.d0
double precision :: synch_6=0.d0, synch_7=0.d0, synch_8=0.d0
double precision :: gammacp=1.d0
integer :: nmode_flip=0
end module twisscfi
module twissotmfi
implicit none
public
double precision :: rotm(6,6)=0.d0, rw(6,6)=0.d0, skick(6)=0.d0, sorb(6)=0.d0
double precision :: srmat(6,6)=0.d0, stmat(6,6,6)=0.d0
end module twissotmfi
module twissbeamfi
use math_constfi, only : zero
implicit none
public
logical, save :: radiate=.false.
double precision, save :: energy=zero, deltap=zero, beta=zero, gamma=zero, pc=zero
double precision, save :: arad=zero, dtbyds=zero, charge=zero, npart=zero
end module twissbeamfi
module max_iterate
implicit none
public
integer, parameter :: maxiter=250
end module max_iterate
module twiss_elpfi
implicit none
public
!---fixed positions for element parameters
double precision :: g_elpar(50)=0.d0
!-general
integer, parameter :: g_el=2, g_kmax=3, g_kmin=4, g_calib=5, g_polarity=6
!-bend
integer, parameter :: b_angle=7, b_tilt=8, b_k0=9, b_k0s=10
integer, parameter :: b_k1=11, b_k1s=12, b_e1=13 , b_e2=14, b_k2=15
integer, parameter :: b_k2s=16, b_h1=17, b_h2=18, b_hgap=19
integer, parameter :: b_fint=20, b_fintx=21, b_k3=22, b_k3s=23
!-quad
integer, parameter :: q_tilt=7, q_k1=8, q_k1s=9, q_k1t=10, q_k1st=11
!-sext
integer, parameter :: s_tilt=7, s_k2=8, s_k2s=9, s_k2t=10, s_k2st=11
!-oct
integer, parameter :: o_tilt=7, o_k3=8, o_k3s=9
!-mult
integer, parameter :: m_tilt=7, m_lrad=8
!-sol
integer, parameter :: so_lrad=7, so_ks=8, so_ksi=9
!-rfc
integer, parameter :: r_volt=7, r_lag=8, r_freq=9, r_lagt=10
!-elsep
integer, parameter :: e_tilt=7, e_ex=8, e_ey=9
!-hkick
integer, parameter :: h_tilt=7, h_lrad=8, h_kick=9, h_hkick=10, h_chkick=11
!-vkick
integer, parameter :: v_tilt=7, v_lrad=8, v_kick=9, v_vkick=10, v_cvkick=11
!-kick
integer, parameter :: k_tilt=7, k_lrad=8, k_hkick=9, k_vkick=10, k_chkick=11, k_cvkick=12
end module twiss_elpfi
module emitfi
implicit none
public
double precision, save :: qx=0.d0, qy=0.d0, qs=0.d0, cg=0.d0, sum(3)=0.d0, sumu0=0.d0
end module emitfi
module twtrrfi
implicit none
public
!---- maxmul is the maximum multipole order both in twiss and trrun
integer, parameter :: maxmul=20, maxferr=50, maxnaper=100
end module twtrrfi
module twtapering
implicit none
public
!---- for tapering
integer :: totrfcav =0, orderrun=0
double precision :: endpt=0
end module twtapering
module ibsdbfi
implicit none
public
integer :: bunch=0
double precision :: circ=0.d0, arad=0.d0, freq0=0.d0, alpha=0.d0
double precision :: amass=0.d0, charge=0.d0, en0=0.d0, gammas=0.d0, gamma=0.d0
double precision :: ex=0.d0, ey=0.d0, et=0.d0, sigt=0.d0, sige=0.d0, sigx=0.d0, sigy=0.d0
double precision :: betas=0.d0, beta=0.d0
double precision :: parnum=0.d0, currnt=0.d0, alfa=0.d0
end module ibsdbfi
module matchfi
implicit none
public
integer :: icovar=0, ilevel=0
double precision :: edm=0.d0, fmin=0.d0
end module matchfi
module name_lenfi
implicit none
public
integer, parameter :: name_len=48
end module name_lenfi
module warncolim
implicit none
public
integer :: warnede = 0
integer :: warnedr = 0
end module warncolim
module physconsfi
implicit none
public
double precision :: amu0=0.d0,elamda=0.d0,emass=0.d0,eps0=0.d0,erad=0.d0,&
hbar=0.d0,plamda=0.d0,pmass=0.d0,prad=0.d0,qelect=0.d0,mumass=0.d0
end module physconsfi
module touschekfi
implicit none
public
integer :: bunch=0
double precision :: circ=0.d0, arad=0.d0, freq0=0.d0, amass=0.d0
double precision :: charge=0.d0, en0=0.d0, gammas=0.d0, gamma=0.d0, deltap=0.d0
double precision :: ex=0.d0, ey=0.d0, et=0.d0, sigt=0.d0, sige=0.d0
double precision :: betas=0.d0, beta=0.d0, parnum=0.d0, currnt=0.d0, alfa=0.d0
double precision :: um1=0.d0, fb1=0.d0, fb2=0.d0
end module touschekfi
module trackfi
implicit none
public
double precision, save :: arad=0.d0, betas=0.d0, beti=0.d0, gammas=0.d0, dtbyds=0.d0
double precision, save :: bet0=0.d0, bet0i=0.d0
double precision :: deltas=0.d0, t_max=1.d20, pt_max=1.d20
logical :: radiate=.false., damp=.false., quantum=.false., fsecarb=.false., thin_cf=.false.
end module trackfi
module time_varfi
use twtrrfi
use name_lenfi
implicit none
public
logical time_var_m, time_var_p, time_var_c
integer, parameter :: n_time_var = 10000
integer, save :: time_var_m_cnt, time_var_p_cnt, time_var_c_cnt
integer, save :: time_var_m_lnt, time_var_p_lnt, time_var_c_lnt, trrun_nt
double precision, save :: myfield(n_time_var,2,0:maxmul), phase_tromb(n_time_var,36), cav_volt(n_time_var)
double precision, save :: time_var_m_ind(n_time_var), time_var_p_ind(n_time_var), time_var_c_ind(n_time_var)
double precision, save :: time_var_m_nt(n_time_var), time_var_p_nt(n_time_var), time_var_c_nt(n_time_var)
character(len=name_len), save :: time_var_m_ch(n_time_var), time_var_p_ch(n_time_var), time_var_c_ch(n_time_var)
end module time_varfi
module spch_bbfi
use name_lenfi
use bbfi
implicit none
public
logical :: lost_in_turn = .false., is_lost = .false.
integer, save :: i_turn, N_macro_surv, N_for_I, N_spch, i_spch
integer, parameter :: N_macro_max=16000
double precision, save :: Ex_rms, Ey_rms, sigma_p, sigma_z
double precision, save :: Ix_array(N_macro_max), Iy_array(N_macro_max)
double precision, save :: dpi_array(N_macro_max), z_part_array(N_macro_max)
double precision :: alpha, I_div_E_sum_max
! parameter(alpha=0.0, I_div_E_sum_max=7.0)
double precision, save :: betx_bb(bbd_max), bety_bb(bbd_max), &
alfx_bb(bbd_max), alfy_bb(bbd_max), &
gamx_bb(bbd_max), gamy_bb(bbd_max), &
dx_bb(bbd_max), dy_bb(bbd_max)
double precision,save :: rat_bb_n_ions=1d0
double precision, save :: sigma_t=0.d0, mean_t=0.d0 ! calculate and transfer to BB
character(len=name_len), save :: spch_bb_name(bbd_max)
end module spch_bbfi
module plotfi
implicit none
public
!--- m_adble is the number of different types of elements
integer, parameter :: mtype = 50, m_adble = 20
!--- mcnam adjusted to NAME_L
integer, parameter :: mcnam = 48, maxpnt = 500
!--- szcompar is the size of the arrays returned by the routine comm_para
integer, parameter :: szcompar = 100
!--- szchara is the size of the character strings char_a & version in
!--- the routine pesopt
integer, parameter :: szchara = 400
!--- character sizes:
! MLSIZE label character height
! MTSIZE text - " -
! MASIZE annotation - " -
integer, parameter :: mlsize = 13 ,mtsize = 13, masize = 20
!--- parameters used in the routine pegacn in file plot.F
integer, parameter :: mposx = 8, mposy = 3, mpost = mposx * mposy
!--- parameters used in the routine peschm in file plot.F
integer, parameter :: mobj = 14, msize = 88
integer, parameter :: mtitl = 128, mxlabl = 300 !hbu mxlabl = 160 increased to 300 as required by plot.f90
integer, parameter :: mnvar = 74, mxdep = 2
integer, parameter :: mqadd = 100000
integer, parameter :: mntmax = 20, mksmax = 10
integer, parameter :: mplred = 46, mplout = 47
integer, parameter :: maxseql = 150000, mtwcol = 46, mpparm = 10
integer, parameter :: mxcurv = 10, mopt = 60, mfile = 120, marg = 60
integer, parameter :: maxarg = 1000, mxdp = 25, mxplot = 100
integer, parameter :: mintpl = 18
!--- Definition of common / peaddi /
!--- itbv set in routine pesopt, used in routines pemima, peplot
!--- and pesopt.
!--- nivvar set in routine pesopt, used in routines pefill, peintp,
!--- pemima, peplot and pesopt.
!--- nelmach set in routine pefill, used in routines pefill, peplot.
!--- numax set in routine pemima, used in routines pemima, peplot.
!--- interf set in routine pesopt, used in routines pecurv, pefill.
!--- noline set in routine pesopt, used in routines pefill, pesopt.
!--- nqval set in routine pefill and peintp, used in routines pefill,
!--- peintp, pemima and peplot.
!--- nvvar set in routine pesopt and pemima, used in routine pemima.
!--- nrrang set in routine pefill, used in routine pesopt and pefill.
!--- proc_flag set in routine pesopt, used in routine pefill, peintp
!--- and pesopt.
!--- ipparm set in routine peintp and pesopt, used in routine peplot
!--- and pesopt.
!--- naxref set in routine pemima and pesopt, used in routine pemima
!--- and pesopt.
!--- ieltyp set in routine pefill, used in routine psplot.
integer, save :: itbv=0, nivvar=0, nelmach=0, numax=0, interf=0, noline=0
integer, save :: nqval(mxcurv)=0, nvvar(4)=0, nrrang(2)=0
integer, save :: proc_flag(2,mxcurv)=0, ipparm(mpparm,mxcurv)=0
integer, save :: naxref(mxcurv)=0, ieltyp(maxseql)=0
!--- Definition of common / peaddr /
!--- qascl set in routine pesopt, used in routine peplot.
!--- qlscl set in routine pesopt, used in routine peplot.
!--- qsscl set in routine pesopt, used in routine peplot.
!--- qtscl set in routine pesopt, used in routine peplot.
!--- hrange set in routine pesopt, used in routines pefill, peplot.
!--- vrange set in routine pesopt, used in routine peplot.
!--- hmima set in routines pesopt and pemima,
!--- used in routines peplot, pesopt and pemima.
!--- vmima set in routines pesopt and pemima,
!--- used in routines peplot and pemima.
!--- qhval set in routines pefill and peintp,
!--- used in routines peplot, pefill and pemima.
!--- qvval set in routines pefill and peintp,
!--- used in routines peplot, pefill and pemima.
!--- estart set in routine pefill, and peintp,
!--- used in routines peplot and pefill.
!--- eend set in routine pefill, used in routine peplot.
real, save :: qascl=0., qlscl=0., qsscl=0., qtscl=0.
real, save :: hrange(2)=0., vrange(2,4)=0., hmima(2)=0., vmima(2,4)=0.
real, save :: qhval(maxseql,mxcurv)=0., qvval(maxseql,mxcurv)=0.
real, save :: estart(maxseql)=0., eend(maxseql)=0.
!--- Definition of common / peaddc /
!--- horname set in routine pesopt,
!--- used in routines pefill, peplot and pesopt.
!--- tabname set in routine pesopt,
!--- used in routines pefill, peintp, pelfill and pesopt.
!--- toptitle set in routine pesopt, used in routine peplot.
!--- plfnam set in routine plginit, used in routines plotit and plginit.
!--- axlabel set in routine pemima, used in routine peplot.
!--- sname set in routine pesopt,
!--- used in routines pefill and pesopt.
!--- slabl set in routine pesplit,
!--- used in routines peplot, pemima and pesopt.
character(len=mfile), save :: plfnam=' '
character(len=mcnam), save :: horname=' ', tabname=' ', sname(mxcurv)=' ', slabl(mxcurv)=' '
character(len=mxlabl), save :: axlabel(4)=' '
character(len=mtitl), save :: toptitle=' '
end module plotfi
module plot_bfi
implicit none
public
!--- Definition of common / peotcl /
!--- fpmach set in routines pesopt and pefill, used in routine peplot
!--- ddp_flag set in routine pefill, used in routine peplot
!--- ptc_flag set in routines pesopt, used in routine pefill
logical, save :: fpmach=.false., dpp_flag=.false., ptc_flag=.false.
end module plot_bfi
module resindexfi
implicit none
public
integer, parameter :: mnres=1000, mymorder=20
end module resindexfi
module gxx11_common
implicit none
public
real, parameter :: toleps=1.e-5, versio=1.50
integer :: normt
integer, parameter :: madim1=500, madim2=100, maxset=20, mconid=7, merrun=10
integer, parameter :: metaun=11, miunit=5, mmetat=4, mounit=6, mpaxs=23, mpcurv=10
integer, parameter :: mtermt=101, mtick=10, mtmeta=2, mtterm=1, mtfont=12
integer, parameter :: mxaxs=4, mxpix=1000, mxsize=27, myaxs=4, mypix=1000, mysize=19
integer, parameter :: mnormt=2, mx11pr=10, mx11tf=10, mxxpix=1200, mxypix=1000
integer, parameter :: mcolor=6, mpspro=8, meppro=8, mdict=24, mlpro=68, mpsep=3, mepep=2
integer, parameter :: mhead=4, mline=72, msfact=4, mlbb1=17, mlbb2=30, mubb1=573, mubb2=790
integer, parameter :: mwid1 = mubb1 - mlbb1, mwid2 = mubb2 - mlbb2
integer :: itermt=0, interm=0, inmeta=0, ierrun=0, imetun=0, inunit=0, iounit=0, ipage=0
integer :: isfflg=0, isqflg=0, iwtflg=0, iclflg=0, inormt=0, ipseps=0, iepsop=0, itseop=0
integer :: iepscf=0, imetps=0, ipctct=0, iczebr=0, idinit=0, ipstyp=0, iclear=0, istotx=0
integer :: lmpict=0, ltermt=0, lnterm=0, lnmeta=0, lerrun=0, lmetun=0, lnunit=0, lounit=0
integer :: lsfflg=0, lsqflg=0, lwtflg=0, lclflg=0, lnormt=0, lmetax=0, lmetay=0, lmetnm=0
integer :: lerrnm=0, ldefnl=0, lerrop=0, lmetop=0, ltotin=0, lacttm=0, lpseps=0, lundef=0
integer :: lttime=0, ldinit=0, ltseop=0
integer :: ixapar(mpaxs,mxaxs)=0, iyapar(mpaxs,myaxs)=0, icvpar(mpcurv ,maxset)=0
integer :: nxpix=0, nypix=0, lxpix=0, lypix=0, icucol=0, iorips=0
integer :: iutlps=0, ibbox(4)=0, ix11pr(mx11pr)=0, ix11tf(mx11tf)=0, ix11op(mx11tf)=0
real :: fxpix=0., fypix=0., rx11pr(mx11pr)=0., rgbcol(3,mcolor)=0.
real :: xmetaf=0., ymetaf=0., xsterm=0., ysterm=0., wfact=0., wttime=0., wxfact=0., wyfact=0.
real :: vpfacx=0., vpfacy=0., vptdef(4)=0., vploc(4)=0., actwnd(4)=0.
real :: rangex(2,mxaxs)=0., rangey(2 ,myaxs)=0.
real :: cvwnwd(4,maxset)=0., axwndx(2,maxset), axwndy(2,maxset)=0.
real :: xp(madim2+1)=0., xvp(madim2+1)=0, yp(madim2+1)=0., yvp(madim2+1)=0
real :: p(madim1,2)=0., s(madim1)=0., yy1d(madim1,2)=0., yy2d(madim1,2)=0.
character(len=256) :: smetnm=" ", serrnm=" ", spsnam=" "
character(len=300) :: sxtext(mxaxs)=" ", sytext(myaxs)=" "
character(len=20) :: sxform(mxaxs)=" ", syform(myaxs)=" ", stortx=" "
character(len=1) :: sdefnl=" "
character(len=16) :: colour(mcolor)=" "
character(len=60) :: pshead(mhead)=" "
character(len=maxset) :: splotc=" "
end module gxx11_common
module gxx11_aux
implicit none
public
!
character(len=100) :: strloc
integer, save, dimension(14) :: ivals=(/ 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 1, 1, 0 /)
! ivals(1) marker type
! (2) fill area interior style
! (3) horizontal text alignment
! (4) vertical text alignment
! (5) text font
! (6) text precision
! (7) marker colour index
! (8) metafile status (0 closed, 1 open)
! (9) text colour index
! (10) free
! (11) polyline colour index
! (12) polyline style
! (13) current normalisation transformation number
! (14) last call type: 0 undef., 1 line, 2 text, 3 marker
real, save, dimension(14) :: rvals=(/ 0., 1., 0.01, 0., 1., 0., 1., 0., 1., 0., 1., 1., 1., 1. /)
! rvals(1-2) chup vector
! 3 character height
! 4-7 window
! 8-11 viewport
! 12 character expansion factor
! 13 line width scale factor
! 14 marker scale factor
end module gxx11_aux
module fasterror
implicit none
logical :: fasterror_on = .false.
integer :: kstep
integer, parameter :: nx=490, ny=470, idim=(nx+2)*(ny+2)
double precision :: hrecip, wtimag(idim), wtreal(idim)
end module fasterror
! SUBROUTINES
subroutine fort_info(t1, t2)
implicit none
character(*) :: t1, t2
integer, external :: get_option
if (get_option('info ') .ne. 0 .and. get_option('warn ') .ne. 0) &
print '(a,1x,a,1x,a)', '++++++ info:', t1, t2
end subroutine fort_info
subroutine fort_warn(t1, t2)
implicit none
!----------------------------------------------------------------------*
! Purpose: *
! Print warning message. *
! Input: *
! T1 (char) usually calling routine name or feature *
! T2 (char) Message. *
!----------------------------------------------------------------------*
character(*) :: t1, t2
integer, external :: get_option
if (get_option('warn ') .ne. 0) then
print '(a,1x,a,1x,a)', '++++++ warning:', t1, t2
call augmentfwarn()
endif
end subroutine fort_warn
subroutine fort_fail(t1,t2)
implicit none
!----------------------------------------------------------------------*
! Purpose: *
! Print fatal error message. *
! Input: *
! T1 (char) usually calling routine name or feature *
! T2 (char) Message *
!----------------------------------------------------------------------*
character(*) :: t1, t2
integer, external :: get_option
print *,' '
print *, '+-+-+- fatal: ',t1,t2
print *,' '
if (get_option('no_fatal_stop ') .eq. 0) stop 1
end subroutine fort_fail
subroutine aafail(rout,text)
implicit none
character(*) :: rout, text
call fort_fail(rout,text)
end subroutine aafail
logical function m66sta(amat)
use math_constfi , only : one
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Check effect of a matrix on momentum.
! Input:
! AMAT(6,6) (real) Input matrix.
! Result:
! .TRUE. For static case (constant p).
! .FALSE. For dynamic case (variable p).
!----------------------------------------------------------------------*
double precision, intent(IN) :: amat(6,6)
integer :: j
double precision, parameter :: tol=1d-12
m66sta = abs(amat(6,6) - one) .le. tol
do j = 1, 5
m66sta = m66sta .and. abs(amat(6,j)) .le. tol
enddo
end function m66sta
subroutine dcopy(in,out,n)
implicit none
!----------------------------------------------------------------------*
! Purpose: *
! Copy arrays. *
! Input: *
! in (double) array to be copied. *
! n (integer) array length. *
! Output: *
! out (double) target array. *
!----------------------------------------------------------------------*
integer, intent(IN) :: n
double precision, intent(IN) :: in(*)
double precision, intent(OUT) :: out(*)
OUT(1:n) = IN(1:n)
end subroutine dcopy
subroutine solver(augmat,ndim,mdim,irank)
use math_constfi, only : zero
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Solve the linear equation A * X = B.
! Input:
! AUGMAT(n,n+m) A(n,n), augmented by B(n,m).
! NDIM, MDIM n, m.
! Output:
! AUGMAT(n,n+m) Identity(n,n), augmented by X(n,m).
! IRANK Rank of A.
!----------------------------------------------------------------------*
integer, intent(IN) :: ndim, mdim
integer, intent(OUT) :: irank
double precision, intent(IN OUT) :: augmat(ndim,ndim+mdim)
double precision :: h, pivot
integer :: ic, ip, ir, it, nc, nr
nr = ndim
nc = ndim + mdim
irank = 0
do it = 1, nr
pivot = zero
ip = 0
do ir = it, nr
if (abs(augmat(ir,it)) .ge. abs(pivot)) then
pivot = augmat(ir,it)
ip = ir
endif
enddo
if (pivot .eq. zero) return
irank = it
do ic = 1, nc
augmat(ip,ic) = augmat(ip,ic) / pivot
enddo
if (ip .ne. it) then
do ic = 1, nc
h = augmat(ip,ic)
augmat(ip,ic) = augmat(it,ic)
augmat(it,ic) = h
enddo
endif
do ir = 1, nr
if (ir .ne. it) then
h = augmat(ir,it)
do ic = 1, nc
augmat(ir,ic) = augmat(ir,ic) - h * augmat(it,ic)
enddo
endif
enddo
enddo
irank = ndim
end subroutine solver
subroutine symsol(a,n,eflag,work_1,work_2,work_3)
use math_constfi, only : zero, one
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Invert symmetric matrix.
! Input:
! A(*,*) (real) Matrix to be inverted.
! N (integer) Actual size of A.
! Output:
! A(*,*) (real) Inverted matrix.
! EFLAG (logical) Error flag.
!----------------------------------------------------------------------*
integer, intent(IN) :: n
double precision, intent(IN OUT) :: a(n,n)
logical, intent(OUT) :: eflag
integer :: i, j, k
double precision :: si, work_1(n), work_2(n), work_3(n)
!---- Scale upper triangle.
eflag = .true.
do i = 1, n
si = a(i,i)
if (si .le. zero) return
work_1(i) = one / sqrt(si)
enddo
do i = 1, n
do j = i, n
a(i,j) = a(i,j) * work_1(i) * work_1(j)
enddo
enddo
!---- Invert upper triangle.
do i = 1, n
if (a(i,i) .eq. zero) return
work_2(i) = one
work_3(i) = one / a(i,i)
a(i,i) = zero
do j = 1, n
if (j .lt. i) then
work_2(j) = a(j,i)
work_3(j) = work_2(j) * work_3(i)
a(j,i) = zero
else if (j .gt. i) then
work_2(j) = a(i,j)
work_3(j) = - work_2(j) * work_3(i)
a(i,j) = zero
endif
enddo
do j = 1, n
do k = j, n
a(j,k) = a(j,k) + work_2(j) * work_3(k)
enddo
enddo
enddo
!---- Rescale upper triangle and symmetrize.
do i = 1, n
do j = i, n
a(i,j) = a(i,j) * work_1(i) * work_1(j)
a(j,i) = a(i,j)
enddo
enddo
eflag = .false.
end subroutine symsol
subroutine symeig(a,nd,n,eigen,nval,work)