Skip to content

Feature/wjiang/fix debug#173

Open
weiyuan-jiang wants to merge 3 commits intodevelopfrom
feature/wjiang/fix_debug
Open

Feature/wjiang/fix debug#173
weiyuan-jiang wants to merge 3 commits intodevelopfrom
feature/wjiang/fix_debug

Conversation

@weiyuan-jiang
Copy link
Copy Markdown
Contributor

This PR fixes the run in debug mode. It is 0-diff

In debug mode, Intel Fortran raises error 65 (floating invalid) when
comparing NaN values (e.g. NaN >= 0.). Input scaling parameter files
use NaN as a no-data indicator, which causes comparisons like
sclprm_std_obs >= 0. to raise FP exceptions before returning false.

Fix: Add NaN guards using the standard Fortran idiom (val == val is
.false. for NaN) before the existing range checks at all 3 guard sites
in clsm_ensupd_read_obs.F90 (~line 9755, ~9989, ~10384).
When N_files=1, lon_min_vec(2) and lon_max_vec(2) remain initialized
to MAPL_UNDEF (1.0e15). Whole-array operations like:
  start_ind = (lon_min_vec - CMG_ll_lon) / CMG_dlon
produce ~2e16 which overflows a 32-bit integer, causing
forrtl: error (65): floating invalid in debug mode.

Fix: Restrict array operations to (1:N_files) elements only:
  start_ind(1:N_files) = (lon_min_vec(1:N_files) - CMG_ll_lon)/CMG_dlon
  last_ind(1:N_files)  = (lon_max_vec(1:N_files) - CMG_ll_lon)/CMG_dlon
  N_lon_vec(1:N_files) = last_ind(1:N_files) - start_ind(1:N_files) + 1
@weiyuan-jiang weiyuan-jiang requested a review from a team as a code owner May 10, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant