Skip to content

Commit 1daf95b

Browse files
Spencer Bryngelsonclaude
andcommitted
Fix use of uninitialized FT in s_TSat Newton loop
The do while condition checked abs(FT) before FT was ever assigned. Fortran .or. is not short-circuit, so abs(FT) was always evaluated on the first iteration even though (ns == 0) guaranteed loop entry. Restructure to do...exit: compute FT first, then check convergence. Logically identical, no uninitialized reads, no intrinsics, safe on all GPU device compilers (exit maps to a plain conditional branch). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a2c4d1d commit 1daf95b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/common/m_phase_change.fpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ contains
717717

718718
! underrelaxation factor
719719
Om = 1.0e-3_wp
720-
do while ((abs(FT) > ptgalpha_eps) .or. (ns == 0))
720+
do
721721
! increasing counter
722722
ns = ns + 1
723723

@@ -738,6 +738,7 @@ contains
738738
! updating saturation temperature
739739
TSat = TSat - Om*FT/dFdT
740740

741+
if (abs(FT) <= ptgalpha_eps) exit
741742
end do
742743

743744
end if

0 commit comments

Comments
 (0)