PB3D
[2.45]
Ideal linear high-n MHD stability in 3-D
|
Go to the documentation of this file.
5 #include <PB3D_macros.h>
32 character(*),
parameter :: rout_name =
'start_MPI'
39 chckerr(
'MPI init failed')
40 call mpi_comm_rank(mpi_comm_world,
rank,ierr)
41 chckerr(
'MPI rank failed')
42 call mpi_comm_size(mpi_comm_world,
n_procs,ierr)
43 chckerr(
'MPI size failed')
79 integer function stop_mpi(grid_eq,grid_eq_B,grid_X,grid_X_B,grid_sol,eq_1,&
80 &eq_2,X_1,X_2,vac,sol)
result(ierr)
100 character(*),
parameter :: rout_name =
'stop_MPI'
103 type(
grid_type),
intent(inout),
optional :: grid_eq
104 type(
grid_type),
intent(inout),
pointer,
optional :: grid_eq_b
105 type(
grid_type),
intent(inout),
optional :: grid_x
106 type(
grid_type),
intent(inout),
pointer,
optional :: grid_x_b
107 type(
grid_type),
intent(inout),
optional :: grid_sol
108 type(
eq_1_type),
intent(inout),
optional :: eq_1
109 type(
eq_2_type),
intent(inout),
optional :: eq_2
110 type(
x_1_type),
intent(inout),
optional :: x_1
111 type(
x_2_type),
intent(inout),
optional :: x_2
112 type(
vac_type),
intent(inout),
optional :: vac
113 type(
sol_type),
intent(inout),
optional :: sol
118 integer,
allocatable :: ser_n_waits(:)
125 call writo(
'Stopping MPI')
128 if (
present(grid_eq))
then
129 if (
associated(grid_eq%r_F))
call grid_eq%dealloc()
131 if (
present(grid_eq_b))
then
132 if (
associated(grid_eq_b))
then
133 if (eq_style.eq.2)
then
134 call grid_eq_b%dealloc()
135 deallocate(grid_eq_b)
140 if (
present(grid_x))
then
141 if (
associated(grid_x%r_F))
call grid_x%dealloc()
143 if (
present(grid_x_b))
then
144 if (
associated(grid_x_b))
then
145 if (eq_style.eq.2)
then
146 call grid_x_b%dealloc()
152 if (
present(grid_sol))
then
153 if (
associated(grid_sol%r_F))
call grid_sol%dealloc()
155 if (
present(eq_1))
then
156 if (
allocated(eq_1%pres_FD))
call eq_1%dealloc()
158 if (
present(eq_2))
then
159 if (
allocated(eq_2%jac_FD))
call eq_2%dealloc()
161 if (
present(x_1))
then
162 if (
allocated(x_1%U_0))
call x_1%dealloc()
164 if (
present(x_2))
then
165 if (
allocated(x_2%PV_0))
call x_2%dealloc()
167 if (
present(vac))
then
168 if (
allocated(vac%res))
call vac%dealloc()
170 if (
present(sol))
then
171 if (
allocated(sol%val))
call sol%dealloc()
201 if (
rank.eq.0 .and. (minval(ser_n_waits).ne.
n_waits .or. &
202 &maxval(ser_n_waits).ne.
n_waits))
then
203 call writo(
'The number of wait_MPI commands was not consistent')
206 call writo(
'For rank '//trim(
i2str(id-1))//
': '//&
207 &trim(
i2str(ser_n_waits(id))))
219 call mpi_finalize(ierr)
220 chckerr(
'MPI stop failed')
226 integer function abort_mpi()
result(ierr)
227 character(*),
parameter :: rout_name =
'abort_MPI'
232 call mpi_abort(mpi_comm_world,0,ierr)
233 chckerr(
'MPI abort failed')
269 character(*),
parameter :: rout_name =
'broadcast_input_opts'
272 character(len=max_str_ln) :: err_msg
278 err_msg =
'MPI broadcast failed'
282 call writo(
'Broadcasting input option variables')
286 call mpi_bcast(
ltest,1,mpi_logical,0,mpi_comm_world,ierr)
288 call mpi_bcast(
no_plots,1,mpi_logical,0,mpi_comm_world,ierr)
291 &mpi_comm_world,ierr)
294 call mpi_bcast(
plot_flux_q,1,mpi_logical,0,mpi_comm_world,ierr)
296 call mpi_bcast(
plot_kappa,1,mpi_logical,0,mpi_comm_world,ierr)
298 call mpi_bcast(
plot_magn_grid,1,mpi_logical,0,mpi_comm_world,ierr)
300 call mpi_bcast(
plot_b,1,mpi_logical,0,mpi_comm_world,ierr)
302 call mpi_bcast(
plot_j,1,mpi_logical,0,mpi_comm_world,ierr)
304 call mpi_bcast(
plot_resonance,1,mpi_logical,0,mpi_comm_world,ierr)
306 call mpi_bcast(
tol_zero,1,mpi_double_precision,0,mpi_comm_world,&
310 &mpi_comm_world,ierr)
313 &mpi_comm_world,ierr)
316 &mpi_comm_world,ierr)
319 &mpi_comm_world,ierr)
321 call mpi_bcast(
min_r_plot,1,mpi_double_precision,0,mpi_comm_world,&
324 call mpi_bcast(
max_r_plot,1,mpi_double_precision,0,mpi_comm_world,&
327 call mpi_bcast(
max_tot_mem,1,mpi_double_precision,0,&
328 &mpi_comm_world,ierr)
330 call mpi_bcast(
sol_n_procs,1,mpi_integer,0,mpi_comm_world,ierr)
332 call mpi_bcast(
n_theta_plot,1,mpi_integer,0,mpi_comm_world,ierr)
334 call mpi_bcast(
n_zeta_plot,1,mpi_integer,0,mpi_comm_world,ierr)
336 call mpi_bcast(
max_it_rich,1,mpi_integer,0,mpi_comm_world,ierr)
338 call mpi_bcast(
max_it_zero,1,mpi_integer,0,mpi_comm_world,ierr)
343 call mpi_bcast(
ex_plot_style,1,mpi_integer,0,mpi_comm_world,ierr)
345 call mpi_bcast(
plot_size,2,mpi_integer,0,mpi_comm_world,ierr)
348 &mpi_comm_world,ierr)
354 call mpi_bcast(
no_guess,1,mpi_logical,0,mpi_comm_world,ierr)
356 call mpi_bcast(
jump_to_sol,1,mpi_logical,0,mpi_comm_world,&
359 call mpi_bcast(
export_hel,1,mpi_logical,0,mpi_comm_world,&
363 &mpi_comm_world,ierr)
366 &mpi_comm_world,ierr)
368 call mpi_bcast(
min_n_par_x,1,mpi_integer,0,mpi_comm_world,&
372 &mpi_comm_world,ierr)
375 &mpi_comm_world,ierr)
378 &mpi_comm_world,ierr)
380 call mpi_bcast(
max_it_slepc,1,mpi_integer,0,mpi_comm_world,&
384 &mpi_comm_world,ierr)
386 call mpi_bcast(
ev_guess,1,mpi_double_precision,0,&
387 &mpi_comm_world,ierr)
389 call mpi_bcast(
tol_norm,1,mpi_double_precision,0,&
390 &mpi_comm_world,ierr)
392 call mpi_bcast(
min_par_x,1,mpi_double_precision,0,&
393 &mpi_comm_world,ierr)
395 call mpi_bcast(
max_par_x,1,mpi_double_precision,0,&
396 &mpi_comm_world,ierr)
398 call mpi_bcast(
max_x_mem,1,mpi_double_precision,&
399 &0,mpi_comm_world,ierr)
401 call mpi_bcast(
tol_rich,1,mpi_double_precision,0,&
402 &mpi_comm_world,ierr)
406 &0,mpi_comm_world,ierr)
409 call mpi_bcast(
swap_angles,1,mpi_logical,0,mpi_comm_world,&
413 &mpi_comm_world,ierr)
415 call mpi_bcast(
plot_sol_xi,1,mpi_logical,0,mpi_comm_world,&
418 call mpi_bcast(
plot_sol_q,1,mpi_logical,0,mpi_comm_world,&
421 call mpi_bcast(
plot_vac_pot,1,mpi_logical,0,mpi_comm_world,&
424 call mpi_bcast(
plot_e_rec,1,mpi_logical,0,mpi_comm_world,&
428 &mpi_comm_world,ierr)
431 &mpi_comm_world,ierr)
433 call mpi_bcast(
n_vac_plot,2,mpi_integer,0,mpi_comm_world,&
437 &mpi_comm_world,ierr)
440 &mpi_comm_world,ierr)
442 call mpi_bcast(
rich_lvl,1,mpi_integer,0,mpi_comm_world,ierr)
444 call mpi_bcast(
post_style,1,mpi_integer,0,mpi_comm_world,&
448 &mpi_double_precision,0,mpi_comm_world,ierr)
450 call mpi_bcast(
rz_0,2,mpi_double_precision,0,&
451 &mpi_comm_world,ierr)
454 &mpi_comm_world,ierr)
457 &mpi_comm_world,ierr)
460 &mpi_comm_world,ierr)
463 &mpi_comm_world,ierr)
466 err_msg =
'No program style associated with '//&
473 call writo(
'Input option variables broadcasted')
486 integer,
intent(in) :: ierr
489 integer :: ierr_abort
492 call writo(
'>> calling routine: PB3D (main) of rank '//&
494 call writo(
'ERROR CODE '//trim(
i2str(ierr))//&
495 &
'. Aborting MPI rank '//trim(
i2str(
rank)),&
502 if (ierr_abort.ne.0)
then
503 call writo(
'MPI cannot abort...',persistent=.true.)
504 call writo(
'Shutting down',persistent=.true.)
Gather parallel variable in serial version on group master.
logical, public plot_e_rec
whether to plot energy reconstruction in POST
integer, public n_waits
number of waits
integer, public ex_plot_style
external plot style (1: GNUPlot, 2: Bokeh for 2D, Mayavi for 3D)
integer function, public stop_mpi(grid_eq, grid_eq_B, grid_X, grid_X_B, grid_sol, eq_1, eq_2, X_1, X_2, vac, sol)
Stop MPI.
logical, public plot_sol_xi
whether to plot plasma perturbation of solution in POST
logical, public swap_angles
swap angles theta and zeta in plots (only for POST)
logical, public plot_resonance
whether to plot the q-profile or iota-profile with resonances
logical, public invert_top_bottom_h
invert top and bottom for HELENA equilibria
integer, parameter, public dp
double precision
Variables that have to do with equilibrium quantities and the grid used in the calculations:
integer, dimension(4), public n_sol_plotted
how many solutions to be plot (first unstable, last unstable, first stable, last stable)
Operations related to MPI.
Numerical utilities related to MPI.
Numerical variables used by most other modules.
integer function, public abort_mpi()
Abort MPI suddenly.
integer, parameter, public max_str_ln
maximum length of strings
integer, public max_it_zero
maximum number of iterations to find zeros
logical, public plot_sol_q
whether to plot magnetic perturbation of solution in POST
Variables concerning Richardson extrapolation.
elemental character(len=max_str_ln) function, public i2str(k)
Convert an integer to string.
logical, public retain_all_sol
retain also faulty solutions
real(dp), public max_par_x
max. of parallel coordinate [ ] in field-aligned grid
integer, dimension(2), public plot_size
size of plot in inches
integer, public n_sol_requested
how many solutions requested
integer, public n_zeta_plot
nr. of toroidal points in plot
logical, public post_output_sol
POST has outputs of solution.
real(dp), public min_zvac_plot
min. of Z in which to plot vacuum
real(dp), public max_theta_plot
max. of theta_plot
integer, public n_procs
nr. of MPI processes
integer, public n_alloc_eq_1s
nr. of allocated eq_1 variables
real(dp), public ev_guess
first guess for eigenvalue
logical, public plot_magn_grid
whether to plot the grid in real coordinates
integer, public n_alloc_sols
nr. of allocated grids
integer, public prog_style
program style (1: PB3D, 2: PB3D_POST)
logical, public ltest
whether or not to call the testing routines
Variables pertaining to MPI.
real(dp), public min_zeta_plot
min. of zeta_plot
Variables pertaining to the vacuum quantities.
integer, public n_alloc_x_1s
nr. of allocated X_1's
integer, public max_it_slepc
maximum nr. of iterations for SLEPC
logical, public compare_tor_pos
compare quantities at toroidal positions (only for POST)
real(dp), public max_zvac_plot
max. of Z in which to plot vacuum
real(dp), public min_theta_plot
min. of theta_plot
real(dp), public min_par_x
min. of parallel coordinate [ ] in field-aligned grid
integer, public rich_restart_lvl
starting Richardson level (0: none [default])
logical, public export_hel
export HELENA
real(dp), dimension(2), public rz_0
origin of geometrical poloidal coordinate
integer, public n_alloc_discs
nr. of allocated discretizations
tensorial perturbation type
logical, public print_mem_usage
print memory usage is printed
integer, public max_nr_backtracks_hh
maximum number of backtracks for Householder, relax. factors
real(dp), public min_r_plot
min. of r_plot
logical, public plot_b
whether to plot the magnetic field in real coordinates
integer, public eq_style
either 1 (VMEC) or 2 (HELENA)
integer, public max_it_rich
number of levels for Richardson extrapolation
real(dp), dimension(:), allocatable, public tol_slepc
tolerance for SLEPC for different Richardson levels
Variables pertaining to the perturbation quantities.
logical, public plot_j
whether to plot the current in real coordinates
integer function, public start_mpi()
Start MPI and gather information.
logical, public plot_kappa
whether to plot curvature
real(dp), public tol_zero
tolerance for zeros
logical, public no_guess
disable guessing Eigenfunction from previous level of Richardson
subroutine, public writo(input_str, persistent, error, warning, alert)
Write output to file identified by output_i.
Numerical utilities related to giving output.
real(dp), public max_rvac_plot
max. of R in which to plot vacuum
integer function, public broadcast_input_opts()
Broadcasts options (e.g. user-prescribed) that are not passed through the HDF5 output file (i....
logical, public plot_vmec_modes
plot VMEC modes
real(dp), parameter, public pi
logical, public do_execute_command_line
call "execute_command_line" inside program
character(len=max_str_ln), public pb3d_name
name of PB3D output file
logical, public jump_to_sol
jump to solution
integer(kind=8), public time_start
start time of simulation
Variables pertaining to the different grids used.
logical, public plot_vac_pot
whether to plot vacuum potential in POST
subroutine, public lvl_ud(inc)
Increases/decreases lvl of output.
real(dp), public max_r_plot
max. of r_plot
logical, public no_plots
no plots made
integer, public n_alloc_x_2s
nr. of allocated X_2's
subroutine, public sudden_stop(ierr)
Suddenly stops the computations, aborting MPI, etc.
integer, public plot_grid_style
style for POST plot grid (0: 3-D plots, 1: slab plots, 2: slab plots with folding,...
real(dp), public min_rvac_plot
min. of R in which to plot vacuum
real(dp), public pert_mult_factor_post
factor with which to multiply perturbation strength for POST
integer, public min_n_par_x
min. of n_par_X (e.g. first value in Richardson loop)
integer function, public dealloc_lock(lock_loc)
Deallocates a lock.
integer, public rich_lvl
current level of Richardson extrapolation
vectorial perturbation type
Variables pertaining to the solution quantities.
type(lock_type), public hdf5_lock
HDF5 lock.
logical, public post_output_full
POST has output on full grids.
integer, public n_alloc_grids
nr. of allocated grids
logical, public plot_flux_q
whether to plot flux quantities in real coordinates
integer, public solver_slepc_style
style for solver (1: Krylov-Schur, 2: GD)
integer, public sol_n_procs
nr. of MPI processes for solution with SLEPC
real(dp), public max_zeta_plot
max. of zeta_plot
integer, public rank
MPI rank.
integer, dimension(2), public n_vac_plot
nr. of points in R and Z in vacuum
real(dp), public max_tot_mem
maximum total memory for all processes [MB]
integer, public n_alloc_eq_2s
nr. of allocated eq_2 variables
integer, public post_style
style for POST (1: extended grid, 2: B-aligned grid)
real(dp), public tol_norm
tolerance for normal range (normalized to 0..1)
real(dp), public max_x_mem
maximum memory for perturbation calculations for all processes [MB]
integer, public n_theta_plot
nr. of poloidal points in plot
real(dp), public tol_rich
tolerance for Richardson extrapolation