PB3D  [2.45]
Ideal linear high-n MHD stability in 3-D
num_vars.f90
Go to the documentation of this file.
1 !------------------------------------------------------------------------------!
3 !------------------------------------------------------------------------------!
4 module num_vars
5  use iso_fortran_env
6 
7  implicit none
8  private
11  &debug_version, &
24  &max_njq_change, &
26  &tol_zero, tol_norm, &
27  &ex_max_size, eq_name, &
37  &rz_0, &
42 
43  ! technical variables
44  !integer, parameter :: dp = kind(1.d0) !< double precision
45  !integer, parameter :: qp = selected_real_kind (32) !< quadruple precision
46  integer, parameter :: dp = real64
47  !integer, parameter :: qp = REAL128 !< quadruple precision
48  integer, parameter :: dpi = int64
49  real(dp), parameter :: weight_dp = 0.008
50  integer, parameter :: max_str_ln = 120
51  integer, parameter :: max_name_ln = 30
52  integer, parameter :: max_deriv = 2
53  integer :: prog_style
54  character(len=4) :: prog_name
55  character(len=3), parameter :: output_name = 'out'
56  character(len=14), parameter :: shell_commands_name = 'shell_commands'
57  character(len=9), parameter :: mem_usage_name = 'mem_usage'
58  integer :: mem_usage_count
59  real(dp), parameter :: prog_version = 2.45_dp
60  real(dp), parameter :: min_pb3d_version = 2.43_dp
61 #if ldebug
62  logical :: debug_version = .true.
63 #else
64  logical :: debug_version = .false.
65 #endif
66 
67  ! MPI variables
68  integer :: rank
69  integer :: n_procs
70  integer :: sol_n_procs
71  integer(kind=8) :: time_start
72 
73  ! job variables
74  real(dp) :: max_tot_mem
75  real(dp) :: max_x_mem
76  integer, allocatable :: x_jobs_lims(:,:)
77  integer, allocatable :: eq_jobs_lims(:,:)
78  integer :: x_job_nr
79  integer :: eq_job_nr
80  real(dp), parameter :: mem_scale_fac = 6.0
81 
82  ! physical and mathematical variables
83  real(dp), parameter :: pi=4_dp*datan(1.0_dp)
84  real(dp), parameter :: mu_0_original = 4e-7_dp*pi
85  complex(dp), parameter :: iu = (0,1)
86 
87  ! concerning runtime
88  integer :: ev_style
89  integer :: eq_style
90  integer :: rho_style
91  integer :: u_style
92  integer :: norm_style
93  integer :: k_style
94  integer :: bc_style(2)
95  integer :: x_style
96  integer :: matrix_slepc_style
97  integer :: solver_slepc_style
98  integer :: post_style
99  integer :: x_grid_style
100  integer :: alpha_style
101  integer :: max_it_slepc
102  logical :: plot_resonance
103  logical :: plot_magn_grid
104  logical :: plot_b
105  logical :: plot_j
106  logical :: plot_flux_q
107  logical :: plot_kappa
108  logical :: plot_sol_xi
109  logical :: plot_sol_q
110  logical :: plot_vac_pot
111  logical :: plot_e_rec
112  logical :: ltest
113  logical :: use_pol_flux_e
114  logical :: use_pol_flux_f
115  logical :: use_normalization
116  real(dp) :: ev_bc
117  real(dp) :: ev_guess
118  real(dp), allocatable :: tol_slepc(:)
120  integer :: norm_disc_prec_eq
121  integer :: norm_disc_prec_x
124  integer :: magn_int_style
125 
126  ! concerning Richardson extrapolation
127  integer :: max_it_rich
128  real(dp) :: tol_rich
129 
130  ! concerning finding the magnetic field lines
131  integer :: max_it_zero
133  real(dp) :: tol_zero
134  real(dp) :: tol_norm
135 
136  ! concerning input / output
137  integer, parameter :: ex_max_size = 10000
138  character(len=max_str_ln) :: eq_name
139  character(len=max_str_ln) :: pb3d_name
140  logical :: no_plots = .false.
141  logical :: jump_to_sol = .false.
142  logical :: export_hel = .false.
143  logical :: plot_vmec_modes = .false.
144  logical :: invert_top_bottom_h = .false.
145  logical :: no_output = .false.
146  logical :: post_output_full = .false.
147  logical :: post_output_sol = .false.
148  logical :: do_execute_command_line = .false.
149  logical :: print_mem_usage = .false.
150  logical :: swap_angles = .false.
151  logical :: compare_tor_pos = .false.
152  logical :: retain_all_sol
153  character(len=5) :: plot_dir = 'Plots'
154  character(len=7) :: script_dir = 'Scripts'
155  character(len=4) :: data_dir = 'Data'
156  integer :: n_theta_plot
157  integer :: n_zeta_plot
158  integer :: n_vac_plot(2)
161  real(dp) :: min_zeta_plot
162  real(dp) :: max_zeta_plot
163  real(dp) :: min_r_plot
164  real(dp) :: max_r_plot
165  real(dp) :: min_rvac_plot
166  real(dp) :: max_rvac_plot
167  real(dp) :: min_zvac_plot
168  real(dp) :: max_zvac_plot
169  integer :: plot_grid_style
170  integer :: n_sol_requested
171  integer :: n_sol_plotted(4)
172  integer :: plot_size(2)
173  integer :: rich_restart_lvl
174  character(len=max_str_ln) :: input_name
175  integer :: ex_plot_style
177 
178  ! Concerning comparing toroidal positions
179  real(dp) :: rz_0(2)
180 
181  ! Concerning file numbers
182  integer, parameter :: input_i = 50
183  integer, parameter :: eq_i = 51
184  integer, parameter :: pb3d_i = 52
185  integer, parameter :: output_i = 53
186  integer, parameter :: shell_commands_i = 54
187  integer, parameter :: mem_usage_i = 55
188  integer, parameter :: output_ev_i = 56
189  integer, parameter :: decomp_i = 57
190  integer, parameter :: hel_export_i = 59
191  integer, parameter :: hel_pert_i = 58
192  integer, parameter :: prop_b_tor_i = 60
193 end module num_vars
num_vars::plot_e_rec
logical, public plot_e_rec
whether to plot energy reconstruction in POST
Definition: num_vars.f90:111
num_vars::x_grid_style
integer, public x_grid_style
style for normal component of X grid (1: eq, 2: sol, 3: enriched)
Definition: num_vars.f90:99
num_vars::ex_plot_style
integer, public ex_plot_style
external plot style (1: GNUPlot, 2: Bokeh for 2D, Mayavi for 3D)
Definition: num_vars.f90:175
num_vars::u_style
integer, public u_style
style for calculation of U (1: ord.2, 2: ord.1, 1: ord.0)
Definition: num_vars.f90:91
num_vars::max_name_ln
integer, parameter, public max_name_ln
maximum length of filenames
Definition: num_vars.f90:51
num_vars::plot_sol_xi
logical, public plot_sol_xi
whether to plot plasma perturbation of solution in POST
Definition: num_vars.f90:108
num_vars::swap_angles
logical, public swap_angles
swap angles theta and zeta in plots (only for POST)
Definition: num_vars.f90:150
num_vars::plot_resonance
logical, public plot_resonance
whether to plot the q-profile or iota-profile with resonances
Definition: num_vars.f90:102
num_vars::output_ev_i
integer, parameter, public output_ev_i
file number of output of EV
Definition: num_vars.f90:188
num_vars::invert_top_bottom_h
logical, public invert_top_bottom_h
invert top and bottom for HELENA equilibria
Definition: num_vars.f90:144
num_vars::mu_0_original
real(dp), parameter, public mu_0_original
permeability of free space
Definition: num_vars.f90:84
num_vars::hel_pert_i
integer, parameter, public hel_pert_i
file number of HELENA equilibrium perturbation file
Definition: num_vars.f90:191
num_vars::dp
integer, parameter, public dp
double precision
Definition: num_vars.f90:46
num_vars::script_dir
character(len=7), public script_dir
directory where to save scripts for plots
Definition: num_vars.f90:154
num_vars::input_i
integer, parameter, public input_i
file number of input file
Definition: num_vars.f90:182
num_vars::n_sol_plotted
integer, dimension(4), public n_sol_plotted
how many solutions to be plot (first unstable, last unstable, first stable, last stable)
Definition: num_vars.f90:171
num_vars::use_normalization
logical, public use_normalization
whether to use normalization or not
Definition: num_vars.f90:115
num_vars::bc_style
integer, dimension(2), public bc_style
style for BC left and right
Definition: num_vars.f90:94
num_vars
Numerical variables used by most other modules.
Definition: num_vars.f90:4
num_vars::input_name
character(len=max_str_ln), public input_name
will hold the full name of the input file
Definition: num_vars.f90:174
num_vars::max_str_ln
integer, parameter, public max_str_ln
maximum length of strings
Definition: num_vars.f90:50
num_vars::max_it_zero
integer, public max_it_zero
maximum number of iterations to find zeros
Definition: num_vars.f90:131
num_vars::ex_max_size
integer, parameter, public ex_max_size
maximum size of matrices for external plot
Definition: num_vars.f90:137
num_vars::plot_sol_q
logical, public plot_sol_q
whether to plot magnetic perturbation of solution in POST
Definition: num_vars.f90:109
num_vars::norm_disc_prec_eq
integer, public norm_disc_prec_eq
precision for normal discretization for equilibrium
Definition: num_vars.f90:120
num_vars::dpi
integer, parameter, public dpi
double precision
Definition: num_vars.f90:48
num_vars::retain_all_sol
logical, public retain_all_sol
retain also faulty solutions
Definition: num_vars.f90:152
num_vars::plot_size
integer, dimension(2), public plot_size
size of plot in inches
Definition: num_vars.f90:172
num_vars::n_sol_requested
integer, public n_sol_requested
how many solutions requested
Definition: num_vars.f90:170
num_vars::max_njq_change
real(dp), public max_njq_change
maximum change of prim. mode number times saf. fac. / rot. transf. when using X_style 2 (fast)
Definition: num_vars.f90:119
num_vars::n_zeta_plot
integer, public n_zeta_plot
nr. of toroidal points in plot
Definition: num_vars.f90:157
num_vars::post_output_sol
logical, public post_output_sol
POST has outputs of solution.
Definition: num_vars.f90:147
num_vars::eq_job_nr
integer, public eq_job_nr
nr. of eq job
Definition: num_vars.f90:79
num_vars::min_zvac_plot
real(dp), public min_zvac_plot
min. of Z in which to plot vacuum
Definition: num_vars.f90:167
num_vars::shell_commands_i
integer, parameter, public shell_commands_i
file number of shell commands file
Definition: num_vars.f90:186
num_vars::iu
complex(dp), parameter, public iu
complex unit
Definition: num_vars.f90:85
num_vars::max_theta_plot
real(dp), public max_theta_plot
max. of theta_plot
Definition: num_vars.f90:160
num_vars::n_procs
integer, public n_procs
nr. of MPI processes
Definition: num_vars.f90:69
num_vars::norm_disc_prec_sol
integer, public norm_disc_prec_sol
precision for normal discretization for solution
Definition: num_vars.f90:122
num_vars::ev_guess
real(dp), public ev_guess
first guess for eigenvalue
Definition: num_vars.f90:117
num_vars::x_style
integer, public x_style
style for secondary mode numbers (1: prescribed, 2: fast)
Definition: num_vars.f90:95
num_vars::x_job_nr
integer, public x_job_nr
nr. of X job
Definition: num_vars.f90:78
num_vars::debug_version
logical, public debug_version
debug version used
Definition: num_vars.f90:62
num_vars::data_dir
character(len=4), public data_dir
directory where to save data for plots
Definition: num_vars.f90:155
num_vars::plot_magn_grid
logical, public plot_magn_grid
whether to plot the grid in real coordinates
Definition: num_vars.f90:103
num_vars::decomp_i
integer, parameter, public decomp_i
file number of output of EV decomposition
Definition: num_vars.f90:189
num_vars::prog_style
integer, public prog_style
program style (1: PB3D, 2: PB3D_POST)
Definition: num_vars.f90:53
num_vars::prog_name
character(len=4), public prog_name
name of program, used for info
Definition: num_vars.f90:54
num_vars::ltest
logical, public ltest
whether or not to call the testing routines
Definition: num_vars.f90:112
num_vars::min_zeta_plot
real(dp), public min_zeta_plot
min. of zeta_plot
Definition: num_vars.f90:161
num_vars::shell_commands_name
character(len=14), parameter, public shell_commands_name
name of shell commands file
Definition: num_vars.f90:56
num_vars::max_it_slepc
integer, public max_it_slepc
maximum nr. of iterations for SLEPC
Definition: num_vars.f90:101
num_vars::compare_tor_pos
logical, public compare_tor_pos
compare quantities at toroidal positions (only for POST)
Definition: num_vars.f90:151
num_vars::max_zvac_plot
real(dp), public max_zvac_plot
max. of Z in which to plot vacuum
Definition: num_vars.f90:168
num_vars::norm_disc_style_sol
integer, public norm_disc_style_sol
style for normal discretization for solution (1: central fin. diff., 2: left fin. diff....
Definition: num_vars.f90:123
num_vars::weight_dp
real(dp), parameter, public weight_dp
size of double precision in kB
Definition: num_vars.f90:49
num_vars::min_theta_plot
real(dp), public min_theta_plot
min. of theta_plot
Definition: num_vars.f90:159
num_vars::ev_bc
real(dp), public ev_bc
value of artificial Eigenvalue for boundary condition
Definition: num_vars.f90:116
num_vars::rich_restart_lvl
integer, public rich_restart_lvl
starting Richardson level (0: none [default])
Definition: num_vars.f90:173
num_vars::export_hel
logical, public export_hel
export HELENA
Definition: num_vars.f90:142
num_vars::rz_0
real(dp), dimension(2), public rz_0
origin of geometrical poloidal coordinate
Definition: num_vars.f90:179
num_vars::print_mem_usage
logical, public print_mem_usage
print memory usage is printed
Definition: num_vars.f90:149
num_vars::max_nr_backtracks_hh
integer, public max_nr_backtracks_hh
maximum number of backtracks for Householder, relax. factors
Definition: num_vars.f90:132
num_vars::min_r_plot
real(dp), public min_r_plot
min. of r_plot
Definition: num_vars.f90:163
num_vars::mem_usage_i
integer, parameter, public mem_usage_i
file number of memory usage file
Definition: num_vars.f90:187
num_vars::plot_b
logical, public plot_b
whether to plot the magnetic field in real coordinates
Definition: num_vars.f90:104
num_vars::eq_style
integer, public eq_style
either 1 (VMEC) or 2 (HELENA)
Definition: num_vars.f90:89
num_vars::max_it_rich
integer, public max_it_rich
number of levels for Richardson extrapolation
Definition: num_vars.f90:127
num_vars::mem_usage_count
integer, public mem_usage_count
counter for memory usage output
Definition: num_vars.f90:58
num_vars::rho_style
integer, public rho_style
style for equilibrium density profile
Definition: num_vars.f90:90
num_vars::tol_slepc
real(dp), dimension(:), allocatable, public tol_slepc
tolerance for SLEPC for different Richardson levels
Definition: num_vars.f90:118
num_vars::use_pol_flux_e
logical, public use_pol_flux_e
whether poloidal flux is used in E coords.
Definition: num_vars.f90:113
num_vars::plot_j
logical, public plot_j
whether to plot the current in real coordinates
Definition: num_vars.f90:105
num_vars::plot_kappa
logical, public plot_kappa
whether to plot curvature
Definition: num_vars.f90:107
num_vars::tol_zero
real(dp), public tol_zero
tolerance for zeros
Definition: num_vars.f90:133
num_vars::norm_style
integer, public norm_style
style for normalization
Definition: num_vars.f90:92
num_vars::no_output
logical, public no_output
no output shown
Definition: num_vars.f90:145
num_vars::magn_int_style
integer, public magn_int_style
style for magnetic integrals (1: trapezoidal, 2: Simpson 3/8)
Definition: num_vars.f90:124
num_vars::max_deriv
integer, parameter, public max_deriv
highest derivatives for metric factors in Flux coords.
Definition: num_vars.f90:52
num_vars::alpha_style
integer, public alpha_style
style for alpha (1: one field line, many turns, 2: many field lines, one turn)
Definition: num_vars.f90:100
num_vars::k_style
integer, public k_style
style for kinetic energy
Definition: num_vars.f90:93
num_vars::max_rvac_plot
real(dp), public max_rvac_plot
max. of R in which to plot vacuum
Definition: num_vars.f90:166
num_vars::plot_vmec_modes
logical, public plot_vmec_modes
plot VMEC modes
Definition: num_vars.f90:143
num_vars::pi
real(dp), parameter, public pi
Definition: num_vars.f90:83
num_vars::mem_scale_fac
real(dp), parameter, public mem_scale_fac
empirical scale factor of memory to calculate eq compared to just storing it
Definition: num_vars.f90:80
num_vars::mem_usage_name
character(len=9), parameter, public mem_usage_name
name of memory usage file
Definition: num_vars.f90:57
num_vars::do_execute_command_line
logical, public do_execute_command_line
call "execute_command_line" inside program
Definition: num_vars.f90:148
num_vars::pb3d_name
character(len=max_str_ln), public pb3d_name
name of PB3D output file
Definition: num_vars.f90:139
num_vars::jump_to_sol
logical, public jump_to_sol
jump to solution
Definition: num_vars.f90:141
num_vars::time_start
integer(kind=8), public time_start
start time of simulation
Definition: num_vars.f90:71
num_vars::plot_vac_pot
logical, public plot_vac_pot
whether to plot vacuum potential in POST
Definition: num_vars.f90:110
num_vars::eq_i
integer, parameter, public eq_i
file number of equilibrium file from VMEC or HELENA
Definition: num_vars.f90:183
num_vars::min_pb3d_version
real(dp), parameter, public min_pb3d_version
minimum PB3D version for POST
Definition: num_vars.f90:60
num_vars::max_r_plot
real(dp), public max_r_plot
max. of r_plot
Definition: num_vars.f90:164
num_vars::no_plots
logical, public no_plots
no plots made
Definition: num_vars.f90:140
num_vars::pb3d_i
integer, parameter, public pb3d_i
file number of PB3D output file
Definition: num_vars.f90:184
num_vars::plot_dir
character(len=5), public plot_dir
directory where to save plots
Definition: num_vars.f90:153
num_vars::prog_version
real(dp), parameter, public prog_version
version number
Definition: num_vars.f90:59
num_vars::plot_grid_style
integer, public plot_grid_style
style for POST plot grid (0: 3-D plots, 1: slab plots, 2: slab plots with folding,...
Definition: num_vars.f90:169
num_vars::min_rvac_plot
real(dp), public min_rvac_plot
min. of R in which to plot vacuum
Definition: num_vars.f90:165
num_vars::pert_mult_factor_post
real(dp), public pert_mult_factor_post
factor with which to multiply perturbation strength for POST
Definition: num_vars.f90:176
num_vars::output_name
character(len=3), parameter, public output_name
name of output file
Definition: num_vars.f90:55
num_vars::use_pol_flux_f
logical, public use_pol_flux_f
whether poloidal flux is used in F coords.
Definition: num_vars.f90:114
num_vars::eq_jobs_lims
integer, dimension(:,:), allocatable, public eq_jobs_lims
data about eq jobs: [ , ] for all jobs
Definition: num_vars.f90:77
num_vars::post_output_full
logical, public post_output_full
POST has output on full grids.
Definition: num_vars.f90:146
num_vars::plot_flux_q
logical, public plot_flux_q
whether to plot flux quantities in real coordinates
Definition: num_vars.f90:106
num_vars::solver_slepc_style
integer, public solver_slepc_style
style for solver (1: Krylov-Schur, 2: GD)
Definition: num_vars.f90:97
num_vars::sol_n_procs
integer, public sol_n_procs
nr. of MPI processes for solution with SLEPC
Definition: num_vars.f90:70
num_vars::max_zeta_plot
real(dp), public max_zeta_plot
max. of zeta_plot
Definition: num_vars.f90:162
num_vars::rank
integer, public rank
MPI rank.
Definition: num_vars.f90:68
num_vars::prop_b_tor_i
integer, parameter, public prop_b_tor_i
file number of proportionality factor file
Definition: num_vars.f90:192
num_vars::output_i
integer, parameter, public output_i
file number of output file
Definition: num_vars.f90:185
num_vars::n_vac_plot
integer, dimension(2), public n_vac_plot
nr. of points in R and Z in vacuum
Definition: num_vars.f90:158
num_vars::max_tot_mem
real(dp), public max_tot_mem
maximum total memory for all processes [MB]
Definition: num_vars.f90:74
num_vars::eq_name
character(len=max_str_ln), public eq_name
name of equilibrium file from VMEC or HELENA
Definition: num_vars.f90:138
num_vars::hel_export_i
integer, parameter, public hel_export_i
file number of output of HELENA equilibrium export file
Definition: num_vars.f90:190
num_vars::post_style
integer, public post_style
style for POST (1: extended grid, 2: B-aligned grid)
Definition: num_vars.f90:98
num_vars::matrix_slepc_style
integer, public matrix_slepc_style
style for matrix storage (1: sparse, 2: shell)
Definition: num_vars.f90:96
num_vars::tol_norm
real(dp), public tol_norm
tolerance for normal range (normalized to 0..1)
Definition: num_vars.f90:134
num_vars::max_x_mem
real(dp), public max_x_mem
maximum memory for perturbation calculations for all processes [MB]
Definition: num_vars.f90:75
num_vars::n_theta_plot
integer, public n_theta_plot
nr. of poloidal points in plot
Definition: num_vars.f90:156
num_vars::x_jobs_lims
integer, dimension(:,:), allocatable, public x_jobs_lims
data about X jobs: [ , , , ] for all jobs
Definition: num_vars.f90:76
num_vars::tol_rich
real(dp), public tol_rich
tolerance for Richardson extrapolation
Definition: num_vars.f90:128
num_vars::ev_style
integer, public ev_style
determines the method used for solving an EV problem
Definition: num_vars.f90:88
num_vars::norm_disc_prec_x
integer, public norm_disc_prec_x
precision for normal discretization for perturbation
Definition: num_vars.f90:121