diff --git a/src/Infrastructure/Grid/interface/ESMF_Grid.F90 b/src/Infrastructure/Grid/interface/ESMF_Grid.F90 index 258fdfd8c6..6476cfdb79 100644 --- a/src/Infrastructure/Grid/interface/ESMF_Grid.F90 +++ b/src/Infrastructure/Grid/interface/ESMF_Grid.F90 @@ -5217,6 +5217,10 @@ subroutine convert_corner_arrays_to_1D(isSphere,dim1,dim2,cornerX2D,cornerY2D,co integer :: count,inPos,outPos integer :: ip1,im1 + !RASF Corner checking is potentially incorrect for tripolar grids with corner at the tripole. If possible try to + ! implement check on next point + integer :: offset + ! make sure no dimensions are 0 if ((dim1 < 1) .or. (dim2 <1)) then call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG,msg="- Currently can't handle a grid of width <1 in a dim.", & @@ -5261,56 +5265,74 @@ subroutine convert_corner_arrays_to_1D(isSphere,dim1,dim2,cornerX2D,cornerY2D,co ! Figure out which corner indice is the top row of corners ! It won't match any of the neighbors corners - TopCorner=-1 - do i=1,4 + + + offset=0 + do + + ! If default offset=0 fails then try with 1 if dimension allows it. + if ((dim1 == 2 ).and. (offset == 1) ) then + call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & + msg="- Currently can't handle a grid thats width 2 in only 1st dim with offset=1", & + ESMF_CONTEXT, rcToReturn=rc) + return + endif + + TopCorner=-1 + do i=1,4 ! See if it matches nbr to the right - matches=.false. - do j=1,4 - if ((abs(cornerX2D(i,1)-cornerX2D(j,2))