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
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
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')
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.
Variables that have to do with equilibrium quantities and the grid used in the calculations:
integer, public n_alloc_eq_1s
nr. of allocated eq_1 variables
integer, public n_alloc_eq_2s
nr. of allocated eq_2 variables
Variables pertaining to the different grids used.
integer, public n_alloc_discs
nr. of allocated discretizations
real(dp), public min_par_x
min. of parallel coordinate [ ] in field-aligned grid
integer, public n_alloc_grids
nr. of allocated grids
real(dp), public max_par_x
max. of parallel coordinate [ ] in field-aligned grid
Numerical utilities related to giving output.
subroutine, public lvl_ud(inc)
Increases/decreases lvl of output.
subroutine, public writo(input_str, persistent, error, warning, alert)
Write output to file identified by output_i.
Operations related to MPI.
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.
subroutine, public sudden_stop(ierr)
Suddenly stops the computations, aborting MPI, etc.
integer function, public abort_mpi()
Abort MPI suddenly.
integer function, public start_mpi()
Start MPI and gather information.
integer function, public broadcast_input_opts()
Broadcasts options (e.g. user-prescribed) that are not passed through the HDF5 output file (i....
Numerical utilities related to MPI.
integer, public n_waits
number of waits
Variables pertaining to MPI.
type(lock_type), public hdf5_lock
HDF5 lock.
integer function, public dealloc_lock(lock_loc)
Deallocates a lock.
Numerical variables used by most other modules.
integer, public sol_n_procs
nr. of MPI processes for solution with SLEPC
integer, parameter, public dp
double precision
logical, public ltest
whether or not to call the testing routines
integer, public post_style
style for POST (1: extended grid, 2: B-aligned grid)
logical, public plot_b
whether to plot the magnetic field in real coordinates
integer, public n_theta_plot
nr. of poloidal points in plot
integer, public plot_grid_style
style for POST plot grid (0: 3-D plots, 1: slab plots, 2: slab plots with folding,...
logical, public plot_kappa
whether to plot curvature
real(dp), public max_r_plot
max. of r_plot
real(dp), public min_theta_plot
min. of theta_plot
real(dp), parameter, public pi
logical, public print_mem_usage
print memory usage is printed
real(dp), public max_zeta_plot
max. of zeta_plot
logical, public compare_tor_pos
compare quantities at toroidal positions (only for POST)
real(dp), public tol_norm
tolerance for normal range (normalized to 0..1)
integer, public n_procs
nr. of MPI processes
logical, public plot_flux_q
whether to plot flux quantities in real coordinates
integer, dimension(2), public plot_size
size of plot in inches
integer, public n_sol_requested
how many solutions requested
integer, parameter, public max_str_ln
maximum length of strings
logical, public plot_sol_q
whether to plot magnetic perturbation of solution in POST
real(dp), public ev_guess
first guess for eigenvalue
logical, public post_output_sol
POST has outputs of solution.
integer, public prog_style
program style (1: PB3D, 2: PB3D_POST)
integer, dimension(2), public n_vac_plot
nr. of points in R and Z in vacuum
real(dp), public max_zvac_plot
max. of Z in which to plot vacuum
logical, public plot_vac_pot
whether to plot vacuum potential in POST
integer, public n_zeta_plot
nr. of toroidal points in plot
real(dp), public max_rvac_plot
max. of R in which to plot vacuum
integer(kind=8), public time_start
start time of simulation
logical, public plot_resonance
whether to plot the q-profile or iota-profile with resonances
real(dp), public min_zeta_plot
min. of zeta_plot
logical, public post_output_full
POST has output on full grids.
integer, public eq_style
either 1 (VMEC) or 2 (HELENA)
integer, public max_it_slepc
maximum nr. of iterations for SLEPC
logical, public plot_vmec_modes
plot VMEC modes
character(len=max_str_ln), public pb3d_name
name of PB3D output file
integer, dimension(4), public n_sol_plotted
how many solutions to be plot (first unstable, last unstable, first stable, last stable)
logical, public invert_top_bottom_h
invert top and bottom for HELENA equilibria
real(dp), public min_rvac_plot
min. of R in which to plot vacuum
real(dp), public tol_rich
tolerance for Richardson extrapolation
logical, public export_hel
export HELENA
real(dp), public pert_mult_factor_post
factor with which to multiply perturbation strength for POST
logical, public plot_j
whether to plot the current in real coordinates
integer, public max_nr_backtracks_hh
maximum number of backtracks for Householder, relax. factors
integer, public ex_plot_style
external plot style (1: GNUPlot, 2: Bokeh for 2D, Mayavi for 3D)
real(dp), dimension(2), public rz_0
origin of geometrical poloidal coordinate
real(dp), public min_r_plot
min. of r_plot
integer, public rank
MPI rank.
real(dp), public min_zvac_plot
min. of Z in which to plot vacuum
integer, public rich_restart_lvl
starting Richardson level (0: none [default])
logical, public plot_sol_xi
whether to plot plasma perturbation of solution in POST
real(dp), dimension(:), allocatable, public tol_slepc
tolerance for SLEPC for different Richardson levels
logical, public jump_to_sol
jump to solution
integer, public max_it_zero
maximum number of iterations to find zeros
logical, public do_execute_command_line
call "execute_command_line" inside program
logical, public plot_magn_grid
whether to plot the grid in real coordinates
logical, public swap_angles
swap angles theta and zeta in plots (only for POST)
logical, public retain_all_sol
retain also faulty solutions
real(dp), public max_theta_plot
max. of theta_plot
real(dp), public tol_zero
tolerance for zeros
real(dp), public max_tot_mem
maximum total memory for all processes [MB]
logical, public plot_e_rec
whether to plot energy reconstruction in POST
real(dp), public max_x_mem
maximum memory for perturbation calculations for all processes [MB]
integer, public max_it_rich
number of levels for Richardson extrapolation
logical, public no_plots
no plots made
integer, public solver_slepc_style
style for solver (1: Krylov-Schur, 2: GD)
Variables concerning Richardson extrapolation.
integer, public min_n_par_x
min. of n_par_X (e.g. first value in Richardson loop)
logical, public no_guess
disable guessing Eigenfunction from previous level of Richardson
integer, public rich_lvl
current level of Richardson extrapolation
Variables pertaining to the solution quantities.
integer, public n_alloc_sols
nr. of allocated grids
elemental character(len=max_str_ln) function, public i2str(k)
Convert an integer to string.
Variables pertaining to the vacuum quantities.
Variables pertaining to the perturbation quantities.
integer, public n_alloc_x_2s
nr. of allocated X_2's
integer, public n_alloc_x_1s
nr. of allocated X_1's
vectorial perturbation type
tensorial perturbation type