24 REAL(rprec),
DIMENSION(nrzt,0:1),
INTENT(inout) :: lu
25 REAL(rprec),
DIMENSION(nrzt,0:1),
INTENT(inout) :: lv
29 INTEGER :: l, js, ndim, lk, ku, m, n, rzl
30 REAL(rprec) :: r2, volume, curpol_temp
32 integer :: dim_j, dim_k, dim_l, linear_index
35 REAL(rprec) :: arnorm, aznorm, tcon_mul
38 REAL(rprec),
POINTER,
DIMENSION(:) :: luu, luv, lvv, tau
39 REAL(rprec),
DIMENSION(:),
POINTER :: bsupu, bsubuh, bsupv, bsubvh, r12sq
96 r12sq(1:nrzt) =
r1(1:nrzt,
meven)*
r1(1:nrzt,
meven) + r12sq(1:nrzt)* &
110 r12sq(l) = p5*( r12sq(l) + r12sq(l-1) +
shalf(l)*(phipog(l) + phipog(l-1)) )
122 tau(1:nrzt) = gsqrt(1:nrzt)
126 gsqrt(1:nrzt) = r12(1:nrzt)*tau(1:nrzt)
130 gsqrt(1:nrzt:ns) = gsqrt(2:nrzt:ns)
133 gvv(2:nrzt) =
gvv(2:nrzt) + r12sq(2:nrzt)
137 call add_real_3d(
"gsqrt", ns, nzeta, ntheta3, gsqrt)
138 call add_real_3d(
"guu", ns, nzeta, ntheta3,
guu )
139 call add_real_3d(
"r12sq", ns, nzeta, ntheta3, r12sq)
140 call add_real_3d(
"gvv", ns, nzeta, ntheta3,
gvv )
143 call add_real_3d(
"guv", ns, nzeta, ntheta3,
guv )
155 WHERE (gsqrt(2:ndim) .ne. zero) phipog(2:ndim) = one/gsqrt(2:ndim)
158 phipog(1:ndim:ns) = 0.0_dp
167 IF (
iter2 .eq. 1)
then
174 call add_real_1d(
"vp", ns+1,
vp)
175 call add_real(
"voli",
voli)
193 lu(js:nrzt:ns,0) = lu(js:nrzt:ns,0) +
phipf(js)
196 bsupu(2:nrzt) = phipog(2:nrzt) * p5*( lv(2:nrzt,0) + lv(1:nrzt-1,0) &
197 +
shalf(2:nrzt)*(lv(2:nrzt,1) + lv(1:nrzt-1,1)) )
198 bsupv(2:nrzt) = phipog(2:nrzt) * p5*( lu(2:nrzt,0) + lu(1:nrzt-1,0) &
199 +
shalf(2:nrzt)*(lu(2:nrzt,1) + lu(1:nrzt-1,1)) )
211 call add_real_3d(
"bsupu", ns, nzeta, ntheta3, bsupu)
212 call add_real_3d(
"bsupv", ns, nzeta, ntheta3, bsupv)
230 bsubuh(1:nrzt) =
guu(1:nrzt)*bsupu(1:nrzt) +
guv(1:nrzt)*bsupv(1:nrzt)
231 bsubvh(1:nrzt) =
guv(1:nrzt)*bsupu(1:nrzt) +
gvv(1:nrzt)*bsupv(1:nrzt)
234 bsubuh(ndim) = 0.0_dp
235 bsubvh(ndim) = 0.0_dp
239 bsq(:nrzt) = p5*(bsupu(:nrzt)*bsubuh(:nrzt) + bsupv(:nrzt)*bsubvh(:nrzt))
243 wb =
hs*abs(sum(
wint(:nrzt)*gsqrt(:nrzt)*bsq(:nrzt)))
253 bsq(js:nrzt:ns) = bsq(js:nrzt:ns) +
pres(js)
258 call add_real_3d(
"bsubuh", ns, nzeta, ntheta3, bsubuh)
259 call add_real_3d(
"bsubvh", ns, nzeta, ntheta3, bsubvh)
260 call add_real_3d(
"bsq", ns, nzeta, ntheta3, bsq )
262 call add_real_1d(
"pres", ns-1,
pres(2:ns))
264 call add_real(
"wb",
wb)
265 call add_real(
"wp",
wp)
272 lvv = phipog(:ndim)*
gvv
273 bsubv_e(1:nrzt) = p5*(lvv(1:nrzt)+lvv(2:ndim))*lu(1:nrzt,0)
280 bsubu_e(:nrzt) =
guv(:nrzt)*bsupu(:nrzt)
298 bsubv_e(1:nrzt) = bsubv_e(1:nrzt) &
299 + p5*((lvv(1:nrzt) + lvv(2:ndim))*lu(1:nrzt,1) &
300 + bsubu_e(1:nrzt) + bsubu_e(2:ndim))
311 call add_real_3d(
"lvv", ns, nzeta, ntheta3, lvv )
312 call add_real_4d(
"lu", ns, 2, nzeta, ntheta3, lu, order=(/1, 3, 4, 2 /))
313 call add_real_3d(
"bsubu_e", ns, nzeta, ntheta3, bsubu_e)
314 call add_real_3d(
"bsubv_e", ns, nzeta, ntheta3, bsubv_e)
326 rbtor0= c1p5*fpsi(2) - p5*fpsi(3)
327 rbtor = c1p5*fpsi(ns) - p5*fpsi(ns-1)
348 lvv(l:nrzt:ns) =
bdamp(l)
371 bsubu_e(1:nrzt) = p5* (bsubuh(1:nrzt) + bsubuh(2:ndim))
372 bsubv_e(1:nrzt) = lvv(1:nrzt) * bsubv_e(1:nrzt) &
373 + p5*(1-lvv(1:nrzt))*(bsubvh(1:nrzt) + bsubvh(2:ndim))
377 call add_real(
"rbtor0",
rbtor0)
378 call add_real(
"rbtor",
rbtor)
379 call add_real(
"ctor",
ctor)
381 call add_real_1d(
"bdamp", ns,
bdamp)
383 call add_real_3d(
"bsubu_e", ns, nzeta, ntheta3, bsubu_e)
384 call add_real_3d(
"bsubv_e", ns, nzeta, ntheta3, bsubv_e)
389 if (
iequi .eq. 0)
then
399 phipog(:nrzt) = phipog(:nrzt)*
wint(:nrzt)
403 CALL precondn(bsupv, bsq, gsqrt, r12, &
404 zs, zu12,
zu,
zu(1,1),
z1(1,1), &
407 CALL precondn(bsupv, bsq, gsqrt, r12, &
408 rs, ru12,
ru,
ru(1,1),
r1(1,1), &
414 call add_real_2d(
"arm", ns+1, 2,
arm)
415 call add_real_2d(
"ard", ns+1, 2,
ard)
416 call add_real_2d(
"brm", ns+1, 2,
brm)
417 call add_real_2d(
"brd", ns+1, 2,
brd)
418 call add_real_1d(
"crd", ns+1,
crd)
419 call add_real_2d(
"azm", ns+1, 2,
azm)
420 call add_real_2d(
"azd", ns+1, 2,
azd)
421 call add_real_2d(
"bzm", ns+1, 2,
bzm)
422 call add_real_2d(
"bzd", ns+1, 2,
bzd)
427 volume =
hs*sum(
vp(2:ns))
429 r2 = max(
wb,
wp)/volume
432 guu(:nrzt) =
guu(:nrzt)*r12(:nrzt)**2
454 tcon0 = min(abs(tcon0), one)
457 tcon_mul = tcon0*(1 + r2*(one/60 + r2/(200*120)))
459 tcon_mul = tcon_mul/((4*
r0scale**2)**2)
465 arnorm = sum(
wint(js:nrzt:ns)*
ru0(js:nrzt:ns)**2)
466 aznorm = sum(
wint(js:nrzt:ns)*
zu0(js:nrzt:ns)**2)
467 IF (arnorm.eq.zero .or. aznorm.eq.zero)
then
468 stop
'arnorm or aznorm=0 in bcovar'
471 tcon(js) = min(abs(
ard(js,1)/arnorm), abs(
azd(js,1)/aznorm)) * tcon_mul*(32*
hs)**2
483 call add_real(
"volume", volume)
484 call add_real(
"r2", max(
wb,
wp)/volume)
485 call add_real(
"fnorm",
fnorm)
486 call add_real(
"fnorm1",
fnorm1)
487 call add_real(
"fnormL",
fnorml)
488 call add_real(
"tcon0", tcon0)
489 call add_real(
"tcon_mul", tcon_mul)
490 call add_real_1d(
"tcon", ns-1,
tcon(2:ns))
492 call add_real_3d(
"guu", ns, nzeta, ntheta3,
guu)
493 call add_real_5d(
"xc", 3,
ntmax, ns, ntor1, mpol,
xc, order=(/ 3, 4, 5, 2, 1 /) )
503 bsubu_o(:nrzt) =
sqrts(:nrzt)*bsubu_e(:nrzt)
504 bsubv_o(:nrzt) =
sqrts(:nrzt)*bsubv_e(:nrzt)
507 lvv(2:nrzt) = gsqrt(2:nrzt)
508 guu(2:nrzt) = bsupu(2:nrzt)*bsupu(2:nrzt)*lvv(2:nrzt)
509 guv(2:nrzt) = bsupu(2:nrzt)*bsupv(2:nrzt)*lvv(2:nrzt)
510 gvv(2:nrzt) = bsupv(2:nrzt)*bsupv(2:nrzt)*lvv(2:nrzt)
511 lv(2:nrzt,0) = bsq(2:nrzt)*tau(2:nrzt)
512 lu(2:nrzt,0) = bsq(2:nrzt)*r12(2:nrzt)
516 call add_real_3d(
"bsubu_e", ns, nzeta, ntheta3, bsubu_e )
517 call add_real_3d(
"bsubv_e", ns, nzeta, ntheta3, bsubv_e )
518 call add_real_3d(
"bsubu_o", ns, nzeta, ntheta3, bsubu_o )
519 call add_real_3d(
"bsubv_o", ns, nzeta, ntheta3, bsubv_o )
520 call add_real_3d(
"lvv", ns, nzeta, ntheta3, lvv )
521 call add_real_3d(
"guu", ns, nzeta, ntheta3,
guu )
522 call add_real_3d(
"guv", ns, nzeta, ntheta3,
guv )
523 call add_real_3d(
"gvv", ns, nzeta, ntheta3,
gvv )
524 call add_real_4d(
"lv", ns, 2, nzeta, ntheta3, lv, order=(/1, 3, 4, 2 /))
525 call add_real_4d(
"lu", ns, 2, nzeta, ntheta3, lu, order=(/1, 3, 4, 2 /))
537 lu(:nrzt,0) = bsupv(:nrzt)
538 lv(:nrzt,0) = bsupu(:nrzt)
546 bsubvh(l) = 2*bsubv_e(l) - bsubvh(l+1)
552 curpol_temp = fpsi(js) - sum(bsubvh(js:nrzt:ns)*
wint(js:nrzt:ns))
555 bsubvh(l) = bsubvh(l) + curpol_temp
560 bsubu_e(:nrzt) = bsubuh(:nrzt)
561 bsubv_e(:nrzt) = bsubvh(:nrzt)
563 bsubu_o(:nrzt) =
shalf(:nrzt)*bsubu_e(:nrzt)
564 bsubv_o(:nrzt) =
shalf(:nrzt)*bsubv_e(:nrzt)
568 call add_real_3d(
"lu_e", ns, nzeta, ntheta3, lu(:nrzt,0))
569 call add_real_3d(
"lv_e", ns, nzeta, ntheta3, lv(:nrzt,0))
571 call add_real_1d(
"fpsi", ns-1, fpsi(2:ns))
575 call add_real_3d(
"bsubu_e", ns, nzeta, ntheta3, bsubu_e)
576 call add_real_3d(
"bsubv_e", ns, nzeta, ntheta3, bsubv_e)
578 call add_real_3d(
"bsubu_o", ns, nzeta, ntheta3, bsubu_o)
579 call add_real_3d(
"bsubv_o", ns, nzeta, ntheta3, bsubv_o)