Skip to content

Commit 6737113

Browse files
ChristianStegerChristian StegerstelliomChristian Steger
authored
Correct grid shift in topography data (#426)
Co-authored-by: Christian Steger <csteger@balfrin-ln003.cscs.ch> Co-authored-by: stelliom <67868694+stelliom@users.noreply.github.com> Co-authored-by: Christian Steger <csteger@balfrin-ln002.cscs.ch> Co-authored-by: Mikael Stellio <mikael.stellio@c2sm.ethz.ch>
1 parent ff478f3 commit 6737113

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

src/mo_topo_data.f90

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,15 @@ SUBROUTINE fill_topo_data(raw_data_orography_path,topo_files, &
248248
SELECT CASE (itopo_type) ! Also topo could additionally be used for SELECT CASE (must first be read in)
249249
CASE(topo_aster) ! ASTER topography, as it has 36 tiles at the moment.
250250
CALL logging%info('ASTER is used as topography')
251-
half_gridp = 1./(3600.*2.) ! the resolution of the ASTER data is 1./3600. degrees as it is half a grid point
251+
half_gridp = 1._wp/7200._wp ! the resolution of the ASTER data is 1./3600. degrees as it is half a grid point
252252
! it is additionally divided by 2
253253
CASE (topo_gl) ! GLOBE topography is composed of 16 tiles
254254
CALL logging%info('GLOBE is used as topography')
255-
half_gridp = 1./(120.*2.) ! GLOBE resolution is 1./120. degrees (30 arc-seconds)
255+
half_gridp = 1._wp/240._wp ! GLOBE resolution is 1./120. degrees (30 arc-seconds)
256256

257257
CASE(topo_merit) ! ASTER topography, as it has 36 tiles at the moment.
258258
CALL logging%info('MERIT is used as topography')
259-
half_gridp = 1./(1200.*2.) ! the resolution of the MERIT data is 1./1200. degrees as it is half a grid point
259+
half_gridp = 1._wp/2400._wp ! the resolution of the MERIT data is 1./1200. degrees as it is half a grid point
260260
! it is additionally divided by 2
261261
END SELECT
262262

@@ -278,10 +278,19 @@ SUBROUTINE fill_topo_data(raw_data_orography_path,topo_files, &
278278
! reads in the last latitude value of tile i
279279
CALL check_netcdf(nf90_close(ncid))
280280
! the netcdf file is closed again
281-
tiles_lon_min(i) = REAL(NINT(tiles_lon_min(i) - half_gridp)) !< half of a grid point must be
282-
tiles_lon_max(i) = REAL(NINT(tiles_lon_max(i) + half_gridp)) !< added, as the ASTER/GLOBE/MERIT data
283-
tiles_lat_min(i) = REAL(NINT(tiles_lat_min(i) + half_gridp)) !< is located at the pixel center
284-
tiles_lat_max(i) = REAL(NINT(tiles_lat_max(i) - half_gridp))
281+
SELECT CASE (itopo_type)
282+
! compute domain extent of tiles (coordinates refer to domain edges) from pixel center coordinates
283+
CASE(topo_aster, topo_gl) ! edges of raw data tiles align with integer coordinates
284+
tiles_lon_min(i) = REAL(NINT(tiles_lon_min(i) - half_gridp), wp)
285+
tiles_lon_max(i) = REAL(NINT(tiles_lon_max(i) + half_gridp), wp)
286+
tiles_lat_min(i) = REAL(NINT(tiles_lat_min(i) - half_gridp), wp)
287+
tiles_lat_max(i) = REAL(NINT(tiles_lat_max(i) + half_gridp), wp)
288+
CASE(topo_merit) ! edges of raw data tiles do not align with integer coordinates
289+
tiles_lon_min(i) = tiles_lon_min(i) - half_gridp
290+
tiles_lon_max(i) = tiles_lon_max(i) + half_gridp
291+
tiles_lat_min(i) = tiles_lat_min(i) - half_gridp
292+
tiles_lat_max(i) = tiles_lat_max(i) + half_gridp
293+
END SELECT
285294
END DO
286295

287296
SELECT CASE(itopo_type)

src/mo_topo_routines.f90

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,13 @@ SUBROUTINE det_topo_tiles_grid(topo_tiles_grid)
285285
dlat = -1.0_wp * (tiles_lat_max(k) - tiles_lat_min(k)) / REAL(tiles_nrows(k),wp)
286286

287287
! latitude from north to south, negative increment
288-
topo_tiles_grid(k)%start_lon_reg = tiles_lon_min(k) + 0.5 * dlon
289-
topo_tiles_grid(k)%end_lon_reg = tiles_lon_max(k) - 0.5 * dlon
288+
topo_tiles_grid(k)%start_lon_reg = tiles_lon_min(k) + 0.5_wp * dlon
289+
topo_tiles_grid(k)%end_lon_reg = tiles_lon_max(k) - 0.5_wp * dlon
290290

291291
! latitude from north to south, note the negative increment!
292-
topo_tiles_grid(k)%start_lat_reg = tiles_lat_max(k) + 0.5 * dlat
292+
topo_tiles_grid(k)%start_lat_reg = tiles_lat_max(k) + 0.5_wp * dlat
293293
! latitude from north to south, note the negative increment!
294-
topo_tiles_grid(k)%end_lat_reg = tiles_lat_min(k) - 0.5 * dlat
294+
topo_tiles_grid(k)%end_lat_reg = tiles_lat_min(k) - 0.5_wp * dlat
295295

296296
topo_tiles_grid(k)%dlon_reg = dlon
297297
topo_tiles_grid(k)%dlat_reg = dlat
@@ -318,7 +318,7 @@ SUBROUTINE det_topo_grid(topo_grid)
318318

319319
dlon = (aster_lon_max - aster_lon_min) / REAL(nc_tot,wp)
320320

321-
dlat = -1. * (aster_lat_max - aster_lat_min) / REAL(nr_tot,wp)
321+
dlat = -1._wp * (aster_lat_max - aster_lat_min) / REAL(nr_tot,wp)
322322
! latitude from north to south, negative increment
323323

324324
topo_grid%start_lon_reg = aster_lon_min + 0.5_wp * dlon
@@ -331,7 +331,7 @@ SUBROUTINE det_topo_grid(topo_grid)
331331

332332
dlon = (merit_lon_max - merit_lon_min) / REAL(nc_tot,wp)
333333

334-
dlat = -1. * (merit_lat_max - merit_lat_min) / REAL(nr_tot,wp)
334+
dlat = -1._wp * (merit_lat_max - merit_lat_min) / REAL(nr_tot,wp)
335335

336336
WRITE(message_text,*)'Latitude increment for MERIT data, dlat = ', dlat
337337
CALL logging%info(message_text)
@@ -347,7 +347,7 @@ SUBROUTINE det_topo_grid(topo_grid)
347347
CASE(topo_gl)
348348

349349
dlon = 360._wp / REAL(nc_tot,wp)
350-
dlat = -1. * 180._wp / REAL(nr_tot,wp)
350+
dlat = -1._wp * 180._wp / REAL(nr_tot,wp)
351351
! latitude from north to south, negative increment
352352

353353
topo_grid%start_lon_reg = -180._wp + 0.5_wp * dlon

test/testsuite/data/get_data.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,38 @@ fi
1414
# mch
1515
test -d mch || exit 1
1616
cd mch/c7_globe
17-
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_mch_c7_PR417.nc'
17+
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_mch_c7_PR426.nc'
1818
cd -
1919

2020
test -d mch || exit 1
2121
cd mch/c1_aster
22-
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_mch_c1_PR417.nc'
22+
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_mch_c1_PR426.nc'
2323
cd -
2424

2525
# clm
2626
test -d clm || exit 1
2727
cd clm/12km_globe
28-
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_12km_globe_PR417.nc'
28+
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_12km_globe_PR426.nc'
2929
cd -
3030

3131
cd clm/ecoclimap_sg
3232
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/icon_grid_bolivia.nc'
33-
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_icon_eco_PR417.nc'
33+
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_icon_eco_PR426.nc'
3434
cd -
3535

3636
# dwd
3737
test -d dwd || exit 1
3838

3939
cd dwd/icon_d2
4040
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/icon_grid_DOM01.nc'
41-
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_icon_d2_PR417.nc'
41+
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_icon_d2_PR426.nc'
4242
cd -
4343

4444
cd dwd/icon_ecci
4545
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/icon_grid_bolivia.nc'
4646
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/clim_t2m_icon_ecci.nc'
4747
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/clim_tsea_icon_ecci.nc'
48-
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_icon_ecci_PR417.nc'
48+
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_icon_ecci_PR426.nc'
4949
cd -
5050

5151
# mpim
@@ -54,14 +54,14 @@ cd mpim/icon_r2b4
5454
wget --quiet 'http://icon-downloads.mpimet.mpg.de/grids/public/mpim/0013/icon_grid_0013_R02B04_G.nc'
5555
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/clim_t2m_icon_r2b4.nc'
5656
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/clim_tsea_icon_r2b4.nc'
57-
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_icon_mpim_PR417.nc'
57+
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/external_parameter_icon_mpim_PR426.nc'
5858
cd -
5959

6060
# ecmwf
6161
test -d ecmwf || exit 1
6262
cd ecmwf/corine_icon
6363
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/corine/icon_grid_0099_R19B10.nc'
64-
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/corine/external_parameter_icon_corine_PR417.nc'
64+
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/corine/external_parameter_icon_corine_PR426.nc'
6565
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/corine/clim_tsea_corine.nc'
6666
wget --quiet 'ftp://iacftp.ethz.ch/pub_read/stelliom/corine/clim_t2m_corine.nc'
6767
cd -

0 commit comments

Comments
 (0)