Skip to content

Commit

Permalink
Merge branch 'fix_negative_start_lat' into release-v4.2 (PR #145)
Browse files Browse the repository at this point in the history
This merge fixes an issue in scaling negative starting latitudes in GRIB2
datasets on a Gaussian grid.

Prior to the changes in this merge, 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 merge 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 performed.

Thanks to Linda Maoyi for identifying the issue addressed in this merge.

This merge fixes issue #142 .

* fix_negative_start_lat:
  Fix scaling of negative starting latitude for Gaussian grids in g2print
  Fix scaling of starting latitude in GRIB2 datasets on a Gaussian grid
  • Loading branch information
mgduda committed Apr 23, 2020
2 parents 5690c15 + ddfbcba commit 1292d42
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ungrib/src/g2print.F
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ungrib/src/rd_grib2.F
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1292d42

Please sign in to comment.