Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add use_center_grid_points namelist #1566

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions data_override/include/data_override.inc
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,15 @@ logical :: reproduce_null_char_bug = .false.
!! to reproduce the mpp_io bug where lat/lon_bnd were
!! not read correctly if null characters are present in
!! the netcdf file
logical :: use_center_grid_points=.false. !< Flag indicating
!! whether or not to use the centroid values of the
!! supergrid from the grid file as opposed to calculating it
!! by taking the average of the four corner points.
!! This is only relevant to OCN and ICE grids.
logical :: use_data_table_yaml = .false.

namelist /data_override_nml/ debug_data_override, grid_center_bug, reproduce_null_char_bug, use_data_table_yaml
namelist /data_override_nml/ debug_data_override, grid_center_bug, reproduce_null_char_bug, use_data_table_yaml, &
use_center_grid_points

public :: DATA_OVERRIDE_INIT_IMPL_, DATA_OVERRIDE_UNSET_ATM_, DATA_OVERRIDE_UNSET_OCN_, &
& DATA_OVERRIDE_UNSET_LND_, DATA_OVERRIDE_UNSET_ICE_, DATA_OVERRIDE_0D_, &
Expand Down Expand Up @@ -340,7 +346,7 @@ end if
call mpp_get_compute_domain( ocn_domain,is,ie,js,je)
allocate(lon_local_ocn(is:ie,js:je), lat_local_ocn(is:ie,js:je))
call get_grid_version_2(fileobj, 'ocn', ocn_domain, is, ie, js, je, lon_local_ocn, lat_local_ocn, &
min_glo_lon_ocn, max_glo_lon_ocn )
min_glo_lon_ocn, max_glo_lon_ocn, use_center_grid_points)
endif

if (lnd_on .and. .not. allocated(lon_local_lnd) ) then
Expand All @@ -354,7 +360,7 @@ end if
call mpp_get_compute_domain( ice_domain,is,ie,js,je)
allocate(lon_local_ice(is:ie,js:je), lat_local_ice(is:ie,js:je))
call get_grid_version_2(fileobj, 'ocn', ice_domain, is, ie, js, je, lon_local_ice, lat_local_ice, &
min_glo_lon_ice, max_glo_lon_ice )
min_glo_lon_ice, max_glo_lon_ice, use_center_grid_points )
endif
end if
if(use_get_grid_version .EQ. 2) then
Expand Down
38 changes: 24 additions & 14 deletions data_override/include/get_grid_version.inc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ end subroutine GET_GRID_VERSION_1_

!> Get global lon and lat of three model (target) grids from mosaic.nc.
!! Currently we assume the refinement ratio is 2 and there is one tile on each pe.
subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lon, lat, min_lon, max_lon)
subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lon, lat, min_lon, max_lon, &
use_center_grid_points)
integer, parameter :: lkind = FMS_GET_GRID_VERSION_KIND_

type(FmsNetcdfFile_t), intent(in) :: fileobj !< file object for grid file
Expand All @@ -152,6 +153,11 @@ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lo
integer, intent(in) :: isc, iec, jsc, jec
real(lkind), dimension(isc:,jsc:), intent(out) :: lon, lat
real(lkind), intent(out) :: min_lon, max_lon
logical, optional, intent(in) :: use_center_grid_points !< Flag indicating whether or not to use the
!! centroid values of the supergrid from the
!! grid file as opposed to calcuating it by
!! taking the average of the four corner points.
!! This is only relevant to OCN and ICE grids.

integer :: i, j, siz(2)
integer :: nlon, nlat ! size of global grid
Expand All @@ -164,6 +170,10 @@ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lo
logical :: open_solo_mosaic
type(FmsNetcdfFile_t) :: mosaicfileobj, tilefileobj
integer :: start(2), nread(2)
logical :: use_center_grid_points_local

use_center_grid_points_local = .false.
if (present(use_center_grid_points)) use_center_grid_points_local = use_center_grid_points

if(trim(mod_name) .NE. 'atm' .AND. trim(mod_name) .NE. 'ocn' .AND. &
trim(mod_name) .NE. 'ice' .AND. trim(mod_name) .NE. 'lnd' ) call mpp_error(FATAL, &
Expand Down Expand Up @@ -215,20 +225,20 @@ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lo
call read_data( tilefileobj, 'y', tmpy, corner=start,edge_lengths=nread)

! copy data onto model grid
if(trim(mod_name) == 'ocn' .OR. trim(mod_name) == 'ice') then
do j = jsc, jec
do i = isc, iec
lon(i,j) = (tmpx(i*2-1,j*2-1)+tmpx(i*2+1,j*2-1)+tmpx(i*2+1,j*2+1)+tmpx(i*2-1,j*2+1))*0.25_lkind
lat(i,j) = (tmpy(i*2-1,j*2-1)+tmpy(i*2+1,j*2-1)+tmpy(i*2+1,j*2+1)+tmpy(i*2-1,j*2+1))*0.25_lkind
end do
end do
if(trim(mod_name) == 'atm' .OR. trim(mod_name) == 'lnd' .OR. use_center_grid_points_local) then
do j = jsc, jec
do i = isc, iec
lon(i,j) = tmpx(i*2,j*2)
lat(i,j) = tmpy(i*2,j*2)
end do
end do
else
do j = jsc, jec
do i = isc, iec
lon(i,j) = tmpx(i*2,j*2)
lat(i,j) = tmpy(i*2,j*2)
end do
end do
do j = jsc, jec
do i = isc, iec
lon(i,j) = (tmpx(i*2-1,j*2-1)+tmpx(i*2+1,j*2-1)+tmpx(i*2+1,j*2+1)+tmpx(i*2-1,j*2+1))*0.25_lkind
lat(i,j) = (tmpy(i*2-1,j*2-1)+tmpy(i*2+1,j*2-1)+tmpy(i*2+1,j*2+1)+tmpy(i*2-1,j*2+1))*0.25_lkind
end do
end do
endif

! convert to radian
Expand Down
Loading