11 USE v3_utilities,
ONLY:
assert
14 USE nscalingtools,
ONLY: startglobrow, endglobrow
38 USE descriptor_mod,
ONLY: inhessian
45 LOGICAL,
INTENT(in) :: l_add_res
52 REAL (dp),
DIMENSION(:,:,:),
ALLOCATABLE :: resistivity
58 REAL (dp),
DIMENSION(:,:,:),
ALLOCATABLE :: esubsijf
59 REAL (dp),
DIMENSION(:,:,:),
ALLOCATABLE :: esubuijf
60 REAL (dp),
DIMENSION(:,:,:),
ALLOCATABLE :: esubvijf
61 REAL (dp),
DIMENSION(:,:,:),
POINTER :: esubsmnf
62 REAL (dp),
DIMENSION(:,:,:),
POINTER :: esubumnf
63 REAL (dp),
DIMENSION(:,:,:),
POINTER :: esubvmnf
68 nsmin = max(1, startglobrow - 1)
69 nsmax = min(ns, endglobrow + 1)
73 ALLOCATE(esubsijf(ntheta,nzeta,nsmin:nsmax),
74 esubuijf(ntheta,nzeta,nsmin:nsmax),
75 esubvijf(ntheta,nzeta,nsmin:nsmax), stat=istat)
76 CALL assert_eq(0, istat,
'Allocation1 failed in UPDATE_BFIELD')
85 esubsijf = -(jvsupuijf(:,:,nsmin:nsmax)*bsupvijf0(:,:,nsmin:nsmax)
86 jvsupvijf(:,:,nsmin:nsmax)*bsupuijf0(:,:,nsmin:nsmax)
88 esubuijf = -(jvsupvijf(:,:,nsmin:nsmax)*bsupsijf0(:,:,nsmin:nsmax)
89 jvsupsijf(:,:,nsmin:nsmax)*bsupvijf0(:,:,nsmin:nsmax)
91 esubvijf = -(jvsupsijf(:,:,nsmin:nsmax)*bsupuijf0(:,:,nsmin:nsmax)
92 jvsupuijf(:,:,nsmin:nsmax)*bsupsijf0(:,:,nsmin:nsmax)
94 IF (nsmin .eq. 1)
THEN
100 IF (nsmax .eq. ns)
THEN
101 CALL assert(all(esubuijf(:,:,ns).EQ.zero),
102 'esubuijf(ns) != 0 in UPDATE_BFIELD')
104 IF (nsmax .eq. ns)
THEN
105 CALL assert(all(esubvijf(:,:,ns).EQ.zero),
106 'esubvijf(ns) != 0 in UPDATE_BFIELD')
121 ALLOCATE(resistivity(ntheta,nzeta,nsmin:nsmax), stat=istat)
122 CALL assert_eq(0, istat,
'Allocation2 failed in update_bfield')
126 eta_prof = rho*rho*(1 - rho)
127 resistivity(:,:,js) = delt_cfl*eta_prof
131 resistivity = resistivity*
buv_res(:,:,nsmin:nsmax)
134 resistivity = resistivity/jacobf(:,:,nsmin:nsmax)
139 esubsijf = esubsijf + resistivity*ksubsijf(:,:,nsmin:nsmax)
140 esubuijf = esubuijf + resistivity*ksubuijf(:,:,nsmin:nsmax)
141 esubvijf = esubvijf + resistivity*ksubvijf(:,:,nsmin:nsmax)
143 IF (nsmin .eq. 1)
THEN
147 DEALLOCATE (resistivity)
151 CALL faraday(djbsupsmnsh, djbsupumnch, djbsupvmnch,
152 esubsijf, esubuijf, esubvijf,
f_sin, nsmin, nsmax)
154 CALL faraday(djbsupsmnch, djbsupumnsh, djbsupvmnsh,
155 esubsijf, esubuijf, esubvijf,
f_cos, nsmin, nsmax)
158 DEALLOCATE(esubsijf, esubuijf, esubvijf, stat=istat)
159 CALL assert_eq(0, istat,
'Deallocation failed in update_bfield')
162 time_update_bfield = time_update_bfield + (toff - ton)
185 SUBROUTINE faraday(djbsupsmnh, djbsupumnh, djbsupvmnh, &
186 esubsijf, esubuijf, esubvijf, parity, nsmin, nsmax)
188 USE hessian,
ONLY: l_compute_hessian
189 USE utilities,
ONLY: curl_ftoh, set_bndy_full_origin
195 REAL (dp),
DIMENSION(:,:,:),
ALLOCATABLE,
INTENT(inout) :: djbsupsmnh
196 REAL (dp),
DIMENSION(:,:,:),
ALLOCATABLE,
INTENT(inout) :: djbsupumnh
197 REAL (dp),
DIMENSION(:,:,:),
ALLOCATABLE,
INTENT(inout) :: djbsupvmnh
198 REAL (dp),
DIMENSION(:,:,:),
INTENT(in) :: esubsijf
199 REAL (dp),
DIMENSION(:,:,:),
INTENT(in) :: esubuijf
200 REAL (dp),
DIMENSION(:,:,:),
INTENT(in) :: esubvijf
201 INTEGER,
INTENT(in) :: parity
202 INTEGER,
INTENT(in) :: nsmin
203 INTEGER,
INTENT(in) :: nsmax
210 REAL (dp),
DIMENSION(:,:,:),
POINTER :: esubsmnf
211 REAL (dp),
DIMENSION(:,:,:),
POINTER :: esubumnf
212 REAL (dp),
DIMENSION(:,:,:),
POINTER :: esubvmnf
215 IF (parity .EQ.
f_sin)
THEN
228 ALLOCATE(esubsmnf(0:mpol,-ntor:ntor,nsmin:nsmax),
229 esubumnf(0:mpol,-ntor:ntor,nsmin:nsmax),
230 esubvmnf(0:mpol,-ntor:ntor,nsmin:nsmax))
238 IF (startglobrow .EQ. 1)
THEN
241 CALL set_bndy_full_origin(esubsmnf, esubumnf, esubvmnf)
256 CALL curl_ftoh(esubsmnf, esubumnf, esubvmnf,
257 djbsupsmnh, djbsupumnh, djbsupvmnh,
258 parity, nsmin, nsmax)
260 DEALLOCATE(esubsmnf, esubumnf, esubvmnf)
264 IF (nsmin .eq. 1)
THEN
265 djbsupsmnh(:,:,1) = 0
266 djbsupsmnh(
m1,:,1) = djbsupsmnh(
m1,:,2)
267 djbsupumnh(:,:,1) = 0
268 djbsupumnh(
m0:
m1,:,1) = djbsupumnh(
m0:
m1,:,2)
269 djbsupvmnh(:,:,1) = 0
270 djbsupvmnh(
m0,:,1) = djbsupvmnh(
m0,:,2);
278 djbsupsmnh = -
delta_t*djbsupsmnh
279 djbsupumnh = -
delta_t*djbsupumnh
280 djbsupvmnh = -
delta_t*djbsupvmnh