SCALE-RM
Functions/Subroutines
mod_cnvtopo Module Reference

module Convert topography More...

Functions/Subroutines

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

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.

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

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

  • PARAM_CNVTOPO_USERFILE
    nametypedefault valuecomment
    USERFILE_TYPE character(len=H_SHORT) '' ! "TILE" or "GrADS"
    USERFILE_DTYPE character(len=H_SHORT) 'REAL4' datatype (REAL4,REAL8,INT2,INT4)
    USERFILE_DLAT real(RP) -1.0_RP width of latitude tile [deg.]
    USERFILE_DLON real(RP) -1.0_RP width of longitude tile [deg.]
    USERFILE_CATALOGUE character(len=H_LONG) '' catalogue file
    USERFILE_DIR character(len=H_LONG) '.' directory contains data files (GrADS format)
    USERFILE_YREVERS logical .false. data of the latitude direction is stored in ordar of North->South?
    USERFILE_MINVAL real(RP) 0.0_RP
    USERFILE_GRADS_FILENAME character(len=H_LONG) '' single data file (GrADS format)
    USERFILE_GRADS_VARNAME character(len=H_SHORT) 'topo'
    USERFILE_GRADS_LATNAME character(len=H_SHORT) 'lat'
    USERFILE_GRADS_LONNAME character(len=H_SHORT) 'lon'
    USERFILE_INTERP_TYPE character(len=H_SHORT) 'LINEAR'
    USERFILE_INTERP_LEVEL integer 5

History Output
No history output

Function/Subroutine Documentation

◆ cnvtopo_setup()

subroutine, public mod_cnvtopo::cnvtopo_setup

Setup.

Definition at line 76 of file mod_cnvtopo.F90.

76  use scale_prc, only: &
77  prc_abort
78  use scale_const, only: &
79  d2r => const_d2r, &
80  huge => const_huge
81  use scale_statistics, only: &
82  statistics_horizontal_min
83  use scale_atmos_grid_cartesc, only: &
84  cdz => atmos_grid_cartesc_cdz, &
85  fdx => atmos_grid_cartesc_fdx, &
87  implicit none
88 
89  character(len=H_SHORT) :: CNVTOPO_name = 'NONE' ! keep backward compatibility
90 
91  namelist / param_cnvtopo / &
92  cnvtopo_name, &
93  cnvtopo_usegtopo30, &
94 ! CNVTOPO_UseGMTED2010, &
95  cnvtopo_usedem50m, &
96  cnvtopo_useuserfile, &
97  cnvtopo_smooth_trim_ocean, &
98  cnvtopo_smooth_hypdiff_order, &
99  cnvtopo_smooth_hypdiff_niter, &
100  cnvtopo_smooth_maxslope_ratio, &
101  cnvtopo_smooth_maxslope, &
102  cnvtopo_smooth_local, &
103  cnvtopo_smooth_itelim, &
104  cnvtopo_smooth_type, &
105  cnvtopo_copy_parent
106 
107  real(RP) :: minslope(IA,JA)
108  real(RP) :: DXL(IA-1)
109  real(RP) :: DYL(JA-1)
110  real(RP) :: DZDX, DZDY
111 
112  integer :: ierr
113  integer :: k, i, j
114  !---------------------------------------------------------------------------
115 
116  log_newline
117  log_info("CNVTOPO_setup",*) 'Setup'
118 
119  dxl(:) = fdx(:)
120  dyl(:) = fdy(:)
121 
122  !--- read namelist
123  rewind(io_fid_conf)
124  read(io_fid_conf,nml=param_cnvtopo,iostat=ierr)
125  if( ierr < 0 ) then !--- missing
126  log_info("CNVTOPO_setup",*) 'Not found namelist. Default used.'
127  elseif( ierr > 0 ) then !--- fatal error
128  log_error("CNVTOPO_setup",*) 'Not appropriate names in namelist PARAM_CNVTOPO. Check!'
129  call prc_abort
130  endif
131  log_nml(param_cnvtopo)
132 
133  select case(cnvtopo_name)
134  case('NONE')
135  ! do nothing
136  case('GTOPO30')
137  cnvtopo_usegtopo30 = .true.
138  cnvtopo_usegmted2010 = .false.
139  cnvtopo_usedem50m = .false.
140  cnvtopo_useuserfile = .false.
141 !!$ case('GMTED2010')
142 !!$ CNVTOPO_UseGTOPO30 = .false.
143 !!$ CNVTOPO_UseGMTED2010 = .true.
144 !!$ CNVTOPO_UseDEM50M = .false.
145 !!$ CNVTOPO_UseUSERFILE = .false.
146  case('DEM50M')
147  cnvtopo_usegtopo30 = .false.
148  cnvtopo_usegmted2010 = .false.
149  cnvtopo_usedem50m = .true.
150  cnvtopo_useuserfile = .false.
151  case('COMBINE')
152  cnvtopo_usegtopo30 = .true.
153  cnvtopo_usegmted2010 = .true.
154  cnvtopo_usedem50m = .true.
155  cnvtopo_useuserfile = .false.
156  case('USERFILE')
157  ! You can use GTOPO30, GMTED2010, DEM50M and combine User-defined file as you like
158  cnvtopo_useuserfile = .true.
159  case default
160  log_error("CNVTOPO_setup",*) 'Unsupported TYPE: ', trim(cnvtopo_name)
161  call prc_abort
162  endselect
163 
164  cnvtopo_donothing = .true.
165 
166  if ( cnvtopo_usegtopo30 ) then
167  cnvtopo_donothing = .false.
168  log_info("CNVTOPO_setup",*) 'Use GTOPO, global 30 arcsec. data'
169  if ( cnvtopo_usegmted2010 ) then
170  log_info("CNVTOPO_setup",*) 'Use GMTED2010, new global 5 arcsec. data'
171  log_info("CNVTOPO_setup",*) 'Overwrite Existing region'
172  endif
173  if ( cnvtopo_usedem50m ) then
174  log_info("CNVTOPO_setup",*) 'Use DEM 50m data for Japan region'
175  log_info("CNVTOPO_setup",*) 'Overwrite Japan region'
176  endif
177  elseif ( cnvtopo_usegmted2010 ) then
178  cnvtopo_donothing = .false.
179  log_info("CNVTOPO_setup",*) 'Use GMTED2010, new global 5 arcsec. data'
180  if ( cnvtopo_usedem50m ) then
181  log_info("CNVTOPO_setup",*) 'Use DEM 50m data for Japan region'
182  log_info("CNVTOPO_setup",*) 'Overwrite Japan region'
183  endif
184  elseif ( cnvtopo_usedem50m ) then
185  cnvtopo_donothing = .false.
186  log_info("CNVTOPO_setup",*) 'Use DEM 50m data, Japan region only'
187  elseif ( cnvtopo_useuserfile ) then
188  cnvtopo_donothing = .false.
189  log_info("CNVTOPO_setup",*) 'Use user-defined file'
190  endif
191 
192  if ( cnvtopo_donothing ) then
193  log_info("CNVTOPO_setup",*) 'Do nothing for topography data'
194  endif
195 
196  if( cnvtopo_smooth_maxslope > 0.0_rp ) then
197 
198  cnvtopo_smooth_maxslope_limit = cnvtopo_smooth_maxslope
199 
200  else
201 
202  !$acc data create(minslope)
203 
204  !$acc kernels
205  minslope(:,:) = huge
206  !$acc end kernels
207 
208  j = js-1
209  i = is-1
210  !$acc kernels
211  !$acc loop independent
212  do k = ks, ke
213  dzdx = atan2( cnvtopo_smooth_maxslope_ratio * cdz(k), dxl(i) ) / d2r
214  dzdy = atan2( cnvtopo_smooth_maxslope_ratio * cdz(k), dyl(j) ) / d2r
215  minslope(is,js) = min( minslope(is,js), dzdx, dzdy )
216  enddo
217  !$accend kernels
218 
219  j = js-1
220  !$acc kernels
221  !$acc loop collapse(2) independent
222  do i = is, ie
223  do k = ks, ke
224  dzdx = atan2( cnvtopo_smooth_maxslope_ratio * cdz(k), dxl(i) ) / d2r
225  dzdy = atan2( cnvtopo_smooth_maxslope_ratio * cdz(k), dyl(j) ) / d2r
226  minslope(i,js) = min( minslope(i,js), dzdx, dzdy )
227  enddo
228  enddo
229  !$acc end kernels
230 
231  i = is-1
232  !$omp parallel do &
233  !$omp private(DZDX,DZDY)
234  !$acc kernels
235  !$acc loop collapse(2) independent
236  do j = js, je
237  do k = ks, ke
238  dzdx = atan2( cnvtopo_smooth_maxslope_ratio * cdz(k), dxl(i) ) / d2r
239  dzdy = atan2( cnvtopo_smooth_maxslope_ratio * cdz(k), dyl(j) ) / d2r
240  minslope(is,j) = min( minslope(is,j), dzdx, dzdy )
241  enddo
242  enddo
243  !$acc end kernels
244 
245  !$omp parallel do &
246  !$omp private(DZDX,DZDY)
247  !$acc kernels
248  !$acc loop collapse(3) independent
249  do j = js, je
250  do i = is, ie
251  do k = ks, ke
252  dzdx = atan2( cnvtopo_smooth_maxslope_ratio * cdz(k), dxl(i) ) / d2r
253  dzdy = atan2( cnvtopo_smooth_maxslope_ratio * cdz(k), dyl(j) ) / d2r
254  minslope(i,j) = min( minslope(i,j), dzdx, dzdy )
255  enddo
256  enddo
257  enddo
258  !$acc end kernels
259 
260  call statistics_horizontal_min( ia, is, ie, ja, js, je, &
261  minslope(:,:), cnvtopo_smooth_maxslope_limit )
262 
263  !$acc end data
264 
265  end if
266 
267  return

References scale_atmos_grid_cartesc::atmos_grid_cartesc_cdz, scale_atmos_grid_cartesc::atmos_grid_cartesc_fdx, scale_atmos_grid_cartesc::atmos_grid_cartesc_fdy, scale_const::const_d2r, scale_const::const_huge, scale_atmos_grid_cartesc_index::ia, scale_atmos_grid_cartesc_index::ie, scale_io::io_fid_conf, scale_atmos_grid_cartesc_index::is, scale_atmos_grid_cartesc_index::ja, scale_atmos_grid_cartesc_index::je, scale_atmos_grid_cartesc_index::js, scale_tracer::k, scale_atmos_grid_cartesc_index::ke, scale_atmos_grid_cartesc_index::ks, and scale_prc::prc_abort().

Referenced by mod_convert::convert_setup().

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 273 of file mod_cnvtopo.F90.

273  use scale_const, only: &
274  undef => const_undef, &
275  d2r => const_d2r
276  use scale_prc, only: &
277  prc_abort
278  use scale_topography, only: &
281  use mod_copytopo, only: &
282  copytopo
283  use scale_atmos_grid_cartesc_real, only: &
286  implicit none
287 
288  integer :: i, j
289  !---------------------------------------------------------------------------
290 
291  if ( cnvtopo_donothing ) then
292  log_newline
293  log_progress(*) 'skip convert topography data'
294  else
295  log_newline
296  log_progress(*) 'start convert topography data'
297 
298  !$omp parallel do
299 !OCL XFILL
300  !$acc kernels
301  do j = 1, ja
302  do i = 1, ia
303  topography_zsfc(i,j) = 0.0_rp
304  end do
305  end do
306  !$acc end kernels
307 
308  if ( cnvtopo_usegtopo30 ) then
309  call cnvtopo_gtopo30( topography_zsfc(:,:) ) ! [INOUT]
310  endif
311 
312  if ( cnvtopo_usegmted2010 ) then
313  call cnvtopo_gmted2010( topography_zsfc(:,:) ) ! [INOUT]
314  endif
315 
316  if ( cnvtopo_usedem50m ) then
317  call cnvtopo_dem50m( topography_zsfc(:,:) ) ! [INOUT]
318  endif
319 
320  if ( cnvtopo_useuserfile ) then
321  call cnvtopo_userfile( topography_zsfc(:,:) ) ! [INOUT]
322  endif
323 
324  call cnvtopo_smooth( topography_zsfc(:,:) ) ! (inout)
325  call topography_fillhalo( fill_bnd=.true. )
326 
327  if( cnvtopo_copy_parent ) call copytopo( topography_zsfc )
328 
329  log_progress(*) 'end convert topography data'
330 
331  endif
332 
333  return

References scale_atmos_grid_cartesc::atmos_grid_cartesc_fdx, scale_atmos_grid_cartesc::atmos_grid_cartesc_fdy, scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_latxv, scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_lonuy, mod_cnv2d::cnv2d_exec(), mod_cnv2d::cnv2d_grads_init(), mod_cnv2d::cnv2d_tile_init(), scale_const::const_d2r, scale_const::const_eps, scale_const::const_undef, mod_copytopo::copytopo(), scale_atmos_grid_cartesc_index::ia, scale_atmos_grid_cartesc_index::ie, scale_io::io_fid_conf, scale_atmos_grid_cartesc_index::is, scale_atmos_grid_cartesc_index::ja, scale_atmos_grid_cartesc_index::je, scale_atmos_grid_cartesc_index::js, scale_landuse::landuse_fact_ocean, scale_prc::prc_abort(), scale_topography::topography_fillhalo(), and scale_topography::topography_zsfc.

Referenced by mod_convert::convert().

Here is the call graph for this function:
Here is the caller graph for this function:
scale_statistics
module Statistics
Definition: scale_statistics.F90:11
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale_atmos_grid_cartesc::atmos_grid_cartesc_cdz
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cdz
z-length of control volume [m]
Definition: scale_atmos_grid_cartesC.F90:43
scale_atmos_grid_cartesc::atmos_grid_cartesc_fdy
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_fdy
y-length of grid(j+1) to grid(j) [m]
Definition: scale_atmos_grid_cartesC.F90:64
mod_copytopo::copytopo
subroutine, public copytopo(TOPO_child)
Setup and Main.
Definition: mod_copytopo.F90:79
scale_topography
module TOPOGRAPHY
Definition: scale_topography.F90:11
scale_atmos_grid_cartesc_real
module Atmosphere GRID CartesC Real(real space)
Definition: scale_atmos_grid_cartesC_real.F90:11
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_const
module CONSTANT
Definition: scale_const.F90:11
scale_const::const_huge
real(rp), public const_huge
huge number
Definition: scale_const.F90:37
scale_atmos_grid_cartesc::atmos_grid_cartesc_fdx
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_fdx
x-length of grid(i+1) to grid(i) [m]
Definition: scale_atmos_grid_cartesC.F90:63
mod_copytopo
module Copy topography
Definition: mod_copytopo.F90:11
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_latxv
real(rp), dimension(:,:), allocatable, public atmos_grid_cartesc_real_latxv
latitude at staggered point (xv) [rad,-pi,pi]
Definition: scale_atmos_grid_cartesC_real.F90:55
scale_topography::topography_zsfc
real(rp), dimension(:,:), allocatable, public topography_zsfc
absolute ground height [m]
Definition: scale_topography.F90:39
scale_const::const_d2r
real(rp), public const_d2r
degree to radian
Definition: scale_const.F90:33
scale_atmos_grid_cartesc
module atmosphere / grid / cartesC
Definition: scale_atmos_grid_cartesC.F90:12
scale_const::const_undef
real(rp), public const_undef
Definition: scale_const.F90:43
scale_topography::topography_fillhalo
subroutine, public topography_fillhalo(Zsfc, FILL_BND)
HALO Communication.
Definition: scale_topography.F90:119
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_lonuy
real(rp), dimension(:,:), allocatable, public atmos_grid_cartesc_real_lonuy
longitude at staggered point (uy) [rad,0-2pi]
Definition: scale_atmos_grid_cartesC_real.F90:50