From a9081cc8b2390df995815f3fdbe9d5aed76e7dd6 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 22 Nov 2019 18:02:46 +0000 Subject: [PATCH 1/2] feature/chgres_ice_check: This commit references #32. 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. --- sorc/chgres_cube.fd/model_grid.F90 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sorc/chgres_cube.fd/model_grid.F90 b/sorc/chgres_cube.fd/model_grid.F90 index 1fc4f2567..37c8a3072 100644 --- a/sorc/chgres_cube.fd/model_grid.F90 +++ b/sorc/chgres_cube.fd/model_grid.F90 @@ -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(:) @@ -320,22 +322,22 @@ 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) @@ -343,17 +345,17 @@ subroutine define_input_grid_gaussian(localpet, npets) 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 From 289d36a7bbb3d201b6a49274b289e4a5c99e4dd6 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 22 Nov 2019 19:07:05 +0000 Subject: [PATCH 2/2] feature/chgres_ice_check: This commit references #32. chgres_cube.fd/surface.F90: Ensure sea ice fraction does not exceed 1.00. --- sorc/chgres_cube.fd/surface.F90 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index d68f704a9..3ac79c632 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -603,8 +603,11 @@ subroutine interp(localpet) if (localpet == 0) then do j = 1, j_target do i = 1, i_target - if (data_one_tile(i,j) < 0.15) data_one_tile(i,j) = 0.0 - if (data_one_tile(i,j) >= 0.15) mask_target_one_tile(i,j) = 2 + if (data_one_tile(i,j) > 1.0_esmf_kind_r8) then + data_one_tile(i,j) = 1.0_esmf_kind_r8 + endif + if (data_one_tile(i,j) < 0.15_esmf_kind_r8) data_one_tile(i,j) = 0.0_esmf_kind_r8 + if (data_one_tile(i,j) >= 0.15_esmf_kind_r8) mask_target_one_tile(i,j) = 2 enddo enddo endif