1818!***********************************************************************
1919
2020!> Get global lon and lat of three model (target) grids, with a given file name
21- subroutine GET_GRID_VERSION_1_(grid_file, mod_name, domain, isc, iec, jsc, jec, lon, lat, min_lon, max_lon)
21+ subroutine GET_GRID_VERSION_1_(grid_file, mod_name, domain, lon, lat, min_lon, max_lon)
2222 integer, parameter :: lkind = FMS_GET_GRID_VERSION_KIND_
2323
2424 character(len=*), intent(in ) :: grid_file !< name of grid file
2525 character(len=*), intent(in ) :: mod_name !< module name
2626 type (domain2d), intent(in ) :: domain !< 2D domain
27- integer, intent(in ) :: isc, iec, jsc, jec
28- real(lkind), dimension(isc:,jsc:), intent(out) :: lon, lat
29- real(lkind), intent(out) :: min_lon, max_lon
27+ real(lkind), intent(out), dimension(:,:), allocatable :: lon, lat
28+ real(lkind), intent(out) :: min_lon, max_lon
3029
3130 integer :: i, j, siz(4 )
3231 integer :: nlon, nlat !< size of global lon and lat
3332 real(lkind), dimension(:,:,:), allocatable :: lon_vert, lat_vert !< of OCN grid vertices
3433 real(lkind), dimension(:), allocatable :: glon, glat !< lon and lat of 1 -D grid of atm/lnd
3534 logical :: is_new_grid
3635 integer :: is , ie, js, je
37- integer :: isd, ied, jsd, jed
3836 integer :: isg, ieg, jsg, jeg
37+ integer :: isc, iec, jsc, jec
3938 character(len=3 ) :: xname, yname
4039 integer :: start(2 ), nread(2 )
4140 type (FmsNetcdfDomainFile_t) :: fileobj
@@ -45,8 +44,11 @@ subroutine GET_GRID_VERSION_1_(grid_file, mod_name, domain, isc, iec, jsc, jec,
4544 call mpp_error(FATAL, ' data_override_mod(get_grid_version_1): Error in opening file ' // trim(grid_file))
4645 endif
4746
48- call mpp_get_data_domain(domain, isd, ied, jsd, jed)
4947 call mpp_get_global_domain(domain, isg, ieg, jsg, jeg)
48+ call mpp_get_compute_domain(domain, isc, iec, jsc, jec)
49+
50+ allocate(lon(isc:iec, jsc:jec))
51+ allocate(lat(isc:iec, jsc:jec))
5052
5153 select case (mod_name)
5254 case (' ocn' , ' ice' )
@@ -143,16 +145,14 @@ end subroutine GET_GRID_VERSION_1_
143145
144146!> Get global lon and lat of three model (target) grids from mosaic.nc.
145147!! 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, &
147- use_center_grid_points)
148+ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, lon, lat, min_lon, max_lon, use_center_grid_points)
148149 integer, parameter :: lkind = FMS_GET_GRID_VERSION_KIND_
149150
150151 type (FmsNetcdfFile_t), intent(in ) :: fileobj !< file object for grid file
151152 character(len=*), intent(in ) :: mod_name !< module name
152153 type (domain2d), intent(in ) :: domain !< 2D domain
153- integer, intent(in ) :: isc, iec, jsc, jec
154- real(lkind), dimension(isc:,jsc:), intent(out) :: lon, lat
155- real(lkind), intent(out) :: min_lon, max_lon
154+ real(lkind), intent(out), dimension(:,:), allocatable :: lon, lat
155+ real(lkind), intent(out) :: min_lon, max_lon
156156 logical, optional, intent(in ) :: use_center_grid_points !< Flag indicating whether or not to use the
157157 !! centroid values of the supergrid from the
158158 !! grid file as opposed to calcuating it by
@@ -162,8 +162,7 @@ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lo
162162 integer :: i, j, siz(2 )
163163 integer :: nlon, nlat ! size of global grid
164164 integer :: nlon_super, nlat_super ! size of global supergrid.
165- integer :: isd, ied, jsd, jed
166- integer :: isg, ieg, jsg, jeg
165+ integer :: isc, iec, jsc, jec
167166 integer :: isc2, iec2, jsc2, jec2
168167 character(len=FMS_PATH_LEN) :: solo_mosaic_file, grid_file
169168 real(lkind), allocatable :: tmpx(:,:), tmpy(:,:)
@@ -179,8 +178,10 @@ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lo
179178 trim(mod_name) .NE. ' ice' .AND . trim(mod_name) .NE. ' lnd' ) call mpp_error(FATAL, &
180179 " data_override_mod: mod_name should be 'atm', 'ocn', 'ice' or 'lnd' " )
181180
182- call mpp_get_data_domain(domain, isd, ied, jsd, jed)
183- call mpp_get_global_domain(domain, isg, ieg, jsg, jeg)
181+ call mpp_get_compute_domain(domain, isc, iec, jsc, jec)
182+
183+ allocate(lon(isc:iec, jsc:jec))
184+ allocate(lat(isc:iec, jsc:jec))
184185
185186 ! get the grid file to read
186187
@@ -189,7 +190,7 @@ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lo
189190
190191 solo_mosaic_file = ' INPUT/' // trim(solo_mosaic_file)
191192 if (.not . open_file(mosaicfileobj, solo_mosaic_file, ' read' )) then
192- call mpp_error(FATAL, ' data_override_mod(get_grid_version_2: Error in opening solo mosaic file ' // &
193+ call mpp_error(FATAL, ' data_override_mod(get_grid_version_2) : Error in opening solo mosaic file ' // &
193194 & trim(solo_mosaic_file))
194195 endif
195196 open_solo_mosaic=.true.
@@ -201,7 +202,7 @@ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lo
201202 call get_mosaic_tile_grid(grid_file, mosaicfileobj, domain)
202203
203204 if (.not . open_file(tilefileobj, grid_file, ' read' )) then
204- call mpp_error(FATAL, ' data_override_mod(get_grid_version_2: Error in opening tile file ' // trim(grid_file))
205+ call mpp_error(FATAL, ' data_override_mod(get_grid_version_2) : Error in opening tile file ' // trim(grid_file))
205206 endif
206207
207208 call get_variable_size(tilefileobj, ' area' , siz)
0 commit comments