VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
read_wout_mod.f
Go to the documentation of this file.
1
3
6!
7! USE READ_WOUT_MOD to include variables dynamically allocated
8! in this module
9! Call DEALLOCATE_READ_WOUT to free this memory when it is no longer needed
10!
11! Reads in output from VMEC equilibrium code(s), contained in wout file
12!
13! Contained subroutines:
14!
15! read_wout_file wrapper alias called to read/open wout file
16! read_wout_text called by read_wout_file to read text file wout
17! read_wout_nc called by read_wout_file to read netcdf file wout
18!
19! Post-processing routines
20!
21! mse_pitch user-callable function to compute mse pitch angle
22! for the computed equilibrium
23!
24 USE stel_kinds
25 USE mgrid_mod
26
27 IMPLICIT NONE
28C-----------------------------------------------
29C L O C A L P A R A M E T E R S
30C-----------------------------------------------
31! Variable names (vn_...) : put eventually into library, used by read_wout too...
32 CHARACTER(LEN=*), PARAMETER ::
33 1 vn_version = 'version_',
34 2 vn_extension = 'input_extension', vn_mgrid = 'mgrid_file',
35 3 vn_magen = 'wb', vn_therm = 'wp', vn_gam = 'gamma',
36 4 vn_maxr = 'rmax_surf', vn_minr = 'rmin_surf',
37 5 vn_maxz = 'zmax_surf', vn_fp = 'nfp',
38 6 vn_radnod = 'ns', vn_polmod = 'mpol', vn_tormod = 'ntor',
39 7 vn_maxmod = 'mnmax', vn_maxit = 'niter',
40 8 vn_asym = 'lasym', vn_free = 'lfreeb',
41 9 vn_error = 'ier_flag', vn_aspect = 'aspect',
42 a vn_maxmod_nyq = 'mnmax_nyq',
43 b vn_beta = 'betatotal', vn_pbeta = 'betapol',
44 c vn_tbeta = 'betator', vn_abeta = 'betaxis',
45 d vn_b0 = 'b0', vn_rbt0 = 'rbtor0', vn_rbt1 = 'rbtor',
46 e vn_sgs = 'signgs', vn_lar = 'IonLarmor', vn_modb = 'volavgB',
47 f vn_ctor = 'ctor', vn_amin = 'Aminor_p', vn_rmaj = 'Rmajor_p',
48 g vn_vol = 'volume_p', vn_am = 'am', vn_ai = 'ai', vn_ac = 'ac',
49 g vn_ah = 'hot particle fraction', vn_atuname = 'T-perp/T-par',
50 h vn_pmass_type = 'pmass_type', vn_piota_type = 'piota_type',
51 i vn_pcurr_type = 'pcurr_type',
52 j vn_am_aux_s = 'am_aux_s', vn_am_aux_f = 'am_aux_f',
53 k vn_ai_aux_s = 'ai_aux_s', vn_ai_aux_f = 'ai_aux_f',
54 l vn_ac_aux_s = 'ac_aux_s', vn_ac_aux_f = 'ac_aux_f',
55 m vn_mse = 'imse', vn_thom = 'itse',
56 n vn_pmod = 'xm', vn_tmod = 'xn', vn_pmod_nyq = 'xm_nyq',
57 o vn_tmod_nyq = 'xn_nyq',
58 p vn_racc = 'raxis_cc', vn_zacs = 'zaxis_cs',
59 q vn_racs = 'raxis_cs', vn_zacc = 'zaxis_cc', vn_iotaf = 'iotaf',
60 q vn_qfact='q-factor', vn_chi='chi', vn_chipf='chipf',
61 r vn_presf = 'presf', vn_phi = 'phi', vn_phipf = 'phipf',
62 s vn_jcuru = 'jcuru', vn_jcurv = 'jcurv', vn_iotah = 'iotas',
63 t vn_mass = 'mass', vn_presh = 'pres', vn_betah = 'beta_vol',
64 u vn_buco = 'buco', vn_bvco = 'bvco', vn_vp = 'vp',
65 v vn_specw = 'specw', vn_phip = 'phips', vn_jdotb = 'jdotb',
66 w vn_overr = 'over_r',
67 x vn_bgrv = 'bdotgradv', vn_merc = 'DMerc', vn_mshear = 'DShear',
68 y vn_mwell = 'DWell', vn_mcurr = 'DCurr', vn_mgeo = 'DGeod',
69 z vn_equif = 'equif', vn_fsq = 'fsqt', vn_wdot = 'wdot',
70 1 vn_ftolv = 'ftolv', vn_fsql= 'fsql', vn_fsqr = 'fsqr',
71 2 vn_fsqz = 'fsqz',
72 3 vn_extcur = 'extcur', vn_curlab = 'curlabel', vn_rmnc = 'rmnc',
73 4 vn_zmns = 'zmns', vn_lmns = 'lmns', vn_gmnc = 'gmnc',
74 5 vn_bmnc = 'bmnc', vn_bsubumnc = 'bsubumnc',
75 6 vn_bsubvmnc = 'bsubvmnc', vn_bsubsmns = 'bsubsmns',
76 7 vn_bsupumnc = 'bsupumnc', vn_bsupvmnc = 'bsupvmnc',
77 8 vn_rmns = 'rmns', vn_zmnc = 'zmnc',
78 9 vn_lmnc = 'lmnc', vn_gmns = 'gmns', vn_bmns = 'bmns',
79 a vn_bsubumns = 'bsubumns', vn_bsubvmns = 'bsubvmns',
80 b vn_bsubsmnc = 'bsubsmnc', vn_bsupumns = 'bsupumns',
81 c vn_bsupvmns = 'bsupvmns',
82 d vn_bsubumnc_sur = 'bsubumnc_sur',
83 e vn_bsubvmnc_sur = 'bsubvmnc_sur',
84 f vn_bsupumnc_sur = 'bsupumnc_sur',
85 g vn_bsupvmnc_sur = 'bsupvmnc_sur',
86 h vn_bsubumns_sur = 'bsubumns_sur',
87 i vn_bsubvmns_sur = 'bsubvmns_sur',
88 j vn_bsupumns_sur = 'bsupumns_sur',
89 k vn_bsupvmns_sur = 'bsupvmns_sur',
90 d vn_rbc = 'rbc', vn_zbs = 'zbs', vn_rbs = 'rbs', vn_zbc = 'zbc',
91 e vn_potvac = 'potvac'
92
93! Long names (ln_...)
94 CHARACTER(LEN=*), PARAMETER ::
95 1 ln_version = 'VMEC Version',
96 2 ln_extension = 'Input file extension',
97 3 ln_mgrid = 'MGRID file',
98 4 ln_magen = 'Magnetic Energy', ln_therm = 'Thermal Energy',
99 5 ln_gam = 'Gamma', ln_maxr = 'Maximum R', ln_minr = 'Minimum R',
100 6 ln_maxz = 'Maximum Z', ln_fp = 'Field Periods',
101 7 ln_radnod = 'Radial nodes', ln_polmod = 'Poloidal modes',
102 8 ln_tormod = 'Toroidal modes', ln_maxmod = 'Fourier modes',
103 8 ln_maxmod_nyq = 'Fourier modes (Nyquist)',
104 9 ln_maxit = 'Max iterations',
105 1 ln_asym = 'Asymmetry', ln_recon = 'Reconstruction',
106 1 ln_free = 'Free boundary',
107 2 ln_error = 'Error flag', ln_aspect = 'Aspect ratio',
108 3 ln_beta = 'Total beta', ln_pbeta = 'Poloidal beta',
109 4 ln_tbeta = 'Toroidal beta', ln_abeta = 'Beta axis',
110 5 ln_b0 = 'RB-t over R axis', ln_rbt0 = 'RB-t axis',
111 6 ln_rbt1 = 'RB-t edge', ln_sgs = 'Sign jacobian',
112 7 ln_lar = 'Ion Larmor radius', ln_modb = 'avg mod B',
113 8 ln_ctor = 'Toroidal current', ln_amin = 'minor radius',
114 9 ln_rmaj = 'major radius', ln_vol = 'Plasma volume',
115 1 ln_mse = 'Number of MSE points',
116 1 ln_thom = 'Number of Thompson scattering points',
117 1 ln_am = 'Specification parameters for mass(s)',
118 1 ln_ac = 'Specification parameters for <J>(s)',
119 1 ln_ai = 'Specification parameters for iota(s)',
120 1 ln_pmass_type = 'Profile type specifier for mass(s)',
121 1 ln_pcurr_type = 'Profile type specifier for <J>(s)',
122 1 ln_piota_type = 'Profile type specifier for iota(s)',
123 1 ln_am_aux_s = 'Auxiliary-s parameters for mass(s)',
124 1 ln_am_aux_f = 'Auxiliary-f parameters for mass(s)',
125 1 ln_ac_aux_s = 'Auxiliary-s parameters for <J>(s)',
126 1 ln_ac_aux_f = 'Auxiliary-f parameters for <J>(s)',
127 1 ln_ai_aux_s = 'Auxiliary-s parameters for iota(s)',
128 1 ln_ai_aux_f = 'Auxiliary-f parameters for iota(s)',
129 4 ln_pmod = 'Poloidal mode numbers',
130 5 ln_tmod = 'Toroidal mode numbers',
131 4 ln_pmod_nyq = 'Poloidal mode numbers (Nyquist)',
132 5 ln_tmod_nyq = 'Toroidal mode numbers (Nyquist)',
133 5 ln_racc = 'raxis (cosnv)', ln_racs = 'raxis (sinnv)',
134 6 ln_zacs = 'zaxis (sinnv)', ln_zacc = 'zaxis (cosnv)',
135 7 ln_iotaf = 'iota on full mesh',
136 7 ln_qfact = 'q-factor on full mesh',
137 8 ln_presf = 'pressure on full mesh',
138 8 ln_phi = 'Toroidal flux on full mesh',
139 9 ln_phipf = 'd(phi)/ds: Toroidal flux deriv on full mesh',
140 9 ln_chi = 'Poloidal flux on full mesh',
141 9 ln_chipf = 'd(chi)/ds: Poroidal flux deriv on full mesh',
142 9 ln_jcuru = 'j dot gradu full',
143 1 ln_jcurv = 'j dot gradv full', ln_iotah = 'iota half',
144 2 ln_mass = 'mass half', ln_presh = 'pressure half',
145 3 ln_betah = 'beta half', ln_buco = 'bsubu half',
146 4 ln_bvco = 'bsubv half', ln_vp = 'volume deriv half',
147 5 ln_specw = 'Spectral width half',
148 6 ln_phip = 'tor flux deriv over 2pi half',
149 7 ln_jdotb = 'J dot B', ln_bgrv = 'B dot grad v',
150 8 ln_merc = 'Mercier criterion', ln_mshear = 'Shear Mercier',
151 9 ln_mwell = 'Well Mercier', ln_mcurr = 'Current Mercier',
152 1 ln_mgeo = 'Geodesic Mercier', ln_equif='Average force balance',
153 1 ln_fsq = 'Residual decay',
154 2 ln_wdot = 'Wdot decay', ln_extcur = 'External coil currents',
155 2 ln_fsqr = 'Residual decay - radial',
156 2 ln_fsqz = 'Residual decay - vertical',
157 2 ln_fsql = 'Residual decay - hoop',
158 2 ln_ftolv = 'Residual decay - requested',
159 3 ln_curlab = 'External current names',
160
161 3 ln_rmnc = 'cosmn component of cylindrical R, full mesh',
162 4 ln_zmns = 'sinmn component of cylindrical Z, full mesh',
163 4 ln_lmns = 'sinmn component of lambda, half mesh',
164 5 ln_gmnc = 'cosmn component of jacobian, half mesh',
165 6 ln_bmnc = 'cosmn component of mod-B, half mesh',
166 6 ln_bsubumnc = 'cosmn covariant u-component of B, half mesh',
167 6 ln_bsubvmnc = 'cosmn covariant v-component of B, half mesh',
168 7 ln_bsubsmns = 'sinmn covariant s-component of B, full mesh',
169
170 8 ln_bsubumnc_sur = 'cosmn bsubu of B, surface',
171 9 ln_bsubvmnc_sur = 'cosmn bsubv of B, surface',
172 a ln_bsupumnc_sur = 'cosmn bsupu of B, surface',
173 b ln_bsupvmnc_sur = 'cosmn bsupv of B, surface',
174
175 7 ln_bsupumnc = 'BSUPUmnc half',
176 8 ln_bsupvmnc = 'BSUPVmnc half',
177
178 3 ln_rmns = 'sinmn component of cylindrical R, full mesh',
179 4 ln_zmnc = 'cosmn component of cylindrical Z, full mesh',
180 4 ln_lmnc = 'cosmn component of lambda, half mesh',
181 5 ln_gmns = 'sinmn component of jacobian, half mesh',
182 6 ln_bmns = 'sinmn component of mod-B, half mesh',
183 6 ln_bsubumns = 'sinmn covariant u-component of B, half mesh',
184 6 ln_bsubvmns = 'sinmn covariant v-component of B, half mesh',
185 7 ln_bsubsmnc = 'cosmn covariant s-component of B, full mesh',
186
187 8 ln_bsubumns_sur = 'sinmn bsubu of B, surface',
188 9 ln_bsubvmns_sur = 'sinmn bsubv of B, surface',
189 a ln_bsupumns_sur = 'sinmn bsupu of B, surface',
190 b ln_bsupvmns_sur = 'sinmn bsupv of B, surface',
191
192 4 ln_bsupumns = 'BSUPUmns half', ln_bsupvmns = 'BSUPVmns half',
193 6 ln_rbc = 'Initial boundary R cos(mu-nv) coefficients',
194 7 ln_zbs = 'Initial boundary Z sin(mu-nv) coefficients',
195 8 ln_rbs = 'Initial boundary R sin(mu-nv) coefficients',
196 9 ln_zbc = 'Initial boundary Z cos(mu-nv) coefficients',
197 1 ln_potvac = 'Vacuum Potential on Boundary'
198!-----------------------------------------------
199! L o c a l V a r i a b l e s
200!-----------------------------------------------
201 INTEGER :: nfp, ns, mpol, ntor, mnmax, mnmax_nyq, niter,
208 3 fsql, fsqr, fsqz, ftolv,
210 5 machsq !SAL
211 REAL(rprec), ALLOCATABLE :: rzl_local(:,:,:,:)
212 REAL(rprec), DIMENSION(:,:), ALLOCATABLE ::
216 REAL(rprec), DIMENSION(:,:), ALLOCATABLE ::
219 REAL(rprec), DIMENSION(:), ALLOCATABLE ::
221 1 qfact, chipf, phi, chi,
223 3 specw, jdotb, bdotgradv, fsqt, wdot, am, ac, ai,
229
230 LOGICAL :: lasym, lthreed, lwout_opened=.false.
231 CHARACTER :: mgrid_file*200, input_extension*100
232 CHARACTER :: pmass_type*20, pcurr_type*20, piota_type*20
233
234 INTEGER, PARAMETER :: norm_term_flag=0,
235 1 bad_jacobian_flag=1, more_iter_flag=2, jac75_flag=4
236
237! OVERLOAD SUBROUTINE READ_WOUT_FILE TO ACCEPT BOTH UNIT NO. (OPENED EXTERNALLY)
238! OR FILENAME (HANDLE OPEN/CLOSE HERE)
240 MODULE PROCEDURE readw_and_open
241 END INTERFACE
242
243 PRIVATE :: read_wout_nc
244 PRIVATE :: norm_term_flag, bad_jacobian_flag,
245 1 more_iter_flag, jac75_flag
246
247 CONTAINS
248
249 SUBROUTINE readw_and_open(file_or_extension, ierr, iopen)
250 USE safe_open_mod
251 IMPLICIT NONE
252C-----------------------------------------------
253C D u m m y A r g u m e n t s
254C-----------------------------------------------
255 INTEGER, INTENT(out) :: ierr
256 INTEGER, OPTIONAL :: iopen
257 CHARACTER(LEN=*), INTENT(in) :: file_or_extension
258C-----------------------------------------------
259C L o c a l V a r i a b l e s
260C-----------------------------------------------
261 INTEGER, PARAMETER :: iunit_init = 10
262 LOGICAL :: isnc
263 CHARACTER(len=LEN_TRIM(file_or_extension)+10) :: filename
264C-----------------------------------------------
265!
266! THIS SUBROUTINE READS THE WOUT FILE CREATED BY THE VMEC CODE
267! AND STORES THE DATA IN THE READ_WOUT MODULE
268!
269! FIRST, CHECK IF THIS IS A FULLY-QUALIFIED PATH NAME
270! MAKE SURE wout IS NOT EMBEDDED IN THE NAME (PERVERSE USER...)
271!
272 filename = 'wout'
273 CALL parse_extension(filename, file_or_extension, isnc)
274 CALL flush(6)
275 IF (isnc) THEN
276 CALL read_wout_nc(filename, ierr)
277 END IF
278
279 IF (PRESENT(iopen)) iopen = ierr
280 lwout_opened = (ierr .eq. 0)
281 ! WHEN READING A NETCDF FILE, A BAD RUN MAY PREVENT XN FROM BEING
282 ! READ, SUBSEQUENTLY WE MUST CHECK TO SEE IF XN HAS BEEN ALLOCATED
283 ! BEFORE DOING ANYTHING WITH IT OTHERWISE WE DEFAULT LTHREED TO
284 ! FALSE. - SAL 09/07/11
285 IF (ALLOCATED(xn)) THEN
286 lthreed = any(nint(xn) .ne. 0)
287 ELSE
288 lthreed = .false.
289 END IF
290
291 END SUBROUTINE readw_and_open
292
293 SUBROUTINE read_wout_nc(filename, ierr)
294 USE ezcdf
295 USE stel_constants, ONLY: mu0
296 IMPLICIT NONE
297C-----------------------------------------------
298C D u m m y A r g u m e n t s
299C-----------------------------------------------
300 INTEGER, INTENT(out) :: ierr
301 CHARACTER(LEN=*), INTENT(in) :: filename
302C-----------------------------------------------
303C L o c a l V a r i a b l e s
304C-----------------------------------------------
305 INTEGER :: nwout, ierror
306 INTEGER, DIMENSION(3) :: dimlens
307 REAL(rprec) :: ohs
308 REAL(rprec), DIMENSION(:), ALLOCATABLE :: raxis_cc, raxis_cs,
309 1 zaxis_cs, zaxis_cc
310C-----------------------------------------------
311! Open cdf File
312 CALL cdf_open(nwout,filename,'r', ierr)
313 IF (ierr .ne. 0) THEN
314 print *,' Error opening wout .nc file'
315 RETURN
316 END IF
317
318! Be sure all arrays are deallocated
320
321 ! reset iasym, needed when using the same instance multiple times -jons
322 iasym = 0
323
324! Read in scalar variables
325 CALL cdf_read(nwout, vn_error, ierr_vmec)
326
327 IF (ierr_vmec.ne.norm_term_flag .and. ierr_vmec.ne.more_iter_flag)
328 1 GOTO 1000
329
330 CALL cdf_read(nwout, vn_version, version_)
331 CALL cdf_read(nwout, vn_extension, input_extension)
332 CALL cdf_read(nwout, vn_mgrid, mgrid_file)
333 CALL cdf_read(nwout, vn_magen, wb)
334 CALL cdf_read(nwout, vn_therm, wp)
335 CALL cdf_read(nwout, vn_gam, gamma)
336 CALL cdf_read(nwout, vn_maxr, rmax_surf)
337 CALL cdf_read(nwout, vn_minr, rmin_surf)
338 CALL cdf_read(nwout, vn_maxz, zmax_surf)
339 CALL cdf_read(nwout, vn_fp, nfp)
340 CALL cdf_read(nwout, vn_radnod, ns)
341 CALL cdf_read(nwout, vn_polmod, mpol)
342 CALL cdf_read(nwout, vn_tormod, ntor)
343 CALL cdf_read(nwout, vn_maxmod, mnmax)
344 mnmax_nyq = -1
345 CALL cdf_read(nwout, vn_maxmod_nyq, mnmax_nyq)
346 CALL cdf_read(nwout, vn_maxit, niter)
347 CALL cdf_read(nwout, vn_asym, lasym)
348 IF (lasym) iasym = 1
349 CALL cdf_read(nwout, vn_free, lfreeb)
350 CALL cdf_read(nwout, vn_aspect, aspect)
351 CALL cdf_read(nwout, vn_beta, betatot)
352 CALL cdf_read(nwout, vn_pbeta, betapol)
353 CALL cdf_read(nwout, vn_tbeta, betator)
354 CALL cdf_read(nwout, vn_abeta, betaxis)
355 CALL cdf_read(nwout, vn_b0, b0)
356 CALL cdf_read(nwout, vn_rbt0, rbtor0)
357 CALL cdf_read(nwout, vn_rbt1, rbtor)
358 CALL cdf_read(nwout, vn_sgs, isigng)
359 CALL cdf_read(nwout, vn_lar, ionlarmor)
360 CALL cdf_read(nwout, vn_modb, volavgb)
361 CALL cdf_read(nwout, vn_ctor, itor)
362 CALL cdf_read(nwout, vn_amin, aminor)
363 CALL cdf_read(nwout, vn_rmaj, rmajor)
364 CALL cdf_read(nwout, vn_vol, volume)
365 CALL cdf_read(nwout, vn_ftolv, ftolv)
366 CALL cdf_read(nwout, vn_fsqr, fsqr)
367 CALL cdf_read(nwout, vn_fsqz, fsqz)
368 CALL cdf_read(nwout, vn_fsql, fsql)
369 CALL cdf_read(nwout, vn_pcurr_type, pcurr_type)
370 CALL cdf_read(nwout, vn_piota_type, piota_type)
371 CALL cdf_read(nwout, vn_pmass_type, pmass_type)
372 imse = -1
373 CALL cdf_read(nwout, vn_nextcur, nextcur)
374
375 mgrid_mode = 'N'
376 CALL cdf_inquire(nwout, vn_mgmode, dimlens, ier=ierror)
377 IF (ierror.eq.0) CALL cdf_read(nwout, vn_mgmode, mgrid_mode)
378
379! Inquire existence, dimensions of arrays for allocation
380! 1D Arrays
381 CALL cdf_inquire(nwout, vn_pmod, dimlens)
382 ALLOCATE (xm(dimlens(1)), stat = ierror)
383 CALL cdf_inquire(nwout, vn_tmod, dimlens)
384 ALLOCATE (xn(dimlens(1)), stat = ierror)
385 IF (mnmax_nyq .gt. 0) THEN
386 CALL cdf_inquire(nwout, vn_pmod_nyq, dimlens)
387 ALLOCATE (xm_nyq(dimlens(1)), stat = ierror)
388 CALL cdf_inquire(nwout, vn_tmod_nyq, dimlens)
389 ALLOCATE (xn_nyq(dimlens(1)), stat = ierror)
390 END IF
391
392 CALL cdf_inquire(nwout, vn_racc, dimlens)
393 ALLOCATE (raxis_cc(0:dimlens(1)-1), stat = ierror)
394 CALL cdf_inquire(nwout, vn_zacs, dimlens)
395 ALLOCATE (zaxis_cs(0:dimlens(1)-1), stat = ierror)
396 IF (lasym) THEN
397 CALL cdf_inquire(nwout, vn_racs, dimlens)
398 ALLOCATE (raxis_cs(0:dimlens(1)-1), stat = ierror)
399 CALL cdf_inquire(nwout, vn_zacc, dimlens)
400 ALLOCATE (zaxis_cc(0:dimlens(1)-1), stat = ierror)
401 END IF
402
403! Profile coefficients, dimensioned from 0
404 CALL cdf_inquire(nwout, vn_am, dimlens)
405 ALLOCATE (am(0:dimlens(1)-1), stat = ierror)
406 CALL cdf_inquire(nwout, vn_ac, dimlens)
407 ALLOCATE (ac(0:dimlens(1)-1), stat = ierror)
408 CALL cdf_inquire(nwout, vn_ai, dimlens)
409 ALLOCATE (ai(0:dimlens(1)-1), stat = ierror)
410
411 CALL cdf_inquire(nwout, vn_ac_aux_s, dimlens)
412 ALLOCATE (ac_aux_s(dimlens(1)), stat = ierror)
413 CALL cdf_inquire(nwout, vn_ac_aux_f, dimlens)
414 ALLOCATE (ac_aux_f(dimlens(1)), stat = ierror)
415 CALL cdf_inquire(nwout, vn_ai_aux_s, dimlens)
416 ALLOCATE (ai_aux_s(dimlens(1)), stat = ierror)
417 CALL cdf_inquire(nwout, vn_ai_aux_f, dimlens)
418 ALLOCATE (ai_aux_f(dimlens(1)), stat = ierror)
419 CALL cdf_inquire(nwout, vn_am_aux_s, dimlens)
420 ALLOCATE (am_aux_s(dimlens(1)), stat = ierror)
421 CALL cdf_inquire(nwout, vn_am_aux_f, dimlens)
422 ALLOCATE (am_aux_f(dimlens(1)), stat = ierror)
423
424 CALL cdf_inquire(nwout, vn_iotaf, dimlens)
425 ALLOCATE (iotaf(dimlens(1)), stat = ierror)
426 CALL cdf_inquire(nwout, vn_qfact, dimlens)
427 ALLOCATE (qfact(dimlens(1)), stat = ierror)
428 CALL cdf_inquire(nwout, vn_presf, dimlens)
429 ALLOCATE (presf(dimlens(1)), stat = ierror)
430 CALL cdf_inquire(nwout, vn_phi, dimlens)
431 ALLOCATE (phi(dimlens(1)), stat = ierror)
432 CALL cdf_inquire(nwout, vn_chi, dimlens)
433 ALLOCATE (chi(dimlens(1)), stat = ierror)
434 CALL cdf_inquire(nwout, vn_phipf, dimlens)
435 ALLOCATE (phipf(dimlens(1)), stat = ierror)
436 CALL cdf_inquire(nwout, vn_chipf, dimlens)
437 ALLOCATE (chipf(dimlens(1)), stat = ierror)
438 CALL cdf_inquire(nwout, vn_jcuru, dimlens)
439 ALLOCATE (jcuru(dimlens(1)), stat = ierror)
440 CALL cdf_inquire(nwout, vn_jcurv, dimlens)
441 ALLOCATE (jcurv(dimlens(1)), stat = ierror)
442 CALL cdf_inquire(nwout, vn_iotah, dimlens)
443 ALLOCATE (iotas(dimlens(1)), stat = ierror)
444 CALL cdf_inquire(nwout, vn_mass, dimlens)
445 ALLOCATE (mass(dimlens(1)), stat = ierror)
446 CALL cdf_inquire(nwout, vn_presh, dimlens)
447 ALLOCATE (pres(dimlens(1)), stat = ierror)
448 CALL cdf_inquire(nwout, vn_betah, dimlens)
449 ALLOCATE (beta_vol(dimlens(1)), stat = ierror)
450 CALL cdf_inquire(nwout, vn_buco, dimlens)
451 ALLOCATE (buco(dimlens(1)), stat = ierror)
452 CALL cdf_inquire(nwout, vn_bvco, dimlens)
453 ALLOCATE (bvco(dimlens(1)), stat = ierror)
454 CALL cdf_inquire(nwout, vn_vp, dimlens)
455 ALLOCATE (vp(dimlens(1)), stat = ierror)
456 CALL cdf_inquire(nwout, vn_specw, dimlens)
457 ALLOCATE (specw(dimlens(1)), stat = ierror)
458 CALL cdf_inquire(nwout, vn_phip, dimlens)
459 ALLOCATE (phip(dimlens(1)), stat = ierror)
460 CALL cdf_inquire(nwout, vn_overr, dimlens)
461 ALLOCATE (overr(dimlens(1)), stat = ierror)
462
463 CALL cdf_inquire(nwout, vn_jdotb, dimlens)
464 ALLOCATE (jdotb(dimlens(1)), stat = ierror)
465 CALL cdf_inquire(nwout, vn_bgrv, dimlens)
466 ALLOCATE (bdotgradv(dimlens(1)), stat = ierror)
467
468 CALL cdf_inquire(nwout, vn_merc, dimlens)
469 ALLOCATE (dmerc(dimlens(1)), stat = ierror)
470 CALL cdf_inquire(nwout, vn_mshear, dimlens)
471 ALLOCATE (dshear(dimlens(1)), stat = ierror)
472 CALL cdf_inquire(nwout, vn_mwell, dimlens)
473 ALLOCATE (dwell(dimlens(1)), stat = ierror)
474 CALL cdf_inquire(nwout, vn_mcurr, dimlens)
475 ALLOCATE (dcurr(dimlens(1)), stat = ierror)
476 CALL cdf_inquire(nwout, vn_mgeo, dimlens)
477 ALLOCATE (dgeod(dimlens(1)), stat = ierror)
478 CALL cdf_inquire(nwout, vn_equif, dimlens)
479 ALLOCATE (equif(dimlens(1)), stat = ierror)
480
481 CALL cdf_inquire(nwout, vn_fsq, dimlens)
482 ALLOCATE (fsqt(dimlens(1)), stat = ierror)
483 CALL cdf_inquire(nwout, vn_wdot, dimlens)
484 ALLOCATE (wdot(dimlens(1)), stat = ierror)
485
486 IF (nextcur .gt. 0) THEN
487 CALL cdf_inquire(nwout, vn_extcur, dimlens)
488 ALLOCATE (extcur(dimlens(1)), stat = ierror)
489!NOTE: curlabel is an array of CHARACTER(30) strings - defined in mgrid_mod
490! so dimlens(1) == 30 (check this) and dimlens(2) is the number of strings in the array
491 CALL cdf_inquire(nwout, vn_curlab, dimlens)
492 ALLOCATE (curlabel(dimlens(2)), stat = ierror)
493 ! SAL
494 CALL cdf_inquire(nwout, vn_potvac, dimlens, ier = ierror)
495 IF (ierror == 0) ALLOCATE (potvac(1:dimlens(1)), stat = ierror)
496 ENDIF
497
498! 2D Arrays
499 CALL cdf_inquire(nwout, vn_rmnc, dimlens)
500 ALLOCATE (rmnc(dimlens(1),dimlens(2)), stat = ierror)
501 CALL cdf_inquire(nwout, vn_zmns, dimlens)
502 ALLOCATE (zmns(dimlens(1),dimlens(2)), stat = ierror)
503 CALL cdf_inquire(nwout, vn_lmns, dimlens)
504 ALLOCATE (lmns(dimlens(1),dimlens(2)), stat = ierror)
505 CALL cdf_inquire(nwout, vn_gmnc, dimlens)
506 ALLOCATE (gmnc(dimlens(1),dimlens(2)), stat = ierror)
507 CALL cdf_inquire(nwout, vn_bmnc, dimlens)
508 ALLOCATE (bmnc(dimlens(1),dimlens(2)), stat = ierror)
509 CALL cdf_inquire(nwout, vn_bsubumnc, dimlens)
510 ALLOCATE (bsubumnc(dimlens(1),dimlens(2)), stat = ierror)
511 CALL cdf_inquire(nwout, vn_bsubvmnc, dimlens)
512 ALLOCATE (bsubvmnc(dimlens(1),dimlens(2)), stat = ierror)
513 CALL cdf_inquire(nwout, vn_bsubsmns, dimlens)
514 ALLOCATE (bsubsmns(dimlens(1),dimlens(2)), stat = ierror)
515
516! ELIMINATE THESE EVENTUALLY: DON'T NEED THEM
517 CALL cdf_inquire(nwout, vn_bsupumnc, dimlens)
518 ALLOCATE (bsupumnc(dimlens(1),dimlens(2)), stat = ierror)
519 CALL cdf_inquire(nwout, vn_bsupvmnc, dimlens)
520 ALLOCATE (bsupvmnc(dimlens(1),dimlens(2)), stat = ierror)
521
522 IF (.NOT. lasym) GO TO 800
523
524 CALL cdf_inquire(nwout, vn_rmns, dimlens)
525 ALLOCATE (rmns(dimlens(1),dimlens(2)), stat = ierror)
526 CALL cdf_inquire(nwout, vn_zmnc, dimlens)
527 ALLOCATE (zmnc(dimlens(1),dimlens(2)), stat = ierror)
528 CALL cdf_inquire(nwout, vn_lmnc, dimlens)
529 ALLOCATE (lmnc(dimlens(1),dimlens(2)), stat = ierror)
530 CALL cdf_inquire(nwout, vn_gmns, dimlens)
531 ALLOCATE (gmns(dimlens(1),dimlens(2)), stat = ierror)
532 CALL cdf_inquire(nwout, vn_bmns, dimlens)
533 ALLOCATE (bmns(dimlens(1),dimlens(2)), stat = ierror)
534 CALL cdf_inquire(nwout, vn_bsubumns, dimlens)
535 ALLOCATE (bsubumns(dimlens(1),dimlens(2)), stat = ierror)
536 CALL cdf_inquire(nwout, vn_bsubvmns, dimlens)
537 ALLOCATE (bsubvmns(dimlens(1),dimlens(2)), stat = ierror)
538 CALL cdf_inquire(nwout, vn_bsubsmnc, dimlens)
539 ALLOCATE (bsubsmnc(dimlens(1),dimlens(2)), stat = ierror)
540
541! ELIMINATE THESE EVENTUALLY: DO NOT NEED THEM
542 CALL cdf_inquire(nwout, vn_bsupumns, dimlens)
543 ALLOCATE (bsupumns(dimlens(1),dimlens(2)), stat = ierror)
544 CALL cdf_inquire(nwout, vn_bsupvmns, dimlens)
545 ALLOCATE (bsupvmns(dimlens(1),dimlens(2)), stat = ierror)
546
547 800 CONTINUE
548
549! Read Arrays
550 CALL cdf_read(nwout, vn_pmod, xm)
551 CALL cdf_read(nwout, vn_tmod, xn)
552 IF (mnmax_nyq .le. 0) THEN
554 ALLOCATE (xm_nyq(mnmax_nyq), xn_nyq(mnmax_nyq), stat=ierror)
555 xm_nyq = xm; xn_nyq = xn
556 ELSE
557 CALL cdf_read(nwout, vn_pmod_nyq, xm_nyq)
558 CALL cdf_read(nwout, vn_tmod_nyq, xn_nyq)
559 END IF
560
561 mnyq = int(maxval(xm_nyq)); nnyq = int(maxval(abs(xn_nyq)))/nfp
562
563 CALL cdf_read(nwout, vn_racc, raxis_cc)
564 CALL cdf_read(nwout, vn_zacs, zaxis_cs)
565
566 IF (SIZE(raxis_cc) .ne. ntor+1)
567 1 stop 'WRONG SIZE(raxis_cc) in READ_WOUT_NC'
568 ALLOCATE (raxis(0:ntor,2), zaxis(0:ntor,2), stat=ierror)
569 raxis(:,1) = raxis_cc(0:ntor); zaxis(:,1) = zaxis_cs(0:ntor)
570 raxis(:,2) = 0; zaxis(:,2) = 0
571 DEALLOCATE (raxis_cc, zaxis_cs, stat=ierror)
572
573 CALL cdf_read(nwout, vn_rmnc, rmnc)
574 CALL cdf_read(nwout, vn_zmns, zmns)
575 CALL cdf_read(nwout, vn_lmns, lmns)
576 CALL cdf_read(nwout, vn_gmnc, gmnc) !Half mesh
577 CALL cdf_read(nwout, vn_bmnc, bmnc) !Half mesh
578 CALL cdf_read(nwout, vn_bsubumnc, bsubumnc) !Half mesh
579 CALL cdf_read(nwout, vn_bsubvmnc, bsubvmnc) !Half mesh
580 CALL cdf_read(nwout, vn_bsubsmns, bsubsmns) !Full mesh
581! ELIMINATE THESE EVENTUALLY: DON'T NEED THEM (can express in terms of lambdas)
582 CALL cdf_read(nwout, vn_bsupumnc, bsupumnc)
583 CALL cdf_read(nwout, vn_bsupvmnc, bsupvmnc)
584 IF (lasym) THEN
585 CALL cdf_read(nwout, vn_racs, raxis_cs)
586 CALL cdf_read(nwout, vn_zacc, zaxis_cc)
587 raxis(:,2) = raxis_cs; zaxis(:,2) = zaxis_cc
588 DEALLOCATE (raxis_cs, zaxis_cc, stat=ierror)
589 CALL cdf_read(nwout, vn_rmns, rmns)
590 CALL cdf_read(nwout, vn_zmnc, zmnc)
591 CALL cdf_read(nwout, vn_lmnc, lmnc)
592 CALL cdf_read(nwout, vn_gmns, gmns)
593 CALL cdf_read(nwout, vn_bmns, bmns)
594 CALL cdf_read(nwout, vn_bsubumns, bsubumns)
595 CALL cdf_read(nwout, vn_bsubvmns, bsubvmns)
596 CALL cdf_read(nwout, vn_bsubsmnc, bsubsmnc)
597! ELIMINATE THESE EVENTUALLY: DON'T NEED THEM
598 CALL cdf_read(nwout, vn_bsupumns, bsupumns)
599 CALL cdf_read(nwout, vn_bsupvmns, bsupvmns)
600 END IF
601
602 CALL cdf_read(nwout, vn_am, am)
603 CALL cdf_read(nwout, vn_ac, ac)
604 CALL cdf_read(nwout, vn_ai, ai)
605
606 CALL cdf_read(nwout, vn_am_aux_s, am_aux_s)
607 CALL cdf_read(nwout, vn_am_aux_f, am_aux_f)
608 CALL cdf_read(nwout, vn_ac_aux_s, ac_aux_s)
609 CALL cdf_read(nwout, vn_ac_aux_f, ac_aux_f)
610 CALL cdf_read(nwout, vn_ai_aux_s, ai_aux_s)
611 CALL cdf_read(nwout, vn_ai_aux_f, ai_aux_f)
612
613 CALL cdf_read(nwout, vn_iotaf, iotaf)
614 CALL cdf_read(nwout, vn_qfact, qfact)
615 CALL cdf_read(nwout, vn_presf, presf)
616 CALL cdf_read(nwout, vn_phi, phi)
617 CALL cdf_read(nwout, vn_phipf, phipf)
618 CALL cdf_read(nwout, vn_chi, chi)
619 CALL cdf_read(nwout, vn_chipf, chipf)
620 CALL cdf_read(nwout, vn_jcuru, jcuru)
621 CALL cdf_read(nwout, vn_jcurv, jcurv)
622
623
624! HALF-MESH quantities
625! NOTE: jdotb is in units_of_A (1/mu0 incorporated in jxbforce...)
626! prior to version 6.00, this was output in internal VMEC units...
627 CALL cdf_read(nwout, vn_iotah, iotas)
628 CALL cdf_read(nwout, vn_mass, mass)
629 CALL cdf_read(nwout, vn_presh, pres)
630 CALL cdf_read(nwout, vn_betah, beta_vol)
631 CALL cdf_read(nwout, vn_buco, buco)
632 CALL cdf_read(nwout, vn_bvco, bvco)
633 CALL cdf_read(nwout, vn_vp, vp)
634 CALL cdf_read(nwout, vn_specw, specw)
635 CALL cdf_read(nwout, vn_phip, phip)
636 CALL cdf_read(nwout, vn_jdotb, jdotb)
637 CALL cdf_read(nwout, vn_bgrv, bdotgradv)
638
639! MERCIER_CRITERION
640 CALL cdf_read(nwout, vn_merc, dmerc)
641 CALL cdf_read(nwout, vn_mshear, dshear)
642 CALL cdf_read(nwout, vn_mwell, dwell)
643 CALL cdf_read(nwout, vn_mcurr, dcurr)
644 CALL cdf_read(nwout, vn_mgeo, dgeod)
645 CALL cdf_read(nwout, vn_equif, equif)
646
647 CALL cdf_read(nwout, vn_fsq, fsqt)
648 CALL cdf_read(nwout, vn_wdot, wdot)
649
650 IF (nextcur .gt. 0) THEN
651 CALL cdf_read(nwout, vn_extcur, extcur)
652 CALL cdf_read(nwout, vn_curlab, curlabel)
653 ENDIF
654
655 !SAL Addition
656 IF (ALLOCATED(potvac)) CALL cdf_read(nwout,vn_potvac, potvac)
657
658 1000 CONTINUE
659
660 CALL cdf_close(nwout, ierr)
661
662 IF (.not.ALLOCATED(bsubumnc)) RETURN !Moved this here because ns may not be set. SAL -09/07/11
663!
664! COMPUTE CONTRAVARIANT CURRENT COMPONENTS IN AMPS
665! ON THE FULL RADIAL MESH, WHERE JACOBIAN = SQRT(G)
666!
667! CURRU = SQRT(G) * J dot grad(u)
668! CURRV = SQRT(G) * J dot grad(v)
669!
670 ohs = (ns-1)
671
672
673 IF (ierror .eq. 0) CALL compute_currents(ierror)
674
675 IF (ierr. ne. 0) print *,"in read_wout_nc ierr=",ierr
676 IF (ierror. ne. 0) print *,"in read_wout_nc ierror=",ierror
677
678 END SUBROUTINE read_wout_nc
679
680 SUBROUTINE compute_currents(ierror)
681 USE stel_constants, ONLY: mu0
682 IMPLICIT NONE
683 INTEGER, INTENT(out) :: ierror
684!-----------------------------------------------
685! L o c a l V a r i a b l e s
686!-----------------------------------------------
687 INTEGER :: js
688 REAL(rprec) :: ohs, hs, shalf(ns), sfull(ns)
689 REAL(rprec), DIMENSION(mnmax_nyq) :: bu1, bu0, bv1, bv0, t1, t2,
690 & t3
691!-----------------------------------------------
692!
693! Computes current harmonics for currXmn == sqrt(g)*JsupX, X = u,v
694! [Corrected above "JsubX" to "JsupX", JDH 2010-08-16]
695
696! NOTE: bsub(s,u,v)mn are on HALF radial grid
697! (in earlier versions, bsubsmn was on FULL radial grid)
698
699!
700 ohs = (ns-1)
701 hs = 1._dp/ohs
702
703 DO js = 2, ns
704 shalf(js) = sqrt(hs*(js-1.5_dp))
705 sfull(js) = sqrt(hs*(js-1))
706 END DO
707
708 ALLOCATE (currumnc(mnmax_nyq,ns), currvmnc(mnmax_nyq,ns), &
709 & stat=ierror)
710 IF (ierror .ne. 0) RETURN
711
712 DO js = 2, ns-1
713 WHERE (mod(int(xm_nyq),2) .EQ. 1)
714 t1 = 0.5_dp*(shalf(js+1)*bsubsmns(:,js+1) + &
715 & shalf(js) *bsubsmns(:,js)) /sfull(js)
716 bu0 = bsubumnc(:,js )/shalf(js)
717 bu1 = bsubumnc(:,js+1)/shalf(js+1)
718 t2 = ohs*(bu1-bu0)*sfull(js)+0.25_dp*(bu0+bu1)/sfull(js)
719 bv0 = bsubvmnc(:,js )/shalf(js)
720 bv1 = bsubvmnc(:,js+1)/shalf(js+1)
721 t3 = ohs*(bv1-bv0)*sfull(js)+0.25_dp*(bv0+bv1)/sfull(js)
722 ELSEWHERE
723 t1 = 0.5_dp*(bsubsmns(:,js+1)+bsubsmns(:,js))
724 t2 = ohs*(bsubumnc(:,js+1)-bsubumnc(:,js))
725 t3 = ohs*(bsubvmnc(:,js+1)-bsubvmnc(:,js))
726 ENDWHERE
727 currumnc(:,js) = -xn_nyq(:)*t1 - t3
728 currvmnc(:,js) = -xm_nyq(:)*t1 + t2
729 END DO
730
731 WHERE (xm_nyq .LE. 1)
732 currvmnc(:,1) = 2*currvmnc(:,2) - currvmnc(:,3)
733 currumnc(:,1) = 2*currumnc(:,2) - currumnc(:,3)
734 ELSEWHERE
735 currvmnc(:,1) = 0
736 currumnc(:,1) = 0
737 ENDWHERE
738
739 currumnc(:,ns) = 2*currumnc(:,ns-1) - currumnc(:,ns-2)
740 currvmnc(:,ns) = 2*currvmnc(:,ns-1) - currvmnc(:,ns-2)
742
743 IF (.NOT.lasym) RETURN
744
745 ALLOCATE (currumns(mnmax_nyq,ns), currvmns(mnmax_nyq,ns), &
746 & stat=ierror)
747
748 DO js = 2, ns-1
749 WHERE (mod(int(xm_nyq),2) .EQ. 1)
750 t1 = 0.5_dp*(shalf(js+1)*bsubsmnc(:,js+1) &
751 & + shalf(js) *bsubsmnc(:,js)) / sfull(js)
752 bu0 = bsubumns(:,js )/shalf(js+1)
753 bu1 = bsubumns(:,js+1)/shalf(js+1)
754 t2 = ohs*(bu1-bu0)*sfull(js) + 0.25_dp*(bu0+bu1)/sfull(js)
755 bv0 = bsubvmns(:,js )/shalf(js)
756 bv1 = bsubvmns(:,js+1)/shalf(js+1)
757 t3 = ohs*(bv1-bv0)*sfull(js)+0.25_dp*(bv0+bv1)/sfull(js)
758 ELSEWHERE
759 t1 = 0.5_dp*(bsubsmnc(:,js+1) + bsubsmnc(:,js))
760 t2 = ohs*(bsubumns(:,js+1)-bsubumns(:,js))
761 t3 = ohs*(bsubvmns(:,js+1)-bsubvmns(:,js))
762 END WHERE
763 currumns(:,js) = xn_nyq(:)*t1 - t3
764 currvmns(:,js) = xm_nyq(:)*t1 + t2
765 END DO
766
767 WHERE (xm_nyq .LE. 1)
768 currvmns(:,1) = 2*currvmns(:,2) - currvmns(:,3)
769 currumns(:,1) = 2*currumns(:,2) - currumns(:,3)
770 ELSEWHERE
771 currvmns(:,1) = 0
772 currumns(:,1) = 0
773 END WHERE
774 currumns(:,ns) = 2*currumns(:,ns-1) - currumns(:,ns-2)
775 currvmns(:,ns) = 2*currvmns(:,ns-1) - currvmns(:,ns-2)
777
778 END SUBROUTINE compute_currents
779
781 IMPLICIT NONE
782!-----------------------------------------------
783! L o c a l V a r i a b l e s
784!-----------------------------------------------
785 INTEGER :: istat(10)
786!-----------------------------------------------
787 istat = 0
788 lwout_opened = .false.
789
790 IF (ALLOCATED(extcur)) DEALLOCATE (extcur,
791 1 stat = istat(1))
792 IF (ALLOCATED(curlabel)) DEALLOCATE (curlabel,
793 1 stat = istat(1))
794 IF (ALLOCATED(overr)) DEALLOCATE (overr, stat = istat(2))
795
796 IF (ALLOCATED(xm)) DEALLOCATE (xm, xn, xm_nyq, xn_nyq,
799 3 pres, beta_vol, phip, buco, bvco, phi, vp, jcuru, am, ac, ai,
801 5 bdotgradv, raxis, zaxis, fsqt, wdot, stat = istat(3))
802
803 IF (ALLOCATED(chipf)) DEALLOCATE (chipf, chi)
804
805 IF (ALLOCATED(am_aux_s)) DEALLOCATE (am_aux_s, am_aux_f, ac_aux_s,
806 1 ac_aux_f, ai_aux_s, ai_aux_f, stat=istat(6))
807
808 IF (ALLOCATED(rmns)) DEALLOCATE (rmns, zmnc, lmnc,
810 2 bsupumns, bsupvmns, stat=istat(5))
811
812 IF (ALLOCATED(currumnc)) DEALLOCATE (currumnc)
813 IF (ALLOCATED(currumns)) DEALLOCATE (currumns, currvmns)
814 IF (ALLOCATED(rzl_local)) DEALLOCATE (rzl_local)
815
816 ! SAL Addition
817 IF (ALLOCATED(potvac)) DEALLOCATE(potvac)
818
819 IF (any(istat .ne. 0)) THEN
820 print *,istat
821 stop 'Deallocation error in read_wout_deallocate'
822 END IF
823
824 END SUBROUTINE read_wout_deallocate
825
826 SUBROUTINE tosuvspace (s_in, u_in, v_in, gsqrt,
827 1 bsupu, bsupv, jsupu, jsupv, lam)
828 USE stel_constants, ONLY: zero, one
829 IMPLICIT NONE
830C-----------------------------------------------
831C D u m m y A r g u m e n t s
832C-----------------------------------------------
833 REAL(rprec), INTENT(in) :: s_in, u_in, v_in
834 REAL(rprec), INTENT(out), OPTIONAL :: gsqrt, bsupu, bsupv,
835 1 jsupu, jsupv, lam
836C-----------------------------------------------
837C L o c a l V a r i a b l e s
838C-----------------------------------------------
839 REAL(rprec), PARAMETER :: c1p5 = 1.5_dp
840 INTEGER :: m, n, n1, mn, ipresent, jslo, jshi
841 REAL(rprec) :: hs1, wlo, whi, wlo_odd, whi_odd
842 REAL(rprec), DIMENSION(mnmax_nyq) :: gmnc1, gmns1, bsupumnc1,
843 1 bsupumns1, bsupvmnc1, bsupvmns1, jsupumnc1, jsupumns1,
844 2 jsupvmnc1, jsupvmns1, wmins, wplus, lammns1, lammnc1
845 REAL(rprec) :: cosu, sinu, cosv, sinv, tcosmn, tsinmn, sgn
846 REAL(rprec) :: cosmu(0:mnyq), sinmu(0:mnyq),
847 1 cosnv(0:nnyq), sinnv(0:nnyq)
848 LOGICAL :: lgsqrt, lbsupu, lbsupv, ljsupu, ljsupv, llam
849C-----------------------------------------------
850!
851! COMPUTE VARIOUS HALF/FULL-RADIAL GRID QUANTITIES AT THE INPUT POINT
852! (S, U, V) , WHERE
853! S = normalized toroidal flux (0 - 1),
854! U = poloidal angle
855! V = N*phi = toroidal angle * no. field periods
856!
857! HALF-RADIAL GRID QUANTITIES
858! gsqrt, bsupu, bsupv
859!
860! FULL-RADIAL GRID QUANTITIES
861! dbsubuds, dbsubvds, dbsubsdu, dbsubsdv
862!
863C-----------------------------------------------
864 IF (s_in.lt.zero .or. s_in.gt.one) THEN
865 WRITE(6, *)
866 1 ' In tosuvspace, s(flux) must be between 0 and 1'
867 RETURN
868 END IF
869
870 IF (.not.lwout_opened) THEN
871 WRITE(6, *)
872 1 ' tosuvspace can only be called AFTER opening wout file!'
873 RETURN
874 END IF
875
876!
877! SETUP TRIG ARRAYS
878!
879 cosu = cos(u_in); sinu = sin(u_in)
880 cosv = cos(v_in); sinv = sin(v_in)
881
882 cosmu(0) = 1; sinmu(0) = 0
883 cosnv(0) = 1; sinnv(0) = 0
884 DO m = 1, mnyq
885 cosmu(m) = cosmu(m-1)*cosu - sinmu(m-1)*sinu
886 sinmu(m) = sinmu(m-1)*cosu + cosmu(m-1)*sinu
887 END DO
888
889 DO n = 1, nnyq
890 cosnv(n) = cosnv(n-1)*cosv - sinnv(n-1)*sinv
891 sinnv(n) = sinnv(n-1)*cosv + cosnv(n-1)*sinv
892 END DO
893
894
895!
896! FIND INTERPOLATED s VALUE AND COMPUTE INTERPOLATION WEIGHTS wlo, whi
897! RECALL THAT THESE QUANTITIES ARE ON THE HALF-RADIAL GRID...
898! s-half(j) = (j-1.5)*hs, for j = 2,...ns
899!
900 hs1 = one/(ns-1)
901 jslo = int(c1p5 + s_in/hs1)
902 jshi = jslo+1
903 wlo = (hs1*(jshi-c1p5) - s_in)/hs1
904 whi = 1 - wlo
905 IF (jslo .eq. ns) THEN
906! USE Xhalf(ns+1) = 2*Xhalf(ns) - Xhalf(ns-1) FOR "GHOST" POINT VALUE 1/2hs OUTSIDE EDGE
907! THEN, X = wlo*Xhalf(ns) + whi*Xhalf(ns+1) == Xhalf(ns) + whi*(Xhalf(ns) - Xhalf(ns-1))
908 jshi = jslo-1
909 wlo = 1+whi; whi = -whi
910 ELSE IF (jslo .eq. 1) THEN
911 jslo = 2
912 END IF
913
914!
915! FOR ODD-m MODES X ~ SQRT(s), SO INTERPOLATE Xmn/SQRT(s)
916!
917 whi_odd = whi*sqrt(s_in/(hs1*(jshi-c1p5)))
918 IF (jslo .ne. 1) THEN
919 wlo_odd = wlo*sqrt(s_in/(hs1*(jslo-c1p5)))
920 ELSE
921 wlo_odd = 0
922 whi_odd = sqrt(s_in/(hs1*(jshi-c1p5)))
923 END IF
924
925 WHERE (mod(nint(xm_nyq(:)),2) .eq. 0)
926 wmins = wlo
927 wplus = whi
928 ELSEWHERE
929 wmins = wlo_odd
930 wplus = whi_odd
931 END WHERE
932
933 ipresent = 0
934 lgsqrt = PRESENT(gsqrt)
935 IF (lgsqrt) THEN
936 gsqrt = 0 ; ipresent = ipresent+1
937 gmnc1 = wmins*gmnc(:,jslo) + wplus*gmnc(:,jshi)
938 IF (lasym)
939 1 gmns1 = wmins*gmns(:,jslo) + wplus*gmns(:,jshi)
940 END IF
941 lbsupu = PRESENT(bsupu)
942 IF (lbsupu) THEN
943 bsupu = 0 ; ipresent = ipresent+1
944 bsupumnc1 = wmins*bsupumnc(:,jslo) + wplus*bsupumnc(:,jshi)
945 IF (lasym)
946 1 bsupumns1 = wmins*bsupumns(:,jslo) + wplus*bsupumns(:,jshi)
947 END IF
948 lbsupv = PRESENT(bsupv)
949 IF (lbsupv) THEN
950 bsupv = 0 ; ipresent = ipresent+1
951 bsupvmnc1 = wmins*bsupvmnc(:,jslo) + wplus*bsupvmnc(:,jshi)
952 IF (lasym)
953 1 bsupvmns1 = wmins*bsupvmns(:,jslo) + wplus*bsupvmns(:,jshi)
954 END IF
955 llam = PRESENT(lam)
956 IF (llam) THEN
957 lam = 0 ; ipresent = ipresent+1
958 lammns1 = wmins*lmns(:,jslo) + wplus*lmns(:,jshi)
959 IF (lasym)
960 1 lammnc1 = wmins*lmnc(:,jslo) + wplus*lmnc(:,jshi)
961 END IF
962
963 IF (ipresent .eq. 0) GOTO 1000
964
965!
966! COMPUTE GSQRT, ... IN REAL SPACE
967! tcosmn = cos(mu - nv); tsinmn = sin(mu - nv)
968!
969 DO mn = 1, mnmax_nyq
970 m = nint(xm_nyq(mn)); n = nint(xn_nyq(mn))/nfp
971 n1 = abs(n); sgn = sign(1,n)
972 tcosmn = cosmu(m)*cosnv(n1) + sgn*sinmu(m)*sinnv(n1)
973 tsinmn = sinmu(m)*cosnv(n1) - sgn*cosmu(m)*sinnv(n1)
974 IF (lgsqrt) gsqrt = gsqrt + gmnc1(mn)*tcosmn
975 IF (lbsupu) bsupu = bsupu + bsupumnc1(mn)*tcosmn
976 IF (lbsupv) bsupv = bsupv + bsupvmnc1(mn)*tcosmn
977 IF (llam) lam = lam + lammns1(mn)*tsinmn
978 END DO
979
980 IF (.not.lasym) GOTO 1000
981
982 DO mn = 1, mnmax_nyq
983 m = nint(xm_nyq(mn)); n = nint(xn_nyq(mn))/nfp
984 n1 = abs(n); sgn = sign(1,n)
985 tcosmn = cosmu(m)*cosnv(n1) + sgn*sinmu(m)*sinnv(n1)
986 tsinmn = sinmu(m)*cosnv(n1) - sgn*cosmu(m)*sinnv(n1)
987 IF (lgsqrt) gsqrt = gsqrt + gmns1(mn)*tsinmn
988 IF (lbsupu) bsupu = bsupu + bsupumns1(mn)*tsinmn
989 IF (lbsupv) bsupv = bsupv + bsupvmns1(mn)*tsinmn
990 IF (llam) lam = lam + lammnc1(mn)*tcosmn
991 END DO
992
993 1000 CONTINUE
994
995! FULL-MESH QUANTITIES
996!
997! FIND INTERPOLATED s VALUE AND COMPUTE INTERPOLATION WEIGHTS wlo, whi
998! RECALL THAT THESE QUANTITIES ARE ON THE FULL-RADIAL GRID...
999! s-full(j) = (j-1)*hs, for j = 1,...ns
1000!
1001 hs1 = one/(ns-1)
1002 jslo = 1+int(s_in/hs1)
1003 jshi = jslo+1
1004 IF (jslo .eq. ns) jshi = ns
1005 wlo = (hs1*(jshi-1) - s_in)/hs1
1006 whi = 1 - wlo
1007!
1008! FOR ODD-m MODES X ~ SQRT(s), SO INTERPOLATE Xmn/SQRT(s)
1009!
1010 whi_odd = whi*sqrt(s_in/(hs1*(jshi-1)))
1011 IF (jslo .ne. 1) THEN
1012 wlo_odd = wlo*sqrt(s_in/(hs1*(jslo-1)))
1013 ELSE
1014 wlo_odd = 0
1015 whi_odd = sqrt(s_in/(hs1*(jshi-1)))
1016 END IF
1017
1018 WHERE (mod(nint(xm_nyq(:)),2) .eq. 0)
1019 wmins = wlo
1020 wplus = whi
1021 ELSEWHERE
1022 wmins = wlo_odd
1023 wplus = whi_odd
1024 END WHERE
1025
1026 ipresent = 0
1027 ljsupu = PRESENT(jsupu)
1028 IF (ljsupu) THEN
1029 IF (.not.lgsqrt) stop 'MUST compute gsqrt for jsupu'
1030 jsupu = 0 ; ipresent = ipresent+1
1031 jsupumnc1 = wmins*currumnc(:,jslo) + wplus*currumnc(:,jshi)
1032 IF (lasym)
1033 1 jsupumns1 = wmins*currumns(:,jslo) + wplus*currumns(:,jshi)
1034 END IF
1035
1036 ljsupv = PRESENT(jsupv)
1037 IF (ljsupv) THEN
1038 IF (.not.lgsqrt) stop 'MUST compute gsqrt for jsupv'
1039 jsupv = 0 ; ipresent = ipresent+1
1040 jsupvmnc1 = wmins*currvmnc(:,jslo) + wplus*currvmnc(:,jshi)
1041 IF (lasym)
1042 1 jsupvmns1 = wmins*currvmns(:,jslo) + wplus*currvmns(:,jshi)
1043 END IF
1044
1045 IF (ipresent .eq. 0) RETURN
1046
1047 DO mn = 1, mnmax_nyq
1048 m = nint(xm_nyq(mn)); n = nint(xn_nyq(mn))/nfp
1049 n1 = abs(n); sgn = sign(1,n)
1050 tcosmn = cosmu(m)*cosnv(n1) + sgn*sinmu(m)*sinnv(n1)
1051 IF (ljsupu) jsupu = jsupu + jsupumnc1(mn)*tcosmn
1052 IF (ljsupv) jsupv = jsupv + jsupvmnc1(mn)*tcosmn
1053 END DO
1054
1055 IF (.not.lasym) GOTO 2000
1056
1057 DO mn = 1, mnmax_nyq
1058 m = nint(xm_nyq(mn)); n = nint(xn_nyq(mn))/nfp
1059 n1 = abs(n); sgn = sign(1,n)
1060 tsinmn = sinmu(m)*cosnv(n1) - sgn*cosmu(m)*sinnv(n1)
1061 IF (ljsupu) jsupu = jsupu + jsupumns1(mn)*tsinmn
1062 IF (ljsupv) jsupv = jsupv + jsupvmns1(mn)*tsinmn
1063 END DO
1064
1065 2000 CONTINUE
1066
1067 IF (ljsupu) jsupu = jsupu/gsqrt
1068 IF (ljsupv) jsupv = jsupv/gsqrt
1069
1070 END SUBROUTINE tosuvspace
1071
1072 SUBROUTINE loadrzl
1073 IMPLICIT NONE
1074C-----------------------------------------------
1075C L o c a l V a r i a b l e s
1076C-----------------------------------------------
1077 INTEGER :: rcc, rss, zsc, zcs, rsc, rcs, zcc, zss
1078 INTEGER :: mpol1, mn, m, n, n1
1079 REAL(rprec) :: sgn
1080C-----------------------------------------------
1081!
1082! Arrays must be stacked (and ns,ntor,mpol ordering imposed)
1083! as coefficients of cos(mu)*cos(nv), etc
1084! Only need R, Z components(not lambda, for now anyhow)
1085!
1086 IF (ALLOCATED(rzl_local)) RETURN
1087
1088 mpol1 = mpol-1
1089 rcc = 1; zsc = 1
1090 IF (.not.lasym) THEN
1091 IF (lthreed) THEN
1092 ntmax = 2
1093 rss = 2; zcs = 2
1094 ELSE
1095 ntmax = 1
1096 END IF
1097 ELSE
1098 IF (lthreed) THEN
1099 ntmax = 4
1100 rss = 2; rsc = 3; rcs = 4
1101 zcs = 2; zcc = 3; zss = 4
1102 ELSE
1103 ntmax = 2
1104 rsc = 2; zcc = 2
1105 END IF
1106 END IF
1107
1108! only ALLOCATE 2*ntmax, don't need lambdas
1109 zsc = 1+ntmax; zcs = zcs+ntmax; zcc = zcc+ntmax; zss = zss+ntmax
1110 ALLOCATE(rzl_local(ns,0:ntor,0:mpol1,2*ntmax), stat=n)
1111 IF (n .ne. 0) stop 'Allocation error in LoadRZL'
1112 rzl_local = 0
1113
1114 DO mn = 1, mnmax
1115 m = nint(xm(mn)); n = nint(xn(mn))/nfp; n1 = abs(n)
1116 sgn = sign(1, n)
1117 rzl_local(:,n1,m,rcc) = rzl_local(:,n1,m,rcc) + rmnc(mn,:)
1118 rzl_local(:,n1,m,zsc) = rzl_local(:,n1,m,zsc) + zmns(mn,:)
1119 IF (lthreed) THEN
1120 rzl_local(:,n1,m,rss) = rzl_local(:,n1,m,rss)
1121 1 + sgn*rmnc(mn,:)
1122 rzl_local(:,n1,m,zcs) = rzl_local(:,n1,m,zcs)
1123 1 - sgn*zmns(mn,:)
1124 END IF
1125 IF (lasym) THEN
1126 rzl_local(:,n1,m,rsc) = rzl_local(:,n1,m,rsc)
1127 1 + rmns(mn,:)
1128 rzl_local(:,n1,m,zcc) = rzl_local(:,n1,m,zcc)
1129 1 + zmnc(mn,:)
1130 IF (lthreed) THEN
1131 rzl_local(:,n1,m,rcs) = rzl_local(:,n1,m,rcs)
1132 1 - sgn*rmns(mn,:)
1133 rzl_local(:,n1,m,zss) = rzl_local(:,n1,m,zss)
1134 1 + sgn*zmnc(mn,:)
1135 END IF
1136 END IF
1137 END DO
1138
1139! ADDED by SAL for Vecpot calc
1140 IF (.not. ALLOCATED(chi)) ALLOCATE(chi(1:ns))
1141 DO mn = 1, ns
1142 chi(mn) = sum(iotaf(1:mn)*phipf(1:mn))
1143 END DO
1144
1145 END SUBROUTINE loadrzl
1146
1147 END MODULE read_wout_mod
1148
character(len= *), parameter vn_mgmode
Definition mgrid_mod.f:16
character(len=30), dimension(:), allocatable curlabel
Definition mgrid_mod.f:95
character(len=1) mgrid_mode
Definition mgrid_mod.f:102
integer nextcur
Definition mgrid_mod.f:78
character(len= *), parameter vn_nextcur
Definition mgrid_mod.f:16
Reading of wout VMEC output file.
character(len= *), parameter vn_bmns
subroutine readw_and_open(file_or_extension, ierr, iopen)
character(len= *), parameter vn_piota_type
real(rprec) aminor
character(len= *), parameter vn_bsupumns_sur
character pcurr_type
character(len= *), parameter vn_bsubvmns_sur
character(len= *), parameter vn_aspect
real(rprec), dimension(:,:), allocatable lmns
character(len= *), parameter vn_bsupumnc
character(len= *), parameter ln_ctor
character(len= *), parameter ln_tmod
character(len= *), parameter ln_vp
character(len= *), parameter vn_rmns
real(rprec) flmwgt
character(len= *), parameter ln_beta
character(len= *), parameter vn_radnod
character(len= *), parameter ln_bsupumns_sur
character(len= *), parameter ln_curlab
real(rprec), dimension(:), allocatable qfact
character(len= *), parameter ln_pbeta
real(rprec), dimension(:), allocatable y2thom
character(len= *), parameter vn_zacs
character(len= *), parameter ln_am_aux_f
real(rprec), dimension(:), allocatable fsqt
character(len= *), parameter vn_rbt1
character(len= *), parameter ln_maxmod_nyq
character(len= *), parameter vn_bsupumns
character(len= *), parameter vn_bsubsmns
character(len= *), parameter ln_extcur
character(len= *), parameter vn_pmass_type
character(len= *), parameter ln_zbs
character(len= *), parameter ln_fsq
character(len= *), parameter ln_amin
character(len= *), parameter ln_bsubvmns
character(len= *), parameter ln_ftolv
real(rprec) aspect
character(len= *), parameter ln_chipf
subroutine tosuvspace(s_in, u_in, v_in, gsqrt, bsupu, bsupv, jsupu, jsupv, lam)
real(rprec), dimension(:,:), allocatable bsubvmnc
character(len= *), parameter ln_maxit
character(len= *), parameter vn_lmnc
real(rprec), dimension(:,:), allocatable currvmns
real(rprec), dimension(:,:), allocatable zmns
character(len= *), parameter ln_bsubumns
character(len= *), parameter ln_jcurv
character(len= *), parameter vn_tbeta
character(len= *), parameter ln_bsubvmnc
character(len= *), parameter ln_presh
character(len= *), parameter ln_bsupumnc_sur
real(rprec), dimension(:), allocatable presf
real(rprec), dimension(:), allocatable rthom
real(rprec), dimension(:,:), allocatable bsubumnc
character(len= *), parameter ln_merc
real(rprec), dimension(:,:), allocatable bsupumnc
character(len= *), parameter ln_zacc
real(rprec), dimension(:), allocatable extcur
real(rprec), dimension(:,:), allocatable zaxis
character(len= *), parameter ln_thom
character(len= *), parameter ln_rmns
character(len= *), parameter vn_overr
character(len= *), parameter vn_ftolv
character(len= *), parameter ln_therm
character(len= *), parameter ln_bsubumnc_sur
real(rprec), dimension(:), allocatable pres
character(len= *), parameter vn_curlab
real(rprec), dimension(:), allocatable datathom
character(len= *), parameter vn_specw
character(len= *), parameter ln_lmns
real(rprec), dimension(:,:), allocatable rmnc
character(len= *), parameter vn_vp
real(rprec), dimension(:), allocatable am_aux_f
character(len= *), parameter vn_vol
character(len= *), parameter vn_magen
real(rprec), dimension(:), allocatable presmid
real(rprec), dimension(:,:), allocatable rmns
real(rprec) fsql
character(len= *), parameter ln_fsql
character(len= *), parameter vn_maxz
character(len= *), parameter vn_bsupvmns_sur
real(rprec), dimension(:), allocatable xn_nyq
character(len= *), parameter ln_racc
character(len= *), parameter vn_ah
character(len= *), parameter vn_abeta
real(rprec), dimension(:), allocatable buco
real(rprec), dimension(:,:), allocatable currumnc
character pmass_type
character(len= *), parameter vn_ac
character(len= *), parameter vn_presf
real(rprec), dimension(:,:), allocatable gmnc
character(len= *), parameter vn_chipf
real(rprec), dimension(:,:), allocatable bsupvmnc
real(rprec) fsqr
character(len= *), parameter vn_jcuru
character(len= *), parameter ln_recon
character(len= *), parameter ln_ai_aux_s
real(rprec), dimension(:), allocatable xn
character(len= *), parameter vn_free
character(len= *), parameter vn_version
character(len= *), parameter vn_buco
real(rprec) betator
real(rprec) fsqz
character(len= *), parameter vn_mse
character(len= *), parameter vn_phipf
character(len= *), parameter ln_bsubsmns
character(len= *), parameter ln_pmod
real(rprec), dimension(:), allocatable dcurr
real(rprec), dimension(:), allocatable equif
real(rprec), dimension(:), allocatable phipf
real(rprec) volume
character(len= *), parameter vn_ac_aux_f
character(len= *), parameter ln_radnod
character(len= *), parameter vn_bgrv
real(rprec), dimension(:,:), allocatable bmns
character(len= *), parameter vn_mgrid
character(len= *), parameter ln_extension
character(len= *), parameter vn_zmnc
real(rprec), dimension(:), allocatable pknots
character(len= *), parameter ln_chi
character(len= *), parameter vn_iotah
character(len= *), parameter vn_lmns
real(rprec), dimension(:), allocatable dsiobt
real(rprec), dimension(:), allocatable rstark
character(len= *), parameter ln_rbs
real(rprec), dimension(:), allocatable phip
character(len= *), parameter ln_ai
real(rprec), dimension(:,:), allocatable currumns
real(rprec), dimension(:), allocatable mass
character(len= *), parameter vn_bvco
character(len= *), parameter vn_fsqr
character(len= *), parameter vn_zacc
character(len= *), parameter ln_mse
character(len= *), parameter vn_bsubvmnc_sur
character(len= *), parameter vn_gam
real(rprec), dimension(:), allocatable ai
character(len= *), parameter ln_ac_aux_f
real(rprec), dimension(:), allocatable xm_nyq
real(rprec), dimension(:), allocatable bvco
character(len= *), parameter vn_betah
character(len= *), parameter ln_fsqr
real(rprec), dimension(:), allocatable jcurv
character(len= *), parameter ln_bsupvmns_sur
character(len= *), parameter ln_maxr
character(len= *), parameter vn_bsupvmnc
real(rprec), dimension(:), allocatable ystark
character(len= *), parameter ln_mgeo
real(rprec), dimension(:), allocatable y2stark
real(rprec), dimension(:), allocatable jdotb
character(len= *), parameter vn_mshear
character(len= *), parameter ln_bgrv
character(len= *), parameter vn_merc
real(rprec) volavgb
character(len= *), parameter vn_b0
real(rprec), dimension(:), allocatable xm
real(rprec), dimension(:), allocatable vp
character(len= *), parameter ln_zmnc
real(rprec), dimension(:), allocatable ythom
character(len= *), parameter ln_ac_aux_s
character(len= *), parameter vn_ai_aux_s
real(rprec), dimension(:), allocatable iotaf
character(len= *), parameter ln_free
subroutine compute_currents(ierror)
character(len= *), parameter ln_zbc
character(len= *), parameter vn_rbc
real(rprec) rmajor
character(len= *), parameter vn_zbs
character(len= *), parameter ln_phip
character(len= *), parameter ln_bsupvmns
character(len= *), parameter ln_buco
character(len= *), parameter vn_gmnc
character(len= *), parameter ln_potvac
real(rprec), dimension(:), allocatable chipf
real(rprec), dimension(:), allocatable beta_vol
real(rprec), dimension(:), allocatable specw
character(len= *), parameter vn_bsupumnc_sur
character(len= *), parameter vn_qfact
real(rprec), dimension(:), allocatable dwell
character(len= *), parameter ln_bmns
character(len= *), parameter vn_maxr
real(rprec) msewgt
character(len= *), parameter vn_bsubsmnc
real(rprec), dimension(:), allocatable jcuru
character(len= *), parameter vn_jcurv
real(rprec), dimension(:,:), allocatable bmnc
character(len= *), parameter vn_zmns
character(len= *), parameter vn_jdotb
character(len= *), parameter ln_bsupvmnc
real(rprec), dimension(:), allocatable ac
character(len= *), parameter ln_equif
character(len= *), parameter ln_am
real(rprec), dimension(:), allocatable ac_aux_f
character(len= *), parameter vn_am_aux_s
real(rprec), dimension(:,:), allocatable currvmnc
character(len= *), parameter vn_tmod_nyq
character(len= *), parameter ln_gmns
real(rprec), dimension(:), allocatable overr
character(len= *), parameter ln_version
real(rprec) pfac
character(len= *), parameter vn_mwell
character(len= *), parameter ln_jcuru
character(len= *), parameter ln_bvco
character(len= *), parameter vn_fsql
character mgrid_file
character(len= *), parameter ln_ac
character(len= *), parameter vn_amin
character(len= *), parameter vn_rmnc
real(rprec), dimension(:), allocatable rmid
character(len= *), parameter ln_bsupvmnc_sur
real(rprec), dimension(:), allocatable chi
character(len= *), parameter vn_mgeo
character(len= *), parameter vn_bsubumns
character(len= *), parameter vn_bsupvmns
character(len= *), parameter vn_mass
character(len= *), parameter vn_modb
real(rprec) zmax_surf
character(len= *), parameter ln_vol
real(rprec) b0
character(len= *), parameter ln_racs
character(len= *), parameter vn_gmns
real(rprec), dimension(:,:), allocatable zmnc
character(len= *), parameter vn_atuname
character(len= *), parameter vn_am
character(len= *), parameter vn_fsq
character(len= *), parameter ln_rbt1
character(len= *), parameter vn_am_aux_f
real(rprec) betaxis
character(len= *), parameter vn_lar
character(len= *), parameter vn_rmaj
character(len= *), parameter ln_specw
real(rprec), dimension(:), allocatable ac_aux_s
logical lwout_opened
character(len= *), parameter vn_bmnc
real(rprec) wb
character(len= *), parameter vn_ai
character(len= *), parameter ln_phipf
character(len= *), parameter ln_polmod
character(len= *), parameter ln_bmnc
character(len= *), parameter ln_mcurr
character(len= *), parameter vn_racc
real(rprec), dimension(:,:), allocatable bsupvmns
character(len= *), parameter ln_bsupumns
character(len= *), parameter vn_pmod
character(len= *), parameter ln_iotah
character(len= *), parameter ln_error
character(len= *), parameter ln_piota_type
real(rprec), dimension(:), allocatable dgeod
character(len= *), parameter vn_wdot
character(len= *), parameter vn_bsubumns_sur
character(len= *), parameter vn_asym
character(len= *), parameter vn_extension
character(len= *), parameter ln_maxz
real(rprec), dimension(:), allocatable phi
real(rprec) tswgt
character(len= *), parameter vn_tmod
character(len= *), parameter ln_mwell
real(rprec) rbtor0
real(rprec), dimension(:), allocatable am
character(len= *), parameter ln_mshear
real(rprec), dimension(:,:), allocatable bbc
real(rprec) rmin_surf
real(rprec) betatot
character(len= *), parameter ln_fsqz
real(rprec), dimension(:), allocatable wdot
real(rprec), dimension(:), allocatable am_aux_s
character(len= *), parameter vn_beta
character(len= *), parameter vn_pcurr_type
character(len= *), parameter ln_rmaj
character(len= *), parameter ln_rmnc
subroutine loadrzl
real(rprec), dimension(:), allocatable shear
character(len= *), parameter ln_lar
character(len= *), parameter vn_bsubvmns
character(len= *), parameter ln_pmass_type
real(rprec), dimension(:), allocatable curmid
character(len= *), parameter vn_tormod
real(rprec) rmax_surf
real(rprec), dimension(:), allocatable anglemse
real(rprec), dimension(:), allocatable iotas
character(len= *), parameter ln_magen
character(len= *), parameter ln_minr
character(len= *), parameter ln_presf
character(len= *), parameter ln_b0
character(len= *), parameter vn_equif
real(rprec), dimension(:), allocatable potvac
integer imatch_phiedge
real(rprec), dimension(:), allocatable datastark
real(rprec) version_
character(len= *), parameter ln_rbt0
real(rprec), dimension(:), allocatable ai_aux_f
character(len= *), parameter ln_fp
real(rprec), dimension(:,:), allocatable bsubsmnc
character input_extension
character(len= *), parameter vn_error
real(rprec) delphid
character(len= *), parameter vn_minr
character(len= *), parameter vn_extcur
character(len= *), parameter vn_pmod_nyq
character(len= *), parameter ln_mass
character(len= *), parameter vn_bsubumnc
real(rprec), dimension(:), allocatable qmid
character(len= *), parameter vn_presh
real(rprec), dimension(:,:), allocatable bsubumns
character(len= *), parameter vn_sgs
character(len= *), parameter ln_pmod_nyq
character(len= *), parameter vn_phi
character(len= *), parameter ln_rbc
character(len= *), parameter ln_aspect
character(len= *), parameter ln_bsubumns_sur
subroutine read_wout_deallocate
real(rprec) bcwgt
character(len= *), parameter vn_ctor
character(len= *), parameter ln_ai_aux_f
character(len= *), parameter vn_racs
character(len= *), parameter vn_pbeta
character(len= *), parameter ln_bsubvmnc_sur
character(len= *), parameter vn_chi
real(rprec) machsq
character(len= *), parameter vn_polmod
real(rprec), dimension(:,:), allocatable bsubvmns
real(rprec), dimension(:), allocatable sknots
character(len= *), parameter vn_mcurr
character(len= *), parameter ln_zmns
real(rprec), dimension(:,:), allocatable bsupumns
real(rprec), dimension(:), allocatable dshear
character(len= *), parameter ln_bsubumnc
character(len= *), parameter vn_maxmod_nyq
character(len= *), parameter vn_bsubvmnc
character(len= *), parameter ln_bsupumnc
character(len= *), parameter ln_sgs
character(len= *), parameter ln_wdot
character(len= *), parameter ln_pcurr_type
character(len= *), parameter vn_thom
character(len= *), parameter ln_tbeta
real(rprec), dimension(:), allocatable qmeas
real(rprec) phidiam
character(len= *), parameter ln_maxmod
character(len= *), parameter vn_maxit
character(len= *), parameter vn_ac_aux_s
character(len= *), parameter vn_rbt0
real(rprec) betapol
character(len= *), parameter ln_lmnc
real(rprec), dimension(:), allocatable alfa
character(len= *), parameter ln_tmod_nyq
character(len= *), parameter vn_fp
character(len= *), parameter ln_bsubsmnc
character(len= *), parameter ln_mgrid
real(rprec), dimension(:), allocatable dmerc
real(rprec) wp
real(rprec) gamma
character(len= *), parameter ln_iotaf
real(rprec), dimension(:,:), allocatable lmnc
character(len= *), parameter vn_zbc
character(len= *), parameter vn_potvac
character(len= *), parameter ln_am_aux_s
character(len= *), parameter ln_phi
character piota_type
character(len= *), parameter ln_asym
character(len= *), parameter ln_tormod
character(len= *), parameter ln_abeta
character(len= *), parameter ln_qfact
character(len= *), parameter vn_maxmod
real(rprec), dimension(:), allocatable ai_aux_s
character(len= *), parameter vn_iotaf
real(rprec) rbtor
character(len= *), parameter ln_betah
real(rprec), dimension(:,:,:,:), allocatable rzl_local
real(rprec), dimension(:,:), allocatable raxis
real(rprec), dimension(:), allocatable bdotgradv
character(len= *), parameter vn_therm
character(len= *), parameter vn_rbs
character(len= *), parameter ln_gmnc
character(len= *), parameter vn_phip
character(len= *), parameter vn_fsqz
character(len= *), parameter vn_bsupvmnc_sur
character(len= *), parameter ln_modb
character(len= *), parameter ln_bsubvmns_sur
real(rprec) itor
character(len= *), parameter ln_gam
real(rprec), dimension(:,:), allocatable gmns
real(rprec) ionlarmor
real(rprec), dimension(:,:), allocatable bsubsmns
character(len= *), parameter ln_jdotb
character(len= *), parameter ln_zacs
character(len= *), parameter vn_ai_aux_f
character(len= *), parameter vn_bsubumnc_sur
real(rprec) ftolv
fault-tolerant file opening routines
real(dp), parameter mu0
real(dp), parameter one
real(dp), parameter zero
integer, parameter rprec
subroutine parse_extension(file_to_parse, file_or_extension, lnc)
Parse the first command-line argument into a filename.