SCALE-RM
Functions/Subroutines | Variables
mod_cnvtopo Module Reference

module Convert topography More...

Functions/Subroutines

subroutine, public cnvtopo_setup
 Setup. More...
 
subroutine, public cnvtopo
 Driver. More...
 

Variables

logical, public cnvtopo_donothing
 
logical, public cnvtopo_usegtopo30 = .false.
 
logical, public cnvtopo_usegmted2010 = .false.
 
logical, public cnvtopo_usedem50m = .false.
 

Detailed Description

module Convert topography

Description
subroutines for preparing topography data (convert from external file)
Author
Team SCALE
NAMELIST
  • PARAM_CNVTOPO
    nametypedefault valuecomment
    CNVTOPO_NAME character(len=H_SHORT) 'NONE' keep backward compatibility
    CNVTOPO_USEGTOPO30 logical .false.
    CNVTOPO_USEGMTED2010 logical .false.
    CNVTOPO_USEDEM50M logical .false.
    CNVTOPO_UNITTILE_DDEG real(RP) dx for unit tile [deg]
    CNVTOPO_OVERSAMPLING_FACTOR real(RP) 2.0_RP factor of min. dx against the unit tile
    CNVTOPO_SMOOTH_MAXSLOPE_RATIO real(RP) 1.0_RP ratio of DZDX, DZDY
    CNVTOPO_SMOOTH_MAXSLOPE real(RP) -1.0_RP [deg]
    CNVTOPO_SMOOTH_LOCAL logical .false.
    CNVTOPO_SMOOTH_ITELIM integer 10000
    CNVTOPO_SMOOTH_TYPE character(len=H_SHORT) 'LAPLACIAN'
    CNVTOPO_COPY_PARENT logical .false.

  • PARAM_CNVTOPO_GTOPO30
    nametypedefault valuecomment
    GTOPO30_IN_CATALOGUE character(len=H_LONG) '' metadata files for GTOPO30
    GTOPO30_IN_DIR character(len=H_LONG) '' directory contains GTOPO30 files (GrADS format)

  • PARAM_CNVTOPO_DEM50M
    nametypedefault valuecomment
    DEM50M_IN_CATALOGUE character(len=H_LONG) '' metadata files for DEM50M
    DEM50M_IN_DIR character(len=H_LONG) '' directory contains DEM50M files (GrADS format)

History Output
No history output

Function/Subroutine Documentation

◆ cnvtopo_setup()

subroutine, public mod_cnvtopo::cnvtopo_setup ( )

Setup.

Definition at line 70 of file mod_cnvtopo.f90.

References cnvtopo_donothing, cnvtopo_usedem50m, cnvtopo_usegmted2010, cnvtopo_usegtopo30, scale_const::const_d2r, scale_const::const_huge, scale_grid::dx, scale_grid::dy, scale_grid::grid_cdz, scale_grid::grid_fdx, scale_grid::grid_fdy, scale_grid_index::ie, scale_stdio::io_fid_conf, scale_stdio::io_fid_log, scale_stdio::io_l, scale_stdio::io_lnml, scale_grid_index::is, scale_grid_index::je, scale_grid_index::js, scale_grid_index::ke, scale_grid_index::ks, scale_process::prc_mpistop(), scale_grid_real::real_dlat, and scale_grid_real::real_dlon.

Referenced by mod_convert::convert_setup().

70  use scale_process, only: &
72  use scale_const, only: &
73  d2r => const_d2r, &
74  huge => const_huge
75  use scale_comm, only: &
76  comm_horizontal_min
77  use scale_grid, only: &
78  dx, &
79  dy, &
80  grid_cdz, &
81  grid_fdx, &
82  grid_fdy
83  use scale_grid_real, only: &
84  real_dlat, &
85  real_dlon
86  implicit none
87 
88  character(len=H_SHORT) :: cnvtopo_name = 'NONE' ! keep backward compatibility
89 
90  namelist / param_cnvtopo / &
91  cnvtopo_name, &
92  cnvtopo_usegtopo30, &
93  cnvtopo_usegmted2010, &
94  cnvtopo_usedem50m, &
95  cnvtopo_unittile_ddeg, &
96  cnvtopo_oversampling_factor, &
97  cnvtopo_smooth_maxslope_ratio, &
98  cnvtopo_smooth_maxslope, &
99  cnvtopo_smooth_local, &
100  cnvtopo_smooth_itelim, &
101  cnvtopo_smooth_type, &
102  cnvtopo_copy_parent
103 
104  real(RP) :: minslope(ia,ja)
105  real(RP) :: dxl(ia-1)
106  real(RP) :: dyl(ja-1)
107  real(RP) :: dzdx, dzdy
108 
109  real(RP) :: drad(ia,ja)
110  real(RP) :: drad_min
111 
112  integer :: ierr
113  integer :: k, i, j
114  !---------------------------------------------------------------------------
115 
116  if( io_l ) write(io_fid_log,*)
117  if( io_l ) write(io_fid_log,*) '++++++ Module[convert topo] / Categ[preprocess] / Origin[SCALE-RM]'
118 
119  if ( cnvtopo_smooth_local ) then
120  dxl(:) = dx
121  dyl(:) = dy
122  else
123  dxl(:) = grid_fdx(:)
124  dyl(:) = grid_fdy(:)
125  endif
126 
127  !--- read namelist
128  rewind(io_fid_conf)
129  read(io_fid_conf,nml=param_cnvtopo,iostat=ierr)
130  if( ierr < 0 ) then !--- missing
131  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
132  elseif( ierr > 0 ) then !--- fatal error
133  write(*,*) 'xxx Not appropriate names in namelist PARAM_CNVTOPO. Check!'
134  call prc_mpistop
135  endif
136  if( io_lnml ) write(io_fid_log,nml=param_cnvtopo)
137 
138  select case(cnvtopo_name)
139  case('NONE')
140  ! do nothing
141  case('GTOPO30')
142  cnvtopo_usegtopo30 = .true.
143  cnvtopo_usegmted2010 = .false.
144  cnvtopo_usedem50m = .false.
145  case('GMTED2010')
146  cnvtopo_usegtopo30 = .false.
147  cnvtopo_usegmted2010 = .true.
148  cnvtopo_usedem50m = .false.
149  case('DEM50M')
150  cnvtopo_usegtopo30 = .false.
151  cnvtopo_usegmted2010 = .false.
152  cnvtopo_usedem50m = .true.
153  case('COMBINE')
154  cnvtopo_usegtopo30 = .true.
155  cnvtopo_usegmted2010 = .true.
156  cnvtopo_usedem50m = .true.
157  case default
158  write(*,*) ' xxx Unsupported TYPE:', trim(cnvtopo_name)
159  call prc_mpistop
160  endselect
161 
162  cnvtopo_donothing = .true.
163 
164  if ( cnvtopo_usegtopo30 ) then
165  cnvtopo_donothing = .false.
166  if( io_l ) write(io_fid_log,*) '*** Use GTOPO, global 30 arcsec. data'
167  if ( cnvtopo_usegmted2010 ) then
168  if( io_l ) write(io_fid_log,*) '*** Use GMTED2010, new global 5 arcsec. data'
169  if( io_l ) write(io_fid_log,*) '*** Overwrite Existing region'
170  endif
171  if ( cnvtopo_usedem50m ) then
172  if( io_l ) write(io_fid_log,*) '*** Use DEM 50m data for Japan region'
173  if( io_l ) write(io_fid_log,*) '*** Overwrite Japan region'
174  endif
175  elseif ( cnvtopo_usegmted2010 ) then
176  cnvtopo_donothing = .false.
177  if( io_l ) write(io_fid_log,*) '*** Use GMTED2010, new global 5 arcsec. data'
178  if ( cnvtopo_usedem50m ) then
179  if( io_l ) write(io_fid_log,*) '*** Use DEM 50m data for Japan region'
180  if( io_l ) write(io_fid_log,*) '*** Overwrite Japan region'
181  endif
182  elseif ( cnvtopo_usedem50m ) then
183  cnvtopo_donothing = .false.
184  if( io_l ) write(io_fid_log,*) '*** Use DEM 50m data, Japan region only'
185  endif
186 
187  if ( cnvtopo_donothing ) then
188  if( io_l ) write(io_fid_log,*) '*** Do nothing for landuse index'
189  else
190  drad(:,:) = min( real_dlat(:,:), real_dlon(:,:) )
191  call comm_horizontal_min( drad_min, drad(:,:) )
192 
193  if ( cnvtopo_unittile_ddeg > 0.0_rp ) then
194  cnvtopo_oversampling_factor = ( drad_min / d2r ) / cnvtopo_unittile_ddeg
195  endif
196  cnvtopo_oversampling_factor = max( 1.0_rp, cnvtopo_oversampling_factor )
197  cnvtopo_unittile_ddeg = ( drad_min / d2r ) / cnvtopo_oversampling_factor
198 
199  if( io_l ) write(io_fid_log,*) '*** The size of tile [deg] = ', cnvtopo_unittile_ddeg
200  if( io_l ) write(io_fid_log,*) '*** oversampling factor = ', cnvtopo_oversampling_factor
201  endif
202 
203  if( cnvtopo_smooth_maxslope > 0.0_rp ) then
204 
205  cnvtopo_smooth_maxslope_limit = cnvtopo_smooth_maxslope
206 
207  else
208  minslope(:,:) = huge
209 
210  j = js-1
211  i = is-1
212  do k = ks, ke
213  dzdx = atan2( cnvtopo_smooth_maxslope_ratio * grid_cdz(k), dxl(i) ) / d2r
214  dzdy = atan2( cnvtopo_smooth_maxslope_ratio * grid_cdz(k), dyl(j) ) / d2r
215  minslope(is,js) = min( minslope(is,js), dzdx, dzdy )
216  enddo
217 
218  j = js-1
219  do i = is, ie
220  do k = ks, ke
221  dzdx = atan2( cnvtopo_smooth_maxslope_ratio * grid_cdz(k), dxl(i) ) / d2r
222  dzdy = atan2( cnvtopo_smooth_maxslope_ratio * grid_cdz(k), dyl(j) ) / d2r
223  minslope(i,js) = min( minslope(i,js), dzdx, dzdy )
224  enddo
225  enddo
226 
227  i = is-1
228  do j = js, je
229  do k = ks, ke
230  dzdx = atan2( cnvtopo_smooth_maxslope_ratio * grid_cdz(k), dxl(i) ) / d2r
231  dzdy = atan2( cnvtopo_smooth_maxslope_ratio * grid_cdz(k), dyl(j) ) / d2r
232  minslope(is,j) = min( minslope(is,j), dzdx, dzdy )
233  enddo
234  enddo
235 
236  do j = js, je
237  do i = is, ie
238  do k = ks, ke
239  dzdx = atan2( cnvtopo_smooth_maxslope_ratio * grid_cdz(k), dxl(i) ) / d2r
240  dzdy = atan2( cnvtopo_smooth_maxslope_ratio * grid_cdz(k), dyl(j) ) / d2r
241  minslope(i,j) = min( minslope(i,j), dzdx, dzdy )
242  enddo
243  enddo
244  enddo
245 
246  call comm_horizontal_min( cnvtopo_smooth_maxslope_limit, minslope(:,:) )
247  end if
248 
249  return
real(rp), public dy
length in the main region [m]: y
real(rp), public const_huge
huge number
Definition: scale_const.F90:38
subroutine, public prc_mpistop
Abort MPI.
real(rp), dimension(:), allocatable, public grid_fdy
y-length of grid(j+1) to grid(j) [m]
real(rp), public dx
length in the main region [m]: x
real(rp), public const_d2r
degree to radian
Definition: scale_const.F90:35
module GRID (real space)
real(rp), dimension(:,:), allocatable, public real_dlon
delta longitude
module COMMUNICATION
Definition: scale_comm.F90:23
module PROCESS
real(rp), dimension(:,:), allocatable, public real_dlat
delta latitude
module CONSTANT
Definition: scale_const.F90:14
module GRID (cartesian)
real(rp), dimension(:), allocatable, public grid_cdz
z-length of control volume [m]
real(rp), dimension(:), allocatable, public grid_fdx
x-length of grid(i+1) to grid(i) [m]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cnvtopo()

subroutine, public mod_cnvtopo::cnvtopo ( )

Driver.

Definition at line 255 of file mod_cnvtopo.f90.

References cnvtopo_donothing, cnvtopo_usedem50m, cnvtopo_usegmted2010, cnvtopo_usegtopo30, scale_const::const_d2r, scale_const::const_eps, scale_const::const_pi, scale_const::const_radius, mod_copytopo::copytopo(), scale_grid::dx, scale_grid::dy, scale_grid::grid_cbfx, scale_grid::grid_cbfy, scale_grid::grid_fdx, scale_grid::grid_fdy, scale_grid_index::ia, scale_grid_index::ie, scale_stdio::io_fid_conf, scale_stdio::io_fid_log, scale_stdio::io_get_available_fid(), scale_stdio::io_l, scale_stdio::io_lnml, scale_grid_index::is, scale_grid_index::ja, scale_grid_index::je, scale_grid_index::js, scale_process::prc_mpistop(), scale_grid_real::real_laty, scale_grid_real::real_lonx, scale_rm_statistics::stat_detail(), scale_topography::topo_fillhalo(), scale_topography::topo_write(), and scale_topography::topo_zsfc.

Referenced by mod_convert::convert().

255  use scale_process, only: &
257  use scale_const, only: &
258  pi => const_pi
259  use scale_grid, only: &
260  cbfx => grid_cbfx, &
261  cbfy => grid_cbfy
262  use scale_topography, only: &
263  topo_fillhalo, &
264  topo_zsfc, &
265  topo_write
266  use mod_copytopo, only: &
267  copytopo
268  implicit none
269 
270  integer :: i, j
271  !---------------------------------------------------------------------------
272 
273  if ( cnvtopo_donothing ) then
274  if( io_l ) write(io_fid_log,*)
275  if( io_l ) write(io_fid_log,*) '++++++ SKIP CONVERT TOPOGRAPHY DATA ++++++'
276  else
277  if( io_l ) write(io_fid_log,*)
278  if( io_l ) write(io_fid_log,*) '++++++ START CONVERT TOPOGRAPHY DATA ++++++'
279 
280  if ( cnvtopo_usegtopo30 ) then
281  call cnvtopo_gtopo30
282  endif
283 
284  if ( cnvtopo_usegmted2010 ) then
285  call cnvtopo_gmted2010
286  endif
287 
288  if ( cnvtopo_usedem50m ) then
289  call cnvtopo_dem50m
290  endif
291 
292  call cnvtopo_smooth( topo_zsfc(:,:) ) ! (inout)
293  call topo_fillhalo
294 
295  if( cnvtopo_copy_parent ) call copytopo( topo_zsfc )
296 
297  if( io_l ) write(io_fid_log,*) '++++++ END CONVERT TOPOGRAPHY DATA ++++++'
298 
299  ! output topography file
300  call topo_write
301  endif
302 
303  return
subroutine, public topo_write
Write topography.
subroutine, public topo_fillhalo(Zsfc)
HALO Communication.
subroutine, public prc_mpistop
Abort MPI.
module Copy topography
real(rp), dimension(:), allocatable, public grid_cbfx
center buffer factor [0-1]: x
module PROCESS
module CONSTANT
Definition: scale_const.F90:14
module GRID (cartesian)
subroutine, public copytopo(topo_cd)
Setup and Main.
real(rp), dimension(:,:), allocatable, public topo_zsfc
absolute ground height [m]
real(rp), dimension(:), allocatable, public grid_cbfy
center buffer factor [0-1]: y
module TOPOGRAPHY
real(rp), public const_pi
pi
Definition: scale_const.F90:34
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cnvtopo_donothing

logical, public mod_cnvtopo::cnvtopo_donothing

Definition at line 34 of file mod_cnvtopo.f90.

Referenced by cnvtopo(), and cnvtopo_setup().

34  logical, public :: cnvtopo_donothing

◆ cnvtopo_usegtopo30

logical, public mod_cnvtopo::cnvtopo_usegtopo30 = .false.

Definition at line 35 of file mod_cnvtopo.f90.

Referenced by cnvtopo(), and cnvtopo_setup().

35  logical, public :: cnvtopo_usegtopo30 = .false.

◆ cnvtopo_usegmted2010

logical, public mod_cnvtopo::cnvtopo_usegmted2010 = .false.

Definition at line 36 of file mod_cnvtopo.f90.

Referenced by cnvtopo(), and cnvtopo_setup().

36  logical, public :: cnvtopo_usegmted2010 = .false.

◆ cnvtopo_usedem50m

logical, public mod_cnvtopo::cnvtopo_usedem50m = .false.

Definition at line 37 of file mod_cnvtopo.f90.

Referenced by cnvtopo(), and cnvtopo_setup().

37  logical, public :: cnvtopo_usedem50m = .false.