PB3D  [2.45]
Ideal linear high-n MHD stability in 3-D
VMEC_vars.f90
Go to the documentation of this file.
1 !------------------------------------------------------------------------------!
3 !------------------------------------------------------------------------------!
4 module vmec_vars
5 #include <PB3D_macros.h>
6  use str_utilities
7  use output_ops
8  use messages
9  use num_vars, only: &
10  &dp, max_str_ln, pi
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(:,:)
33  real(dp) :: b_0_v
34  real(dp), allocatable :: flux_t_v(:,:)
35  real(dp), allocatable :: flux_p_v(:,:)
36  real(dp), allocatable :: pres_v(:,:)
37  real(dp), allocatable :: rot_t_v(:,:)
38  real(dp), allocatable :: q_saf_v(:,:)
39  real(dp), allocatable :: r_v_c(:,:,:)
40  real(dp), allocatable :: r_v_s(:,:,:)
41  real(dp), allocatable :: z_v_c(:,:,:)
42  real(dp), allocatable :: z_v_s(:,:,:)
43  real(dp), allocatable :: l_v_c(:,:,:)
44  real(dp), allocatable :: l_v_s(:,:,:)
45  real(dp), allocatable :: jac_v_c(:,:,:)
46  real(dp), allocatable :: jac_v_s(:,:,:)
47  real(dp), allocatable :: b_v_sub_c(:,:,:)
48  real(dp), allocatable :: b_v_sub_s(:,:,:)
49 #if ldebug
50  real(dp), allocatable :: b_v_c(:,:)
51  real(dp), allocatable :: b_v_s(:,:)
52  real(dp), allocatable :: j_v_sup_int(:,:)
53 #endif
54 contains
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
97 end module vmec_vars
num_vars::dp
integer, parameter, public dp
double precision
Definition: num_vars.f90:46
num_vars
Numerical variables used by most other modules.
Definition: num_vars.f90:4
vmec_vars::mn_v
integer, dimension(:,:), allocatable, public mn_v
m and n of modes
Definition: VMEC_vars.f90:32
num_vars::max_str_ln
integer, parameter, public max_str_ln
maximum length of strings
Definition: num_vars.f90:50
vmec_vars::dealloc_vmec
subroutine, public dealloc_vmec()
Deallocates VMEC quantities that are not used anymore.
Definition: VMEC_vars.f90:57
str_utilities::i2str
elemental character(len=max_str_ln) function, public i2str(k)
Convert an integer to string.
Definition: str_utilities.f90:18
vmec_vars::b_v_c
real(dp), dimension(:,:), allocatable, public b_v_c
Coeff. of magnitude of B in sine series (HM and FM)
Definition: VMEC_vars.f90:50
vmec_vars::j_v_sup_int
real(dp), dimension(:,:), allocatable, public j_v_sup_int
Integrated poloidal and toroidal current (FM)
Definition: VMEC_vars.f90:52
messages::get_mem_usage
integer function, public get_mem_usage()
Returns the memory usage in kilobytes.
Definition: messages.f90:554
vmec_vars::jac_v_s
real(dp), dimension(:,:,:), allocatable, public jac_v_s
Coeff. of in cosine series (HM and FM) and norm. deriv.
Definition: VMEC_vars.f90:46
str_utilities
Operations on strings.
Definition: str_utilities.f90:4
vmec_vars::b_v_sub_s
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
vmec_vars::flux_p_v
real(dp), dimension(:,:), allocatable, public flux_p_v
poloidal flux
Definition: VMEC_vars.f90:35
vmec_vars::b_v_sub_c
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
num_vars::print_mem_usage
logical, public print_mem_usage
print memory usage is printed
Definition: num_vars.f90:149
vmec_vars::flux_t_v
real(dp), dimension(:,:), allocatable, public flux_t_v
toroidal flux
Definition: VMEC_vars.f90:34
vmec_vars::pres_v
real(dp), dimension(:,:), allocatable, public pres_v
pressure
Definition: VMEC_vars.f90:36
vmec_vars::rot_t_v
real(dp), dimension(:,:), allocatable, public rot_t_v
rotational transform
Definition: VMEC_vars.f90:37
vmec_vars::b_v_s
real(dp), dimension(:,:), allocatable, public b_v_s
Coeff. of magnitude of B in cosine series (HM and FM)
Definition: VMEC_vars.f90:51
messages::writo
subroutine, public writo(input_str, persistent, error, warning, alert)
Write output to file identified by output_i.
Definition: messages.f90:275
messages
Numerical utilities related to giving output.
Definition: messages.f90:4
vmec_vars::z_v_s
real(dp), dimension(:,:,:), allocatable, public z_v_s
Coeff. of in cosine series (FM) and norm. deriv.
Definition: VMEC_vars.f90:42
num_vars::pi
real(dp), parameter, public pi
Definition: num_vars.f90:83
vmec_vars::q_saf_v
real(dp), dimension(:,:), allocatable, public q_saf_v
safety factor
Definition: VMEC_vars.f90:38
vmec_vars::r_v_c
real(dp), dimension(:,:,:), allocatable, public r_v_c
Coeff. of in sine series (FM) and norm. deriv.
Definition: VMEC_vars.f90:39
vmec_vars
Variables that concern the output of VMEC.
Definition: VMEC_vars.f90:4
vmec_vars::l_v_c
real(dp), dimension(:,:,:), allocatable, public l_v_c
Coeff. of in sine series (HM) and norm. deriv.
Definition: VMEC_vars.f90:43
vmec_vars::r_v_s
real(dp), dimension(:,:,:), allocatable, public r_v_s
Coeff. of in cosine series (FM) and norm. deriv.
Definition: VMEC_vars.f90:40
vmec_vars::jac_v_c
real(dp), dimension(:,:,:), allocatable, public jac_v_c
Coeff. of in sine series (HM and FM) and norm. deriv.
Definition: VMEC_vars.f90:45
output_ops
Operations concerning giving output, on the screen as well as in output files.
Definition: output_ops.f90:5
vmec_vars::b_0_v
real(dp), public b_0_v
the magnitude of B at the magnetic axis,
Definition: VMEC_vars.f90:33
num_vars::rank
integer, public rank
MPI rank.
Definition: num_vars.f90:68
vmec_vars::l_v_s
real(dp), dimension(:,:,:), allocatable, public l_v_s
Coeff. of in cosine series (HM) and norm. deriv.
Definition: VMEC_vars.f90:44
vmec_vars::z_v_c
real(dp), dimension(:,:,:), allocatable, public z_v_c
Coeff. of in sine series (FM) and norm. deriv.
Definition: VMEC_vars.f90:41