V3FIT
mapg_mod.f
1  MODULE mapg_mod
2  USE precision
3  IMPLICIT NONE
4 c ===== DIMENSIONal parameters =====
5  INTEGER, PARAMETER :: npsi=513, nthet=257
6 !npsi !SIZE of mapped psi mesh
7 !nthet !SIZE of mapped theta mesh
8 ! these are not related to the gfile DIMENSIONs which are ALLOCATED
9 c ===== DIMENSIONal parameters =====
10  INTEGER, PARAMETER :: kpsi=npsi, kthet=nthet, kv=kthet+2
11 c
12  INTEGER :: nxd
13  INTEGER :: nzd
14  INTEGER :: nxzd
15  INTEGER :: nh2
16  INTEGER :: nwk
17  INTEGER :: kbnd
18  INTEGER :: klim
19  parameter(kbnd=300,klim=300)
20 c ===== i/o channels =====
21  INTEGER :: ninbal !io_unit for inbal
22  INTEGER :: nterm !io_unit for terminal
23  INTEGER :: noutbal !io_unit for outbal
24  INTEGER :: ndskbal !io_unit for dskbal
25  INTEGER :: neqdsk=0 !io_unit for g-eqdsk
26  CHARACTER*40 filename !name of eqdsk or dskbal
27 c ===== input parameters for equilibrium data =====
28  LOGICAL READeqdsk !flag for toq equilibrium
29  INTEGER :: npfit !threshhold pts for using furpl
30  REAL(rprec) alpsi !flux prop. psic^alpsi
31  INTEGER :: rotate !=1 for rotation to READ eqdsk correctly
32  REAL(rprec) percenflux !outermost flux surface is
33  !psiv(npsi)=psiaxis+(psilim-psiaxis)*percenflux
34  CHARACTER*6 contour
35  REAL(rprec) epsarc
36  REAL(rprec) pi !3.14159...
37 
38 c ===== geqdsk variabls READ in for mapper =====
39  REAL(rprec), DIMENSION(:), ALLOCATABLE :: xgrid !x array
40  REAL(rprec), DIMENSION(:), ALLOCATABLE :: zgrid !z array
41  REAL(rprec) :: xaxis !x of mag axis
42  REAL(rprec) :: zaxis !z of mag axis
43  REAL(rprec) :: psiaxis !psi at mag axis
44  REAL(rprec) :: psilim !psi at limiter
45  REAL(rprec) :: dx !x(2)-x(1)
46  REAL(rprec) :: dz !z(2)-z(1)
47  REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: psixz !complete psi array
48  REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: bpsq !calculated in READeqdsk
49  REAL(rprec), DIMENSION(:), ALLOCATABLE :: sp !pressure on equally spaced psi
50  REAL(rprec), DIMENSION(:), ALLOCATABLE :: spp !pprime on equally spaced psi
51  REAL(rprec), DIMENSION(:), ALLOCATABLE :: sf !f on equally spaced psi
52  REAL(rprec), DIMENSION(:), ALLOCATABLE :: sffp !ffprime on equally spaced psi
53  REAL(rprec), DIMENSION(:), ALLOCATABLE :: qpsi !qpsi on equally spaced psi
54  REAL(rprec), DIMENSION(:), ALLOCATABLE :: xbndry !x position of boundary points
55  REAL(rprec), DIMENSION(:), ALLOCATABLE :: zbndry !z position of boundary points
56  REAL(rprec), DIMENSION(:), ALLOCATABLE :: xlim !x position of limiter points
57  REAL(rprec), DIMENSION(:), ALLOCATABLE :: zlim !z position of limiter points
58  REAL(rprec), DIMENSION(:), ALLOCATABLE :: pressw !see Lang's defn for press with rotation
59  REAL(rprec), DIMENSION(:), ALLOCATABLE :: pwprim !see Lang's defn for press with rotation
60  REAL(rprec), DIMENSION(:), ALLOCATABLE :: rho0 !see Lang's defn for press with rotation
61  REAL(rprec), DIMENSION(:), ALLOCATABLE :: rho0p !d(rho0)/d(psi)
62  REAL(rprec) rvtor !reference r for rotation
63  INTEGER nbndry !number of boundary points
64  INTEGER nlim !number of limiter points
65  INTEGER kvtor
66  INTEGER nmass
67  INTEGER nx !SIZE of x mesh
68  INTEGER nz !SIZE of z mesh
69 c ===== variables READ in from dskbal or obtained from mapper=====
70  REAL(rprec) psic(kpsi) !the psi coordinates
71  REAL(rprec) psiv(kpsi) !the REAL poloidal flux array (a.k.a. chi)
72  REAL(rprec) pprime(kpsi) !pprime
73  REAL(rprec) fval(kpsi) !this is f as in Btor=f/R
74  REAL(rprec) ffprime(kpsi) !this is ff'
75  REAL(rprec) chipsi(kpsi) !d(psiv)/d(psic)
76  REAL(rprec) qsfin(kpsi) !the safety factor from input
77  REAL(rprec) xs(kpsi,kthet) !R-coordinate of pts. on psiv contour
78  REAL(rprec) zs(kpsi,kthet) !Z-coordinate
79  REAL(rprec) bps(kpsi,kthet) !bp in flux coordinates
80  REAL(rprec) arcsur(kpsi,kthet) !mapped arc LENgths
81  REAL(rprec) arcrad(kpsi,kthet)
82  REAL(rprec) press(kpsi)
83  REAL(rprec) pw(kpsi)
84  REAL(rprec) pwp(kpsi)
85  REAL(rprec) rho(kpsi)
86  REAL(rprec) rhop(kpsi)
87  REAL(rprec), DIMENSION(:,:,:), ALLOCATABLE :: csplpsi
88  REAL(rprec) dthe !spacing between theta points
89  REAL(rprec) dpsi !spacing between psic surfaces
90  REAL(rprec) jtor(kpsi,kthet)
91  REAL(rprec) eikon(kpsi,kthet)
92  REAL(rprec) qsf(kpsi)
93  REAL(rprec) thec(kthet)
94  REAL(rprec) vprime(kpsi)
95  REAL(rprec) volume(kpsi), wbav(kpsi), tflx(kpsi)
96  REAL(rprec) bsqav(kpsi)
97  REAL(rprec) itor(kpsi)
98  REAL(rprec) jacob(kpsi,kthet)
99  REAL(rprec) jovr(kpsi), iprime(kpsi)
100  REAL(rprec) kappapav(kpsi)
101  REAL(rprec) fracg(kpsi)
102  INTEGER iphi
103  CONTAINS
104 
105  REAL FUNCTION trap(n,x,y)
106  INTEGER, INTENT(IN) :: n
107  real*8, INTENT(IN) :: x(n), y(n)
108  real*8 :: summ=0., half=0.5
109  INTEGER :: j
110  summ=0.
111  DO j=2,n
112  summ=summ+half*(y(j)+y(j-1))*(x(j)-x(j-1))
113  ENDdo
114  trap=summ
115  END FUNCTION trap
116 
117  REAL FUNCTION axisv(x,y,n)
118  IMPLICIT NONE
119  INTEGER, INTENT(in) :: n
120  REAL(rprec), INTENT(in) :: x(n), y(n)
121  axisv=y(2)+(y(3)-y(2))*(x(2)-x(1))/(x(3)-x(2))
122  END FUNCTION axisv
123 
124  END MODULE mapg_mod