19SUBROUTINE jxbforce(bsupu, bsupv, bsubu, bsubv, bsubsh, &
21 gsqrt, bsq, itheta, izeta, brho, ier_flag)
25 USE realspace,
ONLY:
shalf,
wint,
guu,
guv,
gvv,
r1,
ru,
rv,
zu,
zv,
phip
32 REAL(rprec),
DIMENSION(ns,nznt),
INTENT(in) :: bsupu
33 REAL(rprec),
DIMENSION(ns,nznt),
INTENT(in) :: bsupv
34 REAL(rprec),
DIMENSION(ns,nznt,0:1),
TARGET,
INTENT(inout) :: bsubu
35 REAL(rprec),
DIMENSION(ns,nznt,0:1),
TARGET,
INTENT(inout) :: bsubv
36 REAL(rprec),
DIMENSION(ns,nznt),
INTENT(in) :: bsubsh
37 REAL(rprec),
DIMENSION(ns,nznt,0:1) :: bsubsu
38 REAL(rprec),
DIMENSION(ns,nznt,0:1) :: bsubsv
39 REAL(rprec),
DIMENSION(ns,nznt),
INTENT(in) :: gsqrt
40 REAL(rprec),
DIMENSION(ns,nznt),
INTENT(in) :: bsq
41 REAL(rprec),
DIMENSION(ns,nznt),
INTENT(out) :: itheta
42 REAL(rprec),
DIMENSION(ns,nznt),
INTENT(out) :: izeta
43 REAL(rprec),
DIMENSION(ns,nznt),
INTENT(out) :: brho
44 INTEGER,
INTENT(in) :: ier_flag
46 REAL(rprec),
DIMENSION(ns,nznt),
TARGET :: bsubs
49 LOGICAL,
PARAMETER :: lprint = .false.
51 INTEGER lk, lz, lt, k, m, js, j, n, injxbout, mparity, nznt1
52 INTEGER :: njxbout = jxbout0, info
54 REAL(rprec),
DIMENSION(:,:),
ALLOCATABLE :: bdotk, bsubuv, bsubvu
55 REAL(rprec),
DIMENSION(:,:,:,:),
ALLOCATABLE :: bsubsmn
56 REAL(rprec),
DIMENSION(:,:,:),
ALLOCATABLE :: brhomn, &
57 bsubs3, bsubv3, bsubu3, jxb_gradp, jcrossb, sqrtg3, &
58 bsupv3, bsupu3, jsups3, jsupv3, jsupu3, jdotb_sqrtg
60 REAL(rprec),
POINTER :: bs1(:), bu1(:,:), bv1(:,:)
62 REAL(rprec),
DIMENSION(:),
ALLOCATABLE :: kperpu, kperpv, &
63 sqgb2, sqrtg, kp2, jxb, jxb2, bsupu1, bsupv1, bsubu1, bsubv1, &
64 avforce, aminfor, amaxfor, toroidal_angle, phin, pprim, pprime
65 REAL(rprec),
DIMENSION(:,:),
ALLOCATABLE :: bsubua, bsubva
67 bsubsmn1, bsubsmn2, bsubvmn1, bsubvmn2, bsubumn1, bsubumn2, &
68 bsubsmn3, bsubsmn4, bsubvmn3, bsubvmn4, bsubumn3, bsubumn4, &
69 dnorm1, tcos1, tcos2, tsini1, tsini2, tcosi1, tcosi2, &
70 tcosm1, tcosm2, tcosn1, tcosn2, tsinm1, tsinm2, tsin1, tsin2, &
71 tsinn1, tsinn2, tjnorm, ovp, pnorm, brho00(ns)
72 REAL(rprec),
DIMENSION(:,:),
ALLOCATABLE :: bsubu_s, bsubu_a, bsubv_s, bsubv_a
73 REAL(rprec),
DIMENSION(:),
ALLOCATABLE :: bsubs_s, bsubs_a
74 CHARACTER(LEN=100) :: jxbout_file
75 CHARACTER(LEN=100) :: legend(13)
76 LOGICAL :: lprint_flag
78 CHARACTER(LEN=*),
PARAMETER :: &
79 vn_legend =
'legend', &
80 vn_radial_surfaces =
'radial_surfaces', &
81 vn_poloidal_grid_points =
'poloidal_grid_points', &
82 vn_toroidal_grid_points =
'toroidal_grid_points', &
86 vn_toroidal_angle =
'toroidal_angle', &
87 vn_avforce =
'avforce', &
88 vn_jdotb =
'surf_av_jdotb', &
89 vn_sqg_bdotk =
'sqrt(g)*bdotk', &
90 vn_sqrtg =
'sqrt(g)', &
91 vn_bdotgradv =
'bdotgradv', &
92 vn_amaxfor =
'amaxfor', &
93 vn_aminfor =
'aminfor', &
94 vn_pprime =
'pprime', &
100 vn_jcrossb =
'jcrossb', &
101 vn_jxb_gradp =
'jxb_gradp', &
102 vn_bsubu =
'bsubu', &
103 vn_bsubv =
'bsubv', &
119 IF (lprint_flag)
THEN
120 jxbout_file =
'jxbout_'//trim(input_extension)//
'.nc'
122 CALL cdf_open(njxbout,jxbout_file,
'w',injxbout)
123 IF (injxbout .ne. 0)
THEN
124 print *,
' Error opening JXBOUT file in jxbforce'
128 legend(1) =
" S = normalized toroidal flux (0 - 1)"
130 legend(2) =
" U = VMEC poloidal angle (0 - 2*pi, FULL period)"
132 legend(2) =
" U = VMEC poloidal angle (0 - pi, HALF a period)"
134 legend(3) =
" V = VMEC (geometric) toroidal angle (0 - 2*pi)"
135 legend(4) =
" SQRT(g') = |SQRT(g-VMEC)| / VOL': Cylindrical-to-s,u,v Jacobian normed to volume derivative"
136 legend(5) =
" VOL = Int_s'=0,s Int_u Int_v |SQRT(g_VMEC)| : plasma volume enclosed by surface s'=s"
137 legend(6) =
" VOL' = d(VOL)/ds: differential volume element"
138 legend(7) =
" Es = SQRT(g') [grad(U) X grad(V)]: covariant radial unit vector (based on volume radial coordinate)"
139 legend(8) =
" BSUP{U,V} = B DOT GRAD{U,V}: contravariant components of B"
140 legend(9) =
" JSUP{U,V} = SQRT(g) J DOT GRAD{U,V}"
141 legend(10)=
" K X B = Es DOT [K X B]: covariant component of K X B force"
142 legend(11)=
" K * B = K DOT B * SQRT(g')"
143 legend(12)=
" p' = dp/d(VOL): pressure gradient (based on volume radial coordinate)"
144 legend(13)=
" <KSUP{U,V}> = Int_u Int_v [KSUP{U,V}]/dV/ds"
147 nznt1 = nzeta*ntheta2
148 ALLOCATE (avforce(ns),aminfor(ns),amaxfor(ns))
149 ALLOCATE (bdotk(ns,nznt), bsubuv(ns,nznt), &
150 bsubvu(ns,nznt), kperpu(nznt), kperpv(nznt), &
152 jxb(nznt), jxb2(nznt), bsupu1(nznt), &
153 bsubua(nznt1,0:1), bsubva(nznt1,0:1), &
154 bsupv1(nznt), bsubu1(nznt), bsubv1(nznt), &
156 bsubs_s(nznt), bsubs_a(nznt), sqrtg(nznt), &
157 bsubu_s(nznt1,0:1), bsubu_a(nznt1,0:1), &
158 bsubv_s(nznt1,0:1), bsubv_a(nznt1,0:1), stat=j)
159 IF (j .ne. 0) stop
'Allocation error in jxbforce'
168 radial:
DO js = 1, ns
171 IF (js.gt.1 .and. js.lt.ns)
THEN
172 bsubs(js,:) = cp5*(bsubsh(js,:) + bsubsh(js+1,:))
176 bsubu(js,:,1) = bsubu(js,:,1)/
shalf(js)
177 bsubv(js,:,1) = bsubv(js,:,1)/
shalf(js)
188 bsubs_s, bsubu_s, bsubv_s, &
189 bsubs_a, bsubu_a, bsubv_a)
192 bsubs_s(:) = bsubs(js,:)
193 bsubu_s = bsubu(js,:,:)
194 bsubv_s = bsubv(js,:,:)
204 IF (m .eq.
mnyq) dnorm1 = cp5*dnorm1
205 IF (n .eq.
nnyq .and. n.ne.0) dnorm1 = cp5*dnorm1
228 tsini1 = sinmui(j,m)*cosnv(k,n)*dnorm1
229 tsini2 = cosmui(j,m)*sinnv(k,n)*dnorm1
230 tcosi1 = cosmui(j,m)*cosnv(k,n)*dnorm1
231 tcosi2 = sinmui(j,m)*sinnv(k,n)*dnorm1
233 bsubsmn1 = bsubsmn1 + tsini1*bsubs_s(lk)
234 bsubsmn2 = bsubsmn2 + tsini2*bsubs_s(lk)
235 bsubvmn1 = bsubvmn1 + tcosi1*bsubv_s(lk, mparity)
236 bsubvmn2 = bsubvmn2 + tcosi2*bsubv_s(lk, mparity)
237 bsubumn1 = bsubumn1 + tcosi1*bsubu_s(lk, mparity)
238 bsubumn2 = bsubumn2 + tcosi2*bsubu_s(lk, mparity)
241 bsubsmn3 = bsubsmn3 + tcosi1*bsubs_a(lk)
242 bsubsmn4 = bsubsmn4 + tcosi2*bsubs_a(lk)
243 bsubvmn3 = bsubvmn3 + tsini1*bsubv_a(lk, mparity)
244 bsubvmn4 = bsubvmn4 + tsini2*bsubv_a(lk, mparity)
245 bsubumn3 = bsubumn3 + tsini1*bsubu_a(lk, mparity)
246 bsubumn4 = bsubumn4 + tsini2*bsubu_a(lk, mparity)
260 tcos1 = cosmu(j,m)*cosnv(k,n)
261 tcos2 = sinmu(j,m)*sinnv(k,n)
262 bsubua(lk,0) = bsubua(lk,0) + tcos1*bsubumn1 + tcos2*bsubumn2
263 bsubva(lk,0) = bsubva(lk,0) + tcos1*bsubvmn1 + tcos2*bsubvmn2
265 tcosm1 = cosmum(j,m)*cosnv(k,n)
266 tcosm2 = sinmum(j,m)*sinnv(k,n)
267 bsubsu(js,lk,0) = bsubsu(js,lk,0) + tcosm1*bsubsmn1 + tcosm2*bsubsmn2
269 tcosn1 = sinmu(j,m)*sinnvn(k,n)
270 tcosn2 = cosmu(j,m)*cosnvn(k,n)
271 bsubsv(js,lk,0) = bsubsv(js,lk,0) + tcosn1*bsubsmn1 + tcosn2*bsubsmn2
273 tsinm1 = sinmum(j,m)*cosnv(k,n)
274 tsinm2 = cosmum(j,m)*sinnv(k,n)
275 bsubvu(js,lk) = bsubvu(js,lk) + tsinm1*bsubvmn1 + tsinm2*bsubvmn2
277 tsinn1 = cosmu(j,m)*sinnvn(k,n)
278 tsinn2 = sinmu(j,m)*cosnvn(k,n)
279 bsubuv(js,lk) = bsubuv(js,lk) + tsinn1*bsubumn1 + tsinn2*bsubumn2
282 tsin1 = sinmu(j,m)*cosnv(k,n)
283 tsin2 = cosmu(j,m)*sinnv(k,n)
284 bsubua(lk,1) = bsubua(lk,1) + tsin1*bsubumn3 + tsin2*bsubumn4
285 bsubva(lk,1) = bsubva(lk,1) + tsin1*bsubvmn3 + tsin2*bsubvmn4
287 bsubsu(js,lk,1) = bsubsu(js,lk,1) + tsinm1*bsubsmn3 + tsinm2*bsubsmn4
288 bsubsv(js,lk,1) = bsubsv(js,lk,1) + tsinn1*bsubsmn3 + tsinn2*bsubsmn4
290 bsubvu(js,lk) = bsubvu(js,lk) + tcosm1*bsubvmn3 + tcosm2*bsubvmn4
291 bsubuv(js,lk) = bsubuv(js,lk) + tcosn1*bsubumn3 + tcosn2*bsubumn4
305 bsubsmn(js,m,n,0) = bsubsmn1
306 IF (n .gt. 0) bsubsmn(js,m,-n,0) = bsubsmn2
308 IF (.not.lasym) cycle
310 bsubsmn(js,m,n,1) = bsubsmn3
311 IF (n .gt. 0) bsubsmn(js,m,-n,0) = bsubsmn4
321 CALL fext_fft (bsubu(js,:,0), bsubua(:,0), bsubua(:,1))
322 CALL fext_fft (bsubv(js,:,0), bsubva(:,0), bsubva(:,1))
324 bsubu(js,:,0) = bsubua(:,0)
325 bsubv(js,:,0) = bsubva(:,0)
330 DEALLOCATE (bsubua, bsubva)
339 call add_real_3d(
"bsubu_e", ns, nzeta, ntheta3, bsubu(:,:,0))
340 call add_real_3d(
"bsubv_e", ns, nzeta, ntheta3, bsubv(:,:,0))
341 call add_real_3d(
"bsubu_o", ns, nzeta, ntheta3, bsubu(:,:,1))
342 call add_real_3d(
"bsubv_o", ns, nzeta, ntheta3, bsubv(:,:,1))
345 call add_real_3d(
"bsubsu_e", ns, nzeta, ntheta3, bsubsu(:,:,0))
346 call add_real_3d(
"bsubsu_o", ns, nzeta, ntheta3, bsubsu(:,:,1))
347 call add_real_3d(
"bsubsv_e", ns, nzeta, ntheta3, bsubsv(:,:,0))
348 call add_real_3d(
"bsubsv_o", ns, nzeta, ntheta3, bsubsv(:,:,1))
351 call add_real_3d(
"bsubuv", ns, nzeta, ntheta3, bsubuv)
352 call add_real_3d(
"bsubvu", ns, nzeta, ntheta3, bsubvu)
355 call add_real_4d(
"bsubsmn", 2, ns, mpol, 2*ntor+1, bsubsmn, &
356 order=(/ 4, 1, 2, 3 /))
377 correct_bsubs:
DO js = 2, ns-1
379 jxb(:) = cp5*(gsqrt(js,:) + gsqrt(js+1,:))
380 bsupu1(:) = cp5*(bsupu(js,:)*gsqrt(js,:) + bsupu(js+1,:)*gsqrt(js+1,:))
381 bsupv1(:) = cp5*(bsupv(js,:)*gsqrt(js,:) + bsupv(js+1,:)*gsqrt(js+1,:))
382 brho(js,:) =
ohs* ( bsupu1(:)*(bsubu(js+1,:,0) - bsubu(js,:,0)) &
383 + bsupv1(:)*(bsubv(js+1,:,0) - bsubv(js,:,0))) &
388 brho00(js) = sum(brho(js,:)*
wint(js:nrzt:ns))
389 brho(js,:) = brho(js,:) -
signgs*jxb(:)*brho00(js)/(cp5*(
vp(js) +
vp(js+1)))
394 IF (info .ne. 0)
THEN
395 print *,
'Error in GETBRHO: info= ',info,
' js= ',js
396 ELSE IF (lprint)
THEN
397 WRITE (33, *)
' JS = ', js
399 WRITE (33,
'(a)')
' M N BSUBS(old) BSUBS(new) BSUBS(old) BSUBS(new)'
401 WRITE (33,
'(a)')
' M N BSUBS(old) BSUBS(new)'
406 WRITE(33,1223) m, n, bsubsmn(js,m,n,0), brhomn(m,n,0), bsubsmn(js,m,n,1), brhomn(m,n,1)
408 WRITE(33,1224) m, n, bsubsmn(js,m,n,0), brhomn(m,n,0)
413 1223
FORMAT (i4,1x,i4,4(6x,1p,e12.3))
414 1224
FORMAT (i4,1x,i4,2(6x,1p,e12.3))
418 itheta(js,:) = bsubsu(js,:,0)
419 izeta(js,:) = bsubsv(js,:,0)
421 IF (info .ne. 0) cycle
426 IF (lasym) bsubs_a = 0
431 bsubsmn1 = brhomn(m,0,0)
434 bsubsmn1 = brhomn(m, n,0)
435 bsubsmn2 = brhomn(m,-n,0)
440 bsubsmn3 = brhomn(m,0,1)
443 bsubsmn3 = brhomn(m, n,1)
444 bsubsmn4 = brhomn(m,-n,1)
452 tsin1 = sinmu(j,m)*cosnv(k,n)
453 tsin2 = cosmu(j,m)*sinnv(k,n)
454 bsubs_s(lk) = bsubs_s(lk) + tsin1*bsubsmn1 + tsin2*bsubsmn2
456 tcosm1 = cosmum(j,m)*cosnv(k,n)
457 tcosm2 = sinmum(j,m)*sinnv(k,n)
458 bsubsu(js,lk,0) = bsubsu(js,lk,0) + tcosm1*bsubsmn1 + tcosm2*bsubsmn2
460 tcosn1 = sinmu(j,m)*sinnvn(k,n)
461 tcosn2 = cosmu(j,m)*cosnvn(k,n)
462 bsubsv(js,lk,0) = bsubsv(js,lk,0) + tcosn1*bsubsmn1 + tcosn2*bsubsmn2
465 tcos1 = cosmu(j,m)*cosnv(k,n)
466 tcos2 = sinmu(j,m)*sinnv(k,n)
467 bsubs_a(lk) = bsubs_a(lk) + tcos1*bsubsmn3 + tcos2*bsubsmn4
469 tsinm1 = sinmum(j,m)*cosnv(k,n)
470 tsinm2 = cosmum(j,m)*sinnv(k,n)
471 bsubsu(js,lk,1) = bsubsu(js,lk,1) + tsinm1*bsubsmn3 + tsinm2*bsubsmn4
473 tsinn1 = cosmu(j,m)*sinnvn(k,n)
474 tsinn2 = sinmu(j,m)*cosnvn(k,n)
475 bsubsv(js,lk,1) = bsubsv(js,lk,1) + tsinn1*bsubsmn3 + tsinn2*bsubsmn4
488 CALL fext_fft (bs1, bsubs_a, bsubs_s)
490 bsubs(js,:) = bsubs_s(:)
500 WRITE (33,
'(/,2a,/)')
'ANGLE INDEX B*grad(Bs) Frhs Fold'
501 check_fb:
DO js = 2, ns-1
502 bsupu1(:) = cp5*(bsupu(js,:)*gsqrt(js,:) + bsupu(js+1,:)*gsqrt(js+1,:))
503 bsupv1(:) = cp5*(bsupv(js,:)*gsqrt(js,:) + bsupv(js+1,:)*gsqrt(js+1,:))
504 kp2(:) = bsupu1(:)*bsubsu(js,:,0) + bsupv1(:)*bsubsv(js,:,0)
505 jxb(:) = bsupu1(:)*itheta(js,:) + bsupv1(:)*izeta(js,:)
507 WRITE (33,
'(/,a,i4)')
'JS = ',js
509 WRITE(33,1230) lk, brho(js,lk), kp2(lk), jxb(lk)
510 1230
FORMAT (i9,5x, 1p,3e14.4)
517 DEALLOCATE (bsubs_s, bsubs_a, bsubu_s, bsubu_a, bsubv_s, bsubv_a, stat=lk)
520 bsubs(1,:) = 2*bsubs(2,:) - bsubs(3,:)
522 bsubs(ns,:) = 2*bsubs(ns-1,:) - bsubs(ns-2,:)
556 bsubs3(ns,nzeta,ntheta3), bsubv3(ns,nzeta,ntheta3), &
557 bsubu3(ns,nzeta,ntheta3), jxb_gradp(ns,nzeta,ntheta3), &
558 jcrossb(ns,nzeta,ntheta3), bsupv3(ns,nzeta,ntheta3), &
559 bsupu3(ns,nzeta,ntheta3), jsups3(ns,nzeta,ntheta3), &
560 jsupv3(ns,nzeta,ntheta3), jsupu3(ns,nzeta,ntheta3), &
561 jdotb_sqrtg(ns,nzeta,ntheta3), sqrtg3(ns,nzeta,ntheta3), &
562 phin(ns), toroidal_angle(nzeta), stat=j)
585 ALLOCATE (pprime(nznt), pprim(ns),stat=j)
596 ovp = c2p0/(
vp(js+1) +
vp(js))/dnorm1
600 sqgb2(:nznt) = gsqrt(js+1,:nznt) * (bsq(js+1,:nznt)-
pres(js+1)) &
601 + gsqrt(js ,:nznt) * (bsq(js ,:nznt)-
pres(js ))
610 kperpu(:nznt) = cp5*(bsubv(js+1,:nznt,0) + bsubv(js,:nznt,0))*pprime(:)/sqgb2
611 kperpv(:nznt) =-cp5*(bsubu(js+1,:nznt,0) + bsubu(js,:nznt,0))*pprime(:)/sqgb2
613 kp2(:nznt)=cp5*( kperpu**2.0_dp * (
guu(js+1:nrzt:ns) +
guu(js:nrzt:ns)) &
614 + 2.0_dp*kperpu*kperpv * (
guv(js+1:nrzt:ns) +
guv(js:nrzt:ns)) &
615 + kperpv**2.0_dp * (
gvv(js+1:nrzt:ns) +
gvv(js:nrzt:ns)))
617 itheta(js,:nznt) = bsubsv(js,:nznt,0) -
ohs*(bsubv(js+1,:nznt,0) - bsubv(js,:nznt,0))
618 izeta(js,:nznt) = -bsubsu(js,:nznt,0) +
ohs*(bsubu(js+1,:nznt,0) - bsubu(js,:nznt,0))
620 itheta(js,:nznt) = itheta(js,:nznt)/mu0
621 izeta(js,:nznt) = izeta(js,:nznt)/mu0
624 sqrtg(:) = cp5*(gsqrt(js,:) + gsqrt(js+1,:))
626 bsupu1(:nznt) = cp5*(bsupu(js+1,:nznt)*gsqrt(js+1,:) + bsupu(js,:nznt)*gsqrt(js,:)) / sqrtg(:)
627 bsupv1(:nznt) = cp5*(bsupv(js+1,:nznt)*gsqrt(js+1,:) + bsupv(js,:nznt)*gsqrt(js,:)) / sqrtg(:)
629 bsubu1(:nznt) = cp5*(bsubu(js+1,:nznt,0) + bsubu(js,:nznt,0))
630 bsubv1(:nznt) = cp5*(bsubv(js+1,:nznt,0) + bsubv(js,:nznt,0))
632 jxb(:nznt) = ovp*(itheta(js,:nznt) * bsupv1(:nznt) - izeta(js,:nznt) * bsupu1(:nznt))
634 bdotk(js,:nznt) = itheta(js,:nznt) * bsubu1(:nznt) + izeta(js,:nznt) * bsubv1(:nznt)
636 pprime(:nznt) = ovp*pprime(:nznt)
637 pnorm = one/(abs(pprime(1)) + epsilon(pprime(1)))
639 amaxfor(js) = maxval(jxb(:nznt) - pprime(:))*pnorm
640 aminfor(js) = minval(jxb(:nznt) - pprime(:))*pnorm
642 amaxfor(js) = 100.0_dp*min(amaxfor(js), 9.999_dp)
643 aminfor(js) = 100.0_dp*max(aminfor(js),-9.999_dp)
645 avforce(js) = sum(
wint(js:nrzt:ns)*(jxb(:nznt) - pprime(:)))
647 pprim(js) = sum(
wint(js:nrzt:ns)*pprime(:))
652 jdotb(js) = dnorm1*tjnorm*sum(bdotk(js,:nznt)*
wint(js:nrzt:ns))
653 bdotb(js) = dnorm1*tjnorm*sum(sqgb2(:nznt) *
wint(js:nrzt:ns))
657 jpar2(js) = dnorm1*tjnorm*sum(bdotk(js,:nznt)**2 *
wint(js:nrzt:ns)/sqgb2(:nznt))
658 jperp2(js)= dnorm1*tjnorm*sum(kp2(:nznt)*
wint(js:nrzt:ns)*sqrtg(:nznt))
660 IF (lprint_flag)
THEN
661 phin(js) =
phi(js)/
phi(ns)
663 toroidal_angle(lz)=real(360*(lz-1),rprec)/nzeta
665 lk = lz + nzeta*(lt-1)
668 jsupu3(js,lz,lt) = ovp*itheta(js,lk)
669 jsupv3(js,lz,lt) = ovp*izeta(js,lk)
670 jsups3(js,lz,lt) = ovp*(bsubuv(js,lk) - bsubvu(js,lk))/mu0
672 bsupu3(js,lz,lt) = bsupu1(lk)
673 bsupv3(js,lz,lt) = bsupv1(lk)
675 jcrossb(js,lz,lt) = jxb(lk)
676 jxb_gradp(js,lz,lt) = (jxb(lk) - pprime(lk))
677 jdotb_sqrtg(js,lz,lt) = ovp*bdotk(js,lk)
679 sqrtg3(js,lz,lt) = sqrtg(lk)*ovp
681 bsubu3(js,lz,lt) = bsubu(js,lk,0)
682 bsubv3(js,lz,lt) = bsubv(js,lk,0)
683 bsubs3(js,lz,lt) = bsubs(js,lk)
691 izeta( 1,:nznt) = c2p0*izeta( 2,:nznt) - izeta( 3,:nznt)
692 izeta(ns,:nznt) = c2p0*izeta(ns-1,:nznt) - izeta(ns-2,:nznt)
711 pprim( 1) = 2.0_dp*pprim( 2) - pprim( 3)
712 pprim(ns) = 2.0_dp*pprim(ns-1) - pprim(ns-2)
717 call add_real_3d(
"itheta", ns, nzeta, ntheta3, itheta)
718 call add_real_3d(
"izeta", ns, nzeta, ntheta3, izeta)
719 call add_real_3d(
"bdotk", ns, nzeta, ntheta3, bdotk)
721 call add_real_1d(
"amaxfor", ns, amaxfor)
722 call add_real_1d(
"aminfor", ns, aminfor)
723 call add_real_1d(
"avforce", ns, avforce)
724 call add_real_1d(
"pprim", ns, pprim)
725 call add_real_1d(
"jdotb", ns,
jdotb)
726 call add_real_1d(
"bdotb", ns,
bdotb)
727 call add_real_1d(
"bdotgradv", ns,
bdotgradv)
728 call add_real_1d(
"jpar2", ns,
jpar2)
729 call add_real_1d(
"jperp2", ns,
jperp2)
731 call add_real_3d(
"jsupu3", ns, nzeta, ntheta3, jsupu3)
732 call add_real_3d(
"jsupv3", ns, nzeta, ntheta3, jsupv3)
733 call add_real_3d(
"jsups3", ns, nzeta, ntheta3, jsups3)
734 call add_real_3d(
"bsupu3", ns, nzeta, ntheta3, bsupu3)
735 call add_real_3d(
"bsupv3", ns, nzeta, ntheta3, bsupv3)
736 call add_real_3d(
"jcrossb", ns, nzeta, ntheta3, jcrossb)
737 call add_real_3d(
"jxb_gradp", ns, nzeta, ntheta3, jxb_gradp)
738 call add_real_3d(
"jdotb_sqrtg", ns, nzeta, ntheta3, jdotb_sqrtg)
739 call add_real_3d(
"sqrtg3", ns, nzeta, ntheta3, sqrtg3)
740 call add_real_3d(
"bsubu3", ns, nzeta, ntheta3, bsubu3)
741 call add_real_3d(
"bsubv3", ns, nzeta, ntheta3, bsubv3)
742 call add_real_3d(
"bsubs3", ns, nzeta, ntheta3, bsubs3)
751 IF (lprint_flag)
THEN
753 CALL cdf_define(njxbout, vn_legend, legend)
754 CALL cdf_define(njxbout, vn_mpol, mpol)
755 CALL cdf_define(njxbout, vn_ntor, ntor)
756 CALL cdf_define(njxbout, vn_phin, phin)
757 CALL cdf_define(njxbout, vn_radial_surfaces, ns)
758 CALL cdf_define(njxbout, vn_poloidal_grid_points, ntheta3)
759 CALL cdf_define(njxbout, vn_toroidal_grid_points, nzeta)
760 CALL cdf_define(njxbout, vn_avforce, avforce)
761 CALL cdf_define(njxbout, vn_jdotb,
jdotb)
763 CALL cdf_define(njxbout, vn_sqg_bdotk, jdotb_sqrtg)
764 CALL cdf_define(njxbout, vn_sqrtg, sqrtg3)
766 CALL cdf_define(njxbout, vn_bdotgradv,
bdotgradv)
767 CALL cdf_define(njxbout, vn_pprime, pprim)
768 CALL cdf_define(njxbout, vn_aminfor, aminfor)
769 CALL cdf_define(njxbout, vn_amaxfor, amaxfor)
770 CALL cdf_define(njxbout, vn_jsupu, jsupu3)
771 CALL cdf_define(njxbout, vn_jsupv, jsupv3)
772 CALL cdf_define(njxbout, vn_jsups, jsups3)
773 CALL cdf_define(njxbout, vn_bsupu, bsupu3)
774 CALL cdf_define(njxbout, vn_bsupv, bsupv3)
775 CALL cdf_define(njxbout, vn_jcrossb, jcrossb)
776 CALL cdf_define(njxbout, vn_jxb_gradp, jxb_gradp)
777 CALL cdf_define(njxbout, vn_bsubu, bsubu3)
778 CALL cdf_define(njxbout, vn_bsubv, bsubv3)
779 CALL cdf_define(njxbout, vn_bsubs, bsubs3)
782 CALL cdf_write(njxbout, vn_legend, legend )
783 CALL cdf_write(njxbout, vn_mpol, mpol )
784 CALL cdf_write(njxbout, vn_ntor, ntor )
785 CALL cdf_write(njxbout, vn_phin, phin )
786 CALL cdf_write(njxbout, vn_radial_surfaces, ns )
787 CALL cdf_write(njxbout, vn_poloidal_grid_points, ntheta3 )
788 CALL cdf_write(njxbout, vn_toroidal_grid_points, nzeta )
789 CALL cdf_write(njxbout, vn_avforce, avforce )
790 CALL cdf_write(njxbout, vn_jdotb,
jdotb )
792 CALL cdf_write(njxbout, vn_sqg_bdotk, jdotb_sqrtg)
793 CALL cdf_write(njxbout, vn_sqrtg, sqrtg3 )
795 CALL cdf_write(njxbout, vn_bdotgradv,
bdotgradv )
796 CALL cdf_write(njxbout, vn_pprime, pprim )
797 CALL cdf_write(njxbout, vn_aminfor, aminfor )
798 CALL cdf_write(njxbout, vn_amaxfor, amaxfor )
799 CALL cdf_write(njxbout, vn_jsupu, jsupu3 )
800 CALL cdf_write(njxbout, vn_jsupv, jsupv3 )
801 CALL cdf_write(njxbout, vn_jsups, jsups3 )
802 CALL cdf_write(njxbout, vn_bsupu, bsupu3 )
803 CALL cdf_write(njxbout, vn_bsupv, bsupv3 )
804 CALL cdf_write(njxbout, vn_jcrossb, jcrossb )
805 CALL cdf_write(njxbout, vn_jxb_gradp, jxb_gradp )
806 CALL cdf_write(njxbout, vn_bsubu, bsubu3 )
807 CALL cdf_write(njxbout, vn_bsubv, bsubv3 )
808 CALL cdf_write(njxbout, vn_bsubs, bsubs3 )
810 CALL cdf_close(njxbout)
813 bsubs3, bsubv3, bsubu3, jxb_gradp, jcrossb, bsupv3, &
814 bsupu3, jsups3, jsupv3, jsupu3, jdotb_sqrtg, phin, &
815 toroidal_angle, sqrtg3, stat=j)
818 DEALLOCATE (kperpu, kperpv, sqgb2, sqrtg, kp2, brhomn, bsubsmn, &
819 jxb, jxb2, bsupu1, bsupv1, bsubu1, bsubv1, avforce, aminfor, &
820 amaxfor, pprim, stat=j)
832 DEALLOCATE (bdotk, bsubuv, bsubvu, pprime, stat=j)