13 USE stel_kinds,
ONLY: rprec
32 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: a_r => null()
34 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: a_p => null()
36 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: a_z => null()
39 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: b_r => null()
41 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: b_p => null()
43 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: b_z => null()
80 use,
INTRINSIC :: iso_fortran_env, only : output_unit
88 INTEGER,
INTENT(in) :: p_start
89 INTEGER,
INTENT(in) :: p_end
91 INTEGER,
INTENT(in) :: io_unit
94 REAL (rprec) :: start_time
108 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: r
109 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: z
110 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: r_p
111 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: r_m
112 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosv
113 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinv
114 REAL (rprec) :: total
116 REAL (rprec) :: current
117 REAL (rprec),
DIMENSION(:,:,:),
ALLOCATABLE :: rp
130 num_r =
SIZE(mgrid%a_r, 1)
131 num_p =
SIZE(mgrid%a_p, 3)
132 num_z =
SIZE(mgrid%a_z, 2)
142 ALLOCATE(cosv(num_p))
143 ALLOCATE(sinv(num_p))
151 total = ceiling(total/parallel%num_threads)
159 IF (parallel%stride .gt. 1)
THEN
180 r(i) = (i - 1.0)*mgrid%dr + mgrid%rmin
181 r_p(i) = r(i) + mgrid%dr
182 r_m(i) = r(i) - mgrid%dr
190 z(i) = (i - 1.0)*mgrid%dz + mgrid%zmin
198 x = (i - 1.0)*pgrid%dv
205 IF (parallel%stride .gt. 1)
THEN
217 ALLOCATE(rp(
SIZE(pgrid%x, 1),
229 IF (parallel%offset .eq. 0)
THEN
231 current = current + 1.0
232 done = 100.0*current/total
234 WRITE (io_unit,1000,advance=
'NO')
237 IF (io_unit .ne. output_unit)
THEN
246 rp = sqrt((pgrid%x - x)**2.0 + (pgrid%y - y)**2.0 +
247 & (pgrid%z - z(zi))**2.0)
249 ax = sum(pgrid%j_x/rp)*pgrid%dvol
250 ay = sum(pgrid%j_y/rp)*pgrid%dvol
253 & x/r(ri)*ax + y/r(ri)*ay + mgrid%a_r(ri,zi,vi)
255 & -y/r(ri)*ax + x/r(ri)*ay + mgrid%a_p(ri,zi,vi)
257 & sum(pgrid%j_z/rp)*pgrid%dvol + mgrid%a_z(ri,zi,vi)
266 IF (parallel%stride .gt. 1)
THEN
284 IF (ri .eq. 1 .or. ri .eq. num_r .or.
285 & zi .eq. 1 .or. zi .eq. num_z)
THEN
290 IF (num_p .eq. 1)
THEN
297 ELSE IF (vi .eq. num_p)
THEN
312 & (az_p - az_m)/(2.0*pgrid%dv*r(ri)) -
313 & (ap_p - ap_m)/(2.0*mgrid%dz)
321 & (ar_p - ar_m)/(2.0*mgrid%dz) -
322 & (az_p - az_m)/(2.0*mgrid%dr)
330 & (r_p(ri)*ap_p - r_m(ri)*ap_m)/(2.0*mgrid%dr*r(ri)) -
331 & (ar_p - ar_m)/(2.0*pgrid%dv*r(ri))
338 IF (parallel%stride .gt. 1)
THEN
354 IF (parallel%offset .eq. 0)
THEN
361 1000
FORMAT(a,a,f6.2,
' % Finished')
362 1001
FORMAT(a,
'Unprimed Grid Finished')
387 & dphi, parallel, io_unit)
390 use,
INTRINSIC :: iso_fortran_env, only : output_unit
399 REAL (rprec),
DIMENSION(:,:,:),
INTENT(in) :: r_grid
400 REAL (rprec),
DIMENSION(:,:,:),
INTENT(in) :: z_grid
401 REAL (rprec),
INTENT(in) :: dphi
403 INTEGER,
INTENT(in) :: io_unit
406 REAL (rprec) :: start_time
410 REAL (rprec) :: current
412 REAL (rprec) :: total
417 REAL (rprec),
DIMENSION(:,:,:),
ALLOCATABLE :: rp
424 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: phi
425 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: cosv
426 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sinv
431 IF (maxval(r_grid) .gt. mgrid%rmax .or.
432 & minval(r_grid) .lt. mgrid%rmin .or.
433 & maxval(z_grid) .gt. mgrid%zmax .or.
434 & minval(z_grid) .lt. mgrid%zmin)
THEN
435 IF (parallel%offset .eq. 0)
THEN
436 WRITE (io_unit, 2000)
443 num_1 =
SIZE(r_grid, 1)
444 num_2 =
SIZE(r_grid, 2)
445 num_3 =
SIZE(r_grid, 3)
451 ALLOCATE(cosv(num_2))
452 ALLOCATE(sinv(num_2))
456 total = ceiling(total/parallel%num_threads)
463 IF (parallel%stride .gt. 1)
THEN
478 phi(i) = (i - 1.0)*dphi
479 cosv(i) = cos(phi(i))
480 sinv(i) = sin(phi(i))
485 IF (parallel%stride .gt. 1)
THEN
494 ALLOCATE(rp(
SIZE(pgrid%x, 1),
506 IF (parallel%offset .eq. 0)
THEN
508 current = current + 1.0
509 done = 100.0*current/total
511 WRITE (io_unit,1000,advance=
'NO')
514 IF (io_unit .ne. output_unit)
THEN
525 rp = sqrt((pgrid%x - x)**2.0 +
526 & (pgrid%y - y)**2.0 +
527 & (pgrid%z - z)**2.0)
529 ax = sum(pgrid%j_x/rp)*pgrid%dvol
530 ay = sum(pgrid%j_y/rp)*pgrid%dvol
545 & sum(pgrid%j_z/rp)*pgrid%dvol
555 IF (parallel%stride .gt. 1)
THEN
564 IF (parallel%offset .eq. 0)
THEN
571 1000
FORMAT(a,a,f6.2,
' % Finished')
572 1001
FORMAT(a,
'Unprimed Grid Finished')
574 2000
FORMAT(
'Error: Unprimed grid extends beyond the mgrid grid.')
593 TYPE (unprimed_grid_class),
POINTER :: this
596 IF (
ASSOCIATED(this%a_r))
THEN
601 IF (
ASSOCIATED(this%a_p))
THEN
606 IF (
ASSOCIATED(this%a_z))
THEN
611 IF (
ASSOCIATED(this%b_r))
THEN
616 IF (
ASSOCIATED(this%b_p))
THEN
621 IF (
ASSOCIATED(this%b_z))
THEN