Skip to content

Commit

Permalink
Add bug fix for latlon projection
Browse files Browse the repository at this point in the history
This bug fix is from Michel Bechtold and Samuel Scherrer.  See PR NASA-LIS#1415.
  • Loading branch information
jvgeiger committed Dec 8, 2023
1 parent d927928 commit 8d8c84c
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lis/interp/map_utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ module map_utils
! Brent L. Shaw, NOAA/FSL (CSU/CIRA)
! 09 Apr 2001 - Added compare\_projections routine to compare two
! sets of projection parameters.
! 30 Jun 2021 - Michel Bechtold, Samuel Scherrer, bug fix for latlon projection
! occurred at edges of subdomains in parallel mode

implicit none

Expand Down Expand Up @@ -681,6 +683,7 @@ SUBROUTINE llij_gauss(lat, lon, proj, i, j)
slon360 = proj%lon1
ENDIF
deltalon = lon360 - slon360
IF (deltalon .LT. 0) deltalon = deltalon + 360.

! Compute i/j
i = deltalon/proj%dlon + 1.
Expand Down Expand Up @@ -1131,7 +1134,7 @@ SUBROUTINE llij_latlon(lat, lon, proj, i, j)

REAL :: deltalat
REAL :: deltalon
REAL :: lon360
REAL :: lon360,slon360


! Compute deltalat and deltalon as the difference between the input
Expand All @@ -1146,10 +1149,18 @@ SUBROUTINE llij_latlon(lat, lon, proj, i, j)
ELSE
lon360 = lon
ENDIF
deltalon = lon360 - proj%lon1
! IF (deltalon .LT. 0) deltalon = deltalon + 360.
IF (deltalon .LT. -0.001) deltalon = deltalon + 360.
IF (deltalon .LT. 0) deltalon = Abs(deltalon)
! deltalon = lon360 - proj%lon1
! IF (deltalon .LT. 0) deltalon = deltalon + 360.
! MB: June,2021: deltalon+360 causes
! bug at edges of subdomains in parallel mode.
! Correct handling is like done in llij_gauss
IF (proj%lon1 .LT. 0) THEN
slon360 = proj%lon1 + 360.
ELSE
slon360 = proj%lon1
ENDIF
deltalon = lon360 - slon360
IF (deltalon .LT. 0) deltalon = deltalon + 360.

! Compute i/j
i = deltalon/proj%dlon + 1.
Expand Down

0 comments on commit 8d8c84c

Please sign in to comment.