From 045a6abcf57319290a9cc8a4f4ef2790660ca648 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 11 Jun 2025 16:20:10 -0700 Subject: [PATCH] Change glevel 1 and 2 to ints to prevent floating point equality checks All comparisons to glevel1 and glevel2 are against integer values, relying on implicit conversion during the check if done somewhat correctly. When implicit conversion is not done, the floating point to integer .eq. check can easily fail for values that should normally succeed. Whilst the calculations to generate glevel1 and glevel2 use floating point math, assigning into an integer variable guarantees a float to int conversion is done before the comparison, thus preventing instances where instead of float to int compilers may other arithmetic operations for comparison such as int to float. --- ungrib/src/rd_grib2.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ungrib/src/rd_grib2.F b/ungrib/src/rd_grib2.F index 5a584384..0d930d15 100644 --- a/ungrib/src/rd_grib2.F +++ b/ungrib/src/rd_grib2.F @@ -74,7 +74,7 @@ SUBROUTINE rd_grib2(junit, gribflnm, hdate, real , dimension(maxlvl) :: plvl integer :: nlvl integer , dimension(maxlvl) :: level_array - real :: glevel1, glevel2 + integer :: glevel1, glevel2 logical :: first = .true. real :: pmin