From 37461b03ce2b69229255aca0106d50597e4106cc Mon Sep 17 00:00:00 2001 From: Michael Duda Date: Tue, 21 Apr 2020 14:54:34 -0600 Subject: [PATCH 1/2] Fix scaling of starting latitude in GRIB2 datasets on a Gaussian grid Prior to this commit, the code in rd_grib2.F compared the starting latitude for a field on a Gaussian grid with the scaling factor, and if the starting latitude was larger than the scaling factor, the starting latitude was scaled. However, this fails when the starting latitude is negative, in which case no scaling is applied, and downstream code fails due to an invalid starting latitude in the resulting intermediate file. The fix in this commit is to simply compare the magnitude of the starting latitude with the scaling factor, and if the former exceeds the latter, then scaling of the starting latitude is applied. --- 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 14291b1dc..2b6d8d80f 100644 --- a/ungrib/src/rd_grib2.F +++ b/ungrib/src/rd_grib2.F @@ -492,7 +492,7 @@ SUBROUTINE rd_grib2(junit, gribflnm, hdate, endif ! Scale lat/lon values to 0-180, default range is 1e6. - if (map%lat1.ge.scale_factor) then + if (abs(map%lat1).ge.scale_factor) then map%lat1 = map%lat1/scale_factor endif if (map%lon1.ge.scale_factor) then From ddfbcba361a7c9409eea835b4fe729b7e8e10bc2 Mon Sep 17 00:00:00 2001 From: Michael Duda Date: Wed, 22 Apr 2020 13:26:19 -0600 Subject: [PATCH 2/2] Fix scaling of negative starting latitude for Gaussian grids in g2print Following the change in the preceding commit, this commit modifies the g2print code to ensure that negative starting latitudes for Gaussian grids are scaled appropriately. --- ungrib/src/g2print.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ungrib/src/g2print.F b/ungrib/src/g2print.F index caebcf8bc..1d33a3567 100644 --- a/ungrib/src/g2print.F +++ b/ungrib/src/g2print.F @@ -562,7 +562,7 @@ SUBROUTINE r_grib2(junit, gribflnm, hdate, & endif ! Scale lat/lon values to 0-180, default range is 1e6. - if (map%lat1.ge.scale_factor) then + if (abs(map%lat1).ge.scale_factor) then map%lat1 = map%lat1/scale_factor endif if (map%lon1.ge.scale_factor) then