Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,17 @@ jobs:

- name: Build and test
run: |
rm -f checks.out
rm -f checks*.out
# --stepmgr: the suite's srun steps otherwise congest the Frontier controller (see submit-slurm-job.sh).
sbatch --wait -J MFC-checks -A CFD154 -N 1 -t 01:30:00 -q normal --stepmgr -o checks.out \
--wrap '. ./mfc.sh load -c famd -m c && ./mfc.sh test -v -a -j 32 --no-gpu --reldebug -- -c frontier_amd'
job() { sbatch --wait -J MFC-checks -A CFD154 -N 1 -t 01:30:00 -q normal --stepmgr -o "$1" \
--wrap ". ./mfc.sh load -c famd -m c && ./mfc.sh test -v -a -j 32 --no-gpu --reldebug $2 -- -c frontier_amd"; }
# The -O0 build runs the suite in about 2 h: build every variant once, then two shards side by side.
job checks-build.out --dry-run || { cat checks-build.out > checks.out; exit 1; }
job checks-1.out '--no-build --shard 1/2' & p1=$!
job checks-2.out '--no-build --shard 2/2' & p2=$!
e=0; wait $p1 || e=1; wait $p2 || e=1
cat checks-1.out checks-2.out > checks.out
exit $e

- name: Print Log
if: always()
Expand Down
4 changes: 3 additions & 1 deletion cmake/GPU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")
# not instrument array accesses): trap on invalid, divide-by-zero and overflow, and fill
# uninitialised locals with 0xff bytes (reals NaN, integers -1) so their use shows.
# Older flangs (flang-new 20) know neither flag, so each is added only where accepted.
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-O1> $<$<COMPILE_LANGUAGE:Fortran>:-g>)
# -O0: at -O1 this flang evaluates divisions guarded by an if before the test, and
# no flag forbids it, so the traps would fire on results the code never uses.
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-O0> $<$<COMPILE_LANGUAGE:Fortran>:-g>)
check_fortran_compiler_flag("-ffpe-trap=invalid,zero,overflow" MFC_FLANG_FPE_TRAP)
if (MFC_FLANG_FPE_TRAP)
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-ffpe-trap=invalid,zero,overflow>)
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ compiler.
| Intel ifx | `-Og -check all` | `-Og -check bounds` |
| NVHPC | `-O0 -C -Mbounds`, on CPU also `-Ktrap=fp` | `-O1 -Mbounds`, on CPU also `-Ktrap=fp` |
| Cray ftn | `-O0 -K trap=fp` | `-O1 -K trap=fp` |
| AMD flang (CPU) | `-O1`, plus `-ffpe-trap=invalid,zero,overflow -finit-local=0xff` where the compiler has them | the same |
| AMD flang (CPU) | `-O0`, plus `-ffpe-trap=invalid,zero,overflow -finit-local=0xff` where the compiler has them | the same |

The floating-point traps of NVHPC and AMD flang on CPU stop some of the suite's own tests on
`master` today. They are known and not yet triaged: some may be values computed and then discarded,
Expand Down
5 changes: 3 additions & 2 deletions src/common/m_variables_conversion.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ contains
alpha_K(i) = min(max(0._wp, alpha_K(i)), 1._wp)
alpha_K_sum = alpha_K_sum + alpha_K(i)
end do
alpha_K = alpha_K/max(alpha_K_sum, sgm_eps)
! Only the fluids: with AMD flang these arrays are declared with 3 elements, more than a caller may pass
alpha_K(1:num_fluids) = alpha_K(1:num_fluids)/max(alpha_K_sum, sgm_eps)
end if
call s_compute_mixture_coefficients(alpha_rho_K, alpha_K, rho_K, gamma_K, pi_inf_K, qv_K)

Expand Down Expand Up @@ -1171,7 +1172,7 @@ contains
alpha_K(i) = min(max(0._wp, alpha_K(i)), 1._wp)
alpha_K_sum = alpha_K_sum + alpha_K(i)
end do
alpha_K = alpha_K/max(alpha_K_sum, 1.e-16_wp)
alpha_K(1:num_fluids) = alpha_K(1:num_fluids)/max(alpha_K_sum, 1.e-16_wp)
end if

if (num_fluids == 1 .and. bubbles_euler) alpha_K(1) = q_vf(eqn_idx%adv%beg)%sf(k, l, r)
Expand Down
21 changes: 6 additions & 15 deletions src/simulation/m_ibm.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@ contains
real(wp) :: rho, gamma, pi_inf, dyn_pres !< Mixture variables
real(wp) :: vel_sum_g, E_ghost !< Ghost-point velocity magnitude and energy
real(wp), dimension(2) :: Re_K
real(wp) :: G_K
real(wp) :: qv_K
real(wp) :: pres_IP, pres_GP
real(wp), dimension(3) :: vel_IP
Expand All @@ -634,13 +633,11 @@ contains
integer :: nf1, nf2, nf3 !< Per-call fill-tier tallies

#:if not MFC_CASE_OPTIMIZATION and USING_AMD
real(wp), dimension(3) :: Gs
real(wp), dimension(3) :: alpha_rho_IP, alpha_IP, alpha_rho_GP
real(wp), dimension(3) :: r_IP, v_IP, pb_IP, mv_IP
real(wp), dimension(18) :: nmom_IP
real(wp), dimension(12) :: presb_IP, massv_IP
#:else
real(wp), dimension(num_fluids) :: Gs
real(wp), dimension(num_fluids) :: alpha_rho_IP, alpha_IP, alpha_rho_GP
real(wp), dimension(nb) :: r_IP, v_IP, pb_IP, mv_IP
real(wp), dimension(nb*nmom) :: nmom_IP
Expand Down Expand Up @@ -716,11 +713,11 @@ contains
$:END_GPU_PARALLEL_LOOP()
$:GPU_PARALLEL_LOOP(private='[i, physical_loc, dyn_pres, alpha_rho_IP, alpha_IP, alpha_rho_GP, pres_IP, pres_GP, &
& vel_IP, vel_g, r_IP, v_IP, pb_IP, mv_IP, nmom_IP, presb_IP, massv_IP, rho, gamma, pi_inf, Re_K, &
& G_K, Gs, gp, norm, buf, radial_vector, j, k, l, q, qv_K, c_IP, nbub, patch_id, Ys_IP, &
& W_species, T_IP, mw_IP, e_IP, Ys_g, Ys_s, T_s, T_g, T_adv, mw_s, mw_g, rho_s, rho_g, mdot_s, &
& v_stefan, d, surface_converged, vel_sum_g, E_ghost, alpha_q, alpha_rho_q, e_q, mdot_k, h_w, &
& e_s, nrm_l, wf, h_IP, dh_ccst, p_ratio, use_ccst]', reduction='[[n_not_converged, n_ill_posed, &
& nf1, nf2, nf3]]', reductionOp='[+]', present='[ghost_points]')
& gp, norm, buf, radial_vector, j, k, l, q, qv_K, c_IP, nbub, patch_id, Ys_IP, W_species, T_IP, &
& mw_IP, e_IP, Ys_g, Ys_s, T_s, T_g, T_adv, mw_s, mw_g, rho_s, rho_g, mdot_s, v_stefan, d, &
& surface_converged, vel_sum_g, E_ghost, alpha_q, alpha_rho_q, e_q, mdot_k, h_w, e_s, nrm_l, wf, &
& h_IP, dh_ccst, p_ratio, use_ccst]', reduction='[[n_not_converged, n_ill_posed, nf1, nf2, &
& nf3]]', reductionOp='[+]', present='[ghost_points]')
do i = 1, num_gps
if (record_surface) then
$:GPU_LOOP(parallelism='[seq]')
Expand Down Expand Up @@ -869,13 +866,7 @@ contains
alpha_rho_IP(1) = alpha_IP(1)*rho_g
end if

! If in simulation, use acc mixture subroutines
if (hypoelasticity) then
call s_convert_species_to_mixture_variables_kernel(rho, gamma, pi_inf, qv_K, alpha_IP, alpha_rho_IP, Re_K, &
& G_K, Gs)
else
call s_convert_species_to_mixture_variables_kernel(rho, gamma, pi_inf, qv_K, alpha_IP, alpha_rho_IP, Re_K)
end if
call s_convert_species_to_mixture_variables_kernel(rho, gamma, pi_inf, qv_K, alpha_IP, alpha_rho_IP, Re_K)

if (surface_tension) gp_prim_new(eqn_idx%c, i) = c_IP

Expand Down
4 changes: 2 additions & 2 deletions src/simulation/m_particles_EL.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,11 @@ contains
do l = 1, num_fluids
cv_mix = cv_mix + alpha(l)*cvs(l)/gammas(l) ! R = cv*(gamma - 1), with gammas = 1/(gamma - 1)
end do
fluid_temp = (fluid_pres + pi_inf_mix)/(fluid_rho*cv_mix)
do l = 1, num_fluids
! Constant viscosity unless a Sutherland constant is given
! Constant viscosity unless a Sutherland constant is given; only then is the temperature needed, and cv set
mu_f = particle_params%mu_ref(l)
if (particle_params%suth(l) > 0._wp) then
fluid_temp = (fluid_pres + pi_inf_mix)/(fluid_rho*cv_mix)
mu_f = mu_f*sqrt(fluid_temp/tref)*(1._wp + particle_params%suth(l)/tref)/(1._wp + particle_params%suth(l) &
& /fluid_temp)
end if
Expand Down
53 changes: 48 additions & 5 deletions src/simulation/m_rhs.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ contains
& idwbuff_alloc(2)%beg:idwbuff_alloc(2)%end, idwbuff_alloc(3)%beg:idwbuff_alloc(3)%end))
@:ALLOCATE(qR_prim(i)%vf(l)%sf(idwbuff_alloc(1)%beg:idwbuff_alloc(1)%end, &
& idwbuff_alloc(2)%beg:idwbuff_alloc(2)%end, idwbuff_alloc(3)%beg:idwbuff_alloc(3)%end))
! Zeroed: the gradient's outer ghost cells read faces the reconstruction never writes
qL_prim(i)%vf(l)%sf = 0._wp
qR_prim(i)%vf(l)%sf = 0._wp
end do
end if
@:ACC_SETUP_VFs(qL_prim(i), qR_prim(i))
Expand Down Expand Up @@ -669,11 +672,14 @@ contains
do i = eqn_idx%adv%beg, eqn_idx%adv%end - 1
alf_sum%sf(j, k, l) = alf_sum%sf(j, k, l) + q_cons_qp%vf(i)%sf(j, k, l)
end do
$:GPU_LOOP(parallelism='[seq]')
do i = eqn_idx%adv%beg, eqn_idx%adv%end - 1
q_cons_qp%vf(i)%sf(j, k, l) = q_cons_qp%vf(i)%sf(j, k, &
& l)*(1._wp - q_cons_qp%vf(eqn_idx%alf)%sf(j, k, l))/alf_sum%sf(j, k, l)
end do
! Zero only in ghost cells not yet filled before the first step; they are refilled below
if (alf_sum%sf(j, k, l) > 0._wp) then
$:GPU_LOOP(parallelism='[seq]')
do i = eqn_idx%adv%beg, eqn_idx%adv%end - 1
q_cons_qp%vf(i)%sf(j, k, l) = q_cons_qp%vf(i)%sf(j, k, &
& l)*(1._wp - q_cons_qp%vf(eqn_idx%alf)%sf(j, k, l))/alf_sum%sf(j, k, l)
end do
end if
end do
end do
end do
Expand Down Expand Up @@ -1192,6 +1198,14 @@ contains
end if
irx%end = m; iry%end = n; irz%end = p

if (ib) then
if (amr_in_fine_advance) then
call s_body_faces_take_cell_states(ib_markers_fine, id)
else
call s_body_faces_take_cell_states(ib_markers, id)
end if
end if

! Computing Riemann Solver Flux and Source Flux
call nvtxStartRange("RHS-RIEMANN-SOLVER")
if (hypo_nc_mode == hypo_nc_mode_dual_pass) then
Expand Down Expand Up @@ -2592,6 +2606,35 @@ contains
end subroutine s_finalize_rhs_module

!> Zero the RHS at the body cells of the installed grid frame (marker /= 0).
!> A face between two body cells takes its cells' own states. Only body cells see it, and s_zero_rhs_at_body discards their RHS,
!! but a reconstruction across a thin body can give unphysical states there (a negative WENO density, #2510).
subroutine s_body_faces_take_cell_states(mk, id)

type(integer_field), intent(in) :: mk
integer, intent(in) :: id
integer :: i, j, k, l, dj, dk, dl

dj = merge(1, 0, id == 1); dk = merge(1, 0, id == 2); dl = merge(1, 0, id == 3)

! The face between cells c and c + e_id: the solver's left state is qR_rsx_vf(c), its right state qL_rsx_vf(c + e_id)
$:GPU_PARALLEL_LOOP(private='[i, j, k, l]', collapse=3, copyin='[dj, dk, dl]')
do l = 0, p - dl
do k = 0, n - dk
do j = 0, m - dj
if (mk%sf(j, k, l) /= 0 .and. mk%sf(j + dj, k + dk, l + dl) /= 0) then
$:GPU_LOOP(parallelism='[seq]')
do i = 1, sys_size
qR_rsx_vf(j, k, l, i) = q_prim_qp%vf(i)%sf(j, k, l)
qL_rsx_vf(j + dj, k + dk, l + dl, i) = q_prim_qp%vf(i)%sf(j + dj, k + dk, l + dl)
end do
end if
end do
end do
end do
$:END_GPU_PARALLEL_LOOP()

end subroutine s_body_faces_take_cell_states

subroutine s_zero_rhs_at_body(mk, rhs_vf)

type(integer_field), intent(in) :: mk
Expand Down
12 changes: 6 additions & 6 deletions src/simulation/m_time_steppers.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,10 @@ contains

do i = 1, num_probe_ts
do j = 1, sys_size
! Zeroed: the acceleration probe reads all four levels from the first step, before they hold a state
@:ALLOCATE(q_prim_ts1(i)%vf(j)%sf(idwbuff(1)%beg:idwbuff(1)%end, idwbuff(2)%beg:idwbuff(2)%end, &
& idwbuff(3)%beg:idwbuff(3)%end))
q_prim_ts1(i)%vf(j)%sf = 0._wp
end do
@:ACC_SETUP_VFs(q_prim_ts1(i))
end do
Expand All @@ -229,6 +231,7 @@ contains
do j = 1, sys_size
@:ALLOCATE(q_prim_ts2(i)%vf(j)%sf(idwbuff(1)%beg:idwbuff(1)%end, idwbuff(2)%beg:idwbuff(2)%end, &
& idwbuff(3)%beg:idwbuff(3)%end))
q_prim_ts2(i)%vf(j)%sf = 0._wp
end do
@:ACC_SETUP_VFs(q_prim_ts2(i))
end do
Expand Down Expand Up @@ -714,13 +717,10 @@ contains

integer, intent(in) :: stage

! Before the first RHS the conservative ghosts are unset; Lagrange refills the primitive ones below
! The interior only: before the first RHS the conservative ghosts are unset (a zero bubble number density
! divides by zero there). The Euler source reads no ghost cell; Lagrange refills the primitive ones below.

if (bubbles_lagrange) then
call s_convert_conservative_to_primitive_variables(q_cons_ts(1)%vf, q_T_sf, q_prim_vf, idwint)
else
call s_convert_conservative_to_primitive_variables(q_cons_ts(1)%vf, q_T_sf, q_prim_vf, idwbuff)
end if
call s_convert_conservative_to_primitive_variables(q_cons_ts(1)%vf, q_T_sf, q_prim_vf, idwint)

if (bubbles_euler) then
call s_compute_bubble_EE_source(q_cons_ts(1)%vf, q_prim_vf, rhs_vf, divu)
Expand Down
Loading