SCALE-RM
mod_atmos_phy_cp_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_cp_vars_setup
35 
36  !-----------------------------------------------------------------------------
37  !
38  !++ Public parameters & variables
39  !
40  logical, public :: atmos_phy_cp_restart_output = .false.
41 
42  character(len=H_LONG), public :: atmos_phy_cp_restart_in_basename = ''
43  character(len=H_LONG), public :: atmos_phy_cp_restart_out_basename = ''
44  character(len=H_MID), public :: atmos_phy_cp_restart_out_title = 'ATMOS_PHY_CP restart'
45  character(len=H_MID), public :: atmos_phy_cp_restart_out_dtype = 'DEFAULT'
46 
47  real(RP), public, allocatable :: atmos_phy_cp_momz_t(:,:,:) ! tendency MOMZ [kg/m2/s2]
48  real(RP), public, allocatable :: atmos_phy_cp_momx_t(:,:,:) ! tendency MOMX [kg/m2/s2]
49  real(RP), public, allocatable :: atmos_phy_cp_momy_t(:,:,:) ! tendency MOMY [kg/m2/s2]
50  real(RP), public, allocatable :: atmos_phy_cp_rhot_t(:,:,:) ! tendency RHOT [K*kg/m3/s]
51  real(RP), public, allocatable :: atmos_phy_cp_rhoq_t(:,:,:,:) ! tendency rho*QTRC [kg/kg/s]
52 
53  real(RP), public, allocatable :: atmos_phy_cp_mflx_cloudbase(:,:) ! cloud base mass flux [kg/m2/s]
54 
55  !-----------------------------------------------------------------------------
56  !
57  !++ Private procedure
58  !
59  !-----------------------------------------------------------------------------
60  !
61  !++ Private parameters & variables
62  !
63  integer, private, parameter :: vmax = 1
64  integer, private, parameter :: i_mflx_cloudbase = 1
65 
66  character(len=H_SHORT), private :: var_name(vmax)
67  character(len=H_MID), private :: var_desc(vmax)
68  character(len=H_SHORT), private :: var_unit(vmax)
69 
70  data var_name / 'MFLX_cloudbase' /
71  data var_desc / 'cloud base mass flux' /
72  data var_unit / 'kg/m2/s' /
73 
74  !-----------------------------------------------------------------------------
75 contains
76  !-----------------------------------------------------------------------------
78  subroutine atmos_phy_cp_vars_setup
79  use scale_process, only: &
81  use scale_const, only: &
82  undef => const_undef
83  implicit none
84 
85  namelist / param_atmos_phy_cp_vars / &
91 
92  integer :: ierr
93  integer :: iv
94  !---------------------------------------------------------------------------
95 
96  if( io_l ) write(io_fid_log,*)
97  if( io_l ) write(io_fid_log,*) '++++++ Module[VARS] / Categ[ATMOS PHY_CP] / Origin[SCALE-RM]'
98 
99  allocate( atmos_phy_cp_momz_t(ka,ia,ja) )
100  allocate( atmos_phy_cp_momx_t(ka,ia,ja) )
101  allocate( atmos_phy_cp_momy_t(ka,ia,ja) )
102  allocate( atmos_phy_cp_rhot_t(ka,ia,ja) )
103  allocate( atmos_phy_cp_rhoq_t(ka,ia,ja,qa) )
104  atmos_phy_cp_momz_t(:,:,:) = undef
105  atmos_phy_cp_momx_t(:,:,:) = undef
106  atmos_phy_cp_momy_t(:,:,:) = undef
107  atmos_phy_cp_rhot_t(:,:,:) = undef
108  atmos_phy_cp_rhoq_t(:,:,:,:) = undef
109 
110  allocate( atmos_phy_cp_mflx_cloudbase(ia,ja) )
111  atmos_phy_cp_mflx_cloudbase(:,:) = undef
112 
113  !--- read namelist
114  rewind(io_fid_conf)
115  read(io_fid_conf,nml=param_atmos_phy_cp_vars,iostat=ierr)
116  if( ierr < 0 ) then !--- missing
117  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
118  elseif( ierr > 0 ) then !--- fatal error
119  write(*,*) 'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_CP_VARS. Check!'
120  call prc_mpistop
121  endif
122  if( io_lnml ) write(io_fid_log,nml=param_atmos_phy_cp_vars)
123 
124  if( io_l ) write(io_fid_log,*)
125  if( io_l ) write(io_fid_log,*) '*** [ATMOS_PHY_CP] prognostic/diagnostic variables'
126  if( io_l ) write(io_fid_log,'(1x,A,A15,A,A32,3(A))') &
127  '*** |','VARNAME ','|', 'DESCRIPTION ','[', 'UNIT ',']'
128  do iv = 1, vmax
129  if( io_l ) write(io_fid_log,'(1x,A,i3,A,A15,A,A32,3(A))') &
130  '*** NO.',iv,'|',var_name(iv),'|',var_desc(iv),'[',var_unit(iv),']'
131  enddo
132 
133  if( io_l ) write(io_fid_log,*)
134  if ( atmos_phy_cp_restart_in_basename /= '' ) then
135  if( io_l ) write(io_fid_log,*) '*** Restart input? : ', trim(atmos_phy_cp_restart_in_basename)
136  else
137  if( io_l ) write(io_fid_log,*) '*** Restart input? : NO'
138  endif
140  .AND. atmos_phy_cp_restart_out_basename /= '' ) then
141  if( io_l ) write(io_fid_log,*) '*** Restart output? : ', trim(atmos_phy_cp_restart_out_basename)
142  else
143  if( io_l ) write(io_fid_log,*) '*** Restart output? : NO'
145  endif
146 
147  return
148  end subroutine atmos_phy_cp_vars_setup
149 
150  !-----------------------------------------------------------------------------
152  subroutine atmos_phy_cp_vars_fillhalo
153  use scale_comm, only: &
154  comm_vars8, &
155  comm_wait
156  implicit none
157  !---------------------------------------------------------------------------
158 
159  call comm_vars8( atmos_phy_cp_mflx_cloudbase(:,:), 1 )
160  call comm_wait ( atmos_phy_cp_mflx_cloudbase(:,:), 1 )
161 
162  return
163  end subroutine atmos_phy_cp_vars_fillhalo
164 
165  !-----------------------------------------------------------------------------
168  use scale_fileio, only: &
169  fileio_read
170  use scale_rm_statistics, only: &
171  stat_total
172  implicit none
173 
174  real(RP) :: total
175  !---------------------------------------------------------------------------
176 
177  if( io_l ) write(io_fid_log,*)
178  if( io_l ) write(io_fid_log,*) '*** Input restart file (ATMOS_PHY_CP) ***'
179 
180  if ( atmos_phy_cp_restart_in_basename /= '' ) then
181  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(atmos_phy_cp_restart_in_basename)
182 
183  call fileio_read( atmos_phy_cp_mflx_cloudbase(:,:), & ! [OUT]
184  atmos_phy_cp_restart_in_basename, var_name(1), 'XY', step=1 ) ! [IN]
185 
187 
188  call stat_total( total, atmos_phy_cp_mflx_cloudbase(:,:), var_name(1) )
189  else
190  if( io_l ) write(io_fid_log,*) '*** restart file for ATMOS_PHY_CP is not specified.'
191  endif
192 
193  return
194  end subroutine atmos_phy_cp_vars_restart_read
195 
196  !-----------------------------------------------------------------------------
199  use scale_time, only: &
201  use scale_fileio, only: &
202  fileio_write
203  implicit none
204 
205  character(len=20) :: timelabel
206  character(len=H_LONG) :: basename
207  !---------------------------------------------------------------------------
208 
209  if ( atmos_phy_cp_restart_out_basename /= '' ) then
210 
211  call time_gettimelabel( timelabel )
212  write(basename,'(A,A,A)') trim(atmos_phy_cp_restart_out_basename), '_', trim(timelabel)
213 
214  if( io_l ) write(io_fid_log,*)
215  if( io_l ) write(io_fid_log,*) '*** Output restart file (ATMOS_PHY_CP) ***'
216  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
217 
218  call fileio_write( atmos_phy_cp_mflx_cloudbase(:,:), basename, atmos_phy_cp_restart_out_title, & ! [IN]
219  var_name(1), var_desc(1), var_unit(1), 'XY', atmos_phy_cp_restart_out_dtype ) ! [IN]
220 
221  endif
222 
223  return
224  end subroutine atmos_phy_cp_vars_restart_write
225 
226 end module mod_atmos_phy_cp_vars
real(rp), dimension(:,:,:), allocatable, public atmos_phy_cp_momy_t
module Atmosphere / Physics Cumulus
character(len=h_mid), public atmos_phy_cp_restart_out_title
title of the output file
subroutine, public prc_mpistop
Abort MPI.
real(rp), dimension(:,:,:), allocatable, public atmos_phy_cp_momx_t
character(len=h_long), public atmos_phy_cp_restart_in_basename
basename of the restart file
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:59
subroutine, public atmos_phy_cp_vars_restart_write
Write restart.
logical, public atmos_phy_cp_restart_output
output restart file?
character(len=h_long), public atmos_phy_cp_restart_out_basename
basename of the output file
module STDIO
Definition: scale_stdio.F90:12
integer, public qa
module FILE I/O (netcdf)
real(rp), public const_undef
Definition: scale_const.F90:43
real(rp), dimension(:,:,:,:), allocatable, public atmos_phy_cp_rhoq_t
module Statistics
module grid index
subroutine, public atmos_phy_cp_vars_setup
Setup.
module TRACER
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)
subroutine, public atmos_phy_cp_vars_fillhalo
HALO Communication.
module COMMUNICATION
Definition: scale_comm.F90:23
module TIME
Definition: scale_time.F90:15
real(rp), dimension(:,:,:), allocatable, public atmos_phy_cp_momz_t
module PROCESS
real(rp), dimension(:,:,:), allocatable, public atmos_phy_cp_rhot_t
module CONSTANT
Definition: scale_const.F90:14
module profiler
Definition: scale_prof.F90:10
logical, public io_lnml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:60
module PRECISION
subroutine, public atmos_phy_cp_vars_restart_read
Read restart.
integer, public io_fid_conf
Config file ID.
Definition: scale_stdio.F90:55
real(rp), dimension(:,:), allocatable, public atmos_phy_cp_mflx_cloudbase
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
character(len=h_mid), public atmos_phy_cp_restart_out_dtype
REAL4 or REAL8.
integer, public ja
of y whole cells (local, with HALO)