MFC
Exascale flow solver
Loading...
Searching...
No Matches
p_main.fpp.f90
Go to the documentation of this file.
1# 1 "/home/runner/work/MFC/MFC/src/simulation/p_main.fpp"
2!>
3!! @file
4!! @brief Contains program p_main
5
6!> @brief Quasi-conservative, shock- and interface- capturing finite-volume scheme for the multicomponent Navier-Stokes equations.
7program p_main
8
10 use m_start_up
13 use m_nvtx
14
15 implicit none
16
17 integer :: t_step !< Iterator for the time-stepping loop
18 real(wp) :: time_avg, time_final
19 real(wp) :: io_time_avg, io_time_final
20 real(wp), allocatable, dimension(:) :: proc_time
21 real(wp), allocatable, dimension(:) :: io_proc_time
22 logical :: file_exists
23 real(wp) :: start, finish
24 integer :: nt
25 integer :: last_save !< Index of the last CFL-mode save
26
27 call system_clock(count=cpu_start, count_rate=cpu_rate)
28
29 call nvtxstartrange("INIT")
30
31 ! Initialize MPI
32 call nvtxstartrange("INIT-MPI")
34 call nvtxendrange
35
36 ! Initialize Modules
37 call nvtxstartrange("INIT-MODULES")
39 call nvtxendrange
40
41 allocate (proc_time(0:num_procs - 1))
42 allocate (io_proc_time(0:num_procs - 1))
43
44 call nvtxstartrange("INIT-GPU-VARS")
47 call nvtxendrange
48
49 ! Setting the time-stepper to the first time-step mytime is set by s_initialize_modules
50 if (cfl_dt) then
51 t_step = 0
52 t_step_start = 0
53 last_save = n_start
54 else
55 t_step = t_step_start
56 end if
57
58 call nvtxendrange ! INIT
59
60 ! Save the initial state so post_process sees the smeared particle volume fraction at t = 0. Fresh starts only: on a restart
61 ! this would rewrite the checkpoint being restarted from. CFL runs restart from n_start, fixed-dt runs from t_step_start.
62 if (particles_lagrange .and. merge(n_start, t_step_start, cfl_dt) == 0) then
63 call nvtxstartrange("SAVE-INIT-PARTICLES")
64 call s_save_data(t_step, start, finish, io_time_avg, nt)
65 call nvtxendrange ! SAVE-INIT-PARTICLES
66 end if
67
68 call nvtxstartrange("SIMULATION-TIME-MARCH")
69 ! Time-stepping Loop
70 do
71 if (cfl_dt) then
72 if (mytime >= t_stop) then
73 call s_save_performance_metrics(time_avg, time_final, io_time_avg, io_time_final, proc_time, io_proc_time, &
74 & file_exists)
75 exit
76 end if
77 else
78 if (t_step == t_step_stop) then
79 call s_save_performance_metrics(time_avg, time_final, io_time_avg, io_time_final, proc_time, io_proc_time, &
80 & file_exists)
81 exit
82 end if
83 end if
84
85 call s_perform_time_step(t_step, time_avg)
86
87 if (cfl_dt) then
88 ! Save once per index; a mod(mytime, t_save) < dt test can refire on a restart and overwrite n_start
89 if (int(mytime/t_save) > last_save .or. mytime >= t_stop) then
90 call s_save_data(t_step, start, finish, io_time_avg, nt)
91 last_save = int(mytime/t_save)
92 end if
93 else
94 if (mod(t_step - t_step_start, t_step_save) == 0 .or. t_step == t_step_stop) then
95 call s_save_data(t_step, start, finish, io_time_avg, nt)
96 end if
97 end if
98
99 call system_clock(cpu_end)
100 end do
101
102 ! Step N's IB force and heat records are written at the start of step N, which the loop never reaches for its last step
103 call s_write_ib_history(t_step)
104
105 call nvtxendrange ! Simulation
106
107 deallocate (proc_time, io_proc_time)
108
109 call nvtxstartrange("FINALIZE-MODULES")
110 call s_finalize_modules()
111 call nvtxendrange
112end program p_main
Writes solution data, run-time stability diagnostics (ICFL, VCFL, CCFL, Rc), and probe/center-of-mass...
impure subroutine, public s_write_ib_history(t_step)
Record every immersed body's force, torque and kinematics (D/ib_forces.dat, ib_force_wrt) and its mas...
Global parameters for the computational domain, fluid properties, and simulation algorithm configurat...
real(wp) mytime
Current simulation time.
integer num_procs
Number of processors.
NVIDIA NVTX profiling API bindings for GPU performance instrumentation.
Definition m_nvtx.f90:6
subroutine nvtxstartrange(name, id)
Push a named NVTX range for GPU profiling, optionally with a color based on the given identifier.
Definition m_nvtx.f90:62
subroutine nvtxendrange
Pop the current NVTX range to end the GPU profiling region.
Definition m_nvtx.f90:83
Reads input files, loads initial conditions and grid data, and orchestrates solver initialization and...
impure subroutine, public s_initialize_modules
Initialize all simulation sub-modules in the required dependency order.
impure subroutine, public s_save_performance_metrics(time_avg, time_final, io_time_avg, io_time_final, proc_time, io_proc_time, file_exists)
Collect per-process wall-clock times and write aggregate performance metrics to file.
impure subroutine, public s_save_data(t_step, start, finish, io_time_avg, nt)
Save conservative variable data to disk at the current time step.
subroutine, public s_initialize_gpu_vars
Transfer initial conservative variable and model parameter data to the GPU device.
impure subroutine, public s_initialize_mpi_domain
Set up the MPI execution environment, bind GPUs, and decompose the computational domain.
impure subroutine, public s_amr_start_fresh_blocks
Fresh AMR run, before the first save: put the initial condition patches on the blocks and,...
impure subroutine, public s_finalize_modules
Finalize and deallocate all simulation sub-modules in reverse initialization order.
impure subroutine, public s_perform_time_step(t_step, time_avg)
Advance the simulation by one time step, handling CFL-based dt and time-stepper dispatch.
Total-variation-diminishing (TVD) Runge–Kutta time integrators (1st-, 2nd-, and 3rd-order SSP).
program p_main
Quasi-conservative, shock- and interface- capturing finite-volume scheme for the multicomponent Navie...
Definition p_main.fpp.f90:7