3 SUBROUTINE equilibrium_spider (EQUILIBRIUM_IN, COREPROF_IN, EQUILIBRIUM_OUT, code_parameters)
29 USE deallocate_structures
38 TYPE (type_equilibrium
),
POINTER :: equilibrium_in(:)
39 TYPE (type_equilibrium
),
POINTER :: equilibrium_out(:)
40 TYPE (type_coreprof
),
POINTER :: coreprof_in(:)
42 TYPE (type_param
) :: code_parameters
48 INTEGER :: ndim1, ndim2
49 INTEGER :: idim1, idim2
50 INTEGER :: max_npoints
52 INTEGER :: icontrol,iinput
54 INTEGER :: nrho, ntheta, neq
61 INTEGER :: itheta, irho
62 INTEGER,
PARAMETER :: spid_out = 0
68 REAL (R8) :: pc, pc_int
72 REAL (R8),
ALLOCATABLE :: btmin(:), btmax(:)
73 REAL (R8) :: elongation
74 REAL (R8) :: tria_upper
75 REAL (R8) :: tria_lower
78 REAL (R8),
ALLOCATABLE :: rho(:)
79 REAL (R8),
ALLOCATABLE ::
r_inboard(:), r_outboard(:)
80 REAL (R8),
ALLOCATABLE :: rr(:), rr_in(:)
81 REAL (R8),
ALLOCATABLE :: jpar(:), intjpar(:)
82 REAL (R8),
ALLOCATABLE :: j_bs(:), j_cd(:)
83 REAL (R8),
ALLOCATABLE :: qsf(:)
84 REAL (R8),
ALLOCATABLE :: mu(:)
85 REAL (R8),
ALLOCATABLE :: pr(:), dpr(:)
86 REAL (R8),
ALLOCATABLE :: te(:)
87 REAL (R8),
ALLOCATABLE :: psi(:)
88 REAL (R8),
ALLOCATABLE :: sigma(:)
89 REAL (R8),
ALLOCATABLE :: pprime(:)
90 REAL (R8),
ALLOCATABLE :: ffprime(:)
91 REAL (R8),
ALLOCATABLE :: rzbnd(:)
92 REAL (R8),
ALLOCATABLE :: rout(:,:), zout(:,:)
95 REAL (R8),
ALLOCATABLE :: rhonew(:)
96 REAL (R8),
ALLOCATABLE :: rhonew_s(:)
97 REAL (R8),
ALLOCATABLE :: gm11(:), gm22(:), gm33(:)
98 REAL (R8),
ALLOCATABLE :: b2b02(:)
99 REAL (R8),
ALLOCATABLE :: bb0(:)
100 REAL (R8),
ALLOCATABLE :: b02b2(:)
101 REAL (R8),
ALLOCATABLE ::
fdia(:)
102 REAL (R8),
ALLOCATABLE :: jdia(:), jdias(:)
103 REAL (R8),
ALLOCATABLE :: vol(:), vprime(:), vprimes(:), vprime_psi(:)
104 REAL (R8),
ALLOCATABLE :: surf(:)
105 REAL (R8),
ALLOCATABLE :: gradrho(:)
106 REAL (R8),
ALLOCATABLE :: drhoda(:)
107 REAL (R8),
ALLOCATABLE :: shafr_shift(:)
108 REAL (R8),
ALLOCATABLE :: elong(:)
109 REAL (R8),
ALLOCATABLE :: elong_u(:)
110 REAL (R8),
ALLOCATABLE :: elong_l(:)
111 REAL (R8),
ALLOCATABLE :: triang_l(:)
112 REAL (R8),
ALLOCATABLE :: triang_u(:)
113 REAL (R8),
ALLOCATABLE :: ftrap(:)
116 REAL (R8),
ALLOCATABLE :: g1(:), g2(:), g3(:), g4(:)
117 REAL (R8),
ALLOCATABLE :: g5(:), g6(:), g7(:)
118 REAL (R8),
ALLOCATABLE :: area(:)
122 REAL (R8) :: tolerance = 1.0e-4_r8
123 REAL (R8) :: err_vprime, err_g1, err_fdia
124 REAL (R8),
ALLOCATABLE :: vprime_old(:), g1_old(:), fdia_old(:)
127 REAL (R8) :: theta, tria
128 REAL (R8),
ALLOCATABLE :: amid(:)
129 REAL (R8),
ALLOCATABLE ::
fun(:), intfun(:), fun_in(:)
131 REAL (R8),
ALLOCATABLE :: amid_2d(:), rho_2d(:)
132 REAL (R8),
ALLOCATABLE :: shafr_shift_2d(:), elong_2d(:), elong_u2d(:), elong_l2d(:), triang_l2d(:), triang_u2d(:)
133 REAL (R8),
ALLOCATABLE :: psi_2d(:), jpar_2d(:), pr_2d(:), g11_2d(:), g22_2d(:), g33_2d(:)
135 INTEGER :: return_status
136 LOGICAL,
SAVE :: first=.true.
147 IF (return_status /= 0)
THEN
148 WRITE(*,*)
'ERROR: Could not assign SPIDER parametrs.'
154 npsi =
SIZE (equilibrium_in(1)%profiles_1d%rho_tor, dim=1)
155 ndim1 =
SIZE (equilibrium_in(1)%coord_sys%position%R, dim=1)
156 ndim2 =
SIZE (equilibrium_in(1)%coord_sys%position%R, dim=2)
157 max_npoints =
SIZE (equilibrium_in(1)%eqgeometry%boundary(1)%r, dim=1)
158 ntransp =
SIZE (coreprof_in(1)%rho_tor, dim=1)
174 ALLOCATE (r_outboard(npsi))
176 ALLOCATE (rr_in(npsi))
177 ALLOCATE (jpar(npsi))
178 ALLOCATE (intjpar(npsi))
179 ALLOCATE (j_bs(npsi))
180 ALLOCATE (j_cd(npsi))
187 ALLOCATE (sigma(npsi))
188 ALLOCATE (pprime(npsi))
189 ALLOCATE (ffprime(npsi))
190 ALLOCATE (rzbnd(nbnd * 2))
191 ALLOCATE (rout(npsi,ntheta))
192 ALLOCATE (zout(npsi,ntheta))
194 ALLOCATE (b2b02(npsi))
196 ALLOCATE (b02b2(npsi))
197 ALLOCATE (rhonew(npsi))
198 ALLOCATE (rhonew_s(npsi))
199 ALLOCATE (gm11(npsi))
200 ALLOCATE (gm22(npsi))
201 ALLOCATE (gm33(npsi))
202 ALLOCATE (
fdia(npsi))
203 ALLOCATE (jdia(npsi))
204 ALLOCATE (jdias(npsi))
205 ALLOCATE (btmin(npsi))
206 ALLOCATE (btmax(npsi))
208 ALLOCATE (vprime(npsi))
209 ALLOCATE (vprimes(npsi))
210 ALLOCATE (vprime_psi(npsi))
211 ALLOCATE (surf(npsi))
212 ALLOCATE (gradrho(npsi))
213 ALLOCATE (drhoda(npsi))
214 ALLOCATE (shafr_shift(npsi))
215 ALLOCATE (elong(npsi))
216 ALLOCATE (elong_u(npsi))
217 ALLOCATE (elong_l(npsi))
218 ALLOCATE (triang_l(npsi))
219 ALLOCATE (triang_u(npsi))
220 ALLOCATE (amid(npsi))
221 ALLOCATE (ftrap(npsi))
230 ALLOCATE (area(npsi))
233 ALLOCATE (fun_in(npsi))
234 ALLOCATE (intfun(npsi))
236 ALLOCATE (vprime_old(npsi))
237 ALLOCATE (g1_old(npsi))
238 ALLOCATE (fdia_old(npsi))
240 ALLOCATE (amid_2d(ndim1))
241 ALLOCATE (rho_2d(ndim1))
242 ALLOCATE (elong_2d(ndim1))
243 ALLOCATE (elong_u2d(ndim1))
244 ALLOCATE (elong_l2d(ndim1))
245 ALLOCATE (triang_l2d(ndim1))
246 ALLOCATE (triang_u2d(ndim1))
247 ALLOCATE (shafr_shift_2d(ndim1))
248 ALLOCATE (psi_2d(ndim1))
249 ALLOCATE (jpar_2d(ndim1))
250 ALLOCATE (pr_2d(ndim1))
251 ALLOCATE (g11_2d(ndim1))
252 ALLOCATE (g22_2d(ndim1))
253 ALLOCATE (g33_2d(ndim1))
325 rhon = equilibrium_in(1)%profiles_1d%rho_tor(npsi)
327 rho(ieq) = rhon / (npsi-1) * (ieq-1)
334 IF (ibnd.LE.nbnd)
THEN
335 rzbnd(ibnd) = equilibrium_in(1)%eqgeometry%boundary(1)%r(ibnd)
336 ELSE IF (ibnd.GT.nbnd)
THEN
337 rzbnd(ibnd) = equilibrium_in(1)%eqgeometry%boundary(1)%z(ibnd-nbnd)
345 r0 = equilibrium_in(1)%global_param%mag_axis%position%r
346 z0 = equilibrium_in(1)%global_param%mag_axis%position%z
347 b0 = equilibrium_in(1)%global_param%toroid_field%b0
348 amin = equilibrium_in(1)%eqgeometry%a_minor
349 elongation = equilibrium_in(1)%eqgeometry%elongation
350 tria_upper = equilibrium_in(1)%eqgeometry%tria_upper
351 tria_lower = equilibrium_in(1)%eqgeometry%tria_lower
356 CALL
l3interp(-equilibrium_in(1)%profiles_1d%psi, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
358 CALL
l3interp(equilibrium_in(1)%profiles_1d%jparallel, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
360 CALL
l3interp(-equilibrium_in(1)%profiles_1d%q, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
362 CALL
l3interp(equilibrium_in(1)%profiles_1d%pressure, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
364 CALL
l3interp(equilibrium_in(1)%profiles_1d%gm5 / b0**2, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
366 CALL
l3interp(equilibrium_in(1)%profiles_1d%F_dia/r0/b0, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
368 CALL
l3interp(equilibrium_in(1)%profiles_1d%F_dia, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
370 CALL
l3interp(equilibrium_in(1)%profiles_1d%volume, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
372 CALL
l3interp(equilibrium_in(1)%profiles_1d%gm1, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
374 CALL
l3interp(equilibrium_in(1)%profiles_1d%gm2, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
376 CALL
l3interp(equilibrium_in(1)%profiles_1d%gm3, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
379 CALL
l3deriv(vol, rho, npsi, vprime, rho, npsi)
385 CALL
l3interp(coreprof_in(1)%te%value, coreprof_in(1)%rho_tor, ntransp, &
387 IF (
ASSOCIATED(coreprof_in(1)%psi%sigma_par%value))
THEN
388 CALL
l3interp(coreprof_in(1)%psi%sigma_par%value, coreprof_in(1)%rho_tor, ntransp, &
393 IF (
ASSOCIATED(coreprof_in(1)%psi%jni%value))
THEN
394 CALL
l3interp(coreprof_in(1)%psi%jni%value, coreprof_in(1)%rho_tor, ntransp, &
404 IF(
ASSOCIATED(equilibrium_in(1)%profiles_1d%r_inboard).AND. &
405 ASSOCIATED(equilibrium_in(1)%profiles_1d%r_outboard))
THEN
406 rr_in = (equilibrium_in(1)%profiles_1d%r_inboard + equilibrium_in(1)%profiles_1d%r_outboard) / 2.0_r8
407 CALL
l3interp(rr_in, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
416 j_bs = 0.0_r8 * 1.0e-6_r8
417 j_cd = j_cd * 1.0e-6_r8
418 jpar = jpar * 1.0e-6_r8
420 sigma = sigma * 1.0e-6_r8
432 IF (iter.GT.100)
THEN
433 WRITE(*,*)
'### ERROR! Equilibrium loop in EQUILIBRIUM_SPIDER not converging'
434 stop
'Error - no convergence in EQUILIBRIUM_SPIDER'
447 IF (iinput.EQ.0)
THEN
448 CALL
l3deriv(pr, rho, npsi, dpr, rho, npsi)
450 pprime = - rr * qsf / b0 / rho * dpr
452 IF (rho(1).EQ.0.0_r8) pprime(1) = pprime(2)
454 ffprime = jdia / b2b02 * (jpar * rr / r0 - pprime)
456 ELSE IF (iinput.EQ.1)
THEN
458 CALL
l3interp(equilibrium_in(1)%profiles_1d%pprime, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
460 CALL
l3interp(equilibrium_in(1)%profiles_1d%ffprime, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
467 fun = vprime * jpar / 2.0e0_r8 / itm_pi * b0 /
fdia**2
469 pc_int = intjpar(npsi) *
fdia(npsi) / 1.0e6_r8
471 IF(equilibrium_in(1)%global_param%i_plasma.GT.-1.0e+40_r8)
THEN
472 pc = equilibrium_in(1)%global_param%i_plasma / 1.0e6_r8
483 IF (spid_out.EQ.1)
THEN
485 WRITE(*,*)
'-------------------------------------------------------'
486 WRITE(*,*)
'Set Ip (MA) ',pc
487 WRITE(*,*)
'Calculated Ip (MA) ',pc_int
488 WRITE(*,*)
'R0, RR, B0 ', r0, rr(npsi), b0
489 WRITE(*,*)
'-------------------------------------------------------'
493 OPEN (2,file=
'spidat.out')
494 WRITE(2,100)
' jNPSIL,jnteta,NBND'
495 WRITE(2,102) nrho,ntheta,nbnd
496 WRITE(2,100)
' (rzbnd(j),j=1,2*NBND)'
497 WRITE(2,101) (rzbnd(i),i=1,nbnd*2)
500 WRITE(2,100)
' (eqpf(j),j=1,na1)'
501 WRITE(2,101) (pprime(i),i=1,npsi)
502 WRITE(2,100)
' (eqff(j),j=1,na1)'
503 WRITE(2,101) (ffprime(i),i=1,npsi)
504 WRITE(2,100)
' (fp(j),j=1,na1)'
505 WRITE(2,101) (psi(i),i=1,npsi)
506 WRITE(2,100)
' (rho(j),j=1,na1)'
507 WRITE(2,101) (rho(i),i=1,npsi)
508 WRITE(2,100)
' ipl,rtor,btor,roc,jnstep,'
509 WRITE(2,103) pc,r0,b0,rhon,itime
510 WRITE(2,100)
' (fp(j),j=1,na1)'
511 WRITE(2,101) (psi(i),i=1,npsi)
512 WRITE(2,100)
' (g11(j),j=1,na1)'
513 WRITE(2,101) (gm11(i),i=1,npsi)
514 WRITE(2,100)
' (g22(j),j=1,na1)'
515 WRITE(2,101) (gm22(i),i=1,npsi)
516 WRITE(2,100)
' (g33(j),j=1,na1)'
517 WRITE(2,101) (gm33(i),i=1,npsi)
518 WRITE(2,100)
' (vr(j),j=1,na1)'
519 WRITE(2,101) (vprime(i),i=1,npsi)
520 WRITE(2,100)
' (vrs(j),j=1,na1)'
521 WRITE(2,101) (vprimes(i),i=1,npsi)
522 WRITE(2,100)
' (slat(j),j=1,na1)'
523 WRITE(2,101) (surf(i),i=1,npsi)
524 WRITE(2,100)
' (gradro(j),j=1,na1)'
525 WRITE(2,101) (gradrho(i),i=1,npsi)
526 WRITE(2,100)
' (mu(j),j=1,na1)'
527 WRITE(2,101) (mu(i),i=1,npsi)
528 WRITE(2,100)
' (ipol(j),j=1,na1)'
529 WRITE(2,101) (jdia(j),j=1,npsi)
530 WRITE(2,100)
' (cc(j),j=1,na1)'
531 WRITE(2,101) (sigma(j),j=1,npsi)
532 WRITE(2,100)
' (Te(j),j=1,na1)'
533 WRITE(2,101) (te(j),j=1,npsi)
534 WRITE(2,100)
' (cubs(j),j=1,na1)'
535 WRITE(2,101) (j_bs(j),j=1,npsi)
536 WRITE(2,100)
' (cd(j),j=1,na1)'
537 WRITE(2,101) (j_cd(j),j=1,npsi)
538 WRITE(2,100)
' (pres(j),j=1,na1)'
539 WRITE(2,101) (pr(j),j=1,npsi)
540 WRITE(2,100)
' (cu(j),j=1,na1)'
541 WRITE(2,101) (jpar(j),j=1,npsi)
545 101
FORMAT(1
p,3g24.15e3)
547 103
FORMAT(1
p,3g24.15e3/g24.15e3,i12)
632 rhonew(ieq) = rho(ieq)
634 rhonew(npsi) = rhonnew
637 rhonew_s(ieq) = 0.5_r8 * (rhonew(ieq) + rhonew(ieq+1))
639 rhonew_s(npsi-1) = rhonew_s(npsi-2) + rhonew(2) - rhonew(1)
640 rhonew_s(npsi) = rhonnew
648 fdia = jdia * r0 * b0
656 g2 = gm22 / vprimes * 4.0_r8 * itm_pi**2 / r0
663 area = vprimes * gradrho
665 g4(npsi) = g4(npsi-1) + (g4(npsi-1)-g4(npsi-2)) &
666 / (rhonew_s(npsi-1)-rhonew_s(npsi-2)) &
667 * (rhonew_s(npsi)-rhonew_s(npsi-1))
668 g5(npsi) = g5(npsi-1) + (g5(neq-1)-g5(neq-2)) &
669 / (rhonew_s(neq-1)-rhonew_s(neq-2)) &
670 * (rhonew_s(neq)-rhonew_s(neq-1))
686 CALL
l3interp(area, rhonew_s, neq,
fun, rhonew, neq)
688 CALL
l3interp(surf, rhonew_s, neq,
fun, rhonew, neq)
707 err_vprime = maxval(abs(1.0_r8 - vprime_old(2:neq-1) / vprime(2:neq-1)))
708 err_g1 = maxval(abs(1.0_r8 - g1_old(2:neq-1) / g1(2:neq-1)))
709 err_fdia = maxval(abs(1.0_r8 - fdia_old(2:neq-1) /
fdia(2:neq-1)))
712 conv = max( err_vprime, err_g1, err_fdia)
714 write(*,*)
' CONV SPIDER =', conv, iter
715 write(*,*)
' err_VPRIME =', err_vprime
716 write(*,*)
' err_G1 =', err_g1
717 write(*,*)
' err_FDIA =', err_fdia
727 WRITE(*,*)
'Allocating EQUILIBRIUM_OUT'
728 ALLOCATE(equilibrium_out(1))
740 CALL
l3deriv(vol, psi, neq, vprime_psi, psi, neq)
744 call deallocate_cpo(equilibrium_out(1)%eqconstraint)
745 CALL copy_cpo(equilibrium_in(1)%eqconstraint, equilibrium_out(1)%eqconstraint)
749 call deallocate_cpo(equilibrium_out(1)%eqgeometry)
750 CALL copy_cpo(equilibrium_in(1)%eqgeometry, equilibrium_out(1)%eqgeometry)
754 call deallocate_cpo(equilibrium_out(1)%global_param)
755 CALL copy_cpo(equilibrium_in(1)%global_param, equilibrium_out(1)%global_param)
762 equilibrium_out(1)%global_param%area = area(neq)
763 equilibrium_out(1)%global_param%volume = vol(neq)
764 equilibrium_out(1)%global_param%i_plasma = pc * 1.0e6_r8
765 equilibrium_out(1)%global_param%psi_ax = -psi(1)
766 equilibrium_out(1)%global_param%psi_bound = -psi(neq)
772 ALLOCATE (equilibrium_out(1)%profiles_1d%psi(npsi))
773 ALLOCATE (equilibrium_out(1)%profiles_1d%phi(npsi))
774 ALLOCATE (equilibrium_out(1)%profiles_1d%pressure(npsi))
775 ALLOCATE (equilibrium_out(1)%profiles_1d%F_dia(npsi))
776 ALLOCATE (equilibrium_out(1)%profiles_1d%pprime(npsi))
777 ALLOCATE (equilibrium_out(1)%profiles_1d%ffprime(npsi))
778 ALLOCATE (equilibrium_out(1)%profiles_1d%jphi(npsi))
779 ALLOCATE (equilibrium_out(1)%profiles_1d%jparallel(npsi))
780 ALLOCATE (equilibrium_out(1)%profiles_1d%q(npsi))
781 ALLOCATE (equilibrium_out(1)%profiles_1d%r_inboard(npsi))
782 ALLOCATE (equilibrium_out(1)%profiles_1d%r_outboard(npsi))
783 ALLOCATE (equilibrium_out(1)%profiles_1d%rho_tor(npsi))
784 ALLOCATE (equilibrium_out(1)%profiles_1d%rho_vol(npsi))
785 ALLOCATE (equilibrium_out(1)%profiles_1d%beta_pol(npsi))
786 ALLOCATE (equilibrium_out(1)%profiles_1d%li(npsi))
787 ALLOCATE (equilibrium_out(1)%profiles_1d%elongation(npsi))
788 ALLOCATE (equilibrium_out(1)%profiles_1d%tria_upper(npsi))
789 ALLOCATE (equilibrium_out(1)%profiles_1d%tria_lower(npsi))
790 ALLOCATE (equilibrium_out(1)%profiles_1d%volume(npsi))
791 ALLOCATE (equilibrium_out(1)%profiles_1d%vprime(npsi))
792 ALLOCATE (equilibrium_out(1)%profiles_1d%area(npsi))
793 ALLOCATE (equilibrium_out(1)%profiles_1d%aprime(npsi))
794 ALLOCATE (equilibrium_out(1)%profiles_1d%surface(npsi))
795 ALLOCATE (equilibrium_out(1)%profiles_1d%ftrap(npsi))
796 ALLOCATE (equilibrium_out(1)%profiles_1d%dpsidrho_tor(npsi))
797 ALLOCATE (equilibrium_out(1)%profiles_1d%b_av(npsi))
799 ALLOCATE (equilibrium_out(1)%profiles_1d%gm1(npsi))
800 ALLOCATE (equilibrium_out(1)%profiles_1d%gm2(npsi))
801 ALLOCATE (equilibrium_out(1)%profiles_1d%gm3(npsi))
802 ALLOCATE (equilibrium_out(1)%profiles_1d%gm4(npsi))
803 ALLOCATE (equilibrium_out(1)%profiles_1d%gm5(npsi))
804 ALLOCATE (equilibrium_out(1)%profiles_1d%gm6(npsi))
805 ALLOCATE (equilibrium_out(1)%profiles_1d%gm7(npsi))
806 ALLOCATE (equilibrium_out(1)%profiles_1d%gm8(npsi))
807 ALLOCATE (equilibrium_out(1)%profiles_1d%gm9(npsi))
813 ALLOCATE (rhonew(npsi))
817 rhonew(i) = rho(neq)*(i-1)/(npsi-1)
821 equilibrium_out(1)%profiles_1d%rho_tor = rhonew
824 fun_in = sqrt(vol/vol(neq))
826 equilibrium_out(1)%profiles_1d%rho_vol =
fun
828 equilibrium_out(1)%profiles_1d%gm1 =
fun
830 equilibrium_out(1)%profiles_1d%gm2 =
fun
832 equilibrium_out(1)%profiles_1d%gm3 =
fun
834 equilibrium_out(1)%profiles_1d%gm4 =
fun
836 equilibrium_out(1)%profiles_1d%gm5 =
fun
838 equilibrium_out(1)%profiles_1d%gm6 =
fun
840 equilibrium_out(1)%profiles_1d%gm7 = g7
841 fun_in = 1._r8/g1**0.5
843 equilibrium_out(1)%profiles_1d%gm8 =
fun
846 equilibrium_out(1)%profiles_1d%gm9 =
fun
848 equilibrium_out(1)%profiles_1d%F_dia =
fun
850 equilibrium_out(1)%profiles_1d%volume =
fun
851 CALL
l3interp(vprime_psi, rho, neq,
fun, rhonew, npsi)
852 equilibrium_out(1)%profiles_1d%vprime = -
fun
854 equilibrium_out(1)%profiles_1d%psi = -
fun
855 fun_in = pr * 1.0e6_r8
857 equilibrium_out(1)%profiles_1d%pressure =
fun
858 fun_in = jpar * 1.0e6_r8
860 equilibrium_out(1)%profiles_1d%jparallel =
fun
862 equilibrium_out(1)%profiles_1d%q = -
fun
864 equilibrium_out(1)%profiles_1d%surface =
fun
866 equilibrium_out(1)%profiles_1d%area =
fun
868 equilibrium_out(1)%profiles_1d%elongation =
fun
869 CALL
l3interp(triang_u, rho, neq,
fun, rhonew, npsi)
870 equilibrium_out(1)%profiles_1d%tria_upper =
fun
871 CALL
l3interp(triang_l, rho, neq,
fun, rhonew, npsi)
872 equilibrium_out(1)%profiles_1d%tria_lower =
fun
874 equilibrium_out(1)%profiles_1d%r_inboard = r0 -
fun
875 equilibrium_out(1)%profiles_1d%r_outboard = r0 +
fun
877 equilibrium_out(1)%profiles_1d%ftrap = 1.0_r8 -
fun
878 CALL
l3deriv(psi, rho, neq,
fun, rhonew, npsi)
879 equilibrium_out(1)%profiles_1d%dpsidrho_tor = -
fun
881 equilibrium_out(1)%profiles_1d%pprime = -
fun
882 CALL
l3interp(ffprime, rho, neq,
fun, rhonew, npsi)
883 equilibrium_out(1)%profiles_1d%ffprime =
fun
886 equilibrium_out(1)%profiles_1d%b_av =
fun
891 CALL
l3interp(equilibrium_in(1)%profiles_1d%gm2, &
892 equilibrium_in(1)%profiles_1d%rho_tor, &
893 SIZE (equilibrium_in(1)%profiles_1d%rho_tor), &
894 equilibrium_out(1)%profiles_1d%gm2, &
895 equilibrium_out(1)%profiles_1d%rho_tor, &
896 SIZE (equilibrium_out(1)%profiles_1d%rho_tor))
897 equilibrium_out(1)%profiles_1d%gm2 = equilibrium_out(1)%profiles_1d%gm2 * 0.9_r8 +
fun * 0.1_r8
905 IF(
ASSOCIATED(equilibrium_out(1)%coord_sys%grid%dim1))
DEALLOCATE(equilibrium_out(1)%coord_sys%grid%dim1)
906 IF(
ASSOCIATED(equilibrium_out(1)%coord_sys%grid%dim2))
DEALLOCATE(equilibrium_out(1)%coord_sys%grid%dim2)
907 IF(
ASSOCIATED(equilibrium_out(1)%coord_sys%position%R))
DEALLOCATE(equilibrium_out(1)%coord_sys%position%R)
908 IF(
ASSOCIATED(equilibrium_out(1)%coord_sys%position%Z))
DEALLOCATE(equilibrium_out(1)%coord_sys%position%Z)
909 IF(
ASSOCIATED(equilibrium_out(1)%coord_sys%g_11))
DEALLOCATE(equilibrium_out(1)%coord_sys%g_11)
910 IF(
ASSOCIATED(equilibrium_out(1)%coord_sys%g_22))
DEALLOCATE(equilibrium_out(1)%coord_sys%g_22)
911 IF(
ASSOCIATED(equilibrium_out(1)%coord_sys%g_33))
DEALLOCATE(equilibrium_out(1)%coord_sys%g_33)
912 ALLOCATE(equilibrium_out(1)%coord_sys%grid_type(4))
913 ALLOCATE(equilibrium_out(1)%coord_sys%grid%dim1(ndim1))
914 ALLOCATE(equilibrium_out(1)%coord_sys%grid%dim2(ndim2))
915 ALLOCATE(equilibrium_out(1)%coord_sys%position%R(ndim1,ndim2))
916 ALLOCATE(equilibrium_out(1)%coord_sys%position%Z(ndim1,ndim2))
917 ALLOCATE(equilibrium_out(1)%coord_sys%g_11(ndim1,ndim2))
918 ALLOCATE(equilibrium_out(1)%coord_sys%g_22(ndim1,ndim2))
919 ALLOCATE(equilibrium_out(1)%coord_sys%g_33(ndim1,ndim2))
921 rho_loop2:
DO i=1,ndim1
922 amid_2d(i) = amin/(ndim1-1)*(i-1)
924 CALL
l3interp(rho, amid, neq, rho_2d, amid_2d, ndim1)
925 CALL
l3interp(elong, amid, neq, elong_2d, amid_2d, ndim1)
926 CALL
l3interp(elong_u, amid, neq, elong_u2d, amid_2d, ndim1)
927 CALL
l3interp(elong_l, amid, neq, elong_l2d, amid_2d, ndim1)
928 CALL
l3interp(triang_l, amid, neq, triang_l2d, amid_2d, ndim1)
929 CALL
l3interp(triang_u, amid, neq, triang_u2d, amid_2d, ndim1)
930 CALL
l3interp(shafr_shift, amid, neq, shafr_shift_2d, amid_2d, ndim1)
931 CALL
l3interp(psi, amid, neq, psi_2d, amid_2d, ndim1)
932 fun_in = jpar * 1.0e6_r8
933 CALL
l3interp(fun_in, amid, neq, jpar_2d, amid_2d, ndim1)
934 fun_in = pr * 1.0e6_r8
935 CALL
l3interp(fun_in, amid, neq, pr_2d, amid_2d, ndim1)
936 CALL
l3interp(gm11, amid, neq, g11_2d, amid_2d, ndim1)
937 CALL
l3interp(gm22, amid, neq, g22_2d, amid_2d, ndim1)
938 CALL
l3interp(gm33, amid, neq, g33_2d, amid_2d, ndim1)
943 theta =
REAL(itheta-1,r8)/
REAL(ndim2-1,r8)*2.0_r8*itm_pi
946 equilibrium_out(1)%coord_sys%grid_type(1) =
'2'
947 equilibrium_out(1)%coord_sys%grid_type(2) =
'inverse'
948 equilibrium_out(1)%coord_sys%grid_type(3) =
'3'
949 equilibrium_out(1)%coord_sys%grid_type(4) =
'polar'
950 equilibrium_out(1)%coord_sys%grid%dim1(irho) = -psi_2d(irho)
951 equilibrium_out(1)%coord_sys%grid%dim2(itheta) = theta
952 IF (theta.LE.itm_pi) tria = triang_u2d(irho)
953 IF (theta.GT.itm_pi) tria = triang_l2d(irho)
954 IF (theta.LE.itm_pi) elongation = elong_u2d(irho)
955 IF (theta.GT.itm_pi) elongation = elong_l2d(irho)
957 equilibrium_out(1)%coord_sys%position%R(irho, itheta) = r0 + shafr_shift_2d(irho) + amid_2d(irho) &
958 * (cos(theta)-tria*(sin(theta))**2)
959 equilibrium_out(1)%coord_sys%position%Z(irho, itheta) = z0 + amid_2d(irho) * elongation * sin(theta)
960 equilibrium_out(1)%coord_sys%g_11(irho, itheta) = g11_2d(irho)
961 equilibrium_out(1)%coord_sys%g_22(irho, itheta) = g22_2d(irho)
962 equilibrium_out(1)%coord_sys%g_33(irho, itheta) = g33_2d(irho)
972 ALLOCATE (equilibrium_out(1)%profiles_2d(1))
973 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%grid_type(4))
974 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%grid%dim1(ndim1))
975 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%grid%dim2(ndim2))
976 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%R(ndim1, ndim2))
977 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%Z(ndim1, ndim2))
978 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%psi(ndim1, ndim2))
979 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%theta(ndim1, ndim2))
980 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%jphi(ndim1, ndim2))
981 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%jpar(ndim1, ndim2))
982 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%br(ndim1, ndim2))
983 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%bz(ndim1, ndim2))
984 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%bphi(ndim1, ndim2))
985 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%vphi(ndim1, ndim2))
986 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%vtheta(ndim1, ndim2))
987 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%rho_mass(ndim1, ndim2))
988 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%pressure(ndim1, ndim2))
989 ALLOCATE (equilibrium_out(1)%profiles_2d(1)%temperature(ndim1, ndim2))
993 theta =
REAL(itheta-1,r8)/
REAL(ndim2-1,r8)*2.0_r8*itm_pi
996 equilibrium_out(1)%profiles_2d(1)%grid_type(1) =
'2'
997 equilibrium_out(1)%profiles_2d(1)%grid_type(2) =
'inverse'
998 equilibrium_out(1)%profiles_2d(1)%grid_type(3) =
'3'
999 equilibrium_out(1)%profiles_2d(1)%grid_type(4) =
'polar'
1000 equilibrium_out(1)%profiles_2d(1)%grid%dim1(irho) = -psi_2d(irho)
1001 equilibrium_out(1)%profiles_2d(1)%grid%dim2(itheta) = theta
1002 IF (theta.LE.itm_pi) tria = triang_u2d(irho)
1003 IF (theta.GT.itm_pi) tria = triang_l2d(irho)
1004 IF (theta.LE.itm_pi) elongation = elong_u2d(irho)
1005 IF (theta.GT.itm_pi) elongation = elong_l2d(irho)
1007 equilibrium_out(1)%profiles_2d(1)%R(irho, itheta) = r0 + shafr_shift_2d(irho) + amid_2d(irho) &
1008 * (cos(theta)-tria*(sin(theta))**2)
1009 equilibrium_out(1)%profiles_2d(1)%Z(irho, itheta) = z0 + amid_2d(irho) * elongation * sin(theta)
1010 equilibrium_out(1)%profiles_2d(1)%theta(irho, itheta) = theta
1012 equilibrium_out(1)%profiles_2d(1)%psi(irho, itheta) = -psi_2d(irho)
1013 equilibrium_out(1)%profiles_2d(1)%jpar(irho, itheta) = jpar_2d(irho)
1014 equilibrium_out(1)%profiles_2d(1)%pressure(irho, itheta) = pr_2d(irho)
1024 IF(.NOT.
ASSOCIATED(equilibrium_out(1)%codeparam%codename))
THEN
1025 ALLOCATE(equilibrium_out(1)%codeparam%codename(1))
1026 equilibrium_out(1)%codeparam%codename(1) =
'SPIDER'
1028 IF(.NOT.
ASSOCIATED(equilibrium_out(1)%codeparam%codeversion))
THEN
1029 ALLOCATE(equilibrium_out(1)%codeparam%codeversion(1))
1030 equilibrium_out(1)%codeparam%codeversion(1) =
'14.12.2012'
1032 IF(.NOT.
ASSOCIATED(equilibrium_out(1)%codeparam%parameters))
THEN
1033 ALLOCATE(equilibrium_out(1)%codeparam%parameters(1))
1034 equilibrium_out(1)%codeparam%parameters(1) =
'my_code_specific_parameters'
1036 IF(.NOT.
ASSOCIATED(equilibrium_out(1)%codeparam%output_diag))
THEN
1037 ALLOCATE(equilibrium_out(1)%codeparam%output_diag(1))
1038 equilibrium_out(1)%codeparam%output_diag(1) =
'my_output_diag'
1040 equilibrium_out(1)%codeparam%output_flag = 0
1048 IF(.NOT.
ASSOCIATED(equilibrium_out(1)%datainfo%dataprovider))
THEN
1049 ALLOCATE(equilibrium_out(1)%datainfo%dataprovider(1))
1051 equilibrium_out(1)%datainfo%dataprovider(1) =
'Denis Kalupin'
1052 equilibrium_out(1)%datainfo%cocos = 13
1061 DEALLOCATE (r_outboard)
1065 DEALLOCATE (intjpar)
1076 DEALLOCATE (ffprime)
1085 DEALLOCATE (rhonew_s)
1094 DEALLOCATE (vprimes)
1095 DEALLOCATE (vprime_psi)
1097 DEALLOCATE (gradrho)
1099 DEALLOCATE (shafr_shift)
1101 DEALLOCATE (elong_u)
1102 DEALLOCATE (elong_l)
1103 DEALLOCATE (triang_l)
1104 DEALLOCATE (triang_u)
1121 DEALLOCATE (vprime_old)
1123 DEALLOCATE (fdia_old)
1125 DEALLOCATE (amid_2d)
1127 DEALLOCATE (elong_2d)
1128 DEALLOCATE (elong_u2d)
1129 DEALLOCATE (elong_l2d)
1130 DEALLOCATE (triang_l2d)
1131 DEALLOCATE (triang_u2d)
1132 DEALLOCATE (shafr_shift_2d)
1134 DEALLOCATE (jpar_2d)
1143 str =
'rm -rf *.dat *.wr'
1180 USE euitm_xml_parser
1185 TYPE(type_param
) :: codeparameters
1186 TYPE(tree
) :: parameter_list
1187 TYPE(element
),
POINTER :: temp_pointer
1189 INTEGER(ITM_I4) :: return_status
1190 INTEGER(ITM_I4) :: i, nparm, n_values
1193 CHARACTER(len = 132) :: cname
1202 WRITE(6,*)
'Calling euitm_xml_parse'
1203 CALL euitm_xml_parse(codeparameters, nparm, parameter_list)
1204 WRITE(6,*)
'Called euitm_xml_parse'
1208 temp_pointer => parameter_list%first
1211 cname = char2str(temp_pointer%cname)
1217 temp_pointer => temp_pointer%child
1223 temp_pointer => temp_pointer%child
1227 if (
allocated(temp_pointer%cvalue)) &
1228 call char2num(temp_pointer%cvalue, icontrol)
1231 if (
allocated(temp_pointer%cvalue)) &
1232 call char2num(temp_pointer%cvalue, key_iter)
1235 if (
allocated(temp_pointer%cvalue)) &
1236 call char2num(temp_pointer%cvalue, nrho)
1239 if (
allocated(temp_pointer%cvalue)) &
1240 call char2num(temp_pointer%cvalue, ntheta)
1243 if (
allocated(temp_pointer%cvalue)) &
1244 call char2num(temp_pointer%cvalue, neq)
1247 if (
allocated(temp_pointer%cvalue)) &
1248 call char2num(temp_pointer%cvalue, tolerance)
1251 if (
allocated(temp_pointer%cvalue)) &
1252 call char2num(temp_pointer%cvalue, iinput)
1255 write(*, *)
'ERROR: invalid parameter', cname
1262 if (
associated(temp_pointer%sibling))
then
1263 temp_pointer => temp_pointer%sibling
1266 if (
associated(temp_pointer%parent, parameter_list%first )) &
1268 if (
associated(temp_pointer%parent))
then
1269 temp_pointer => temp_pointer%parent
1271 write(*, *)
'ERROR: broken list.'
1278 CALL destroy_xml_tree(parameter_list)
subroutine l3deriv(y_in, x_in, nr_in, dydx_out, x_out, nr_out)
subroutine l3interp(y_in, x_in, nr_in, y_out, x_out, nr_out)
subroutine equilibrium_spider(EQUILIBRIUM_IN, COREPROF_IN, EQUILIBRIUM_OUT, code_parameters)
subroutine assign_spider_parameters(codeparameters, return_status)
real(r8) function fdia(psi_n)
real(r8) function p(a, x, xr, xs, yr, ys, psi, psir, F_dia)