SCALE-RM
mod_mktopo.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
10 !-------------------------------------------------------------------------------
11 #include "scalelib.h"
12 module mod_mktopo
13  !-----------------------------------------------------------------------------
14  !
15  !++ used modules
16  !
17  use scale_precision
18  use scale_io
19  use scale_prof
21  use scale_tracer
22 
23  use scale_prc, only: &
24  prc_abort
25  use scale_atmos_grid_cartesc, only: &
26  cx => atmos_grid_cartesc_cx, &
28  use scale_topography, only: &
30  !-----------------------------------------------------------------------------
31  implicit none
32  private
33  !-----------------------------------------------------------------------------
34  !
35  !++ Public procedure
36  !
37  public :: mktopo_setup
38  public :: mktopo
39 
40  !-----------------------------------------------------------------------------
41  !
42  !++ Public parameters & variables
43  !
44  integer, public :: mktopo_type = -1
45  integer, public, parameter :: i_ignore = 0
46  integer, public, parameter :: i_flat = 1
47  integer, public, parameter :: i_bellshape = 2
48  integer, public, parameter :: i_schaer = 3
49 
50  !-----------------------------------------------------------------------------
51  !
52  !++ Private procedure
53  !
54  private :: mktopo_flat
55  private :: mktopo_bellshape
56  private :: mktopo_schaer
57 
58  !-----------------------------------------------------------------------------
59  !
60  !++ Private parameters & variables
61  !
62  !-----------------------------------------------------------------------------
63 contains
64 
65  !-----------------------------------------------------------------------------
67  subroutine mktopo_setup
68  implicit none
69 
70  character(len=H_SHORT) :: mktopo_name = 'NONE'
71 
72  namelist / param_mktopo / &
73  mktopo_name
74 
75  integer :: ierr
76  !---------------------------------------------------------------------------
77 
78  log_newline
79  log_info("MKTOPO_setup",*) 'Setup'
80 
81  !--- read namelist
82  rewind(io_fid_conf)
83  read(io_fid_conf,nml=param_mktopo,iostat=ierr)
84  if( ierr < 0 ) then !--- missing
85  log_info("MKTOPO_setup",*) 'Not found namelist. Default used.'
86  elseif( ierr > 0 ) then !--- fatal error
87  log_error("MKTOPO_setup",*) 'Not appropriate names in namelist PARAM_MKTOPO. Check!'
88  call prc_abort
89  endif
90  log_nml(param_mktopo)
91 
92  select case(mktopo_name)
93  case('NONE')
95  case('FLAT')
97  case('BELLSHAPE')
99  case('SCHAER')
101  case default
102  log_error("MKTOPO_setup",*) 'Unsupported TYPE:', trim(mktopo_name)
103  call prc_abort
104  endselect
105 
106  return
107  end subroutine mktopo_setup
108 
109  !-----------------------------------------------------------------------------
111  subroutine mktopo
112  implicit none
113  !---------------------------------------------------------------------------
114 
115  if ( mktopo_type == i_ignore ) then
116  log_newline
117  log_info("MKTOPO",*) 'SKIP MAKING TOPOGRAPHY DATA'
118  else
119  log_newline
120  log_info("MKTOP",*) 'START MAKING TOPOGRAPHY DATA'
121 
122  select case(mktopo_type)
123  case(i_flat)
124  call mktopo_flat
125 
126  case(i_bellshape)
127  call mktopo_bellshape
128 
129  case(i_schaer)
130  call mktopo_schaer
131 
132  case default
133  log_error("MKTOPO",*) 'Unsupported TYPE:', mktopo_type
134  call prc_abort
135  endselect
136 
137  log_info("MKTOPO",*) 'END MAKING TOPOGRAPHY DATA'
138 
139  endif
140 
141  return
142  end subroutine mktopo
143 
144  !-----------------------------------------------------------------------------
146  subroutine mktopo_flat
147  implicit none
148 
149  ! flat mountain parameter
150  real(rp) :: flat_height = 100.0_rp ! height of mountain [m]
151 
152  namelist / param_mktopo_flat / &
153  flat_height
154 
155  integer :: ierr
156  integer :: i, j
157  !---------------------------------------------------------------------------
158 
159  log_newline
160  log_info("MKTOPO_flat",*) 'Setup'
161 
162  !--- read namelist
163  rewind(io_fid_conf)
164  read(io_fid_conf,nml=param_mktopo_flat,iostat=ierr)
165  if( ierr < 0 ) then !--- missing
166  log_info("MKTOPO_flat",*) 'Not found namelist. Default used.'
167  elseif( ierr > 0 ) then !--- fatal error
168  log_error("MKTOPO_flat",*) 'Not appropriate names in namelist PARAM_MKTOPO_FLAT. Check!'
169  call prc_abort
170  endif
171  log_nml(param_mktopo_flat)
172 
173  !$acc kernels
174  do j = 1, ja
175  do i = 1, ia
176  topography_zsfc(i,j) = flat_height
177  enddo
178  enddo
179  !$acc end kernels
180 
181  return
182  end subroutine mktopo_flat
183 
184  !-----------------------------------------------------------------------------
186  subroutine mktopo_bellshape
187  implicit none
188 
189  ! bell-shaped mountain parameter
190  logical :: bell_eachnode = .false. ! Arrange mountain at each node? [kg/kg]
191  real(rp) :: bell_cx = 2.e3_rp ! center location [m]: x
192  real(rp) :: bell_cy = 2.e3_rp ! center location [m]: y
193  real(rp) :: bell_rx = 2.e3_rp ! bubble radius [m]: x
194  real(rp) :: bell_ry = 2.e3_rp ! bubble radius [m]: y
195  real(rp) :: bell_height = 100.0_rp ! height of mountain [m]
196 
197  namelist / param_mktopo_bellshape / &
198  bell_eachnode, &
199  bell_cx, &
200  bell_cy, &
201  bell_rx, &
202  bell_ry, &
203  bell_height
204 
205  real(rp) :: cx_offset
206  real(rp) :: cy_offset
207  real(rp) :: dist
208 
209  integer :: ierr
210  integer :: i, j
211  !---------------------------------------------------------------------------
212 
213  log_newline
214  log_info("MKTOPO_bellshape",*) 'Setup'
215 
216  !--- read namelist
217  rewind(io_fid_conf)
218  read(io_fid_conf,nml=param_mktopo_bellshape,iostat=ierr)
219  if( ierr < 0 ) then !--- missing
220  log_info("MKTOPO_bellshape",*) 'Not found namelist. Default used.'
221  elseif( ierr > 0 ) then !--- fatal error
222  log_error("MKTOPO_bellshape",*) 'Not appropriate names in namelist PARAM_MKTOPO_BELLSHAPE. Check!'
223  call prc_abort
224  endif
225  log_nml(param_mktopo_bellshape)
226 
227  if ( bell_eachnode ) then
228  cx_offset = cx(is)
229  cy_offset = cy(js)
230  else
231  cx_offset = 0.0_rp
232  cy_offset = 0.0_rp
233  endif
234 
235  ! make bell-shaped mountain
236  !$acc kernels
237  do j = 1, ja
238  do i = 1, ia
239 
240  dist = ( (cx(i)-cx_offset-bell_cx)/bell_rx )**2 &
241  + ( (cy(j)-cy_offset-bell_cy)/bell_ry )**2
242 
243  topography_zsfc(i,j) = bell_height / ( 1.0_rp + dist )
244 
245  enddo
246  enddo
247  !$acc end kernels
248 
249  return
250  end subroutine mktopo_bellshape
251 
252  !-----------------------------------------------------------------------------
256  subroutine mktopo_schaer
257  use scale_const, only: &
258  pi => const_pi
259  implicit none
260 
261  ! Schaer-type mountain parameter
262  real(rp) :: schaer_cx = 25.e3_rp ! center location [m]: x
263  real(rp) :: schaer_rx = 5.e3_rp ! bubble radius [m]: x
264  real(rp) :: schaer_lambda = 4.e3_rp ! wavelength of wavelike perturbation [m]: x
265  real(rp) :: schaer_height = 250.0_rp ! height of mountain [m]
266  logical :: schaer_swapxy = .false.
267 
268  namelist / param_mktopo_schaer / &
269  schaer_cx, &
270  schaer_rx, &
271  schaer_lambda, &
272  schaer_height, &
273  schaer_swapxy
274 
275  real(rp) :: dist
276 
277  integer :: ierr
278  integer :: i, j
279  !---------------------------------------------------------------------------
280 
281  log_newline
282  log_info("MKTOPO_schaer",*) 'Setup'
283 
284  !--- read namelist
285  rewind(io_fid_conf)
286  read(io_fid_conf,nml=param_mktopo_schaer,iostat=ierr)
287  if( ierr < 0 ) then !--- missing
288  log_info("MKTOPO_schaer",*) 'Not found namelist. Default used.'
289  elseif( ierr > 0 ) then !--- fatal error
290  log_error("MKTOPO_schaer",*) 'Not appropriate names in namelist PARAM_MKTOPO_SCHAER. Check!'
291  call prc_abort
292  endif
293  log_nml(param_mktopo_schaer)
294 
295  ! make bell-shaped mountain
296  if ( .NOT. schaer_swapxy ) then
297  !$acc kernels
298  do j = 1, ja
299  do i = 1, ia
300 
301  dist = exp( -( (cx(i)-schaer_cx)/schaer_rx )**2 )
302 
303  topography_zsfc(i,j) = schaer_height * dist * ( cos( pi*(cx(i)-schaer_cx)/schaer_lambda ) )**2
304 
305  enddo
306  enddo
307  !$acc end kernels
308  else
309  !$acc kernels
310  do j = 1, ja
311  do i = 1, ia
312 
313  dist = exp( -( (cy(j)-schaer_cx)/schaer_rx )**2 )
314 
315  topography_zsfc(i,j) = schaer_height * dist * ( cos( pi*(cy(j)-schaer_cx)/schaer_lambda ) )**2
316 
317  enddo
318  enddo
319  !$acc end kernels
320  endif
321 
322  return
323  end subroutine mktopo_schaer
324 
325 end module mod_mktopo
mod_mktopo::i_schaer
integer, parameter, public i_schaer
Definition: mod_mktopo.F90:48
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
mod_mktopo::i_ignore
integer, parameter, public i_ignore
Definition: mod_mktopo.F90:45
scale_precision
module PRECISION
Definition: scale_precision.F90:14
mod_mktopo::mktopo_setup
subroutine, public mktopo_setup
Setup.
Definition: mod_mktopo.F90:68
scale_topography
module TOPOGRAPHY
Definition: scale_topography.F90:11
mod_mktopo::mktopo
subroutine, public mktopo
Driver.
Definition: mod_mktopo.F90:112
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_precision::rp
integer, parameter, public rp
Definition: scale_precision.F90:41
scale_io
module STDIO
Definition: scale_io.F90:10
scale_atmos_grid_cartesc_index
module atmosphere / grid / cartesC index
Definition: scale_atmos_grid_cartesC_index.F90:12
scale_const
module CONSTANT
Definition: scale_const.F90:11
scale_atmos_grid_cartesc_index::ia
integer, public ia
Definition: scale_atmos_grid_cartesC_index.F90:48
mod_mktopo::mktopo_type
integer, public mktopo_type
Definition: mod_mktopo.F90:44
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_atmos_grid_cartesc_index::is
integer, public is
start point of inner domain: x, local
Definition: scale_atmos_grid_cartesC_index.F90:53
scale_atmos_grid_cartesc_index::ja
integer, public ja
Definition: scale_atmos_grid_cartesC_index.F90:49
scale_const::const_pi
real(rp), parameter, public const_pi
pi
Definition: scale_const.F90:32
mod_mktopo::i_bellshape
integer, parameter, public i_bellshape
Definition: mod_mktopo.F90:47
scale_tracer
module TRACER
Definition: scale_tracer.F90:12
scale_topography::topography_zsfc
real(rp), dimension(:,:), allocatable, public topography_zsfc
absolute ground height [m]
Definition: scale_topography.F90:39
mod_mktopo::i_flat
integer, parameter, public i_flat
Definition: mod_mktopo.F90:46
mod_mktopo
module MKTOPO
Definition: mod_mktopo.F90:12
scale_atmos_grid_cartesc_index::js
integer, public js
start point of inner domain: y, local
Definition: scale_atmos_grid_cartesC_index.F90:55
scale_atmos_grid_cartesc::atmos_grid_cartesc_cy
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cy
center coordinate [m]: y, local
Definition: scale_atmos_grid_cartesC.F90:57
scale_atmos_grid_cartesc
module atmosphere / grid / cartesC
Definition: scale_atmos_grid_cartesC.F90:12
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:57
scale_atmos_grid_cartesc::atmos_grid_cartesc_cx
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cx
center coordinate [m]: x, local
Definition: scale_atmos_grid_cartesC.F90:56