PB3D [2.47]
Ideal linear high-n MHD stability in 3-D
Loading...
Searching...
No Matches
VMEC_vars.f90
Go to the documentation of this file.
1!------------------------------------------------------------------------------!
2!> Variables that concern the output of VMEC.
3!------------------------------------------------------------------------------!
5#include <PB3D_macros.h>
7 use output_ops
8 use messages
9 use num_vars, only: &
11 use read_wout_mod, only: & ! from LIBSTELL
12 &is_asym_v => lasym, vmec_version => version_, is_freeb_v => lfreeb, & ! stellerator symmetry, version number, free boundary or not
13 &mpol_v => mpol, ntor_v => ntor, & ! mpol, ntor
14 &mnmax_v => mnmax, nfp_v => nfp, & ! mnmax, nfp
15 &aspr_v => aspect, & ! aspect ratio
16 &beta_v => betaxis, & ! beta on axis
17 &gam_v => gamma, & ! gamma in adiabatic law (not important here, incompressibility)
18 &rmax_surf, rmin_surf, zmax_surf ! max and min values of R, Z
19
20 implicit none
21 private
22 public dealloc_vmec, &
23 &r_v_c, r_v_s, z_v_c, z_v_s, l_v_c, l_v_s, jac_v_c, jac_v_s, mnmax_v, &
24 &mpol_v, ntor_v, mn_v, pres_v, rot_t_v, q_saf_v, is_asym_v, flux_t_v, &
25 &flux_p_v, vmec_version, gam_v, is_freeb_v, nfp_v, b_0_v, rmin_surf, &
26 &rmax_surf, aspr_v, beta_v, b_v_sub_s, b_v_sub_c
27#if ldebug
28 public b_v_c, b_v_s, j_v_sup_int
29#endif
30
31 ! global variables
32 integer, allocatable :: mn_v(:,:) !< m and n of modes
33 real(dp) :: b_0_v !< the magnitude of B at the magnetic axis, \f$\theta = \zeta = 0\f$
34 real(dp), allocatable :: flux_t_v(:,:) !< toroidal flux
35 real(dp), allocatable :: flux_p_v(:,:) !< poloidal flux
36 real(dp), allocatable :: pres_v(:,:) !< pressure
37 real(dp), allocatable :: rot_t_v(:,:) !< rotational transform
38 real(dp), allocatable :: q_saf_v(:,:) !< safety factor
39 real(dp), allocatable :: r_v_c(:,:,:) !< Coeff. of \f$R\f$ in sine series (FM) and norm. deriv.
40 real(dp), allocatable :: r_v_s(:,:,:) !< Coeff. of \f$R\f$ in cosine series (FM) and norm. deriv.
41 real(dp), allocatable :: z_v_c(:,:,:) !< Coeff. of \f$Z\f$ in sine series (FM) and norm. deriv.
42 real(dp), allocatable :: z_v_s(:,:,:) !< Coeff. of \f$Z\f$ in cosine series (FM) and norm. deriv.
43 real(dp), allocatable :: l_v_c(:,:,:) !< Coeff. of \f$\lambda\f$ in sine series (HM) and norm. deriv.
44 real(dp), allocatable :: l_v_s(:,:,:) !< Coeff. of \f$\lambda\f$ in cosine series (HM) and norm. deriv.
45 real(dp), allocatable :: jac_v_c(:,:,:) !< Coeff. of \f$\mathcal{J}\f$ in sine series (HM and FM) and norm. deriv.
46 real(dp), allocatable :: jac_v_s(:,:,:) !< Coeff. of \f$\mathcal{J}\f$ in cosine series (HM and FM) and norm. deriv.
47 real(dp), allocatable :: b_v_sub_c(:,:,:) !< Coeff. of B_i in sine series (r,theta,phi) (FM) \ldebug
48 real(dp), allocatable :: b_v_sub_s(:,:,:) !< Coeff. of B_i in cosine series (r,theta,phi) (FM) \ldebug
49#if ldebug
50 real(dp), allocatable :: b_v_c(:,:) !< Coeff. of magnitude of B in sine series (HM and FM) \ldebug
51 real(dp), allocatable :: b_v_s(:,:) !< Coeff. of magnitude of B in cosine series (HM and FM) \ldebug
52 real(dp), allocatable :: j_v_sup_int(:,:) !< Integrated poloidal and toroidal current (FM) \ldebug
53#endif
54contains
55 !> Deallocates VMEC quantities that are not used anymore.
56 subroutine dealloc_vmec()
57#if ldebug
58 use num_vars, only: rank, print_mem_usage
59
60 ! local variables
61 integer :: mem_diff ! difference in memory
62
63 ! memory usage before deallocation
64 if (print_mem_usage) mem_diff = get_mem_usage()
65#endif
66
67 ! deallocate
68 deallocate(rot_t_v)
69 deallocate(q_saf_v)
70 deallocate(pres_v)
71 deallocate(flux_t_v)
72 deallocate(flux_p_v)
73 deallocate(mn_v)
74 deallocate(r_v_c)
75 deallocate(r_v_s)
76 deallocate(z_v_c)
77 deallocate(z_v_s)
78 deallocate(l_v_c)
79 deallocate(l_v_s)
80 deallocate(jac_v_c)
81 deallocate(jac_v_s)
82 deallocate(b_v_sub_c)
83 deallocate(b_v_sub_s)
84#if ldebug
85 deallocate(b_v_c)
86 deallocate(b_v_s)
87 deallocate(j_v_sup_int)
88
89 ! memory usage difference after deallocation
90 if (print_mem_usage) then
91 mem_diff = mem_diff - get_mem_usage()
92 call writo('Rank '//trim(i2str(rank))//' liberated '//&
93 &trim(i2str(mem_diff))//'kB deallocating VMEC')
94 end if
95#endif
96 end subroutine dealloc_vmec
97end module vmec_vars
Numerical utilities related to giving output.
Definition messages.f90:4
integer function, public get_mem_usage()
Returns the memory usage in kilobytes.
Definition messages.f90:554
subroutine, public writo(input_str, persistent, error, warning, alert)
Write output to file identified by output_i.
Definition messages.f90:275
Numerical variables used by most other modules.
Definition num_vars.f90:4
integer, parameter, public dp
double precision
Definition num_vars.f90:46
real(dp), parameter, public pi
Definition num_vars.f90:83
logical, public print_mem_usage
print memory usage is printed
Definition num_vars.f90:149
integer, parameter, public max_str_ln
maximum length of strings
Definition num_vars.f90:50
integer, public rank
MPI rank.
Definition num_vars.f90:68
Operations concerning giving output, on the screen as well as in output files.
Definition output_ops.f90:5
Operations on strings.
elemental character(len=max_str_ln) function, public i2str(k)
Convert an integer to string.
Variables that concern the output of VMEC.
Definition VMEC_vars.f90:4
real(dp), dimension(:,:), allocatable, public q_saf_v
safety factor
Definition VMEC_vars.f90:38
real(dp), dimension(:,:,:), allocatable, public jac_v_c
Coeff. of in sine series (HM and FM) and norm. deriv.
Definition VMEC_vars.f90:45
real(dp), dimension(:,:,:), allocatable, public b_v_sub_c
Coeff. of B_i in sine series (r,theta,phi) (FM).
Definition VMEC_vars.f90:47
integer, dimension(:,:), allocatable, public mn_v
m and n of modes
Definition VMEC_vars.f90:32
real(dp), dimension(:,:,:), allocatable, public l_v_s
Coeff. of in cosine series (HM) and norm. deriv.
Definition VMEC_vars.f90:44
real(dp), dimension(:,:,:), allocatable, public z_v_c
Coeff. of in sine series (FM) and norm. deriv.
Definition VMEC_vars.f90:41
real(dp), dimension(:,:), allocatable, public rot_t_v
rotational transform
Definition VMEC_vars.f90:37
real(dp), public b_0_v
the magnitude of B at the magnetic axis,
Definition VMEC_vars.f90:33
real(dp), dimension(:,:,:), allocatable, public jac_v_s
Coeff. of in cosine series (HM and FM) and norm. deriv.
Definition VMEC_vars.f90:46
real(dp), dimension(:,:,:), allocatable, public r_v_c
Coeff. of in sine series (FM) and norm. deriv.
Definition VMEC_vars.f90:39
real(dp), dimension(:,:), allocatable, public pres_v
pressure
Definition VMEC_vars.f90:36
real(dp), dimension(:,:), allocatable, public j_v_sup_int
Integrated poloidal and toroidal current (FM).
Definition VMEC_vars.f90:52
real(dp), dimension(:,:,:), allocatable, public b_v_sub_s
Coeff. of B_i in cosine series (r,theta,phi) (FM).
Definition VMEC_vars.f90:48
real(dp), dimension(:,:), allocatable, public b_v_s
Coeff. of magnitude of B in cosine series (HM and FM).
Definition VMEC_vars.f90:51
real(dp), dimension(:,:), allocatable, public flux_t_v
toroidal flux
Definition VMEC_vars.f90:34
real(dp), dimension(:,:,:), allocatable, public z_v_s
Coeff. of in cosine series (FM) and norm. deriv.
Definition VMEC_vars.f90:42
real(dp), dimension(:,:,:), allocatable, public r_v_s
Coeff. of in cosine series (FM) and norm. deriv.
Definition VMEC_vars.f90:40
real(dp), dimension(:,:,:), allocatable, public l_v_c
Coeff. of in sine series (HM) and norm. deriv.
Definition VMEC_vars.f90:43
real(dp), dimension(:,:), allocatable, public b_v_c
Coeff. of magnitude of B in sine series (HM and FM).
Definition VMEC_vars.f90:50
real(dp), dimension(:,:), allocatable, public flux_p_v
poloidal flux
Definition VMEC_vars.f90:35
subroutine, public dealloc_vmec()
Deallocates VMEC quantities that are not used anymore.
Definition VMEC_vars.f90:57