SCALE-RM
mod_atmos_phy_tb_vars.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
12 !-------------------------------------------------------------------------------
13 #include "inc_openmp.h"
15  !-----------------------------------------------------------------------------
16  !
17  !++ used modules
18  !
19  use scale_precision
20  use scale_stdio
21  use scale_prof
23  use scale_tracer
24  !-----------------------------------------------------------------------------
25  implicit none
26  private
27  !-----------------------------------------------------------------------------
28  !
29  !++ Public procedure
30  !
31  public :: atmos_phy_tb_vars_setup
35 
36  !-----------------------------------------------------------------------------
37  !
38  !++ Public parameters & variables
39  !
40  logical, public :: atmos_phy_tb_restart_output = .false.
41 
42  character(len=H_LONG), public :: atmos_phy_tb_restart_in_basename = ''
43  character(len=H_LONG), public :: atmos_phy_tb_restart_out_basename = ''
44  character(len=H_MID), public :: atmos_phy_tb_restart_out_title = 'ATMOS_PHY_TB restart'
45  character(len=H_MID), public :: atmos_phy_tb_restart_out_dtype = 'DEFAULT'
46 
47  real(RP), public, allocatable :: atmos_phy_tb_momz_t(:,:,:) ! tendency MOMZ [kg/m2/s2]
48  real(RP), public, allocatable :: atmos_phy_tb_momx_t(:,:,:) ! tendency MOMX [kg/m2/s2]
49  real(RP), public, allocatable :: atmos_phy_tb_momy_t(:,:,:) ! tendency MOMY [kg/m2/s2]
50  real(RP), public, allocatable :: atmos_phy_tb_rhot_t(:,:,:) ! tendency RHOT [K*kg/m3/s]
51  real(RP), public, allocatable :: atmos_phy_tb_rhoq_t(:,:,:,:) ! tendency rho*QTRC [kg/kg/s]
52  real(RP), public, allocatable :: atmos_phy_tb_tke_t(:,:,:) ! tendency TKE @m2/s3]
53 
54  real(RP), public, allocatable :: atmos_phy_tb_tke(:,:,:) ! turburent kinetic energy [m2/s2]
55  real(RP), public, allocatable :: atmos_phy_tb_nu (:,:,:) ! eddy viscosity [m2/s]
56 
57  !-----------------------------------------------------------------------------
58  !
59  !++ Private procedure
60  !
61  !-----------------------------------------------------------------------------
62  !
63  !++ Private parameters & variables
64  !
65  integer, private, parameter :: vmax = 2
66  integer, private, parameter :: i_tke = 1
67  integer, private, parameter :: i_nu = 2
68 
69  character(len=H_SHORT), private :: var_name(vmax)
70  character(len=H_MID), private :: var_desc(vmax)
71  character(len=H_SHORT), private :: var_unit(vmax)
72 
73  data var_name / 'TKE', &
74  'NU' /
75  data var_desc / 'turburent kinetic energy', &
76  'eddy viscosity' /
77  data var_unit / 'm2/s2', &
78  'm2/s' /
79 
80  !-----------------------------------------------------------------------------
81 contains
82  !-----------------------------------------------------------------------------
84  subroutine atmos_phy_tb_vars_setup
85  use scale_process, only: &
87  use scale_const, only: &
88  undef => const_undef
89  implicit none
90  real(RP) :: ATMOS_PHY_TB_TKE_INIT = 1.0e-10_rp
91 
92  namelist / param_atmos_phy_tb_vars / &
98  atmos_phy_tb_tke_init
99 
100  integer :: ierr
101  integer :: iv
102  !---------------------------------------------------------------------------
103 
104  if( io_l ) write(io_fid_log,*)
105  if( io_l ) write(io_fid_log,*) '++++++ Module[VARS] / Categ[ATMOS PHY_TB] / Origin[SCALE-RM]'
106 
107  allocate( atmos_phy_tb_momz_t(ka,ia,ja) )
108  allocate( atmos_phy_tb_momx_t(ka,ia,ja) )
109  allocate( atmos_phy_tb_momy_t(ka,ia,ja) )
110  allocate( atmos_phy_tb_rhot_t(ka,ia,ja) )
111  allocate( atmos_phy_tb_rhoq_t(ka,ia,ja,qa) )
112  allocate( atmos_phy_tb_tke_t(ka,ia,ja) )
113 
114  allocate( atmos_phy_tb_tke(ka,ia,ja) )
115  allocate( atmos_phy_tb_nu(ka,ia,ja) )
116 
117  !--- read namelist
118  rewind(io_fid_conf)
119  read(io_fid_conf,nml=param_atmos_phy_tb_vars,iostat=ierr)
120  if( ierr < 0 ) then !--- missing
121  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
122  elseif( ierr > 0 ) then !--- fatal error
123  write(*,*) 'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_TB_VARS. Check!'
124  call prc_mpistop
125  endif
126  if( io_lnml ) write(io_fid_log,nml=param_atmos_phy_tb_vars)
127 
128  if( io_l ) write(io_fid_log,*)
129  if( io_l ) write(io_fid_log,*) '*** [ATMOS_PHY_TB] prognostic/diagnostic variables'
130  if( io_l ) write(io_fid_log,'(1x,A,A15,A,A32,3(A))') &
131  '*** |','VARNAME ','|', 'DESCRIPTION ','[', 'UNIT ',']'
132  do iv = 1, vmax
133  if( io_l ) write(io_fid_log,'(1x,A,i3,A,A15,A,A32,3(A))') &
134  '*** NO.',iv,'|',var_name(iv),'|',var_desc(iv),'[',var_unit(iv),']'
135  enddo
136 
137  if( io_l ) write(io_fid_log,*)
138  if ( atmos_phy_tb_restart_in_basename /= '' ) then
139  if( io_l ) write(io_fid_log,*) '*** Restart input? : ', trim(atmos_phy_tb_restart_in_basename)
140  else
141  if( io_l ) write(io_fid_log,*) '*** Restart input? : NO'
142  endif
144  .AND. atmos_phy_tb_restart_out_basename /= '' ) then
145  if( io_l ) write(io_fid_log,*) '*** Restart output? : ', trim(atmos_phy_tb_restart_out_basename)
146  else
147  if( io_l ) write(io_fid_log,*) '*** Restart output? : NO'
149  endif
150 
151  atmos_phy_tb_momz_t(:,:,:) = undef
152  atmos_phy_tb_momx_t(:,:,:) = undef
153  atmos_phy_tb_momy_t(:,:,:) = undef
154  atmos_phy_tb_rhot_t(:,:,:) = undef
155  atmos_phy_tb_rhoq_t(:,:,:,:) = undef
156  atmos_phy_tb_tke_t(:,:,:) = undef
157 
158  atmos_phy_tb_tke(:,:,:) = atmos_phy_tb_tke_init
159  atmos_phy_tb_nu(:,:,:) = undef
160 
161  return
162  end subroutine atmos_phy_tb_vars_setup
163 
164  !-----------------------------------------------------------------------------
166  subroutine atmos_phy_tb_vars_fillhalo
167  use scale_comm, only: &
168  comm_vars8, &
169  comm_wait
170  implicit none
171 
172  integer :: i, j
173  !---------------------------------------------------------------------------
174 
175  do j = js, je
176  do i = is, ie
177  atmos_phy_tb_tke( 1:ks-1,i,j) = atmos_phy_tb_tke(ks,i,j)
178  atmos_phy_tb_nu( 1:ks-1,i,j) = atmos_phy_tb_nu(ks,i,j)
179  atmos_phy_tb_tke(ke+1:ka, i,j) = atmos_phy_tb_tke(ke,i,j)
180  atmos_phy_tb_nu(ke+1:ka, i,j) = atmos_phy_tb_nu(ke,i,j)
181  enddo
182  enddo
183 
184  call comm_vars8( atmos_phy_tb_tke(:,:,:), 1 )
185  call comm_vars8( atmos_phy_tb_nu(:,:,:), 2 )
186  call comm_wait ( atmos_phy_tb_tke(:,:,:), 1 )
187  call comm_wait ( atmos_phy_tb_nu(:,:,:), 2 )
188 
189  return
190  end subroutine atmos_phy_tb_vars_fillhalo
191 
192  !-----------------------------------------------------------------------------
195  use scale_fileio, only: &
196  fileio_read
197  use scale_rm_statistics, only: &
198  stat_total
199  implicit none
200 
201  real(RP) :: total
202  !---------------------------------------------------------------------------
203 
204  if( io_l ) write(io_fid_log,*)
205  if( io_l ) write(io_fid_log,*) '*** Input restart file (ATMOS_PHY_TB) ***'
206 
207  if ( atmos_phy_tb_restart_in_basename /= '' ) then
208  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(atmos_phy_tb_restart_in_basename)
209 
210  call fileio_read( atmos_phy_tb_tke(:,:,:), & ! [OUT]
211  atmos_phy_tb_restart_in_basename, var_name(1), 'ZXY', step=1 ) ! [IN]
212 ! call FILEIO_read( ATMOS_PHY_TB_NU (:,:,:), & ! [OUT]
213 ! ATMOS_PHY_TB_RESTART_IN_BASENAME, VAR_NAME(2), 'ZXY', step=1 ) ! [IN]
214 !
215 ! call ATMOS_PHY_TB_vars_fillhalo
216 !
217  call stat_total( total, atmos_phy_tb_tke(:,:,:), var_name(1) )
218 ! call STAT_total( total, ATMOS_PHY_TB_NU (:,:,:), VAR_NAME(2) )
219  else
220  if( io_l ) write(io_fid_log,*) '*** restart file for ATMOS_PHY_TB is not specified.'
221  endif
222 
223  return
224  end subroutine atmos_phy_tb_vars_restart_read
225 
226  !-----------------------------------------------------------------------------
229  use scale_time, only: &
231  use scale_fileio, only: &
232  fileio_write
233  implicit none
234 
235  character(len=20) :: timelabel
236  character(len=H_LONG) :: basename
237  !---------------------------------------------------------------------------
238 
239  if ( atmos_phy_tb_restart_out_basename /= '' ) then
240 
241  call time_gettimelabel( timelabel )
242  write(basename,'(A,A,A)') trim(atmos_phy_tb_restart_out_basename), '_', trim(timelabel)
243 
244  if( io_l ) write(io_fid_log,*)
245  if( io_l ) write(io_fid_log,*) '*** Output restart file (ATMOS_PHY_TB) ***'
246  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
247 
248  call fileio_write( atmos_phy_tb_tke(:,:,:), basename, atmos_phy_tb_restart_out_title, & ! [IN]
249  var_name(1), var_desc(1), var_unit(1), 'ZXY', atmos_phy_tb_restart_out_dtype ) ! [IN]
250 ! call FILEIO_write( ATMOS_PHY_TB_NU (:,:,:), basename, ATMOS_PHY_TB_RESTART_OUT_TITLE, & ! [IN]
251 ! VAR_NAME(2), VAR_DESC(2), VAR_UNIT(2), 'ZXY', ATMOS_PHY_TB_RESTART_OUT_DTYPE ) ! [IN]
252 
253  endif
254 
255  return
256  end subroutine atmos_phy_tb_vars_restart_write
257 
258 end module mod_atmos_phy_tb_vars
integer, public is
start point of inner domain: x, local
integer, public je
end point of inner domain: y, local
subroutine, public atmos_phy_tb_vars_restart_read
Read restart.
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_momx_t
subroutine, public prc_mpistop
Abort MPI.
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_rhot_t
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:59
subroutine, public atmos_phy_tb_vars_restart_write
Write restart.
module STDIO
Definition: scale_stdio.F90:12
integer, public ke
end point of inner domain: z, local
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_tke
integer, public qa
character(len=h_mid), public atmos_phy_tb_restart_out_title
title of the output file
module FILE I/O (netcdf)
real(rp), public const_undef
Definition: scale_const.F90:43
module Statistics
module grid index
character(len=h_long), public atmos_phy_tb_restart_in_basename
basename of the restart file
character(len=h_mid), public atmos_phy_tb_restart_out_dtype
REAL4 or REAL8.
module TRACER
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_nu
integer, public ia
of x whole cells (local, with HALO)
subroutine, public time_gettimelabel(timelabel)
generate time label
Definition: scale_time.F90:90
integer, public ka
of z whole cells (local, with HALO)
module COMMUNICATION
Definition: scale_comm.F90:23
integer, public js
start point of inner domain: y, local
subroutine, public atmos_phy_tb_vars_setup
Setup.
module TIME
Definition: scale_time.F90:15
module PROCESS
module Atmosphere / Physics Turbulence
module CONSTANT
Definition: scale_const.F90:14
integer, public ks
start point of inner domain: z, local
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_momy_t
module profiler
Definition: scale_prof.F90:10
integer, public ie
end point of inner domain: x, local
character(len=h_long), public atmos_phy_tb_restart_out_basename
basename of the output file
logical, public io_lnml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:60
logical, public atmos_phy_tb_restart_output
output restart file?
subroutine, public atmos_phy_tb_vars_fillhalo
HALO Communication.
module PRECISION
real(rp), dimension(:,:,:,:), allocatable, public atmos_phy_tb_rhoq_t
integer, public io_fid_conf
Config file ID.
Definition: scale_stdio.F90:55
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_tke_t
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_momz_t
integer, public ja
of y whole cells (local, with HALO)