From 2c3fcc97faf9124dcc4e92fd66699d62c9d53be0 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 20 Feb 2026 22:21:56 -0500 Subject: [PATCH] Fix s_write_intf_data_file using wrong loop index for distance check euc_d was computed outside the inner loop using the outer variable i (stale from a previous loop) instead of the current stored-point index. Moved distance computation inside the do-loop over stored points and changed cycle to exit for correct early termination when a candidate point is too close to any existing point. Co-Authored-By: Claude Opus 4.6 --- src/post_process/m_data_output.fpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/post_process/m_data_output.fpp b/src/post_process/m_data_output.fpp index ff0aeeee6f..7bc083b0ef 100644 --- a/src/post_process/m_data_output.fpp +++ b/src/post_process/m_data_output.fpp @@ -1546,19 +1546,16 @@ contains counter = counter + 1 x_d1(counter) = x_cc(j) y_d1(counter) = y_cc(k) - euc_d = sqrt((x_cc(j) - x_d1(i))**2 + (y_cc(k) - y_d1(i))**2) - tgp = sqrt(dx(j)**2 + dy(k)**2) else - euc_d = sqrt((x_cc(j) - x_d1(i))**2 + (y_cc(k) - y_d1(i))**2) tgp = sqrt(dx(j)**2 + dy(k)**2) do i = 1, counter + euc_d = sqrt((x_cc(j) - x_d1(i))**2 + (y_cc(k) - y_d1(i))**2) if (euc_d < tgp) then - cycle - elseif (euc_d > tgp .and. i == counter) then + exit + elseif (i == counter) then counter = counter + 1 x_d1(counter) = x_cc(j) y_d1(counter) = y_cc(k) - end if end do end if