9SUBROUTINE residue (gcr, gcz, gcl, fsqrz, old_fsqz)
19 REAL(rprec),
DIMENSION(ns,0:ntor,0:mpol1,ntmax),
INTENT(inout) :: gcr
20 REAL(rprec),
DIMENSION(ns,0:ntor,0:mpol1,ntmax),
INTENT(inout) :: gcz
21 REAL(rprec),
DIMENSION(ns,0:ntor,0:mpol1,ntmax),
INTENT(inout) :: gcl
22 real(rprec),
intent(in) :: fsqrz, old_fsqz
24 INTEGER,
PARAMETER :: n0=0
25 INTEGER,
PARAMETER :: m0=0
26 INTEGER,
PARAMETER :: m1=1
27 INTEGER,
PARAMETER :: n3d=0
28 INTEGER,
PARAMETER :: nasym=1
30 INTEGER :: jedge, j, n, m, i
33 logical,
parameter :: skip_scalfor_dbg = .false.
58 call add_real_4d(
"gcr",
ntmax, ns, ntor1, mpol, gcr, order=(/ 2, 3, 4, 1 /) )
59 call add_real_4d(
"gcz",
ntmax, ns, ntor1, mpol, gcz, order=(/ 2, 3, 4, 1 /) )
60 call add_real_4d(
"gcl",
ntmax, ns, ntor1, mpol, gcl, order=(/ 2, 3, 4, 1 /) )
66 r1 = one/(2.0_dp*
r0scale)**2.0_dp
74 IF (deliter.lt.50 .and. fsqrz.lt.1.e-6_dp)
then
83 fedge = r1*
fnorm * sum(gcr(ns,:,:,:)**2.0_dp + gcz(ns,:,:,:)**2.0_dp)
87 call add_real(
"r0scale",
r0scale)
88 call add_real(
"r1", r1)
89 call add_real(
"fnorm",
fnorm)
90 call add_real(
"fnormL",
fnorml)
91 call add_int(
"jedge", jedge)
92 call add_real(
"fsqr",
fsqr)
93 call add_real(
"fsqz",
fsqz)
94 call add_real(
"fsql",
fsql)
95 call add_real(
"fedge",
fedge)
110 call add_real_4d(
"gcr",
ntmax, ns, ntor1, mpol, gcr, order=(/ 2, 3, 4, 1 /) )
111 call add_real_4d(
"gcz",
ntmax, ns, ntor1, mpol, gcz, order=(/ 2, 3, 4, 1 /) )
129 call add_real_2d(
"arm", ns+1, 2,
arm)
130 call add_real_2d(
"ard", ns+1, 2,
ard)
131 call add_real_2d(
"brm", ns+1, 2,
brm)
132 call add_real_2d(
"brd", ns+1, 2,
brd)
133 call add_real_1d(
"crd", ns+1,
crd)
134 call add_real_2d(
"azm", ns+1, 2,
azm)
135 call add_real_2d(
"azd", ns+1, 2,
azd)
136 call add_real_2d(
"bzm", ns+1, 2,
bzm)
137 call add_real_2d(
"bzd", ns+1, 2,
bzd)
139 call add_real_4d(
"gcr",
ntmax, ns, ntor1, mpol, gcr, order=(/ 2, 3, 4, 1 /) )
140 call add_real_4d(
"gcz",
ntmax, ns, ntor1, mpol, gcz, order=(/ 2, 3, 4, 1 /) )
141 call add_real_4d(
"gcl",
ntmax, ns, ntor1, mpol, gcl, order=(/ 2, 3, 4, 1 /) )
153 call add_real(
"fnorm1",
fnorm1)
154 call add_real(
"fsqr1",
fsqr1)
155 call add_real(
"fsqz1",
fsqz1)
156 call add_real(
"fsql1",
fsql1)
173 REAL(dp),
DIMENSION(ns,0:ntor),
INTENT(inout) :: gcr, gcz
174 real(dp),
intent(in) :: old_fsqz
176 REAL(dp),
PARAMETER :: FThreshold = 1.e-6_dp
177 REAL(dp) :: temp(ns,0:ntor)
184 gcr = osqrt2*(gcr + gcz)
185 gcz = osqrt2*(temp - gcz)
189 IF (old_fsqz.LT.fthreshold .OR.
iter2.LT.2)
then
210 REAL(rprec),
DIMENSION(ns,0:ntor),
INTENT(inout) :: gcr, gcz
212 INTEGER,
PARAMETER :: nodd=2
214 REAL(rprec) :: fac(ns)
218 fac = (
ard(:ns,nodd)+
brd(:ns,nodd) ) &
219 /(
ard(:ns,nodd)+
brd(:ns,nodd)+
azd(:ns,nodd)+
bzd(:ns,nodd))
221 gcr(:,n) = fac*gcr(:,n)
224 fac = (
azd(:ns,nodd)+
bzd(:ns,nodd)) &
225 /(
ard(:ns,nodd)+
brd(:ns,nodd)+
azd(:ns,nodd)+
bzd(:ns,nodd))
227 gcz(:,n) = fac*gcz(:,n)
subroutine getfsq(gcr, gcz, gnormr, gnormz, gnorm, medge)
Compute total force residual on flux surfaces.
logical function open_dbg_context(context_name, repetition, id)
check if any output is desired for the current iteration check if the given context should be openend...
real(rprec), dimension(:), allocatable crd
real(rprec), dimension(:,:), allocatable brd
real(rprec) hs
radial mesh size increment
real(rprec), dimension(:,:), allocatable azd
real(rprec), dimension(:,:,:,:), allocatable faclam
integer iter1
number of iterations at which the currently active evolution was branched off from
real(rprec), dimension(:,:), allocatable brm
real(rprec), dimension(:,:), allocatable bzd
real(rprec), dimension(:,:), allocatable bzm
real(rprec), dimension(:,:), allocatable ard
integer num_eqsolve_retries
real(rprec), dimension(:,:), allocatable arm
integer iter2
total number of iterations
real(rprec), dimension(:,:), allocatable azm
integer, parameter modd
parity selection label for odd poloidal modes of R and Z
integer ntmax
number of contributing Fourier basis function (can be 1, 2 or 4); assigned in read_indata()
integer, parameter meven
parity selection label for even poloidal modes of R and Z
subroutine residue(gcr, gcz, gcl, fsqrz, old_fsqz)
Compute invariant residuals.
subroutine constrain_m1(gcr, gcz, old_fsqz)
Compute internal gr , gz required for constraint.
subroutine scale_m1(gcr, gcz)
Compute internal gr , gz required for constraint.
subroutine scalfor(gcx, axm, bxm, axd, bxd, cx, iflag, skip_scalfor_dbg)
Build forces from different contributions.