12 USE stel_kinds,
ONLY: rprec
45 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: a_r => null()
47 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: a_p => null()
49 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: a_z => null()
69 USE read_wout_mod,
Only: extcur
76 CHARACTER (len=*),
INTENT(in) :: mgrid_file_name
78 INTEGER,
INTENT(in) :: io_unit
81 REAL (rprec) :: start_time
89 REAL (rprec),
DIMENSION(:,:,:),
ALLOCATABLE :: temp_buffer
90 CHARACTER (len=6) :: temp_string
91 INTEGER,
DIMENSION(3) :: temp_dims
98 CALL cdf_open(mgrid_ncid, trim(mgrid_file_name),
'r', status)
100 CALL cdf_inquire(mgrid_ncid,
'ar_001', temp_dims, ier=status)
101 IF (status .ne. 0)
THEN
102 IF (parallel%offset .eq. 0)
THEN
103 WRITE (io_unit,3000) trim(mgrid_file_name)
108 CALL cdf_read(mgrid_ncid,
'ir', num_r)
109 CALL cdf_read(mgrid_ncid,
'kp', num_p)
110 CALL cdf_read(mgrid_ncid,
'jz', num_z)
136 ALLOCATE(temp_buffer(num_r, num_z, num_p))
138 DO i = 1 + parallel%offset,
SIZE(extcur), parallel%stride
139 WRITE (temp_string, 1000) i
140 CALL cdf_read(mgrid_ncid, temp_string, temp_buffer)
142 & + temp_buffer*extcur(i)
144 WRITE (temp_string, 1001) i
145 CALL cdf_read(mgrid_ncid, temp_string, temp_buffer)
147 & + temp_buffer*extcur(i)
149 WRITE (temp_string, 1002) i
150 CALL cdf_read(mgrid_ncid, temp_string, temp_buffer)
152 & + temp_buffer*extcur(i)
155 IF (parallel%stride .gt. 1)
THEN
164 DEALLOCATE(temp_buffer)
166 CALL cdf_close(mgrid_ncid)
168 IF (parallel%offset .eq. 0)
THEN
174 1000
FORMAT(
'ar_',i3.3)
175 1001
FORMAT(
'ap_',i3.3)
176 1002
FORMAT(
'az_',i3.3)
178 2000
FORMAT(
'M Grid Ready')
180 3000
FORMAT(a,
' does not contain the vacuum vector potential.')
199 TYPE (m_grid_class),
POINTER :: this
202 IF (
ASSOCIATED(this%a_r))
THEN
207 IF (
ASSOCIATED(this%a_p))
THEN
212 IF (
ASSOCIATED(this%a_z))
THEN
239 USE stel_constants,
ONLY: twopi
245 REAL (rprec),
INTENT(in) :: r
246 REAL (rprec),
INTENT(in) :: phi
247 REAL (rprec),
INTENT(in) :: z
248 REAL (rprec),
INTENT(out) :: ar
249 REAL (rprec),
INTENT(out) :: ap
250 REAL (rprec),
INTENT(out) :: az
253 REAL (rprec) :: norm_phi
266 dphi = twopi/(this%nfp*
SIZE(this%a_r, 3))
269 DO WHILE (norm_phi > twopi/this%nfp)
270 norm_phi = norm_phi - twopi/this%nfp
274 i = (r - this%rmin)/this%dr + 1.0
275 j = (z - this%zmin)/this%dz + 1.0
276 k = norm_phi/dphi + 1.0
283 IF (k .gt.
SIZE(this%a_r, 3))
THEN
297 & this%a_r(ilow,jlow,klow),
298 & this%a_r(ihigh,jlow,klow),
301 & this%a_r(ilow,jhigh,klow),
302 & this%a_r(ihigh,jhigh,klow),
307 & this%a_r(ilow,jlow,khigh),
308 & this%a_r(ihigh,jlow,khigh),
311 & this%a_r(ilow,jhigh,khigh),
312 & this%a_r(ihigh,jhigh,khigh),
320 & this%a_p(ilow,jlow,klow),
321 & this%a_p(ihigh,jlow,klow),
324 & this%a_p(ilow,jhigh,klow),
325 & this%a_p(ihigh,jhigh,klow),
330 & this%a_p(ilow,jlow,khigh),
331 & this%a_p(ihigh,jlow,khigh),
334 & this%a_p(ilow,jhigh,khigh),
335 & this%a_p(ihigh,jhigh,khigh),
343 & this%a_z(ilow,jlow,klow),
344 & this%a_z(ihigh,jlow,klow),
347 & this%a_z(ilow,jhigh,klow),
348 & this%a_z(ihigh,jhigh,klow),
353 & this%a_z(ilow,jlow,khigh),
354 & this%a_z(ihigh,jlow,khigh),
357 & this%a_z(ilow,jhigh,khigh),
358 & this%a_z(ihigh,jhigh,khigh),
368 PURE FUNCTION m_grid_intf(w1, w2, x)
373 REAL (rprec) :: m_grid_intf
374 REAL (rprec),
INTENT(in) :: w1
375 REAL (rprec),
INTENT(in) :: w2
376 REAL (rprec),
INTENT(in) :: x
379 m_grid_intf = w1*(1.0 - x) + w2*x