SCALE-RM
scale_spnudge.F90
Go to the documentation of this file.
1 #include "scalelib.h"
3  !-----------------------------------------------------------------------------
4  !
5  !++ used modules
6  !
8  use scale_io
9  use scale_prc
10 
11  !-----------------------------------------------------------------------------
12  implicit none
13  private
14  !-----------------------------------------------------------------------------
15  !
16  !++ Public procedure
17  !
18  public :: spnudge_setup
19 
20  !-----------------------------------------------------------------------------
21  !
22  !++ Public variables
23  !
24  logical, public :: spnudge_uv = .false.
25  logical, public :: spnudge_uv_divfree = .false.
26  integer, public :: spnudge_uv_lm = 3
27  integer, public :: spnudge_uv_mm = 3
28 
29  logical, public :: spnudge_pt = .false.
30  integer, public :: spnudge_pt_lm = 3
31  integer, public :: spnudge_pt_mm = 3
32 
33  logical, public :: spnudge_qv = .false.
34  integer, public :: spnudge_qv_lm = 3
35  integer, public :: spnudge_qv_mm = 3
36 
37  real(rp), allocatable, public :: spnudge_u_alpha(:,:,:)
38  real(rp), allocatable, public :: spnudge_v_alpha(:,:,:)
39  real(rp), allocatable, public :: spnudge_pt_alpha(:,:,:)
40  real(rp), allocatable, public :: spnudge_qv_alpha(:,:,:)
41 
42  !-----------------------------------------------------------------------------
43  !
44  !++ Private variables
45  !
46 
47 contains
48 
49  subroutine spnudge_setup(KA, KS, KE, IA, IS, IE, JA, JS, JE)
50  use scale_dft, only: &
51  dft_setup
53  real_cz => atmos_grid_cartesc_real_cz, &
54  real_czuy => atmos_grid_cartesc_real_czuy, &
55  real_czxv => atmos_grid_cartesc_real_czxv
56  implicit none
57  integer, intent(in) :: ka, ks, ke
58  integer, intent(in) :: ia, is, ie
59  integer, intent(in) :: ja, js, je
60 
61  real(rp) :: spnudge_uv_tau = 0.0_rp
62  real(rp) :: spnudge_pt_tau = 0.0_rp
63  real(rp) :: spnudge_qv_tau = 0.0_rp
64 
65  real(rp) :: spnudge_level1 = 0.0_rp
66  real(rp) :: spnudge_level2 = 0.0_rp
67  real(rp) :: spnudge_level3 = 1e10_rp
68  real(rp) :: spnudge_level4 = 1e10_rp
69 
70  namelist /param_spnudge/ &
71  spnudge_uv, &
73  spnudge_uv_lm, &
74  spnudge_uv_mm, &
75  spnudge_uv_tau, &
76  spnudge_pt, &
77  spnudge_pt_lm, &
78  spnudge_pt_mm, &
79  spnudge_pt_tau, &
80  spnudge_qv, &
81  spnudge_qv_lm, &
82  spnudge_qv_mm, &
83  spnudge_qv_tau, &
84  spnudge_level1, &
85  spnudge_level2, &
86  spnudge_level3, &
87  spnudge_level4
88 
89  real(rp) :: uv_alpha, pt_alpha, qv_alpha
90 
91 
92  integer :: k, i, j
93  integer :: ierr
94  !---------------------------------------------------------------------------
95 
96  log_newline
97  log_info("SPNUDGE_setup",*) 'Setup'
98 
99  !--- read namelist
100  rewind(io_fid_conf)
101  read(io_fid_conf,nml=param_spnudge,iostat=ierr)
102  if( ierr < 0 ) then !--- missing
103  log_info("SPNUDGE_setup",*) 'Not found namelist. Default used.'
104  elseif( ierr > 0 ) then !--- fatal error
105  log_error("SPNUDGE_setup",*) 'Not appropriate names in namelist PARAM_SPNUDGE. Check!'
106  call prc_abort
107  endif
108  log_nml(param_spnudge)
109 
110  if ( spnudge_level1 > spnudge_level2 ) then
111  log_error("SPNUDGE_setup",*) 'SPNUDGE_level1 must be lowere or equal to SPNUDGE_level2'
112  call prc_abort
113  end if
114  if ( spnudge_level2 > spnudge_level3 ) then
115  log_error("SPNUDGE_setup",*) 'SPNUDGE_level2 must be lowere or equal to SPNUDGE_level3'
116  call prc_abort
117  end if
118  if ( spnudge_level3 > spnudge_level4 ) then
119  log_error("SPNUDGE_setup",*) 'SPNUDGE_level3 must be lowere or equal to SPNUDGE_level4'
120  call prc_abort
121  end if
122 
123  if ( spnudge_uv .or. spnudge_pt .or. spnudge_qv ) then
124  log_warn("SPNUDGE_setup",*) 'Spectrul nudging is still experimental'
125  end if
126 
127  allocate( spnudge_u_alpha(ka,ia,ja) )
128  allocate( spnudge_v_alpha(ka,ia,ja) )
129  allocate( spnudge_pt_alpha(ka,ia,ja) )
130  allocate( spnudge_qv_alpha(ka,ia,ja) )
131 
132  if ( spnudge_uv .and. spnudge_uv_tau > 0.0_rp ) then
133  uv_alpha = 1.0_rp / spnudge_uv_tau
134 
135  !$omp parallel do
136  do j = js, je
137  do i = is, ie
138  do k = ks, ke
139  if ( real_czuy(k,i,j) < spnudge_level1 ) then
140  spnudge_u_alpha(k,i,j) = 0.0_rp
141  elseif ( real_czuy(k,i,j) < spnudge_level2 ) then
142  spnudge_u_alpha(k,i,j) = ( real_czuy(k,i,j) - spnudge_level1 ) / ( spnudge_level2 - spnudge_level1 ) * uv_alpha
143  elseif ( real_czuy(k,i,j) < spnudge_level3 ) then
144  spnudge_u_alpha(k,i,j) = uv_alpha
145  elseif ( real_czuy(k,i,j) < spnudge_level4 ) then
146  spnudge_u_alpha(k,i,j) = ( real_czuy(k,i,j) - spnudge_level3 ) / ( spnudge_level4 - spnudge_level3 ) * uv_alpha
147  else
148  spnudge_u_alpha(k,i,j) = 0.0_rp
149  endif
150  enddo
151  enddo
152  enddo
153 
154  !$omp parallel do
155  do j = js, je
156  do i = is, ie
157  do k = ks, ke
158  if ( real_czxv(k,i,j) < spnudge_level1 ) then
159  spnudge_v_alpha(k,i,j) = 0.0_rp
160  elseif ( real_czxv(k,i,j) < spnudge_level2 ) then
161  spnudge_v_alpha(k,i,j) = ( real_czxv(k,i,j) - spnudge_level1 ) / ( spnudge_level2 - spnudge_level1 ) * uv_alpha
162  elseif ( real_czxv(k,i,j) < spnudge_level3 ) then
163  spnudge_v_alpha(k,i,j) = uv_alpha
164  elseif ( real_czxv(k,i,j) < spnudge_level4 ) then
165  spnudge_v_alpha(k,i,j) = ( real_czxv(k,i,j) - spnudge_level3 ) / ( spnudge_level4 - spnudge_level3 ) * uv_alpha
166  else
167  spnudge_v_alpha(k,i,j) = 0.0_rp
168  endif
169  enddo
170  enddo
171  enddo
172 
173  else
174 
175  !$omp parallel do
176  do j = js, je
177  do i = is, ie
178  do k = ks, ke
179  spnudge_u_alpha(k,i,j) = 0.0_rp
180  spnudge_v_alpha(k,i,j) = 0.0_rp
181  end do
182  end do
183  end do
184 
185  endif
186 
187  if ( spnudge_pt .and. spnudge_pt_tau > 0.0_rp ) then
188  pt_alpha = 1.0_rp / spnudge_pt_tau
189 
190  !$omp parallel do
191  do j = js, je
192  do i = is, ie
193  do k = ks, ke
194  if ( real_cz(k,i,j) < spnudge_level1 ) then
195  spnudge_pt_alpha(k,i,j) = 0.0_rp
196  elseif ( real_cz(k,i,j) < spnudge_level2 ) then
197  spnudge_pt_alpha(k,i,j) = ( real_cz(k,i,j) - spnudge_level1 ) / ( spnudge_level2 - spnudge_level1 ) * pt_alpha
198  elseif ( real_cz(k,i,j) < spnudge_level3 ) then
199  spnudge_pt_alpha(k,i,j) = pt_alpha
200  elseif ( real_cz(k,i,j) < spnudge_level4 ) then
201  spnudge_pt_alpha(k,i,j) = ( real_cz(k,i,j) - spnudge_level3 ) / ( spnudge_level4 - spnudge_level3 ) * pt_alpha
202  else
203  spnudge_pt_alpha(k,i,j) = 0.0_rp
204  endif
205  enddo
206  enddo
207  enddo
208 
209  else
210 
211  !$omp parallel do
212  do j = js, je
213  do i = is, ie
214  do k = ks, ke
215  spnudge_pt_alpha(k,i,j) = 0.0_rp
216  end do
217  end do
218  end do
219 
220  endif
221 
222  if ( spnudge_qv .and. spnudge_qv_tau > 0.0_rp ) then
223  qv_alpha = 1.0_rp / spnudge_qv_tau
224 
225  !$omp parallel do
226  do j = js, je
227  do i = is, ie
228  do k = ks, ke
229  if ( real_cz(k,i,j) < spnudge_level1 ) then
230  spnudge_qv_alpha(k,i,j) = 0.0_rp
231  elseif ( real_cz(k,i,j) < spnudge_level2 ) then
232  spnudge_qv_alpha(k,i,j) = ( real_cz(k,i,j) - spnudge_level1 ) / ( spnudge_level2 - spnudge_level1 ) * qv_alpha
233  elseif ( real_cz(k,i,j) < spnudge_level3 ) then
234  spnudge_qv_alpha(k,i,j) = qv_alpha
235  elseif ( real_cz(k,i,j) < spnudge_level4 ) then
236  spnudge_qv_alpha(k,i,j) = ( real_cz(k,i,j) - spnudge_level3 ) / ( spnudge_level4 - spnudge_level3 ) * qv_alpha
237  else
238  spnudge_qv_alpha(k,i,j) = 0.0_rp
239  endif
240  enddo
241  enddo
242  enddo
243 
244  else
245 
246  !$omp parallel do
247  do j = js, je
248  do i = is, ie
249  do k = ks, ke
250  spnudge_qv_alpha(k,i,j) = 0.0_rp
251  end do
252  end do
253  end do
254 
255  end if
256 
257  call dft_setup( ka, ks, ke, ia, is, ie, ja, js, je, &
260 
261  return
262  end subroutine spnudge_setup
263 
264 end module scale_spnudge
scale_spnudge::spnudge_setup
subroutine, public spnudge_setup(KA, KS, KE, IA, IS, IE, JA, JS, JE)
Definition: scale_spnudge.F90:50
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:342
scale_spnudge::spnudge_uv_lm
integer, public spnudge_uv_lm
Definition: scale_spnudge.F90:26
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_cz
real(rp), dimension(:,:,:), allocatable, public atmos_grid_cartesc_real_cz
geopotential height [m] (zxy)
Definition: scale_atmos_grid_cartesC_real.F90:38
scale_spnudge::spnudge_pt_lm
integer, public spnudge_pt_lm
Definition: scale_spnudge.F90:30
scale_spnudge::spnudge_pt
logical, public spnudge_pt
Definition: scale_spnudge.F90:29
scale_spnudge::spnudge_pt_alpha
real(rp), dimension(:,:,:), allocatable, public spnudge_pt_alpha
Definition: scale_spnudge.F90:39
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_spnudge::spnudge_uv_divfree
logical, public spnudge_uv_divfree
Definition: scale_spnudge.F90:25
scale_atmos_grid_cartesc_real
module Atmosphere GRID CartesC Real(real space)
Definition: scale_atmos_grid_cartesC_real.F90:11
scale_spnudge::spnudge_qv_lm
integer, public spnudge_qv_lm
Definition: scale_spnudge.F90:34
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_czxv
real(rp), dimension(:,:,:), allocatable, public atmos_grid_cartesc_real_czxv
geopotential height [m] (zxv)
Definition: scale_atmos_grid_cartesC_real.F90:40
scale_spnudge::spnudge_qv
logical, public spnudge_qv
Definition: scale_spnudge.F90:33
scale_dft
Definition: scale_dft.F90:3
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_spnudge::spnudge_pt_mm
integer, public spnudge_pt_mm
Definition: scale_spnudge.F90:31
scale_precision::rp
integer, parameter, public rp
Definition: scale_precision.F90:41
scale_io
module STDIO
Definition: scale_io.F90:10
scale_spnudge::spnudge_u_alpha
real(rp), dimension(:,:,:), allocatable, public spnudge_u_alpha
Definition: scale_spnudge.F90:37
scale_dft::dft_setup
subroutine, public dft_setup(KA, KS, KE, IA, IS, IE, JA, JS, JE, LM, MM)
Definition: scale_dft.F90:36
scale_spnudge::spnudge_qv_mm
integer, public spnudge_qv_mm
Definition: scale_spnudge.F90:35
scale_spnudge::spnudge_uv_mm
integer, public spnudge_uv_mm
Definition: scale_spnudge.F90:27
scale_spnudge
Definition: scale_spnudge.F90:2
scale_spnudge::spnudge_qv_alpha
real(rp), dimension(:,:,:), allocatable, public spnudge_qv_alpha
Definition: scale_spnudge.F90:40
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:56
scale_spnudge::spnudge_uv
logical, public spnudge_uv
Definition: scale_spnudge.F90:24
scale_spnudge::spnudge_v_alpha
real(rp), dimension(:,:,:), allocatable, public spnudge_v_alpha
Definition: scale_spnudge.F90:38
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_czuy
real(rp), dimension(:,:,:), allocatable, public atmos_grid_cartesc_real_czuy
geopotential height [m] (zuy)
Definition: scale_atmos_grid_cartesC_real.F90:39