SCALE-RM
mod_atmos_phy_mp_vars.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
13 !-------------------------------------------------------------------------------
14 #include "inc_openmp.h"
16  !-----------------------------------------------------------------------------
17  !
18  !++ used modules
19  !
20  use scale_precision
21  use scale_stdio
22  use scale_prof
24  use scale_tracer
25  !-----------------------------------------------------------------------------
26  implicit none
27  private
28  !-----------------------------------------------------------------------------
29  !
30  !++ Public procedure
31  !
32  public :: atmos_phy_mp_vars_setup
36 
37  !-----------------------------------------------------------------------------
38  !
39  !++ Public parameters & variables
40  !
41  logical, public :: atmos_phy_mp_restart_output = .false.
42 
43  character(len=H_LONG), public :: atmos_phy_mp_restart_in_basename = ''
44  character(len=H_LONG), public :: atmos_phy_mp_restart_out_basename = ''
45  character(len=H_MID), public :: atmos_phy_mp_restart_out_title = 'ATMOS_PHY_MP restart'
46  character(len=H_MID), public :: atmos_phy_mp_restart_out_dtype = 'DEFAULT'
47 
48  real(RP), public, allocatable :: atmos_phy_mp_dens_t(:,:,:) ! tendency DENS [kg/m3/s]
49  real(RP), public, allocatable :: atmos_phy_mp_momz_t(:,:,:) ! tendency MOMZ [kg/m2/s2]
50  real(RP), public, allocatable :: atmos_phy_mp_momx_t(:,:,:) ! tendency MOMX [kg/m2/s2]
51  real(RP), public, allocatable :: atmos_phy_mp_momy_t(:,:,:) ! tendency MOMY [kg/m2/s2]
52  real(RP), public, allocatable :: atmos_phy_mp_rhot_t(:,:,:) ! tendency RHOT [K*kg/m3/s]
53  real(RP), public, allocatable :: atmos_phy_mp_rhoq_t(:,:,:,:) ! tendency rho*QTRC [kg/kg/s]
54 
55  real(RP), public, allocatable :: atmos_phy_mp_evaporate(:,:,:) ! number concentration of evaporated cloud [/m3]
56  real(RP), public, allocatable :: atmos_phy_mp_sflx_rain(:,:) ! precipitation flux (liquid) [kg/m2/s]
57  real(RP), public, allocatable :: atmos_phy_mp_sflx_snow(:,:) ! precipitation flux (solid) [kg/m2/s]
58 
59  !-----------------------------------------------------------------------------
60  !
61  !++ Private procedure
62  !
63  !-----------------------------------------------------------------------------
64  !
65  !++ Private parameters & variables
66  !
67  integer, private, parameter :: vmax = 2
68  integer, private, parameter :: i_sflx_rain = 1
69  integer, private, parameter :: i_sflx_snow = 2
70 
71  character(len=H_SHORT), private :: var_name(vmax)
72  character(len=H_MID), private :: var_desc(vmax)
73  character(len=H_SHORT), private :: var_unit(vmax)
74 
75  data var_name / 'SFLX_rain', &
76  'SFLX_snow' /
77  data var_desc / 'precipitation flux (liquid)', &
78  'precipitation flux (solid)' /
79  data var_unit / 'kg/m2/s', &
80  'kg/m2/s' /
81 
82  !-----------------------------------------------------------------------------
83 contains
84  !-----------------------------------------------------------------------------
86  subroutine atmos_phy_mp_vars_setup
87  use scale_process, only: &
89  use scale_const, only: &
90  undef => const_undef
91  implicit none
92 
93  namelist / param_atmos_phy_mp_vars / &
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_MP] / Origin[SCALE-RM]'
106 
107  allocate( atmos_phy_mp_dens_t(ka,ia,ja) )
108  allocate( atmos_phy_mp_momz_t(ka,ia,ja) )
109  allocate( atmos_phy_mp_momx_t(ka,ia,ja) )
110  allocate( atmos_phy_mp_momy_t(ka,ia,ja) )
111  allocate( atmos_phy_mp_rhot_t(ka,ia,ja) )
112  allocate( atmos_phy_mp_rhoq_t(ka,ia,ja,qa) )
113  allocate( atmos_phy_mp_evaporate(ka,ia,ja) )
114  ! tentative approach
115  atmos_phy_mp_dens_t(:,:,:) = 0.0_rp
116  atmos_phy_mp_momz_t(:,:,:) = 0.0_rp
117  atmos_phy_mp_momx_t(:,:,:) = 0.0_rp
118  atmos_phy_mp_momy_t(:,:,:) = 0.0_rp
119  atmos_phy_mp_rhot_t(:,:,:) = 0.0_rp
120  atmos_phy_mp_rhoq_t(:,:,:,:) = 0.0_rp
121  atmos_phy_mp_evaporate(:,:,:) = 0.0_rp
122 
123  allocate( atmos_phy_mp_sflx_rain(ia,ja) )
124  allocate( atmos_phy_mp_sflx_snow(ia,ja) )
125  atmos_phy_mp_sflx_rain(:,:) = undef
126  atmos_phy_mp_sflx_snow(:,:) = undef
127 
128  !--- read namelist
129  rewind(io_fid_conf)
130  read(io_fid_conf,nml=param_atmos_phy_mp_vars,iostat=ierr)
131  if( ierr < 0 ) then !--- missing
132  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
133  elseif( ierr > 0 ) then !--- fatal error
134  write(*,*) 'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_MP_VARS. Check!'
135  call prc_mpistop
136  endif
137  if( io_lnml ) write(io_fid_log,nml=param_atmos_phy_mp_vars)
138 
139  if( io_l ) write(io_fid_log,*)
140  if( io_l ) write(io_fid_log,*) '*** [ATMOS_PHY_MP] prognostic/diagnostic variables'
141  if( io_l ) write(io_fid_log,'(1x,A,A15,A,A32,3(A))') &
142  '*** |','VARNAME ','|', 'DESCRIPTION ','[', 'UNIT ',']'
143  do iv = 1, vmax
144  if( io_l ) write(io_fid_log,'(1x,A,i3,A,A15,A,A32,3(A))') &
145  '*** NO.',iv,'|',var_name(iv),'|',var_desc(iv),'[',var_unit(iv),']'
146  enddo
147 
148  if( io_l ) write(io_fid_log,*)
149  if ( atmos_phy_mp_restart_in_basename /= '' ) then
150  if( io_l ) write(io_fid_log,*) '*** Restart input? : ', trim(atmos_phy_mp_restart_in_basename)
151  else
152  if( io_l ) write(io_fid_log,*) '*** Restart input? : NO'
153  endif
155  .AND. atmos_phy_mp_restart_out_basename /= '' ) then
156  if( io_l ) write(io_fid_log,*) '*** Restart output? : ', trim(atmos_phy_mp_restart_out_basename)
157  else
158  if( io_l ) write(io_fid_log,*) '*** Restart output? : NO'
160  endif
161 
162  return
163  end subroutine atmos_phy_mp_vars_setup
164 
165  !-----------------------------------------------------------------------------
167  subroutine atmos_phy_mp_vars_fillhalo
168  use scale_comm, only: &
169  comm_vars8, &
170  comm_wait
171  implicit none
172  !---------------------------------------------------------------------------
173 
174  call comm_vars8( atmos_phy_mp_sflx_rain(:,:), 1 )
175  call comm_vars8( atmos_phy_mp_sflx_snow(:,:), 2 )
176  call comm_wait ( atmos_phy_mp_sflx_rain(:,:), 1 )
177  call comm_wait ( atmos_phy_mp_sflx_snow(:,:), 2 )
178 
179  return
180  end subroutine atmos_phy_mp_vars_fillhalo
181 
182  !-----------------------------------------------------------------------------
185  use scale_fileio, only: &
186  fileio_read
187  use scale_rm_statistics, only: &
188  stat_total
189  implicit none
190 
191  real(RP) :: total
192  !---------------------------------------------------------------------------
193 
194  if( io_l ) write(io_fid_log,*)
195  if( io_l ) write(io_fid_log,*) '*** Input restart file (ATMOS_PHY_MP) ***'
196 
197  if ( atmos_phy_mp_restart_in_basename /= '' ) then
198  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(atmos_phy_mp_restart_in_basename)
199 
200  call fileio_read( atmos_phy_mp_sflx_rain(:,:), & ! [OUT]
201  atmos_phy_mp_restart_in_basename, var_name(1), 'XY', step=1 ) ! [IN]
202  call fileio_read( atmos_phy_mp_sflx_snow(:,:), & ! [OUT]
203  atmos_phy_mp_restart_in_basename, var_name(2), 'XY', step=1 ) ! [IN]
204 
206 
207  call stat_total( total, atmos_phy_mp_sflx_rain(:,:), var_name(1) )
208  call stat_total( total, atmos_phy_mp_sflx_snow(:,:), var_name(2) )
209  else
210  if( io_l ) write(io_fid_log,*) '*** restart file for ATMOS_PHY_MP is not specified.'
211  endif
212 
213  return
214  end subroutine atmos_phy_mp_vars_restart_read
215 
216  !-----------------------------------------------------------------------------
219  use scale_time, only: &
221  use scale_fileio, only: &
222  fileio_write
223  use scale_rm_statistics, only: &
224  stat_total
225  implicit none
226 
227  character(len=20) :: timelabel
228  character(len=H_LONG) :: basename
229 
230  real(RP) :: total
231  !---------------------------------------------------------------------------
232 
233  if ( atmos_phy_mp_restart_out_basename /= '' ) then
234 
235  call time_gettimelabel( timelabel )
236  write(basename,'(A,A,A)') trim(atmos_phy_mp_restart_out_basename), '_', trim(timelabel)
237 
238  if( io_l ) write(io_fid_log,*)
239  if( io_l ) write(io_fid_log,*) '*** Output restart file (ATMOS_PHY_MP) ***'
240  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
241 
243 
244  call stat_total( total, atmos_phy_mp_sflx_rain(:,:), var_name(1) )
245  call stat_total( total, atmos_phy_mp_sflx_snow(:,:), var_name(1) )
246 
247  call fileio_write( atmos_phy_mp_sflx_rain(:,:), basename, atmos_phy_mp_restart_out_title, & ! [IN]
248  var_name(1), var_desc(1), var_unit(1), 'XY', atmos_phy_mp_restart_out_dtype ) ! [IN]
249  call fileio_write( atmos_phy_mp_sflx_snow(:,:), basename, atmos_phy_mp_restart_out_title, & ! [IN]
250  var_name(2), var_desc(2), var_unit(2), 'XY', atmos_phy_mp_restart_out_dtype ) ! [IN]
251 
252  endif
253 
254  return
255  end subroutine atmos_phy_mp_vars_restart_write
256 
257 end module mod_atmos_phy_mp_vars
real(rp), dimension(:,:,:,:), allocatable, public atmos_phy_mp_rhoq_t
real(rp), dimension(:,:,:), allocatable, public atmos_phy_mp_momy_t
subroutine, public prc_mpistop
Abort MPI.
module Atmosphere / Physics Cloud Microphysics
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:59
character(len=h_long), public atmos_phy_mp_restart_in_basename
basename of the restart file
module STDIO
Definition: scale_stdio.F90:12
integer, public qa
real(rp), dimension(:,:,:), allocatable, public atmos_phy_mp_momz_t
real(rp), dimension(:,:), allocatable, public atmos_phy_mp_sflx_rain
module FILE I/O (netcdf)
real(rp), public const_undef
Definition: scale_const.F90:43
module Statistics
module grid index
character(len=h_mid), public atmos_phy_mp_restart_out_title
title of the output file
module TRACER
integer, public ia
of x whole cells (local, with HALO)
real(rp), dimension(:,:,:), allocatable, public atmos_phy_mp_rhot_t
subroutine, public time_gettimelabel(timelabel)
generate time label
Definition: scale_time.F90:90
integer, public ka
of z whole cells (local, with HALO)
character(len=h_long), public atmos_phy_mp_restart_out_basename
basename of the output file
real(rp), dimension(:,:,:), allocatable, public atmos_phy_mp_dens_t
module COMMUNICATION
Definition: scale_comm.F90:23
module TIME
Definition: scale_time.F90:15
module PROCESS
logical, public atmos_phy_mp_restart_output
output restart file?
subroutine, public atmos_phy_mp_vars_fillhalo
HALO Communication.
module CONSTANT
Definition: scale_const.F90:14
character(len=h_mid), public atmos_phy_mp_restart_out_dtype
REAL4 or REAL8.
real(rp), dimension(:,:,:), allocatable, public atmos_phy_mp_evaporate
real(rp), dimension(:,:), allocatable, public atmos_phy_mp_sflx_snow
subroutine, public atmos_phy_mp_vars_setup
Setup.
module profiler
Definition: scale_prof.F90:10
subroutine, public atmos_phy_mp_vars_restart_write
Write restart.
subroutine, public atmos_phy_mp_vars_restart_read
Read restart.
logical, public io_lnml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:60
module PRECISION
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_mp_momx_t
integer, public ja
of y whole cells (local, with HALO)