Skip to content

adam_ripple_fnl_object ​

RIPPLE, the FNL (OpenACC) backend realm.

The CPU backend's twin with the state on the device: a sibling of ripple_cpu_object, extending the same common realm. The initial condition and the initial AMR run on the host, then the state goes to the device and stays there; it comes back only for the outputs. The library's FNL helpers do the device side of the library objects: field_fnl the ghost exchange (local copies, 2:1 transfers, GPU-direct MPI), rk_fnl the Runge-Kutta stages, weno_fnl the WENO coefficients. Device arrays are transposed, (b, i, j, k, v).

Source: src/app/ripple/fnl/adam_ripple_fnl_object.F90

Dependencies

Contents ​

Derived Types ​

ripple_fnl_object ​

RIPPLE FNL realm.

Inheritance

Extends: ripple_common_object

Components ​

NameTypeAttributesDescription
iotype(io_object)IO handler.
amrtype(amr_object)AMR marker handler.
slicestype(slices_object)Slices handler.
blanesmoantype(blanesmoan_object)Blanes-Moan integrator.
cfmtype(cfm_object)Commutator-Free Magnus integrator.
leapfrogtype(leapfrog_object)Leapfrog integrator.
flailtype(flail_object)FLAIL, the elliptic solver library (issue #84).
wenotype(weno_object)WENO reconstructor.
ibtype(ib_object)Immersed boundary.
rktype(rk_object)Runge-Kutta integrator.
adamtype(adam_object)ADAM, grid + tree + field + maps orchestrator.
fdv_schemecharacter(len=:)allocatableFDV scheme, fd/fv.
fdv_orderinteger(kind=I4P)Order of finite difference/volume schemes, general order.
fdv_half_stencilinteger(kind=I4P)Half stencil length of finite difference/volume schemes.
fdv_half_stencilsinteger(kind=I4P)Half stencil length of fdv schemes for each derivative up to 6.
ngcinteger(kind=I4P)pointerNumber of ghost cells.
niinteger(kind=I4P)pointerNumber of cells in i direction.
njinteger(kind=I4P)pointerNumber of cells in j direction.
nkinteger(kind=I4P)pointerNumber of cells in k direction.
nbinteger(kind=I4P)pointerTotal blocks number for MPI.
blocks_numberinteger(kind=I4P)pointerActual blocks number.
nvinteger(kind=I4P)pointerNumber of variables in q vector.
realm_indexinteger(kind=I4P)Inter-realm seam coupling — currently-published stage buffer key.
stage_activeinteger(kind=I4P)A copy of the forest's flux register (its faces and lookup, the accumulators unused), refreshed by the forest each
flux_register_copytype(flux_register_object)Procedure pointer TBPs for FDV operators (set at initialization by backend).
compute_block_total_variationprocedure(compute_block_total_variation_interface)pass(self), pointerCompute TV.
compute_curlprocedure(compute_curl_interface)pass(self), pointerCompute curl.
compute_curl_extendedprocedure(compute_curl_interface)pass(self), pointerCompute curl on extended support.
compute_derivative1procedure(compute_derivative1_interface)pass(self), pointerCompute deriv1.
compute_derivative2procedure(compute_derivative2_interface)pass(self), pointerCompute deriv2.
compute_derivative4procedure(compute_derivative4_interface)pass(self), pointerCompute deriv4.
compute_divergenceprocedure(compute_divergence_interface)pass(self), pointerCompute dive.
compute_gradientprocedure(compute_gradient_interface)pass(self), pointerCompute grad.
compute_gradient_extendedprocedure(compute_gradient_interface)pass(self), pointerCompute gradient on extended support.
compute_laplacianprocedure(compute_laplacian_interface)pass(self), pointerCompute laplac.
qreal(kind=R8P)allocatableState, point values u [1, 1-ngc:ni+ngc, ..., nb].
dqreal(kind=R8P)allocatableResiduals, same shape.
areal(kind=R8P)Advection velocity.
cflreal(kind=R8P)CFL number.
timereal(kind=R8P)Current time.
time_maxreal(kind=R8P)Final time.
dtreal(kind=R8P)Current time step.
itinteger(kind=I4P)Current iteration.
it_maxinteger(kind=I4P)Iterations number; <= 0: run to time_max.
history_unitinteger(kind=I4P)Unit of the history file (rank 0).
amr_criteriatype(amr_criterion_pointer)allocatableRegistered refinement criteria (issue #110).
field_fnltype(field_fnl_object)Field helper: coordinates, maps, ghost exchange.
rk_fnltype(rk_fnl_object)Runge-Kutta helper: the stages on the device.
weno_fnltype(weno_fnl_object)WENO helper: the coefficients on the device.
q_gpureal(kind=R8P)pointerState [nb, 1-ngc:ni+ngc, ..., 1].
dq_gpureal(kind=R8P)pointerResiduals, same shape.
flx_gpureal(kind=R8P)pointerX-face fluxes [nb, 0:ni, 1:nj, 1:nk, 1].
fly_gpureal(kind=R8P)pointerY-face fluxes [nb, 1:ni, 0:nj, 1:nk, 1].
flz_gpureal(kind=R8P)pointerZ-face fluxes [nb, 1:ni, 1:nj, 0:nk, 1].
face_gpureal(kind=R8P)pointerOne face's skin or reflux mismatch [1, largest face].
facereal(kind=R8P)allocatableIts host copy, the same extent.

Type-Bound Procedures ​

NameAttributesDescription
initializepass(self)Initialize common data.
load_fdv_from_filepass(self)Load FDV config from file.
coupling_descriptor_forestpass(self)Report (scheme_time, rk_scheme, nv) for β admissibility.
runtime_amr_forestpass(self)Whether this realm regrids during the run (#74).
regrid_forestpass(self)Invoked by forest%regrid per realm per timestep (#74).
regrid_begin_forestpass(self)Multi-realm regrid, phase 1: is it a regrid step (#110).
regrid_mark_forestpass(self)Phase 2: mark one sweep, marks on the tree (#110).
regrid_apply_forestpass(self)Phase 3: adapt to the (balanced) tree marks (#110).
regrid_end_forestpass(self)Phase 4: refresh the grid-dependent state (#110).
fill_seam_from_peer_forestpass(self)Receive-side roundtrip: copy peer's interior into self's ghosts.
pack_seam_cells_forestpass(self)Pack own cells of the cross-rank seam send rows.
unpack_seam_cells_forestpass(self)Unpack the cross-rank seam receive rows into own ghosts.
after_topology_build_forestpass(self)Backend hook invoked once after the forest builds the seam maps.
close_block_xh5fnopassClose XH5F file block.
close_file_xh5fnopassClose XH5F file.
open_block_xh5fpass(self)Open block file XH5F.
open_file_xh5fpass(self)Open file XH5F.
save_q_xh5fpass(self)Save in XH5F (XDMF/HDF5) format.
compute_curl_fd_extendedpass(self)Compute curl of vector field, finite difference, even for half gcs.
compute_gradient_fd_extendedpass(self)Compute gradient of scalar field, finite difference, even for half
initialize_ripplepass(self)Initialize the common data.
check_inputpass(self)Refuse the inputs RIPPLE cannot honour.
set_initial_conditionspass(self)Set the initial profile on the interior cells.
amr_updatepass(self)Initial AMR: box markers and registered criteria.
register_amr_criterionpass(self)Register a refinement criterion by name (issue #110).
save_outputpass(self)Save one history row and the state (XH5F).
advance_timepass(self)Count the step and cap dt on time_max.
accumulate_seam_skinpass(self)Route one seam face skin to the flux register.
apply_refluxpass(self)Berger-Colella correction of the coarse seam cells of q.
compute_local_dt_forestpass(self)Local CFL time step.
is_done_forestpass(self)True when the run is over.
stages_per_step_forestpass(self)Runge-Kutta stages per step (staged path).
allocate_gpupass(self)Allocate the device data.
copy_statepass(self)Copy q between host and device.
update_ghostpass(self)Fill the ghost cells on the device.
compute_residualspass(self)Residuals of one device state.
accumulate_seam_fluxespass(self)Seam face fluxes of one stage to the flux register.
compute_totalpass(self)Total of u dV on this rank, from the device state.
initialize_forestpass(self)Initialize the realm.
advance_one_step_forestpass(self)Advance one whole step.
post_step_forestpass(self)Save the outputs on their cadence.
finalize_forestpass(self)Finalize the realm.
finalize_mpi_forestpass(self)Finalize the FNL MPI handler.
open_step_forestpass(self)Open a step.
begin_stage_forestpass(self)Begin a stage.
end_stage_forestpass(self)End a stage.
close_step_forestpass(self)Close a step.
apply_reflux_to_stage_forestpass(self)Reflux the committed step on the device.

Subroutines ​

allocate_gpu ​

Allocate the device data, every dev_alloc checked.

fortran
subroutine allocate_gpu(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.

Call graph

copy_state ​

Copy the blocks in use of the state between the host q(v, i, j, k, b) and the device q_gpu(b, i, j, k, v): a device kernel transposes them into a scratch buffer of the host slab's shape, moved by one contiguous copy.

fortran
subroutine copy_state(self, to_device)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.
to_devicelogicalinHost to device, else back.

Call graph

update_ghost ​

Fill the ghost cells on the device: local copies and 2:1 transfers, then the GPU-direct MPI exchange.

fortran
subroutine update_ghost(self, q_gpu)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.
q_gpureal(kind=R8P)inoutState.

Call graph

compute_residuals ​

Compute the residuals dq_gpu of the device state q_gpu (the CPU compute_residuals on the device).

fortran
subroutine compute_residuals(self, q_gpu, s, flux_register)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.
q_gpureal(kind=R8P)inoutState.
sinteger(kind=I4P)inoptionalRunge-Kutta stage.
flux_registerclass(flux_register_object)inoutoptionalForest's flux register.

Call graph

accumulate_seam_fluxes ​

Pack the face flux skin of every registered seam face on the device, bring it to the host and route it to the (host) register, weighted by the SSP coefficient of stage s. One small copy per face: simple, not fast.

fortran
subroutine accumulate_seam_fluxes(self, s, flux_register)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.
sinteger(kind=I4P)inRunge-Kutta stage.
flux_registerclass(flux_register_object)inoutForest's flux register.

Call graph

initialize_forest ​

Initialize the realm: MPI and the device (once per process), the common data within the device budget, the FNL helpers, the device data; initial AMR and initial condition on the host, then the state to the device.

fortran
subroutine initialize_forest(self, filename, realms_number, memory_avail, nv, verbose)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.
filenamecharacter(len=*)inInput file name.
realms_numberinteger(kind=I4P)inoptionalUnused: RIPPLE is single-realm.
memory_availreal(kind=R8P)inoptionalUnused: the budget comes from the device.
nvinteger(kind=I4P)inoptionalUnused: nv = 1.
verboselogicalinoptionalUnused.

Call graph

advance_one_step_forest ​

Advance one whole SSP Runge-Kutta step on the device (fast path: no 2:1 face).

fortran
subroutine advance_one_step_forest(self, dt)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.
dtreal(kind=R8P)inTime step from the forest.

Call graph

post_step_forest ​

Append the history row every step (the total reduced on the device); bring q to the host and save the fields every [IO] it_save steps and at the end.

fortran
subroutine post_step_forest(self, dt, t, it, do_save_state, do_save_residuals, do_save_restart, do_amr, realm)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.
dtreal(kind=R8P)inUnused.
treal(kind=R8P)inUnused.
itinteger(kind=I4P)inUnused.
do_save_statelogicalinoptionalUnused.
do_save_residualslogicalinoptionalUnused.
do_save_restartlogicalinoptionalUnused.
do_amrlogicalinoptionalUnused.
realmtype(realm_pointer)inouttarget, optionalUnused.

Call graph

finalize_forest ​

Finalize the realm: close the history, free the device data (the forest finalizes MPI once).

fortran
subroutine finalize_forest(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.

Call graph

finalize_mpi_forest ​

Finalize the FNL MPI handler (the forest calls it once, after every realm is finalized).

fortran
subroutine finalize_mpi_forest(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm (carries no MPI state).

Call graph

open_step_forest ​

Open a step: count it, cap dt, copy q into every stage.

fortran
subroutine open_step_forest(self, dt)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.
dtreal(kind=R8P)inTime step from the forest.

Call graph

begin_stage_forest ​

Begin stage k: publish it (stage_active) and build its state.

fortran
subroutine begin_stage_forest(self, k, K_total, dt, realm)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.
kinteger(kind=I4P)inStage index.
K_totalinteger(kind=I4P)inUnused.
dtreal(kind=R8P)inUnused: the capped dt is self%dt.
realmtype(realm_pointer)inouttarget, optionalUnused.

Call graph

end_stage_forest ​

End stage k: its residuals, the seam fluxes to the register, the stage assignment.

fortran
subroutine end_stage_forest(self, k, K_total, dt, realm, flux_register)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.
kinteger(kind=I4P)inStage index.
K_totalinteger(kind=I4P)inUnused.
dtreal(kind=R8P)inUnused.
realmtype(realm_pointer)inouttarget, optionalUnused.
flux_registerclass(flux_register_object)inoutoptionalForest's flux register.

Call graph

close_step_forest ​

Close a step: commit q, advance the time, clear the active stage.

fortran
subroutine close_step_forest(self, dt)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.
dtreal(kind=R8P)in

Call graph

apply_reflux_to_stage_forest ​

Reflux the committed device state (the forest calls it after close_step_forest, with the last stage): the host mismatch F_coarse - F_fine of every coarse face this rank owns goes to the device and is added, scaled by sgn dt / dx, to its coarse skin cells.

fortran
subroutine apply_reflux_to_stage_forest(self, stage, dt, flux_register)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inoutThe realm.
stageinteger(kind=I4P)inStage: the correction acts at the last one.
dtreal(kind=R8P)inUnused: the capped dt is self%dt.
flux_registerclass(flux_register_object)inForest's flux register.

Call graph

Functions ​

compute_total ​

Return the total of u dV over the interior cells of this rank's blocks, reduced on the device.

Returns: real(kind=R8P)

fortran
function compute_total(self) result(total)

Arguments

NameTypeIntentAttributesDescription
selfclass(ripple_fnl_object)inThe realm.

Call graph