From 640c5547d5a043cdfcee9351836af5b519e753da Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Wed, 18 Feb 2026 15:54:01 -0700 Subject: [PATCH 1/2] Refactor some conditionals to make ifx happier When there were NaN values on the dataset, these checks were generating "floating invalid". At least part of the reason this is probably appearing with ifx is because ifx apparently doesn't do short-circuit conditional evaluation: in these cases, stream%mapalgo is *not* 'none', so many other compilers probably were never actually evaluating the comparison between the data and the fillvalue, but ifx is. So I'm fixing this by effectively doing the short-circuit evaluation manually - i.e., only doing the data comparison if stream%mapalgo is 'none'. --- streams/dshr_strdata_mod.F90 | 50 +++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index 4c726a669..96b11fdb9 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -1836,14 +1836,16 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & end if if (handlefill) then ! Single point streams are not allowed to have missing values - if (stream%mapalgo == 'none' .and. any(data_real2d == fillvalue_r4)) then - write(errmsg,'(2a)')' ERROR: _Fillvalue found in stream input variable: ',& - trim(per_stream%fldlist_stream(nf)) - if (sdat%mainproc) then - write(sdat%logunit,'(2a)') subname,trim(errmsg) + if (stream%mapalgo == 'none') then + if (any(data_real2d == fillvalue_r4)) then + write(errmsg,'(2a)')' ERROR: _Fillvalue found in stream input variable: ',& + trim(per_stream%fldlist_stream(nf)) + if (sdat%mainproc) then + write(sdat%logunit,'(2a)') subname,trim(errmsg) + end if + call shr_log_error(errmsg, rc=rc) + return end if - call shr_log_error(errmsg, rc=rc) - return endif do lev = 1,stream_nlev do n = 1,size(dataptr2d, dim=2) @@ -1874,13 +1876,15 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & end if if (handlefill) then ! Single point streams are not allowed to have missing values - if (stream%mapalgo == 'none' .and. any(data_real1d == fillvalue_r4)) then - write (errmsg,'(2a)')' ERROR: _Fillvalue found in stream input variable: ',trim(per_stream%fldlist_stream(nf)) - if (sdat%mainproc) then - write(sdat%logunit,'(2a)') subname,trim(errmsg) + if (stream%mapalgo == 'none') then + if (any(data_real1d == fillvalue_r4)) then + write (errmsg,'(2a)')' ERROR: _Fillvalue found in stream input variable: ',trim(per_stream%fldlist_stream(nf)) + if (sdat%mainproc) then + write(sdat%logunit,'(2a)') subname,trim(errmsg) + end if + call shr_log_error(errmsg, rc=rc) + return end if - call shr_log_error(errmsg, rc=rc) - return endif do n=1,size(dataptr1d) @@ -1912,10 +1916,12 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & end if if (handlefill) then ! Single point streams are not allowed to have missing values - if (stream%mapalgo == 'none' .and. any(data_dbl2d == fillvalue_r8)) then - write(errmsg,*) ' ERROR: _Fillvalue found in stream input variable: '// trim(per_stream%fldlist_stream(nf)) - call shr_log_error(errmsg, rc=rc) - return + if (stream%mapalgo == 'none') then + if (any(data_dbl2d == fillvalue_r8)) then + write(errmsg,*) ' ERROR: _Fillvalue found in stream input variable: '// trim(per_stream%fldlist_stream(nf)) + call shr_log_error(errmsg, rc=rc) + return + end if endif do lev = 1,stream_nlev do n = 1,size(dataptr2d, dim=2) @@ -1946,10 +1952,12 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & end if if (handlefill) then ! Single point streams are not allowed to have missing values - if (stream%mapalgo == 'none' .and. any(data_dbl1d == fillvalue_r8)) then - write(errmsg,*) ' ERROR: _Fillvalue found in stream input variable: '// trim(per_stream%fldlist_stream(nf)) - call shr_log_error(subname//trim(errmsg), rc=rc) - return + if (stream%mapalgo == 'none') then + if (any(data_dbl1d == fillvalue_r8)) then + write(errmsg,*) ' ERROR: _Fillvalue found in stream input variable: '// trim(per_stream%fldlist_stream(nf)) + call shr_log_error(subname//trim(errmsg), rc=rc) + return + end if endif do n = 1,size(dataptr1d) if (.not. shr_infnan_isnan(data_dbl1d(n)) .and. data_dbl1d(n) .ne. fillvalue_r8) then From c2c83bd2157406c9a4df2c1c816032b619dba45d Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 19 Feb 2026 06:46:54 -0700 Subject: [PATCH 2/2] Refactor to avoid comparisons with NaN, to make ifx happy Before this change, SMS_D_Ld3_PS.f09_t232.I1850Clm60SpCrujraNoAnthro.derecho_intel.clm-decStart1851_noinitial--clm-nofireemis was failing on one of these changed lines, presumably because ifx doesn't do short-circuit evaluation of conditions, so it was failing when trying to do a comparison on a NaN. This commit refactors conditionals to avoid doing comparisons if we have found that the value is NaN. --- streams/dshr_strdata_mod.F90 | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index 96b11fdb9..1b1529e3b 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -1849,10 +1849,12 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & endif do lev = 1,stream_nlev do n = 1,size(dataptr2d, dim=2) - if (.not. shr_infnan_isnan(data_real2d(n,lev)) .and. data_real2d(n,lev) .ne. fillvalue_r4) then - dataptr2d(lev,n) = real(data_real2d(n,lev), kind=r8) ! Note the order of indices - else + if (shr_infnan_isnan(data_real2d(n,lev))) then + dataptr2d(lev,n) = r8fill + else if (data_real2d(n,lev) == fillvalue_r4) then dataptr2d(lev,n) = r8fill + else + dataptr2d(lev,n) = real(data_real2d(n,lev), kind=r8) ! Note the order of indices endif enddo end do @@ -1888,10 +1890,12 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & endif do n=1,size(dataptr1d) - if(.not. shr_infnan_isnan(data_real1d(n)) .and. data_real1d(n) .ne. fillvalue_r4) then - dataptr1d(n) = real(data_real1d(n), kind=r8) - else + if (shr_infnan_isnan(data_real1d(n))) then + dataptr1d(n) = r8fill + else if (data_real1d(n) == fillvalue_r4) then dataptr1d(n) = r8fill + else + dataptr1d(n) = real(data_real1d(n), kind=r8) endif enddo else @@ -1925,10 +1929,12 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & endif do lev = 1,stream_nlev do n = 1,size(dataptr2d, dim=2) - if (.not. shr_infnan_isnan(data_dbl2d(n,lev)) .and. data_dbl2d(n,lev) .ne. fillvalue_r8) then - dataptr2d(lev,n) = data_dbl2d(n,lev) - else + if (shr_infnan_isnan(data_dbl2d(n,lev))) then + dataptr2d(lev,n) = r8fill + else if (data_dbl2d(n,lev) == fillvalue_r8) then dataptr2d(lev,n) = r8fill + else + dataptr2d(lev,n) = data_dbl2d(n,lev) endif enddo end do @@ -1960,10 +1966,12 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & end if endif do n = 1,size(dataptr1d) - if (.not. shr_infnan_isnan(data_dbl1d(n)) .and. data_dbl1d(n) .ne. fillvalue_r8) then - dataptr1d(n) = data_dbl1d(n) - else + if (shr_infnan_isnan(data_dbl1d(n))) then + dataptr1d(n) = r8fill + else if (data_dbl1d(n) == fillvalue_r8) then dataptr1d(n) = r8fill + else + dataptr1d(n) = data_dbl1d(n) end if enddo else