@@ -143,7 +143,8 @@ end subroutine GET_GRID_VERSION_1_
143143
144144!> Get global lon and lat of three model (target) grids from mosaic.nc.
145145!! Currently we assume the refinement ratio is 2 and there is one tile on each pe.
146- subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lon, lat, min_lon, max_lon)
146+ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lon, lat, min_lon, max_lon, &
147+ use_center_grid_points)
147148 integer, parameter :: lkind = FMS_GET_GRID_VERSION_KIND_
148149
149150 type (FmsNetcdfFile_t), intent(in ) :: fileobj !< file object for grid file
@@ -152,6 +153,11 @@ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lo
152153 integer, intent(in ) :: isc, iec, jsc, jec
153154 real(lkind), dimension(isc:,jsc:), intent(out) :: lon, lat
154155 real(lkind), intent(out) :: min_lon, max_lon
156+ logical, optional, intent(in ) :: use_center_grid_points !< Flag indicating whether or not to use the
157+ !! centroid values of the supergrid from the
158+ !! grid file as opposed to calcuating it by
159+ !! taking the average of the four corner points.
160+ !! This is only relevant to OCN and ICE grids.
155161
156162 integer :: i, j, siz(2 )
157163 integer :: nlon, nlat ! size of global grid
@@ -164,6 +170,10 @@ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lo
164170 logical :: open_solo_mosaic
165171 type (FmsNetcdfFile_t) :: mosaicfileobj, tilefileobj
166172 integer :: start(2 ), nread(2 )
173+ logical :: use_center_grid_points_local
174+
175+ use_center_grid_points_local = .false.
176+ if (present(use_center_grid_points)) use_center_grid_points_local = use_center_grid_points
167177
168178 if (trim(mod_name) .NE. ' atm' .AND . trim(mod_name) .NE. ' ocn' .AND . &
169179 trim(mod_name) .NE. ' ice' .AND . trim(mod_name) .NE. ' lnd' ) call mpp_error(FATAL, &
@@ -215,20 +225,20 @@ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lo
215225 call read_data( tilefileobj, ' y' , tmpy, corner=start,edge_lengths=nread)
216226
217227 ! copy data onto model grid
218- if (trim(mod_name) == ' ocn ' .OR . trim(mod_name) == ' ice ' ) then
219- do j = jsc, jec
220- do i = isc, iec
221- 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
222- 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
223- end do
224- end do
228+ if (trim(mod_name) == ' atm ' .OR . trim(mod_name) == ' lnd ' . OR . use_center_grid_points_local ) then
229+ do j = jsc, jec
230+ do i = isc, iec
231+ lon(i,j) = tmpx(i*2 ,j*2 )
232+ lat(i,j) = tmpy(i*2 ,j*2 )
233+ end do
234+ end do
225235 else
226- do j = jsc, jec
227- do i = isc, iec
228- lon(i,j) = tmpx(i*2 ,j*2 )
229- lat(i,j) = tmpy(i*2 ,j*2 )
230- end do
231- end do
236+ do j = jsc, jec
237+ do i = isc, iec
238+ 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
239+ 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
240+ end do
241+ end do
232242 endif
233243
234244 ! convert to radian
0 commit comments