Skip to content

Commit

Permalink
feature/chgres_ice_check: This commit references ufs-community#32.
Browse files Browse the repository at this point in the history
Sea ice uses conservative regridding, which requires the
corner point lat/lons of each grid.  Update 'model_grid.F90'
to use separate pointers for the center and corner point
lat/lons for gaussian grids.  Recycling the same pointer
for both could cause problems.
  • Loading branch information
GeorgeGayno-NOAA committed Nov 22, 2019
1 parent 2104aff commit a9081cc
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions sorc/chgres_cube.fd/model_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ subroutine define_input_grid_gaussian(localpet, npets)
real(esmf_kind_r8), allocatable :: longitude(:,:)
real(esmf_kind_r8), pointer :: lat_src_ptr(:,:)
real(esmf_kind_r8), pointer :: lon_src_ptr(:,:)
real(esmf_kind_r8), pointer :: lat_corner_src_ptr(:,:)
real(esmf_kind_r8), pointer :: lon_corner_src_ptr(:,:)
real(esmf_kind_r8) :: deltalon
real(esmf_kind_r8), allocatable :: slat(:), wlat(:)

Expand Down Expand Up @@ -320,40 +322,40 @@ subroutine define_input_grid_gaussian(localpet, npets)
call error_handler("IN GridAddCoord", rc)

print*,"- CALL GridGetCoord FOR INPUT GRID X-COORD."
nullify(lon_src_ptr)
nullify(lon_corner_src_ptr)
call ESMF_GridGetCoord(input_grid, &
staggerLoc=ESMF_STAGGERLOC_CORNER, &
coordDim=1, &
farrayPtr=lon_src_ptr, rc=rc)
farrayPtr=lon_corner_src_ptr, rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__line__,file=__file__)) &
call error_handler("IN GridGetCoord", rc)

print*,"- CALL GridGetCoord FOR INPUT GRID Y-COORD."
nullify(lat_src_ptr)
nullify(lat_corner_src_ptr)
call ESMF_GridGetCoord(input_grid, &
staggerLoc=ESMF_STAGGERLOC_CORNER, &
coordDim=2, &
computationalLBound=clb, &
computationalUBound=cub, &
farrayPtr=lat_src_ptr, rc=rc)
farrayPtr=lat_corner_src_ptr, rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__line__,file=__file__)) &
call error_handler("IN GridGetCoord", rc)

print*,'bounds for corners ',localpet,clb(1),cub(1),clb(2),cub(2)

do j = clb(2), cub(2)
do i = clb(1), cub(1)
lon_src_ptr(i,j) = longitude(i,1) - (0.5_esmf_kind_r8*deltalon)
if (lon_src_ptr(i,j) > 360.0_esmf_kind_r8) lon_src_ptr(i,j) = lon_src_ptr(i,j) - 360.0_esmf_kind_r8
lon_corner_src_ptr(i,j) = longitude(i,1) - (0.5_esmf_kind_r8*deltalon)
if (lon_corner_src_ptr(i,j) > 360.0_esmf_kind_r8) lon_corner_src_ptr(i,j) = lon_corner_src_ptr(i,j) - 360.0_esmf_kind_r8
if (j == 1) then
lat_src_ptr(i,j) = 90.0_esmf_kind_r8
lat_corner_src_ptr(i,j) = 90.0_esmf_kind_r8
cycle
endif
if (j == jp1_input) then
lat_src_ptr(i,j) = -90.0_esmf_kind_r8
lat_corner_src_ptr(i,j) = -90.0_esmf_kind_r8
cycle
endif
lat_src_ptr(i,j) = 0.5_esmf_kind_r8 * (latitude(i,j-1)+ latitude(i,j))
lat_corner_src_ptr(i,j) = 0.5_esmf_kind_r8 * (latitude(i,j-1)+ latitude(i,j))
enddo
enddo

Expand Down

0 comments on commit a9081cc

Please sign in to comment.