12 USE stel_kinds,
ONLY: rprec
34 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: x => null()
36 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: y => null()
38 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: z => null()
41 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: j_x => null()
43 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: j_y => null()
45 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: j_z => null()
47 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: vol => null()
74 INTEGER,
INTENT(in) :: num_v
75 INTEGER,
INTENT(in) :: flags
78 INTEGER,
INTENT(in) :: io_unit
81 REAL (rprec) :: start_time
100 IF (parallel%offset .eq. 0)
THEN
106 1000
FORMAT(
'Prime Grid Ready')
122 USE stel_constants,
ONLY: twopi, mu0
123 USE read_wout_mod,
ONLY: mnmax, mnmax_nyq, lasym, isigng, ns, &
124 & xm, xn, xm_nyq, xn_nyq, &
125 & rmnc, zmns, currumnc, currvmnc, &
126 & rmns, zmnc, currumns, currvmns
132 INTEGER,
INTENT(in) :: num_v
136 REAL (rprec) :: start_time
153 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosv
154 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinv
155 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosmu
156 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinmu
157 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosmu_nyq
158 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinmu_nyq
159 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosnv
160 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinnv
161 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosnv_nyq
162 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinnv_nyq
163 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosmn
164 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinmn
165 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosmn_nyq
166 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinmn_nyq
170 INTEGER,
PARAMETER :: num_u = 101
171 REAL (rprec),
PARAMETER :: du = twopi/num_u
178 IF (num_v .eq. 1)
THEN
194 ALLOCATE(cosv(num_v_use))
195 ALLOCATE(sinv(num_v_use))
196 ALLOCATE(cosmu(mnmax,num_u))
197 ALLOCATE(sinmu(mnmax,num_u))
198 ALLOCATE(cosnv(mnmax,num_v_use))
199 ALLOCATE(sinnv(mnmax,num_v_use))
200 ALLOCATE(cosmu_nyq(mnmax_nyq,num_u))
201 ALLOCATE(sinmu_nyq(mnmax_nyq,num_u))
202 ALLOCATE(cosnv_nyq(mnmax_nyq,num_v_use))
203 ALLOCATE(sinnv_nyq(mnmax_nyq,num_v_use))
217 IF (parallel%stride .gt. 1)
THEN
244 cosmu(:,i) = cos(xm*x)
245 sinmu(:,i) = sin(xm*x)
246 cosmu_nyq(:,i) = cos(xm_nyq*x)
247 sinmu_nyq(:,i) = sin(xm_nyq*x)
259 cosnv(:,i) = cos(xn*x)
260 sinnv(:,i) = sin(xn*x)
261 cosnv_nyq(:,i) = cos(xn_nyq*x)
262 sinnv_nyq(:,i) = sin(xn_nyq*x)
266 IF (parallel%stride .gt. 1)
THEN
281 ALLOCATE(cosmn(mnmax))
282 ALLOCATE(sinmn(mnmax))
283 ALLOCATE(cosmn_nyq(mnmax_nyq))
285 ALLOCATE(sinmn_nyq(mnmax_nyq))
296 cosmn = cosmu(:,ui)*cosnv(:,vi) + sinmu(:,ui)*sinnv(:,vi)
297 sinmn = sinmu(:,ui)*cosnv(:,vi) - cosmu(:,ui)*sinnv(:,vi)
298 cosmn_nyq = cosmu_nyq(:,ui)*cosnv_nyq(:,vi)
299 & + sinmu_nyq(:,ui)*sinnv_nyq(:,vi)
301 r = sum(rmnc(:,si)*cosmn(:))
302 z = sum(zmns(:,si)*sinmn(:))
306 ru = -sum(xm*rmnc(:,si)*sinmn(:))
307 rv = sum(xn*rmnc(:,si)*sinmn(:))
308 zu = sum(xm*zmns(:,si)*cosmn(:))
309 zv = -sum(xn*zmns(:,si)*cosmn(:))
311 ju = sum(currumnc(:,si)*cosmn_nyq(:))*mu0
312 jv = sum(currvmnc(:,si)*cosmn_nyq(:))*mu0
318 sinmn_nyq = sinmu_nyq(:,ui)*cosnv_nyq(:,vi)
319 & - cosmu_nyq(:,ui)*sinnv_nyq(:,vi)
321 r = r + sum(rmns(:,si)*sinmn(:))
322 z = z + sum(zmnc(:,si)*cosmn(:))
324 ru = ru + sum(xm*rmns(:,si)*cosmn(:))
325 rv = rv - sum(xn*rmns(:,si)*cosmn(:))
326 zu = zu - sum(xm*zmnc(:,si)*sinmn(:))
327 zv = zv + sum(xn*zmnc(:,si)*sinmn(:))
329 ju = ju + sum(currumns(:,si)*sinmn_nyq(:))*mu0
330 jv = jv + sum(currvmns(:,si)*sinmn_nyq(:))*mu0
337 IF (si .eq. 1 .or. si .eq. ns)
THEN
360 DEALLOCATE(cosmn_nyq)
362 DEALLOCATE(sinmn_nyq)
372 DEALLOCATE(cosmu_nyq)
373 DEALLOCATE(sinmu_nyq)
374 DEALLOCATE(cosnv_nyq)
375 DEALLOCATE(sinnv_nyq)
379 IF (parallel%stride .gt. 1)
THEN
413 USE stel_constants,
ONLY: twopi, mu0
414 USE read_wout_mod,
ONLY: mnmax, mnmax_nyq, lasym, isigng, ns, &
415 & rmnc, rmns, currvmnc, &
416 & zmnc, zmns, currvmns, &
417 & bsupumnc, bsupvmnc, bsupumns, bsupvmns, &
418 & xm, xn, xm_nyq, xn_nyq, presf
424 INTEGER,
INTENT(in) :: num_v
428 REAL (rprec) :: start_time
447 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosv
448 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinv
449 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosmu
450 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinmu
451 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosmu_nyq
452 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinmu_nyq
453 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosnv
454 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinnv
455 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosnv_nyq
456 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinnv_nyq
457 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosmn
458 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinmn
459 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosmn_nyq
460 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinmn_nyq
461 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: rmnch
462 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: rmnsh
463 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: zmnch
464 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: zmnsh
465 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: currvmnch
466 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: currvmnsh
467 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: p_prime
471 INTEGER,
PARAMETER :: num_u = 101
472 REAL (rprec),
PARAMETER :: du = twopi/num_u
479 IF (num_v .eq. 1)
THEN
493 ALLOCATE(cosv(num_v_use))
494 ALLOCATE(sinv(num_v_use))
495 ALLOCATE(cosmu(mnmax,num_u))
496 ALLOCATE(sinmu(mnmax,num_u))
497 ALLOCATE(cosnv(mnmax,num_v_use))
498 ALLOCATE(sinnv(mnmax,num_v_use))
499 ALLOCATE(cosmu_nyq(mnmax_nyq,num_u))
500 ALLOCATE(sinmu_nyq(mnmax_nyq,num_u))
501 ALLOCATE(cosnv_nyq(mnmax_nyq,num_v_use))
502 ALLOCATE(sinnv_nyq(mnmax_nyq,num_v_use))
504 ALLOCATE(rmnch(mnmax,ns - 1))
505 ALLOCATE(zmnsh(mnmax,ns - 1))
506 ALLOCATE(currvmnch(mnmax_nyq,ns - 1))
509 ALLOCATE(rmnsh(mnmax,ns - 1))
510 ALLOCATE(zmnch(mnmax,ns - 1))
511 ALLOCATE(currvmnsh(mnmax_nyq,ns - 1))
514 ALLOCATE(p_prime(ns - 1))
528 IF (parallel%stride .gt. 1)
THEN
564 rmnch(:,i) = (rmnc(:,i + 1) + rmnc(:,i))/2.0
565 zmnsh(:,i) = (zmns(:,i + 1) + zmns(:,i))/2.0
567 currvmnch(:,i) = (currvmnc(:,i + 1) + currvmnc(:,i))/2.0
569 p_prime(i) = (presf(i + 1) - presf(i))/ds
572 rmnsh(:,i) = (rmns(:,i + 1) + rmns(:,i))/2.0
573 zmnch(:,i) = (zmnc(:,i + 1) + zmnc(:,i))/2.0
575 currvmnsh(:,i) = (currvmns(:,i + 1) + currvmns(:,i))/2.0
585 cosmu(:,i) = cos(xm*x)
586 sinmu(:,i) = sin(xm*x)
587 cosmu_nyq(:,i) = cos(xm_nyq*x)
588 sinmu_nyq(:,i) = sin(xm_nyq*x)
599 cosnv(:,i) = cos(xn*x)
600 sinnv(:,i) = sin(xn*x)
601 cosnv_nyq(:,i) = cos(xn_nyq*x)
602 sinnv_nyq(:,i) = sin(xn_nyq*x)
606 IF (parallel%stride .gt. 1)
THEN
630 ALLOCATE(cosmn(mnmax))
631 ALLOCATE(sinmn(mnmax))
632 ALLOCATE(cosmn_nyq(mnmax_nyq))
634 ALLOCATE(sinmn_nyq(mnmax_nyq))
645 cosmn = cosmu(:,ui)*cosnv(:,vi) + sinmu(:,ui)*sinnv(:,vi)
646 sinmn = sinmu(:,ui)*cosnv(:,vi) - cosmu(:,ui)*sinnv(:,vi)
647 cosmn_nyq = cosmu_nyq(:,ui)*cosnv_nyq(:,vi)
648 & + sinmu_nyq(:,ui)*sinnv_nyq(:,vi)
650 r = sum(rmnch(:,si)*cosmn(:))
651 z = sum(zmnsh(:,si)*sinmn(:))
653 ru = -sum(xm*rmnch(:,si)*sinmn(:))
654 rv = sum(xn*rmnch(:,si)*sinmn(:))
655 zu = sum(xm*zmnsh(:,si)*cosmn(:))
656 zv = -sum(xn*zmnsh(:,si)*cosmn(:))
658 jv = sum(currvmnch(:,si)*cosmn_nyq(:))
660 bu = sum(bsupumnc(:,si + 1)*cosmn_nyq(:))
661 bv = sum(bsupvmnc(:,si + 1)*cosmn_nyq(:))
664 sinmn_nyq = sinmu_nyq(:,ui)*cosnv_nyq(:,vi)
665 & - cosmu_nyq(:,ui)*sinnv_nyq(:,vi)
667 r = r + sum(rmnsh(:,si)*sinmn(:))
668 z = z + sum(zmnch(:,si)*cosmn(:))
670 ru = ru + sum(xm*rmnsh(:,si)*cosmn(:))
671 rv = rv - sum(xn*rmnsh(:,si)*cosmn(:))
672 zu = zu - sum(xm*zmnch(:,si)*sinmn(:))
673 zv = zv + sum(xn*zmnch(:,si)*sinmn(:))
675 jv = jv + sum(currvmnsh(:,si)*sinmn_nyq(:))
677 bu = bu + sum(bsupumns(:,si + 1)*sinmn_nyq(:))
678 bv = bv + sum(bsupvmns(:,si + 1)*sinmn_nyq(:))
681 ju = (p_prime(si) + jv*bu)/bv*mu0
701 DEALLOCATE(cosmn_nyq)
703 DEALLOCATE(sinmn_nyq)
713 DEALLOCATE(cosmu_nyq)
714 DEALLOCATE(sinmu_nyq)
715 DEALLOCATE(cosnv_nyq)
716 DEALLOCATE(sinnv_nyq)
720 DEALLOCATE(currvmnch)
725 DEALLOCATE(currvmnsh)
730 IF (parallel%stride .gt. 1)
THEN
764 USE stel_constants,
ONLY: twopi, mu0
765 USE read_wout_mod,
ONLY: mnmax, mnmax_nyq, lasym, isigng, ns, &
766 & rmnc, rmns, currumnc, &
767 & zmnc, zmns, currumns, &
768 & bsupumnc, bsupvmnc, bsupumns, bsupvmns, &
769 & xm, xn, xm_nyq, xn_nyq, presf
775 INTEGER,
INTENT(in) :: num_v
779 REAL (rprec) :: start_time
798 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosv
799 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinv
800 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosmu
801 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinmu
802 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosmu_nyq
803 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinmu_nyq
804 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosnv
805 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinnv
806 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosnv_nyq
807 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinnv_nyq
808 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosmn
809 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinmn
810 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosmn_nyq
811 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinmn_nyq
812 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: rmnch
813 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: rmnsh
814 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: zmnch
815 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: zmnsh
816 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: currumnch
817 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: currumnsh
818 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: p_prime
822 INTEGER,
PARAMETER :: num_u = 101
823 REAL (rprec),
PARAMETER :: du = twopi/num_u
830 IF (num_v .eq. 1)
THEN
844 ALLOCATE(cosv(num_v_use))
845 ALLOCATE(sinv(num_v_use))
846 ALLOCATE(cosmu(mnmax,num_u))
847 ALLOCATE(sinmu(mnmax,num_u))
848 ALLOCATE(cosnv(mnmax,num_v_use))
849 ALLOCATE(sinnv(mnmax,num_v_use))
850 ALLOCATE(cosmu_nyq(mnmax_nyq,num_u))
851 ALLOCATE(sinmu_nyq(mnmax_nyq,num_u))
852 ALLOCATE(cosnv_nyq(mnmax_nyq,num_v_use))
853 ALLOCATE(sinnv_nyq(mnmax_nyq,num_v_use))
855 ALLOCATE(rmnch(mnmax,ns - 1))
856 ALLOCATE(zmnsh(mnmax,ns - 1))
857 ALLOCATE(currumnch(mnmax_nyq,ns - 1))
860 ALLOCATE(rmnsh(mnmax,ns - 1))
861 ALLOCATE(zmnch(mnmax,ns - 1))
862 ALLOCATE(currumnsh(mnmax_nyq,ns - 1))
865 ALLOCATE(p_prime(ns - 1))
879 IF (parallel%stride .gt. 1)
THEN
915 rmnch(:,si) = (rmnc(:,si + 1) + rmnc(:,si))/2.0
916 zmnsh(:,si) = (zmns(:,si + 1) + zmns(:,si))/2.0
918 currumnch(:,si) = (currumnc(:,si + 1) + currumnc(:,si))/2.0
920 p_prime(si) = (presf(si + 1) - presf(si))/ds
923 rmnsh(:,si) = (rmns(:,si + 1) + rmns(:,si))/2.0
924 zmnch(:,si) = (zmnc(:,si + 1) + zmnc(:,si))/2.0
926 currumnsh(:,si) = (currumns(:,si + 1) + currumns(:,si))/2.0
936 cosmu(:,i) = cos(xm*x)
937 sinmu(:,i) = sin(xm*x)
938 cosmu_nyq(:,i) = cos(xm_nyq*x)
939 sinmu_nyq(:,i) = sin(xm_nyq*x)
950 cosnv(:,i) = cos(xn*x)
951 sinnv(:,i) = sin(xn*x)
952 cosnv_nyq(:,i) = cos(xn_nyq*x)
953 sinnv_nyq(:,i) = sin(xn_nyq*x)
957 IF (parallel%stride .gt. 1)
THEN
981 ALLOCATE(cosmn(mnmax))
982 ALLOCATE(sinmn(mnmax))
983 ALLOCATE(cosmn_nyq(mnmax_nyq))
985 ALLOCATE(sinmn_nyq(mnmax_nyq))
996 cosmn = cosmu(:,ui)*cosnv(:,vi) + sinmu(:,ui)*sinnv(:,vi)
997 sinmn = sinmu(:,ui)*cosnv(:,vi) - cosmu(:,ui)*sinnv(:,vi)
998 cosmn_nyq = cosmu_nyq(:,ui)*cosnv_nyq(:,vi)
999 & + sinmu_nyq(:,ui)*sinnv_nyq(:,vi)
1001 r = sum(rmnch(:,si)*cosmn(:))
1002 z = sum(zmnsh(:,si)*sinmn(:))
1004 ru = -sum(xm*rmnch(:,si)*sinmn(:))
1005 rv = sum(xn*rmnch(:,si)*sinmn(:))
1006 zu = sum(xm*zmnsh(:,si)*cosmn(:))
1007 zv = -sum(xn*zmnsh(:,si)*cosmn(:))
1009 ju = sum(currumnch(:,si)*cosmn_nyq(:))
1011 bu = sum(bsupumnc(:,si + 1)*cosmn_nyq(:))
1012 bv = sum(bsupvmnc(:,si + 1)*cosmn_nyq(:))
1015 sinmn_nyq = sinmu_nyq(:,ui)*cosnv_nyq(:,vi)
1016 & - cosmu_nyq(:,ui)*sinnv_nyq(:,vi)
1018 r = r + sum(rmnsh(:,si)*sinmn(:))
1019 z = z + sum(zmnch(:,si)*cosmn(:))
1021 ru = ru + sum(xm*rmnsh(:,si)*cosmn(:))
1022 rv = rv - sum(xn*rmnsh(:,si)*cosmn(:))
1023 zu = zu - sum(xm*zmnch(:,si)*sinmn(:))
1024 zv = zv + sum(xn*zmnch(:,si)*sinmn(:))
1026 ju = ju + sum(currumnsh(:,si)*sinmn_nyq(:))
1028 bu = bu + sum(bsupumns(:,si + 1)*sinmn_nyq(:))
1029 bv = bv + sum(bsupvmns(:,si + 1)*sinmn_nyq(:))
1032 jv = (ju*bv - p_prime(si))/bu*mu0
1052 DEALLOCATE(cosmn_nyq)
1054 DEALLOCATE(sinmn_nyq)
1064 DEALLOCATE(cosmu_nyq)
1065 DEALLOCATE(sinmu_nyq)
1066 DEALLOCATE(cosnv_nyq)
1067 DEALLOCATE(sinnv_nyq)
1071 DEALLOCATE(currumnch)
1076 DEALLOCATE(currumnsh)
1081 IF (parallel%stride .gt. 1)
THEN
1115 USE stel_constants,
ONLY: twopi, mu0
1116 USE read_wout_mod,
ONLY: nfp, ns, rmnc, rmns, zmnc, zmns, isigng, &
1117 & mnmax, xm, xn, lasym
1124 INTEGER,
INTENT(in) :: num_v
1125 CHARACTER (len=*) :: siesta_file_name
1129 REAL (rprec) :: start_time
1154 REAL (rprec) :: wlow
1155 REAL (rprec) :: whigh
1156 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosv
1157 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinv
1158 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosmu
1159 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinmu
1160 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosnv
1161 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinnv
1162 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosmu_vmec
1163 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinmu_vmec
1164 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosnv_vmec
1165 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinnv_vmec
1166 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: cosmn
1167 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sinmn
1168 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosmn_vmec
1169 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinmn_vmec
1170 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: amnint
1171 INTEGER :: num_v_use
1175 INTEGER,
PARAMETER :: num_u = 101
1176 real (rprec),
PARAMETER :: du = twopi/num_u
1185 IF (num_v .eq. 1)
THEN
1205 ALLOCATE(cosv(num_v_use))
1206 ALLOCATE(sinv(num_v_use))
1207 ALLOCATE(cosmu_vmec(mnmax,num_u))
1208 ALLOCATE(sinmu_vmec(mnmax,num_u))
1209 ALLOCATE(cosnv_vmec(mnmax,num_v_use))
1210 ALLOCATE(sinnv_vmec(mnmax,num_v_use))
1211 ALLOCATE(cosmu(0:siesta%mpol,num_u))
1212 ALLOCATE(sinmu(0:siesta%mpol,num_u))
1213 ALLOCATE(cosnv(-siesta%ntor:siesta%ntor,num_v_use))
1214 ALLOCATE(sinnv(-siesta%ntor:siesta%ntor,num_v_use))
1229 IF (parallel%stride .gt. 1)
THEN
1255 cosmu_vmec(:,i) = cos(xm*x)
1256 sinmu_vmec(:,i) = sin(xm*x)
1258 DO m = 0, siesta%mpol
1259 cosmu(m,i) = cos(m*x)
1260 sinmu(m,i) = sin(m*x)
1272 cosnv_vmec(:,i) = cos(xn*x)
1273 sinnv_vmec(:,i) = sin(xn*x)
1274 DO n = -siesta%ntor, siesta%ntor
1275 cosnv(n,i) = cos(n*x)
1276 sinnv(n,i) = sin(n*x)
1281 IF (parallel%stride .gt. 1)
THEN
1296 ALLOCATE(cosmn(0:siesta%mpol,-siesta%ntor:siesta%ntor))
1297 ALLOCATE(sinmn(0:siesta%mpol,-siesta%ntor:siesta%ntor))
1299 ALLOCATE(cosmn_vmec(mnmax))
1300 ALLOCATE(sinmn_vmec(mnmax))
1302 ALLOCATE(amnint(mnmax))
1307 & siesta%nrad*num_u*num_v_use),
1309 & siesta%nrad*num_u*num_v_use)
1314 x = (si - 1.0)/(siesta%nrad - 1.0)
1316 CALL primed_grid_siesta_interpol(x, ilow, wlow, ihigh, whigh)
1318 cosmn_vmec = cosmu_vmec(:,ui)*cosnv_vmec(:,vi)
1319 & + sinmu_vmec(:,ui)*sinnv_vmec(:,vi)
1320 sinmn_vmec = sinmu_vmec(:,ui)*cosnv_vmec(:,vi)
1321 & - cosmu_vmec(:,ui)*sinnv_vmec(:,vi)
1323 DO n = -siesta%ntor, siesta%ntor
1324 DO m = 0, siesta%mpol
1325 cosmn(m,n) = cosmu(m, ui)*cosnv(n, vi)
1326 & - sinmu(m, ui)*sinnv(n, vi)
1327 sinmn(m,n) = sinmu(m, ui)*cosnv(n, vi)
1328 & + cosmu(m, ui)*sinnv(n, vi)
1332 amnint = wlow*rmnc(:,ilow) + whigh*rmnc(:,ihigh)
1333 r = sum(amnint*cosmn_vmec)
1334 ru = -sum(xm*amnint*sinmn_vmec)
1335 rv = sum(xn*amnint*sinmn_vmec)
1337 amnint = wlow*zmns(:,ilow) + whigh*zmns(:,ihigh)
1338 z = sum(amnint*sinmn_vmec)
1339 zu = sum(xm*amnint*cosmn_vmec)
1340 zv = -sum(xn*amnint*cosmn_vmec)
1342 amnint = 2.0*x*(rmnc(:,ihigh) - rmnc(:,ilow))*(ns - 1.0)
1343 rs = sum(amnint*cosmn_vmec)
1345 amnint = 2.0*x*(zmns(:,ihigh) - zmns(:,ilow))*(ns - 1.0)
1346 zs = sum(amnint*sinmn_vmec)
1348 js = sum(siesta%jksupsmnsf(:,:,si)*sinmn)
1349 ju = sum(siesta%jksupumncf(:,:,si)*cosmn)
1350 jv = sum(siesta%jksupvmncf(:,:,si)*cosmn)
1353 amnint = wlow*rmns(:,ilow) + whigh*rmns(:,ihigh)
1354 r = r + sum(amnint*sinmn_vmec)
1355 ru = ru + sum(xm*amnint*cosmn_vmec)
1356 rv = rv - sum(xn*amnint*cosmn_vmec)
1358 amnint = wlow*zmnc(:,ilow) + whigh*zmnc(:,ihigh)
1359 z = z + sum(amnint*cosmn_vmec)
1360 zu = zu - sum(xm*amnint*sinmn_vmec)
1361 zv = zv + sum(xn*amnint*sinmn_vmec)
1363 amnint = 2.0*x*(rmns(:,ihigh) - rmns(:,ilow))*(ns - 1.0)
1364 rs = rs + sum(amnint*sinmn_vmec)
1366 amnint = 2.0*x*(zmnc(:,ihigh) - zmnc(:,ilow))*(ns - 1.0)
1367 zs = zs + sum(amnint*cosmn_vmec)
1370 js = js + sum(siesta%jksupsmncf(:,:,si)*cosmn)
1371 ju = ju + sum(siesta%jksupumnsf(:,:,si)*sinmn)
1372 jv = jv + sum(siesta%jksupvmnsf(:,:,si)*sinmn)
1376 js = js/(siesta%b_factor*mu0)
1377 ju = ju/(siesta%b_factor*mu0)
1378 jv = jv/(siesta%b_factor*mu0)
1380 jr = js*rs + ju*ru + jv*rv
1382 jz = js*zs + ju*zu + jv*zv
1384 IF (si .eq. 1 .or. si .eq. ns)
THEN
1405 DEALLOCATE(cosmn_vmec)
1406 DEALLOCATE(sinmn_vmec)
1413 DEALLOCATE(cosmu_vmec)
1414 DEALLOCATE(sinmu_vmec)
1415 DEALLOCATE(cosnv_vmec)
1416 DEALLOCATE(sinnv_vmec)
1424 IF (parallel%stride .gt. 1)
THEN
1461 TYPE (primed_grid_class),
POINTER :: this
1464 IF (
ASSOCIATED(this%x))
THEN
1469 IF (
ASSOCIATED(this%y))
THEN
1474 IF (
ASSOCIATED(this%z))
THEN
1479 IF (
ASSOCIATED(this%j_x))
THEN
1480 DEALLOCATE(this%j_x)
1484 IF (
ASSOCIATED(this%j_y))
THEN
1485 DEALLOCATE(this%j_y)
1489 IF (
ASSOCIATED(this%j_z))
THEN
1490 DEALLOCATE(this%j_z)
1501 SUBROUTINE primed_grid_siesta_interpol(s, ilow, wlow, &
1503 USE read_wout_mod,
ONLY: ns
1508 REAL (rprec),
INTENT(in) :: s
1509 INTEGER,
INTENT(out) :: ilow
1510 REAL (rprec),
INTENT(out) :: wlow
1511 INTEGER,
INTENT(out) :: ihigh
1512 REAL (rprec),
INTENT(out) :: whigh
1515 REAL (rprec) :: start_time
1516 REAL (rprec) :: wlow_r
1521 wlow_r = s*s*(ns - 1.0) + 1.0
1522 ilow = floor(wlow_r)
1523 IF (ilow .eq. ns)
THEN
1527 wlow = -wlow_r + 1.0 + ilow