bug: check that input netcdf files have consistent FillValues and missing_values are not working with NaNs
The check_attribute_value_int/r4/r8 subroutines ensure that the FillValue and missing_value are consistent across input netcdf files. This check is not working correctly if there are inconsistent values and one of them in a NaN.
It checks if ret_spvalR4 is a NaN with if (ret_spvalR4 /= ret_spvalR4) , but then returns without checking if spvalR4 is also a NaN. So it won't error out as it should with the message that the "variable attribute FillValue in state does not match FillValue in filename"
This is causing this minval function to error out with a floating point exception at this point in the adaptive_inflate_mod - https://github.com/NCAR/DART/blob/c4d5caea0f770bed537f530624e4aa62fad2bcbb/assimilation_code/modules/assimilation/adaptive_inflate_mod.f90#L1457
This small reproducer program without any DART code errors out in the minval function in this way when given NaNs :
masmith@derecho5:/glade/work/masmith/DART11.14.2/DART/models/ROMS_rutgers/minmax_mean-nan> cat tester.f90
program MinMax
use ieee_arithmetic
implicit none
real :: arr(7)
real :: minnie
real :: x
x = sqrt(-1.0) ! Generates a NaN
write(*,*) 'x: ', x
! find min and max vals
arr = [x, x, x, x, 0.0, 2.0, x]
minnie = minval(arr)
write(*,*) 'minnie: ', minnie
!minmax_mean(2) = maxval(ens_handle%copies(ss_inflate_index, :))
end program MinMax
This error only occurs with debugging flags on (namely, -ftrapuv and -fpe0)
Describe the bug
-
List the steps someone needs to take to reproduce the bug.
Run DART with input netcdf files in which some have NaNs specified as the FillValue and others do not. -
What was the expected outcome? DART errors out in check_attributes as it should
-
What actually happened? ### Error Message
DART continues running, which causes it to error out (if debugging flags are being used) in the adaptive_inflate_mod due to NaNs being passed into the minval function
Please provide any error messages. "floating point invalid"
Which model(s) are you working with?
All models
Version of DART
Which version of DART are you using? v11.15.0
Have you modified the DART code?
No
Build information
Please describe:
- The machine you are running on (e.g. windows laptop, NSF NCAR supercomputer Derecho).
- The compiler you are using (e.g. gnu, intel).
All machines, all compilers
Note: some compilers might not error out at the minval function in the adaptive_inflate_mod (both gfortran and ifort do), but the issue of the check not evaluating correctly when one of the FillValues is NaN will be present for all compilers.
There is a fix for the previous inability to check for NaNs as inconsistent attribute values (i.e Fill, missing_value) in the check_attributes_value_r4/r8 subroutines on dev branch nan_check_attributes
The error in the adaptive_inflate_mod persists though; there is more work to be done in terms of exploring which files are given to check_attribtues with various namelist configurations and if this is suitable
released in v11.19