Skip to content

Commit f35b36a

Browse files
committed
Fix three CodeRabbit-flagged bugs in THINC compression
- m_weno.fpp: add missing 'use m_nvtx' for nvtxStartRange/nvtxEndRange calls - m_thinc.fpp: clamp atanh argument in f_log_cosh_diff to avoid Inf/NaN when tanh saturates to ±1 on sharp interfaces - m_checker.fpp: prohibit muscl_order==1 with int_comp>0 (uninitialized workspace)
1 parent 3e3661c commit f35b36a

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/simulation/m_checker.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ contains
8080
@:PROHIBIT(p + 1 < min(1, p)*num_stcls_min*muscl_order, &
8181
& "For 3D simulation, p must be greater than or equal to (num_stcls_min*muscl_order - 1), whose value is " &
8282
& // trim(numStr))
83+
@:PROHIBIT(muscl_order == 1 .and. int_comp > 0, &
84+
& "int_comp requires muscl_order >= 2 (muscl_order=1 leaves the reconstruction workspace uninitialised)")
8385

8486
end subroutine s_check_inputs_muscl
8587

src/simulation/m_thinc.fpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ contains
6262

6363
$:GPU_ROUTINE(parallelism='[seq]')
6464
real(wp), intent(in) :: a, h
65-
real(wp) :: res
65+
real(wp) :: res, t
6666

67-
res = 2._wp*atanh(tanh(a)*tanh(h))
67+
t = tanh(a)*tanh(h)
68+
res = 2._wp*atanh(sign(min(abs(t), 1._wp - epsilon(1._wp)), t))
6869

6970
end function f_log_cosh_diff
7071

src/simulation/m_weno.fpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module m_weno
1414

1515
use m_mpi_proxy
1616
use m_thinc, only: s_thinc_compression
17+
use m_nvtx
1718

1819
private; public :: s_initialize_weno_module, s_initialize_weno, s_finalize_weno_module, s_weno
1920

0 commit comments

Comments
 (0)