1 SUBROUTINE harfun(jacfac, hiota, gpsi, ipsi, js, nznt, xlt,
2 1 xlz, xl, wt, wz, w, uboz, vboz, xjac)
10 REAL(rprec),
DIMENSION(*) :: hiota, gpsi, ipsi
11 REAL(rprec),
DIMENSION(nznt) ::
12 1 xl, xlt, xlz, w, wt, wz, uboz, vboz, xjac
16 REAL(rprec),
PARAMETER :: one = 1, zero = 0
20 REAL(rprec),
ALLOCATABLE,
DIMENSION(:) ::
21 1 bsupu, bsupv, psubu, psubv
22 REAL(rprec) :: dem, dem2, gpsi1, hiota1, ipsi1
47 ALLOCATE(bsupu(nznt), bsupv(nznt), psubu(nznt), psubv(nznt),
49 IF (istat .ne. 0) stop
'Allocation error in harfun!'
51 jacfac = gpsi(js) + hiota(js)*ipsi(js)
53 1 stop
'Boozer coordinate XFORM failed, jacfac = 0!'
56 hiota1 = hiota(js)*dem
59 vboz = dem*w - ipsi1*xl
60 uboz = xl + hiota(js)*vboz
61 psubv = dem*wz - ipsi1*xlz
62 psubu = dem*wt - ipsi1*xlt
64 bsupu = hiota(js) - xlz
69 xjac = bsupv*(1+psubv) + bsupu*psubu
73 IF (dem*dem2 .le. zero) print *,
74 1
' Jacobian xjac changed sign in harfun in xbooz_xform'
76 DEALLOCATE(bsupu, bsupv, psubu, psubv, stat=istat)
80 SUBROUTINE modbooz(bmnc, bmns, bmod, xmb, xnb,
81 1 u_b, v_b, cosmm, sinmm, cosnn, sinnn,
82 2 mnmax, mboz, nboz, nfp, lasym)
88 INTEGER :: mnmax, mboz, nboz, nfp
89 REAL(rprec),
DIMENSION(mnmax),
INTENT(in) ::
91 REAL(rprec),
DIMENSION(mnmax),
INTENT(in) :: xmb, xnb
92 REAL(rprec),
DIMENSION(4),
INTENT(in) :: u_b, v_b
93 REAL(rprec),
DIMENSION(4),
INTENT(out) :: bmod
94 REAL(rprec),
DIMENSION(0:mboz) :: cosmm, sinmm
95 REAL(rprec),
DIMENSION(0:nboz) :: cosnn, sinnn
96 LOGICAL,
INTENT(in) :: lasym
100 REAL(rprec),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
104 INTEGER :: mn, m, n, angles
105 REAL(rprec) :: cost, sint
110 angle_loop:
DO angles=1,4
114 cosmm(1) = cos(u_b(angles))
115 sinmm(1) = sin(u_b(angles))
119 IF (nboz .ge. 1)
THEN
120 cosnn(1) = cos(v_b(angles)*nfp)
121 sinnn(1) = sin(v_b(angles)*nfp)
125 cosmm(m) = cosmm(m-1)*cosmm(1)
126 1 - sinmm(m-1)*sinmm(1)
127 sinmm(m) = sinmm(m-1)*cosmm(1)
128 1 + cosmm(m-1)*sinmm(1)
132 cosnn(n) = cosnn(n-1)*cosnn(1)
133 1 - sinnn(n-1)*sinnn(1)
134 sinnn(n) = sinnn(n-1)*cosnn(1)
135 1 + cosnn(n-1)*sinnn(1)
140 n = nint(abs(xnb(mn)))/nfp
141 sgn = sign(one,xnb(mn))
142 cost = cosmm(m)*cosnn(n)
143 1 + sinmm(m)*sinnn(n)*sgn
144 bmod(angles) = bmod(angles) + bmnc(mn)*cost
146 sint = sinmm(m)*cosnn(n)
147 1 - cosmm(m)*sinnn(n)*sgn
148 bmod(angles) = bmod(angles) + bmns(mn)*sint
154 END SUBROUTINE modbooz