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: &
29  topo_zsfc
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  use scale_topography, only: &
113  topo_write
114  implicit none
115  !---------------------------------------------------------------------------
116 
117  if ( mktopo_type == i_ignore ) then
118  log_newline
119  log_info("MKTOPO",*) 'SKIP MAKING TOPOGRAPHY DATA'
120  else
121  log_newline
122  log_info("MKTOP",*) 'START MAKING TOPOGRAPHY DATA'
123 
124  select case(mktopo_type)
125  case(i_flat)
126  call mktopo_flat
127 
128  case(i_bellshape)
129  call mktopo_bellshape
130 
131  case(i_schaer)
132  call mktopo_schaer
133 
134  case default
135  log_error("MKTOPO",*) 'Unsupported TYPE:', mktopo_type
136  call prc_abort
137  endselect
138 
139  log_info("MKTOPO",*) 'END MAKING TOPOGRAPHY DATA'
140 
141  ! output topography file
142  call topo_write
143  endif
144 
145  return
146  end subroutine mktopo
147 
148  !-----------------------------------------------------------------------------
150  subroutine mktopo_flat
151  implicit none
152 
153  ! flat mountain parameter
154  real(RP) :: FLAT_HEIGHT = 100.0_rp ! height of mountain [m]
155 
156  namelist / param_mktopo_flat / &
157  flat_height
158 
159  integer :: ierr
160  integer :: i, j
161  !---------------------------------------------------------------------------
162 
163  log_newline
164  log_info("MKTOPO_flat",*) 'Setup'
165 
166  !--- read namelist
167  rewind(io_fid_conf)
168  read(io_fid_conf,nml=param_mktopo_flat,iostat=ierr)
169  if( ierr < 0 ) then !--- missing
170  log_info("MKTOPO_flat",*) 'Not found namelist. Default used.'
171  elseif( ierr > 0 ) then !--- fatal error
172  log_error("MKTOPO_flat",*) 'Not appropriate names in namelist PARAM_MKTOPO_FLAT. Check!'
173  call prc_abort
174  endif
175  log_nml(param_mktopo_flat)
176 
177  do j = 1, ja
178  do i = 1, ia
179  topo_zsfc(i,j) = flat_height
180  enddo
181  enddo
182 
183  return
184  end subroutine mktopo_flat
185 
186  !-----------------------------------------------------------------------------
188  subroutine mktopo_bellshape
189  implicit none
190 
191  ! bell-shaped mountain parameter
192  logical :: BELL_eachnode = .false. ! Arrange mountain at each node? [kg/kg]
193  real(RP) :: BELL_CX = 2.e3_rp ! center location [m]: x
194  real(RP) :: BELL_CY = 2.e3_rp ! center location [m]: y
195  real(RP) :: BELL_RX = 2.e3_rp ! bubble radius [m]: x
196  real(RP) :: BELL_RY = 2.e3_rp ! bubble radius [m]: y
197  real(RP) :: BELL_HEIGHT = 100.0_rp ! height of mountain [m]
198 
199  namelist / param_mktopo_bellshape / &
200  bell_eachnode, &
201  bell_cx, &
202  bell_cy, &
203  bell_rx, &
204  bell_ry, &
205  bell_height
206 
207  real(RP) :: CX_offset
208  real(RP) :: CY_offset
209  real(RP) :: dist
210 
211  integer :: ierr
212  integer :: i, j
213  !---------------------------------------------------------------------------
214 
215  log_newline
216  log_info("MKTOPO_bellshape",*) 'Setup'
217 
218  !--- read namelist
219  rewind(io_fid_conf)
220  read(io_fid_conf,nml=param_mktopo_bellshape,iostat=ierr)
221  if( ierr < 0 ) then !--- missing
222  log_info("MKTOPO_bellshape",*) 'Not found namelist. Default used.'
223  elseif( ierr > 0 ) then !--- fatal error
224  log_error("MKTOPO_bellshape",*) 'Not appropriate names in namelist PARAM_MKTOPO_BELLSHAPE. Check!'
225  call prc_abort
226  endif
227  log_nml(param_mktopo_bellshape)
228 
229  if ( bell_eachnode ) then
230  cx_offset = cx(is)
231  cy_offset = cy(js)
232  else
233  cx_offset = 0.0_rp
234  cy_offset = 0.0_rp
235  endif
236 
237  ! make bell-shaped mountain
238  do j = 1, ja
239  do i = 1, ia
240 
241  dist = ( (cx(i)-cx_offset-bell_cx)/bell_rx )**2 &
242  + ( (cy(j)-cy_offset-bell_cy)/bell_ry )**2
243 
244  topo_zsfc(i,j) = bell_height / ( 1.0_rp + dist )
245 
246  enddo
247  enddo
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  do j = 1, ja
298  do i = 1, ia
299 
300  dist = exp( -( (cx(i)-schaer_cx)/schaer_rx )**2 )
301 
302  topo_zsfc(i,j) = schaer_height * dist * ( cos( pi*(cx(i)-schaer_cx)/schaer_lambda ) )**2
303 
304  enddo
305  enddo
306  else
307  do j = 1, ja
308  do i = 1, ia
309 
310  dist = exp( -( (cy(j)-schaer_cx)/schaer_rx )**2 )
311 
312  topo_zsfc(i,j) = schaer_height * dist * ( cos( pi*(cy(j)-schaer_cx)/schaer_lambda ) )**2
313 
314  enddo
315  enddo
316  endif
317 
318  return
319  end subroutine mktopo_schaer
320 
321 end module mod_mktopo
subroutine, public mktopo
Driver.
Definition: mod_mktopo.F90:112
subroutine, public topo_write
Write topography.
integer, public mktopo_type
Definition: mod_mktopo.F90:44
subroutine, public mktopo_setup
Setup.
Definition: mod_mktopo.F90:68
integer, parameter, public i_flat
Definition: mod_mktopo.F90:46
integer, public ia
of whole cells: x, local, with HALO
integer, public ja
of whole cells: y, local, with HALO
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:55
integer, parameter, public i_ignore
Definition: mod_mktopo.F90:45
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cy
center coordinate [m]: y, local
integer, public is
start point of inner domain: x, local
module TRACER
module atmosphere / grid / cartesC index
integer, parameter, public i_schaer
Definition: mod_mktopo.F90:48
module PROCESS
Definition: scale_prc.F90:11
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cx
center coordinate [m]: x, local
module atmosphere / grid / cartesC
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:338
module CONSTANT
Definition: scale_const.F90:11
integer, public js
start point of inner domain: y, local
module MKTOPO
Definition: mod_mktopo.F90:12
module profiler
Definition: scale_prof.F90:11
integer, parameter, public i_bellshape
Definition: mod_mktopo.F90:47
module PRECISION
real(rp), dimension(:,:), allocatable, public topo_zsfc
absolute ground height [m]
module TOPOGRAPHY
real(rp), public const_pi
pi
Definition: scale_const.F90:31
module STDIO
Definition: scale_io.F90:10