SCALE-RM
mod_atmos_phy_bl_vars.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
10 !-------------------------------------------------------------------------------
11 #include "scalelib.h"
13  !-----------------------------------------------------------------------------
14  !
15  !++ used modules
16  !
17  use scale_precision
18  use scale_io
19  use scale_prof
20  use scale_debug
22  use scale_tracer
23  !-----------------------------------------------------------------------------
24  implicit none
25  private
26  !-----------------------------------------------------------------------------
27  !
28  !++ Public procedure
29  !
30  public :: atmos_phy_bl_vars_setup
34 
40 
41  !-----------------------------------------------------------------------------
42  !
43  !++ Public parameters & variables
44  !
45  integer, public :: qs, qe
46 
47  logical, public :: atmos_phy_bl_restart_output = .false.
48 
49  character(len=H_LONG), public :: atmos_phy_bl_restart_in_basename = ''
51  logical, public :: atmos_phy_bl_restart_in_postfix_timelabel = .false.
52  character(len=H_LONG), public :: atmos_phy_bl_restart_out_basename = ''
54  logical, public :: atmos_phy_bl_restart_out_postfix_timelabel = .true.
55  character(len=H_MID), public :: atmos_phy_bl_restart_out_title = 'ATMOS_PHY_BL restart'
56  character(len=H_SHORT), public :: atmos_phy_bl_restart_out_dtype = 'DEFAULT'
57 
58  real(rp), public, allocatable :: atmos_phy_bl_rhou_t(:,:,:) ! tendency RHOU [kg/m2/s2]
59  real(rp), public, allocatable :: atmos_phy_bl_rhov_t(:,:,:) ! tendency RHOV [kg/m2/s2]
60  real(rp), public, allocatable :: atmos_phy_bl_rhot_t(:,:,:) ! tendency RHOT [K*kg/m3/s]
61 
62  real(rp), public, allocatable, target :: atmos_phy_bl_rhoq_t(:,:,:,:) ! tendency rho*QTRC [kg/kg/s]
63 
64  real(rp), public, allocatable :: atmos_phy_bl_zi (:,:) ! depth of the PBL
65 
66  real(rp), public, allocatable :: atmos_phy_bl_ql (:,:,:) ! liquid water content in partial condensation
67  real(rp), public, allocatable :: atmos_phy_bl_cldfrac(:,:,:) ! cloud fraction in partial condensation
68 
69  !-----------------------------------------------------------------------------
70  !
71  !++ Private procedure
72  !
73  !-----------------------------------------------------------------------------
74  !
75  !++ Private parameters & variables
76  !
77  integer, private, parameter :: vmax = 1
78  integer, private, parameter :: i_zi = 1
79 
80  character(len=H_SHORT), private :: var_name(vmax)
81  character(len=H_MID), private :: var_desc(vmax)
82  character(len=H_SHORT), private :: var_unit(vmax)
83  integer, private :: var_id(vmax)
84  integer, private :: restart_fid = -1 ! file ID
85 
86  data var_name / 'PBL_Zi' /
87 
88  data var_desc / 'depth of the boundary layer' /
89 
90  data var_unit / 'm' /
91 
92  !-----------------------------------------------------------------------------
93 contains
94  !-----------------------------------------------------------------------------
96  subroutine atmos_phy_bl_vars_setup
97  use scale_prc, only: &
98  prc_abort
99  use scale_const, only: &
100  undef => const_undef
101  implicit none
102 
103  namelist / param_atmos_phy_bl_vars / &
113 
114  integer :: ierr
115  integer :: iv
116  !---------------------------------------------------------------------------
117 
118  log_newline
119  log_info("ATMOS_PHY_BL_vars_setup",*) 'Setup'
120 
121  allocate( atmos_phy_bl_rhou_t(ka,ia,ja) )
122  allocate( atmos_phy_bl_rhov_t(ka,ia,ja) )
123  allocate( atmos_phy_bl_rhot_t(ka,ia,ja) )
124  allocate( atmos_phy_bl_rhoq_t(ka,ia,ja,qa) )
125  atmos_phy_bl_rhou_t(:,:,:) = undef
126  atmos_phy_bl_rhov_t(:,:,:) = undef
127  atmos_phy_bl_rhot_t(:,:,:) = undef
128  atmos_phy_bl_rhoq_t(:,:,:,:) = undef
129 
130  allocate( atmos_phy_bl_zi(ia,ja) )
131  atmos_phy_bl_zi(:,:) = undef
132 
133  allocate( atmos_phy_bl_ql(ka,ia,ja) )
134  allocate( atmos_phy_bl_cldfrac(ka,ia,ja) )
135  atmos_phy_bl_ql(:,:,:) = undef
136  atmos_phy_bl_cldfrac(:,:,:) = undef
137 
138  !--- read namelist
139  rewind(io_fid_conf)
140  read(io_fid_conf,nml=param_atmos_phy_bl_vars,iostat=ierr)
141  if( ierr < 0 ) then !--- missing
142  log_info("ATMOS_PHY_BL_vars_setup",*) 'Not found namelist. Default used.'
143  elseif( ierr > 0 ) then !--- fatal error
144  log_error("ATMOS_PHY_BL_vars_setup",*) 'Not appropriate names in namelist PARAM_ATMOS_PHY_BL_VARS. Check!'
145  call prc_abort
146  endif
147  log_nml(param_atmos_phy_bl_vars)
148 
149  log_newline
150  log_info("ATMOS_PHY_BL_vars_setup",*) '[ATMOS_PHY_BL] prognostic/diagnostic variables'
151  log_info_cont('(1x,A,A24,A,A48,A,A12,A)') &
152  ' |', 'VARNAME ','|', &
153  'DESCRIPTION ', '[', 'UNIT ', ']'
154  do iv = 1, vmax
155  log_info_cont('(1x,A,I3,A,A24,A,A48,A,A12,A)') &
156  'NO.',iv,'|',var_name(iv),'|',var_desc(iv),'[',var_unit(iv),']'
157  enddo
158 
159  log_newline
160  if ( atmos_phy_bl_restart_in_basename /= '' ) then
161  log_info("ATMOS_PHY_BL_vars_setup",*) 'Restart input? : YES, file = ', trim(atmos_phy_bl_restart_in_basename)
162  log_info("ATMOS_PHY_BL_vars_setup",*) 'Add timelabel? : ', atmos_phy_bl_restart_in_postfix_timelabel
163  else
164  log_info("ATMOS_PHY_BL_vars_setup",*) 'Restart input? : NO'
165  endif
167  .AND. atmos_phy_bl_restart_out_basename /= '' ) then
168  log_info("ATMOS_PHY_BL_vars_setup",*) 'Restart output? : YES, file = ', trim(atmos_phy_bl_restart_out_basename)
169  log_info("ATMOS_PHY_BL_vars_setup",*) 'Add timelabel? : ', atmos_phy_bl_restart_out_postfix_timelabel
170  else
171  log_info("ATMOS_PHY_BL_vars_setup",*) 'Restart output? : NO'
173  endif
174 
175  return
176  end subroutine atmos_phy_bl_vars_setup
177 
178  !-----------------------------------------------------------------------------
180  subroutine atmos_phy_bl_vars_fillhalo
181  use scale_comm_cartesc, only: &
182  comm_vars8, &
183  comm_wait
184  implicit none
185  !---------------------------------------------------------------------------
186 
187  call comm_vars8( atmos_phy_bl_zi(:,:), 1 )
188  call comm_wait ( atmos_phy_bl_zi(:,:), 1 )
189 
190  return
191  end subroutine atmos_phy_bl_vars_fillhalo
192 
193  !-----------------------------------------------------------------------------
196  use scale_time, only: &
198  use scale_file_cartesc, only: &
200  implicit none
201 
202  character(len=19) :: timelabel
203  character(len=H_LONG) :: basename
204  !---------------------------------------------------------------------------
205 
206  log_newline
207  log_info("ATMOS_PHY_BL_vars_restart_open",*) 'Open restart file (ATMOS_PHY_BL) '
208 
209  if ( atmos_phy_bl_restart_in_basename /= '' ) then
210 
212  call time_gettimelabel( timelabel )
213  basename = trim(atmos_phy_bl_restart_in_basename)//'_'//trim(timelabel)
214  else
215  basename = trim(atmos_phy_bl_restart_in_basename)
216  endif
217 
218  log_info("ATMOS_PHY_BL_vars_restart_open",*) 'basename: ', trim(basename)
219 
220  call file_cartesc_open( basename, restart_fid, aggregate=atmos_phy_bl_restart_in_aggregate )
221  else
222  log_info("ATMOS_PHY_BL_vars_restart_open",*) 'restart file for ATMOS_PHY_BL is not specified.'
223  endif
224 
225  return
226  end subroutine atmos_phy_bl_vars_restart_open
227 
228  !-----------------------------------------------------------------------------
231  use scale_file, only: &
233  use scale_file_cartesc, only: &
234  file_cartesc_read, &
236  implicit none
237 
238  integer :: i, j
239  !---------------------------------------------------------------------------
240 
241  if ( restart_fid /= -1 ) then
242  log_newline
243  log_info("ATMOS_PHY_BL_vars_restart_read",*) 'Read from restart file (ATMOS_PHY_BL) '
244 
245  call file_cartesc_read( restart_fid, var_name(1), 'XY', & ! [IN]
246  atmos_phy_bl_zi(:,:) ) ! [OUT]
247 
248  if ( file_get_aggregate(restart_fid) ) then
249  call file_cartesc_flush( restart_fid ) ! X/Y halos have been read from file
250  else
252  end if
253 
255 
256  else
257  log_info("ATMOS_PHY_BL_vars_restart_read",*) 'invalid restart file ID for ATMOS_PHY_BL.'
258  endif
259 
260  return
261  end subroutine atmos_phy_bl_vars_restart_read
262 
263  !-----------------------------------------------------------------------------
266  use scale_time, only: &
268  use scale_file_cartesc, only: &
270  implicit none
271 
272  character(len=19) :: timelabel
273  character(len=H_LONG) :: basename
274  !---------------------------------------------------------------------------
275 
276  if ( atmos_phy_bl_restart_out_basename /= '' ) then
277 
278  log_newline
279  log_info("ATMOS_PHY_BL_vars_restart_create",*) 'Create restart file (ATMOS_PHY_AE) '
280 
282  call time_gettimelabel( timelabel )
283  basename = trim(atmos_phy_bl_restart_out_basename)//'_'//trim(timelabel)
284  else
285  basename = trim(atmos_phy_bl_restart_out_basename)
286  endif
287 
288  log_info("ATMOS_PHY_BL_vars_restart_create",*) 'basename: ', trim(basename)
289 
290  call file_cartesc_create( &
292  restart_fid, & ! [OUT]
293  aggregate=atmos_phy_bl_restart_out_aggregate ) ! [IN]
294  endif
295 
296  return
297  end subroutine atmos_phy_bl_vars_restart_create
298 
299  !-----------------------------------------------------------------------------
302  use scale_file_cartesc, only: &
304  implicit none
305 
306 ! if ( restart_fid /= -1 ) then
307 ! call FILE_CARTESC_enddef( restart_fid ) ! [IN]
308 ! endif
309 
310  return
311  end subroutine atmos_phy_bl_vars_restart_enddef
312 
313  !-----------------------------------------------------------------------------
316  use scale_file_cartesc, only: &
318  implicit none
319  !---------------------------------------------------------------------------
320 
321  if ( restart_fid /= -1 ) then
322  log_newline
323  log_info("ATMOS_PHY_BL_vars_restart_close",*) 'Close restart file (ATMOS_PHY_BL) '
324 
325  call file_cartesc_close( restart_fid ) ! [IN]
326 
327  restart_fid = -1
328  endif
329 
330  return
331  end subroutine atmos_phy_bl_vars_restart_close
332 
333  !-----------------------------------------------------------------------------
336  use scale_file_cartesc, only: &
338  implicit none
339  !---------------------------------------------------------------------------
340 
341  if ( restart_fid /= -1 ) then
342 
343  call file_cartesc_def_var( restart_fid, & ! [IN]
344  var_name(1), var_desc(1), var_unit(1), & ! [IN]
345  'XY', atmos_phy_bl_restart_out_dtype, & ! [IN]
346  var_id(1) ) ! [OUT]
347 
348  endif
349 
350  return
351  end subroutine atmos_phy_bl_vars_restart_def_var
352 
353  !-----------------------------------------------------------------------------
356  use scale_file_cartesc, only: &
357  file_cartesc_write_var
358  implicit none
359 
360  !---------------------------------------------------------------------------
361 
362  if ( restart_fid /= -1 ) then
363 
365 
367 
368  call file_cartesc_write_var( restart_fid, var_id(1), atmos_phy_bl_zi(:,:), &
369  var_name(1), 'XY' ) ! [IN]
370 
371  endif
372 
373  return
374  end subroutine atmos_phy_bl_vars_restart_write
375 
376  subroutine atmos_phy_bl_vars_check
377  use scale_statistics, only: &
378  statistics_total
379  use scale_atmos_grid_cartesc_real, only: &
382  implicit none
383 
384  call valcheck( ia, is, ie, ja, js, je, &
385  atmos_phy_bl_zi(:,:), & ! (in)
386  0.0_rp, 1.0e5_rp, var_name(1), & ! (in)
387  __file__, __line__ ) ! (in)
388 
389  call statistics_total( ia, is, ie, ja, js, je, &
390  atmos_phy_bl_zi(:,:), var_name(1), &
391  atmos_grid_cartesc_real_area(:,:), & ! (in)
393 
394  return
395  end subroutine atmos_phy_bl_vars_check
396 
397 end module mod_atmos_phy_bl_vars
scale_statistics
module Statistics
Definition: scale_statistics.F90:11
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:342
scale_tracer::qa
integer, public qa
Definition: scale_tracer.F90:34
scale_file_cartesc::file_cartesc_enddef
subroutine, public file_cartesc_enddef(fid)
Exit netCDF file define mode.
Definition: scale_file_cartesC.F90:943
scale_file_cartesc::file_cartesc_def_var
subroutine, public file_cartesc_def_var(fid, varname, desc, unit, dim_type, datatype, vid, standard_name, timeintv, nsteps, cell_measures)
Define a variable to file.
Definition: scale_file_cartesC.F90:3307
mod_atmos_phy_bl_vars::atmos_phy_bl_vars_restart_def_var
subroutine, public atmos_phy_bl_vars_restart_def_var
Write restart.
Definition: mod_atmos_phy_bl_vars.F90:336
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_atmos_grid_cartesc_index::ka
integer, public ka
Definition: scale_atmos_grid_cartesC_index.F90:47
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_totarea
real(rp), public atmos_grid_cartesc_real_totarea
total area (xy, local) [m2]
Definition: scale_atmos_grid_cartesC_real.F90:77
mod_atmos_phy_bl_vars::atmos_phy_bl_restart_output
logical, public atmos_phy_bl_restart_output
output restart file?
Definition: mod_atmos_phy_bl_vars.F90:47
mod_atmos_phy_bl_vars::atmos_phy_bl_rhou_t
real(rp), dimension(:,:,:), allocatable, public atmos_phy_bl_rhou_t
Definition: mod_atmos_phy_bl_vars.F90:58
mod_atmos_phy_bl_vars::atmos_phy_bl_restart_out_title
character(len=h_mid), public atmos_phy_bl_restart_out_title
title of the output file
Definition: mod_atmos_phy_bl_vars.F90:55
mod_atmos_phy_bl_vars::atmos_phy_bl_restart_out_basename
character(len=h_long), public atmos_phy_bl_restart_out_basename
Basename of the output file.
Definition: mod_atmos_phy_bl_vars.F90:52
mod_atmos_phy_bl_vars::atmos_phy_bl_rhoq_t
real(rp), dimension(:,:,:,:), allocatable, target, public atmos_phy_bl_rhoq_t
Definition: mod_atmos_phy_bl_vars.F90:62
scale_atmos_grid_cartesc_real
module Atmosphere GRID CartesC Real(real space)
Definition: scale_atmos_grid_cartesC_real.F90:11
scale_file
module file
Definition: scale_file.F90:15
scale_prc
module PROCESS
Definition: scale_prc.F90:11
mod_atmos_phy_bl_vars::atmos_phy_bl_rhov_t
real(rp), dimension(:,:,:), allocatable, public atmos_phy_bl_rhov_t
Definition: mod_atmos_phy_bl_vars.F90:59
scale_precision::rp
integer, parameter, public rp
Definition: scale_precision.F90:41
scale_atmos_grid_cartesc_index::ie
integer, public ie
end point of inner domain: x, local
Definition: scale_atmos_grid_cartesC_index.F90:54
scale_io
module STDIO
Definition: scale_io.F90:10
mod_atmos_phy_bl_vars
module atmosphere / physics / PBL
Definition: mod_atmos_phy_bl_vars.F90:12
mod_atmos_phy_bl_vars::atmos_phy_bl_restart_in_basename
character(len=h_long), public atmos_phy_bl_restart_in_basename
Basename of the input file.
Definition: mod_atmos_phy_bl_vars.F90:49
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_atmos_phy_bl_vars::atmos_phy_bl_restart_in_aggregate
logical, public atmos_phy_bl_restart_in_aggregate
Switch to use aggregate file.
Definition: mod_atmos_phy_bl_vars.F90:50
scale_file_cartesc::file_cartesc_close
subroutine, public file_cartesc_close(fid)
Close a netCDF file.
Definition: scale_file_cartesC.F90:1023
mod_atmos_phy_bl_vars::atmos_phy_bl_vars_restart_create
subroutine, public atmos_phy_bl_vars_restart_create
Create restart file.
Definition: mod_atmos_phy_bl_vars.F90:266
mod_atmos_phy_bl_vars::atmos_phy_bl_zi
real(rp), dimension(:,:), allocatable, public atmos_phy_bl_zi
Definition: mod_atmos_phy_bl_vars.F90:64
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_area
real(rp), dimension(:,:), allocatable, public atmos_grid_cartesc_real_area
horizontal area ( xy, normal z) [m2]
Definition: scale_atmos_grid_cartesC_real.F90:65
scale_atmos_grid_cartesc_index::is
integer, public is
start point of inner domain: x, local
Definition: scale_atmos_grid_cartesC_index.F90:53
mod_atmos_phy_bl_vars::atmos_phy_bl_restart_out_aggregate
logical, public atmos_phy_bl_restart_out_aggregate
Switch to use aggregate file.
Definition: mod_atmos_phy_bl_vars.F90:53
scale_atmos_grid_cartesc_index::ja
integer, public ja
Definition: scale_atmos_grid_cartesC_index.F90:49
scale_time
module TIME
Definition: scale_time.F90:11
mod_atmos_phy_bl_vars::atmos_phy_bl_vars_fillhalo
subroutine, public atmos_phy_bl_vars_fillhalo
HALO Communication.
Definition: mod_atmos_phy_bl_vars.F90:181
mod_atmos_phy_bl_vars::qe
integer, public qe
Definition: mod_atmos_phy_bl_vars.F90:45
scale_tracer
module TRACER
Definition: scale_tracer.F90:12
mod_atmos_phy_bl_vars::atmos_phy_bl_restart_in_postfix_timelabel
logical, public atmos_phy_bl_restart_in_postfix_timelabel
Add timelabel to the basename of input file?
Definition: mod_atmos_phy_bl_vars.F90:51
mod_atmos_phy_bl_vars::atmos_phy_bl_vars_restart_open
subroutine, public atmos_phy_bl_vars_restart_open
Open restart file for read.
Definition: mod_atmos_phy_bl_vars.F90:196
scale_debug
module DEBUG
Definition: scale_debug.F90:11
scale_file_cartesc::file_cartesc_create
subroutine, public file_cartesc_create(basename, title, datatype, fid, date, subsec, haszcoord, append, aggregate, single)
Create/open a netCDF file.
Definition: scale_file_cartesC.F90:780
scale_file_cartesc::file_cartesc_open
subroutine, public file_cartesc_open(basename, fid, aggregate)
open a netCDF file for read
Definition: scale_file_cartesC.F90:746
scale_file_cartesc::file_cartesc_flush
subroutine, public file_cartesc_flush(fid)
Flush all pending requests to a netCDF file (PnetCDF only)
Definition: scale_file_cartesC.F90:997
scale_time::time_gettimelabel
subroutine, public time_gettimelabel(timelabel)
generate time label
Definition: scale_time.F90:91
scale_comm_cartesc
module COMMUNICATION
Definition: scale_comm_cartesC.F90:11
mod_atmos_phy_bl_vars::atmos_phy_bl_vars_restart_read
subroutine, public atmos_phy_bl_vars_restart_read
Read restart.
Definition: mod_atmos_phy_bl_vars.F90:231
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_file::file_get_aggregate
logical function, public file_get_aggregate(fid)
Definition: scale_file.F90:4844
mod_atmos_phy_bl_vars::atmos_phy_bl_vars_restart_write
subroutine, public atmos_phy_bl_vars_restart_write
Write restart.
Definition: mod_atmos_phy_bl_vars.F90:356
mod_atmos_phy_bl_vars::atmos_phy_bl_vars_restart_close
subroutine, public atmos_phy_bl_vars_restart_close
Close restart file.
Definition: mod_atmos_phy_bl_vars.F90:316
mod_atmos_phy_bl_vars::atmos_phy_bl_restart_out_dtype
character(len=h_short), public atmos_phy_bl_restart_out_dtype
REAL4 or REAL8.
Definition: mod_atmos_phy_bl_vars.F90:56
mod_atmos_phy_bl_vars::atmos_phy_bl_vars_setup
subroutine, public atmos_phy_bl_vars_setup
Setup.
Definition: mod_atmos_phy_bl_vars.F90:97
mod_atmos_phy_bl_vars::atmos_phy_bl_cldfrac
real(rp), dimension(:,:,:), allocatable, public atmos_phy_bl_cldfrac
Definition: mod_atmos_phy_bl_vars.F90:67
mod_atmos_phy_bl_vars::atmos_phy_bl_rhot_t
real(rp), dimension(:,:,:), allocatable, public atmos_phy_bl_rhot_t
Definition: mod_atmos_phy_bl_vars.F90:60
mod_atmos_phy_bl_vars::atmos_phy_bl_vars_check
subroutine atmos_phy_bl_vars_check
Definition: mod_atmos_phy_bl_vars.F90:377
mod_atmos_phy_bl_vars::atmos_phy_bl_ql
real(rp), dimension(:,:,:), allocatable, public atmos_phy_bl_ql
Definition: mod_atmos_phy_bl_vars.F90:66
scale_const::const_undef
real(rp), public const_undef
Definition: scale_const.F90:41
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:56
scale_atmos_grid_cartesc_index::je
integer, public je
end point of inner domain: y, local
Definition: scale_atmos_grid_cartesC_index.F90:56
scale_file_cartesc
module file / cartesianC
Definition: scale_file_cartesC.F90:11
mod_atmos_phy_bl_vars::atmos_phy_bl_vars_restart_enddef
subroutine, public atmos_phy_bl_vars_restart_enddef
Exit netCDF define mode.
Definition: mod_atmos_phy_bl_vars.F90:302
mod_atmos_phy_bl_vars::qs
integer, public qs
Definition: mod_atmos_phy_bl_vars.F90:45
mod_atmos_phy_bl_vars::atmos_phy_bl_restart_out_postfix_timelabel
logical, public atmos_phy_bl_restart_out_postfix_timelabel
Add timelabel to the basename of output file?
Definition: mod_atmos_phy_bl_vars.F90:54