SCALE-RM
mod_atmos_phy_ae_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_ae_vars_setup
35 
41 
42  !-----------------------------------------------------------------------------
43  !
44  !++ Public parameters & variables
45  !
46  logical, public :: atmos_phy_ae_restart_output = .false.
47 
48  character(len=H_LONG), public :: atmos_phy_ae_restart_in_basename = ''
49  character(len=H_LONG), public :: atmos_phy_ae_restart_out_basename = ''
50  character(len=H_MID), public :: atmos_phy_ae_restart_out_title = 'ATMOS_PHY_AE restart'
51  character(len=H_MID), public :: atmos_phy_ae_restart_out_dtype = 'DEFAULT'
52 
53  real(RP), public, allocatable :: atmos_phy_ae_rhoq_t(:,:,:,:) ! tendency rho*QTRC [kg/kg/s]
54 
55  real(RP), public, allocatable :: atmos_phy_ae_ccn(:,:,:) ! cloud condensation nuclei [/m3]
56  real(RP), public, allocatable :: atmos_phy_ae_ccn_t(:,:,:) ! tendency CCN [/m3/s]
57  real(RP), public, allocatable :: atmos_phy_ae_emit(:,:,:,:) ! emission of aerosol and gas
58  !-----------------------------------------------------------------------------
59  !
60  !++ Private procedure
61  !
62  !-----------------------------------------------------------------------------
63  !
64  !++ Private parameters & variables
65  !
66  integer, private, parameter :: vmax = 1
67  integer, private, parameter :: i_ccn = 1
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  integer, private :: var_id(vmax)
73  integer, private :: restart_fid = -1 ! file ID
74 
75  data var_name / 'CCN' /
76  data var_desc / 'cloud condensation nuclei' /
77  data var_unit / 'num/m3' /
78 
79  !-----------------------------------------------------------------------------
80 contains
81  !-----------------------------------------------------------------------------
83  subroutine atmos_phy_ae_vars_setup
84  use scale_process, only: &
86  use scale_const, only: &
87  undef => const_undef
88  implicit none
89 
90  namelist / param_atmos_phy_ae_vars / &
96 
97  integer :: ierr
98  integer :: iv
99  !---------------------------------------------------------------------------
100 
101  if( io_l ) write(io_fid_log,*)
102  if( io_l ) write(io_fid_log,*) '++++++ Module[VARS] / Categ[ATMOS PHY_AE] / Origin[SCALE-RM]'
103 
104  allocate( atmos_phy_ae_rhoq_t(ka,ia,ja,qa) )
105  atmos_phy_ae_rhoq_t(:,:,:, :) = undef
106 
107  allocate( atmos_phy_ae_ccn(ka,ia,ja) )
108  atmos_phy_ae_ccn(:,:,:) = undef
109 
110  allocate( atmos_phy_ae_ccn_t(ka,ia,ja) )
111  atmos_phy_ae_ccn_t(:,:,:) = undef
112 
113  allocate( atmos_phy_ae_emit(ka,ia,ja,qa_ae) )
114  atmos_phy_ae_emit(:,:,:,:) = 0.0_rp
115 
116  !--- read namelist
117  rewind(io_fid_conf)
118  read(io_fid_conf,nml=param_atmos_phy_ae_vars,iostat=ierr)
119  if( ierr < 0 ) then !--- missing
120  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
121  elseif( ierr > 0 ) then !--- fatal error
122  write(*,*) 'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_AE_VARS. Check!'
123  call prc_mpistop
124  endif
125  if( io_lnml ) write(io_fid_log,nml=param_atmos_phy_ae_vars)
126 
127  if( io_l ) write(io_fid_log,*)
128  if( io_l ) write(io_fid_log,*) '*** [ATMOS_PHY_AE] prognostic/diagnostic variables'
129  if( io_l ) write(io_fid_log,'(1x,A,A15,A,A32,3(A))') &
130  '*** |','VARNAME ','|', 'DESCRIPTION ','[', 'UNIT ',']'
131  do iv = 1, vmax
132  if( io_l ) write(io_fid_log,'(1x,A,i3,A,A15,A,A32,3(A))') &
133  '*** NO.',iv,'|',var_name(iv),'|',var_desc(iv),'[',var_unit(iv),']'
134  enddo
135 
136  if( io_l ) write(io_fid_log,*)
137  if ( atmos_phy_ae_restart_in_basename /= '' ) then
138  if( io_l ) write(io_fid_log,*) '*** Restart input? : ', trim(atmos_phy_ae_restart_in_basename)
139  else
140  if( io_l ) write(io_fid_log,*) '*** Restart input? : NO'
141  endif
143  .AND. atmos_phy_ae_restart_out_basename /= '' ) then
144  if( io_l ) write(io_fid_log,*) '*** Restart output? : ', trim(atmos_phy_ae_restart_out_basename)
145  else
146  if( io_l ) write(io_fid_log,*) '*** Restart output? : NO'
148  endif
149 
150  return
151  end subroutine atmos_phy_ae_vars_setup
152 
153  !-----------------------------------------------------------------------------
155  subroutine atmos_phy_ae_vars_fillhalo
156  use scale_comm, only: &
157  comm_vars8, &
158  comm_wait
159  implicit none
160 
161  integer :: i, j
162  !---------------------------------------------------------------------------
163 
164  do j = js, je
165  do i = is, ie
166  atmos_phy_ae_ccn( 1:ks-1,i,j) = atmos_phy_ae_ccn(ks,i,j)
167  atmos_phy_ae_ccn(ke+1:ka, i,j) = atmos_phy_ae_ccn(ke,i,j)
168  enddo
169  enddo
170 
171  call comm_vars8( atmos_phy_ae_ccn(:,:,:), 1 )
172  call comm_wait ( atmos_phy_ae_ccn(:,:,:), 1 )
173 
174  return
175  end subroutine atmos_phy_ae_vars_fillhalo
176 
177  !-----------------------------------------------------------------------------
180  use scale_fileio, only: &
181  fileio_read
182  use scale_rm_statistics, only: &
183  stat_total
184  implicit none
185 
186  real(RP) :: total
187  !---------------------------------------------------------------------------
188 
189  if( io_l ) write(io_fid_log,*)
190  if( io_l ) write(io_fid_log,*) '*** Input restart file (ATMOS_PHY_AE) ***'
191 
192  if ( atmos_phy_ae_restart_in_basename /= '' ) then
193  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(atmos_phy_ae_restart_in_basename)
194 
195  call fileio_read( atmos_phy_ae_ccn(:,:,:), & ! [OUT]
196  atmos_phy_ae_restart_in_basename, var_name(1), 'ZXY', step=1 ) ! [IN]
197 
199 
200  call stat_total( total, atmos_phy_ae_ccn(:,:,:), var_name(1) )
201  else
202  if( io_l ) write(io_fid_log,*) '*** restart file for ATMOS_PHY_AE is not specified.'
203  endif
204 
205  return
206  end subroutine atmos_phy_ae_vars_restart_read
207 
208  !-----------------------------------------------------------------------------
211  use scale_time, only: &
213  use scale_fileio, only: &
214  fileio_write
215  implicit none
216 
217  character(len=20) :: timelabel
218  character(len=H_LONG) :: basename
219  !---------------------------------------------------------------------------
220 
221  if ( atmos_phy_ae_restart_out_basename /= '' ) then
222 
223  call time_gettimelabel( timelabel )
224  write(basename,'(A,A,A)') trim(atmos_phy_ae_restart_out_basename), '_', trim(timelabel)
225 
226  if( io_l ) write(io_fid_log,*)
227  if( io_l ) write(io_fid_log,*) '*** Output restart file (ATMOS_PHY_AE) ***'
228  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
229 
230  call fileio_write( atmos_phy_ae_ccn(:,:,:), basename, atmos_phy_ae_restart_out_title, & ! [IN]
231  var_name(1), var_desc(1), var_unit(1), 'ZXY', atmos_phy_ae_restart_out_dtype ) ! [IN]
232 
233  endif
234 
235  return
236  end subroutine atmos_phy_ae_vars_restart_write
237 
238  !-----------------------------------------------------------------------------
241  use scale_time, only: &
243  use scale_fileio, only: &
245  implicit none
246 
247  character(len=20) :: timelabel
248  character(len=H_LONG) :: basename
249  !---------------------------------------------------------------------------
250 
251  if ( atmos_phy_ae_restart_out_basename /= '' ) then
252 
253  call time_gettimelabel( timelabel )
254  write(basename,'(A,A,A)') trim(atmos_phy_ae_restart_out_basename), '_', trim(timelabel)
255 
256  if( io_l ) write(io_fid_log,*)
257  if( io_l ) write(io_fid_log,*) '*** Output restart file (ATMOS_PHY_AE) ***'
258  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
259 
260  call fileio_create(restart_fid, basename, atmos_phy_ae_restart_out_title, & ! [IN]
262 
263  endif
264 
265  return
266  end subroutine atmos_phy_ae_vars_restart_create
267 
268  !-----------------------------------------------------------------------------
271  use scale_fileio, only: &
273  implicit none
274 
275  if ( restart_fid .NE. -1 ) then
276  call fileio_enddef( restart_fid ) ! [IN]
277  endif
278 
279  return
280  end subroutine atmos_phy_ae_vars_restart_enddef
281 
282  !-----------------------------------------------------------------------------
285  use scale_fileio, only: &
287  implicit none
288 
289  if ( restart_fid .NE. -1 ) then
290  call fileio_close( restart_fid ) ! [IN]
291  restart_fid = -1
292  endif
293 
294  return
295  end subroutine atmos_phy_ae_vars_restart_close
296 
297  !-----------------------------------------------------------------------------
300  use scale_fileio, only: &
302  implicit none
303 
304  !---------------------------------------------------------------------------
305 
306  if ( restart_fid .NE. -1 ) then
307  call fileio_def_var( restart_fid, var_id(1), var_name(1), var_desc(1), var_unit(1), &
308  'ZXY', atmos_phy_ae_restart_out_dtype ) ! [IN]
309  endif
310 
311  return
312  end subroutine atmos_phy_ae_vars_restart_def_var
313 
314  !-----------------------------------------------------------------------------
317  use scale_fileio, only: &
318  fileio_write_var
319  implicit none
320 
321  !---------------------------------------------------------------------------
322 
323  if ( restart_fid .NE. -1 ) then
324  call fileio_write_var( restart_fid, var_id(1), atmos_phy_ae_ccn(:,:,:), &
325  var_name(1), 'ZXY' ) ! [IN]
326  endif
327 
328  return
330 
331 end module mod_atmos_phy_ae_vars
character(len=h_long), public atmos_phy_ae_restart_in_basename
basename of the restart file
integer, public is
start point of inner domain: x, local
subroutine, public atmos_phy_ae_vars_restart_create
Create restart file.
subroutine, public atmos_phy_ae_vars_fillhalo
HALO Communication.
integer, public je
end point of inner domain: y, local
integer, public qa_ae
subroutine, public prc_mpistop
Abort MPI.
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:59
logical, public atmos_phy_ae_restart_output
output restart file?
module STDIO
Definition: scale_stdio.F90:12
integer, public ke
end point of inner domain: z, local
integer, public qa
module FILE I/O (netcdf)
real(rp), public const_undef
Definition: scale_const.F90:43
module Statistics
module grid index
module TRACER
subroutine, public fileio_def_var(fid, vid, varname, desc, unit, axistype, datatype, timeintv)
Define a variable to file.
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)
real(rp), dimension(:,:,:,:), allocatable, public atmos_phy_ae_emit
subroutine, public fileio_create(fid, basename, title, datatype, date, subsec, append, nozcoord)
Create/open a netCDF file.
module COMMUNICATION
Definition: scale_comm.F90:23
integer, public js
start point of inner domain: y, local
module TIME
Definition: scale_time.F90:15
module PROCESS
real(rp), dimension(:,:,:,:), allocatable, public atmos_phy_ae_rhoq_t
real(rp), dimension(:,:,:), allocatable, public atmos_phy_ae_ccn
character(len=h_mid), public atmos_phy_ae_restart_out_title
title of the output file
character(len=h_mid), public atmos_phy_ae_restart_out_dtype
REAL4 or REAL8.
subroutine, public atmos_phy_ae_vars_restart_enddef
Exit netCDF define mode.
module CONSTANT
Definition: scale_const.F90:14
integer, public ks
start point of inner domain: z, local
subroutine, public atmos_phy_ae_vars_setup
Setup.
subroutine, public atmos_phy_ae_vars_restart_read
Read restart.
subroutine, public fileio_enddef(fid)
Exit netCDF file define mode.
module profiler
Definition: scale_prof.F90:10
integer, public ie
end point of inner domain: x, local
logical, public io_lnml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:60
module PRECISION
subroutine, public atmos_phy_ae_vars_restart_def_var
Write restart.
subroutine, public atmos_phy_ae_vars_restart_write
Write restart.
subroutine, public fileio_close(fid)
Close a netCDF file.
integer, public io_fid_conf
Config file ID.
Definition: scale_stdio.F90:55
subroutine, public atmos_phy_ae_vars_restart_write_var
Write restart.
subroutine, public atmos_phy_ae_vars_restart_close
Close restart file.
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
character(len=h_long), public atmos_phy_ae_restart_out_basename
basename of the output file
module ATMOSPHERE / Physics Aerosol Microphysics
real(rp), dimension(:,:,:), allocatable, public atmos_phy_ae_ccn_t
integer, public ja
of y whole cells (local, with HALO)