SCALE-RM
mod_atmos_phy_ch_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_ch_vars_setup
35 
36  !-----------------------------------------------------------------------------
37  !
38  !++ Public parameters & variables
39  !
40  logical, public :: atmos_phy_ch_restart_output = .false.
41 
42  character(len=H_LONG), public :: atmos_phy_ch_restart_in_basename = ''
43  character(len=H_LONG), public :: atmos_phy_ch_restart_out_basename = ''
44  character(len=H_MID), public :: atmos_phy_ch_restart_out_title = 'ATMOS_PHY_CH restart'
45  character(len=H_MID), public :: atmos_phy_ch_restart_out_dtype = 'DEFAULT'
46 
47  real(RP), public, allocatable :: atmos_phy_ch_rhoq_t(:,:,:,:) ! tendency QTRC [kg/kg/s]
48 
49  real(RP), public, allocatable :: atmos_phy_ch_o3(:,:,:) ! ozone [PPM]
50 
51  !-----------------------------------------------------------------------------
52  !
53  !++ Private procedure
54  !
55  !-----------------------------------------------------------------------------
56  !
57  !++ Private parameters & variables
58  !
59  integer, private, parameter :: vmax = 1
60  integer, private, parameter :: i_o3 = 1
61 
62  character(len=H_SHORT), private :: var_name(vmax)
63  character(len=H_MID), private :: var_desc(vmax)
64  character(len=H_SHORT), private :: var_unit(vmax)
65 
66  data var_name / 'O3' /
67  data var_desc / 'Ozone' /
68  data var_unit / 'PPM' /
69 
70  !-----------------------------------------------------------------------------
71 contains
72  !-----------------------------------------------------------------------------
74  subroutine atmos_phy_ch_vars_setup
75  use scale_process, only: &
77  use scale_const, only: &
78  undef => const_undef
79  implicit none
80 
81  namelist / param_atmos_phy_ch_vars / &
87 
88  integer :: ierr
89  integer :: iv
90  !---------------------------------------------------------------------------
91 
92  if( io_l ) write(io_fid_log,*)
93  if( io_l ) write(io_fid_log,*) '++++++ Module[VARS] / Categ[ATMOS PHY_CH] / Origin[SCALE-RM]'
94 
95  allocate( atmos_phy_ch_rhoq_t(ka,ia,ja,qa) )
96  atmos_phy_ch_rhoq_t(:,:,:,:) = undef
97 
98  allocate( atmos_phy_ch_o3(ka,ia,ja) )
99  atmos_phy_ch_o3(:,:,:) = undef
100 
101  !--- read namelist
102  rewind(io_fid_conf)
103  read(io_fid_conf,nml=param_atmos_phy_ch_vars,iostat=ierr)
104  if( ierr < 0 ) then !--- missing
105  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
106  elseif( ierr > 0 ) then !--- fatal error
107  write(*,*) 'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_CH_VARS. Check!'
108  call prc_mpistop
109  endif
110  if( io_lnml ) write(io_fid_log,nml=param_atmos_phy_ch_vars)
111 
112  if( io_l ) write(io_fid_log,*)
113  if( io_l ) write(io_fid_log,*) '*** [ATMOS_PHY_CH] prognostic/diagnostic variables'
114  if( io_l ) write(io_fid_log,'(1x,A,A15,A,A32,3(A))') &
115  '*** |','VARNAME ','|', 'DESCRIPTION ','[', 'UNIT ',']'
116  do iv = 1, vmax
117  if( io_l ) write(io_fid_log,'(1x,A,i3,A,A15,A,A32,3(A))') &
118  '*** NO.',iv,'|',var_name(iv),'|',var_desc(iv),'[',var_unit(iv),']'
119  enddo
120 
121  if( io_l ) write(io_fid_log,*)
122  if ( atmos_phy_ch_restart_in_basename /= '' ) then
123  if( io_l ) write(io_fid_log,*) '*** Restart input? : ', trim(atmos_phy_ch_restart_in_basename)
124  else
125  if( io_l ) write(io_fid_log,*) '*** Restart input? : NO'
126  endif
128  .AND. atmos_phy_ch_restart_out_basename /= '' ) then
129  if( io_l ) write(io_fid_log,*) '*** Restart output? : ', trim(atmos_phy_ch_restart_out_basename)
130  else
131  if( io_l ) write(io_fid_log,*) '*** Restart output? : NO'
133  endif
134 
135  return
136  end subroutine atmos_phy_ch_vars_setup
137 
138  !-----------------------------------------------------------------------------
140  subroutine atmos_phy_ch_vars_fillhalo
141  use scale_comm, only: &
142  comm_vars8, &
143  comm_wait
144  implicit none
145 
146  integer :: i, j
147  !---------------------------------------------------------------------------
148 
149  do j = js, je
150  do i = is, ie
151  atmos_phy_ch_o3( 1:ks-1,i,j) = atmos_phy_ch_o3(ks,i,j)
152  atmos_phy_ch_o3(ke+1:ka, i,j) = atmos_phy_ch_o3(ke,i,j)
153  enddo
154  enddo
155 
156  call comm_vars8( atmos_phy_ch_o3(:,:,:), 1 )
157  call comm_wait ( atmos_phy_ch_o3(:,:,:), 1 )
158 
159  return
160  end subroutine atmos_phy_ch_vars_fillhalo
161 
162  !-----------------------------------------------------------------------------
165  use scale_fileio, only: &
166  fileio_read
167  use scale_rm_statistics, only: &
168  stat_total
169  implicit none
170 
171  real(RP) :: total
172  !---------------------------------------------------------------------------
173 
174  if( io_l ) write(io_fid_log,*)
175  if( io_l ) write(io_fid_log,*) '*** Input restart file (ATMOS_PHY_CH) ***'
176 
177  if ( atmos_phy_ch_restart_in_basename /= '' ) then
178  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(atmos_phy_ch_restart_in_basename)
179 
180  call fileio_read( atmos_phy_ch_o3(:,:,:), & ! [OUT]
181  atmos_phy_ch_restart_in_basename, var_name(1), 'ZXY', step=1 ) ! [IN]
182 
184 
185  call stat_total( total, atmos_phy_ch_o3(:,:,:), var_name(1) )
186  else
187  if( io_l ) write(io_fid_log,*) '*** restart file for ATMOS_PHY_CH is not specified.'
188  endif
189 
190  return
191  end subroutine atmos_phy_ch_vars_restart_read
192 
193  !-----------------------------------------------------------------------------
196  use scale_time, only: &
198  use scale_fileio, only: &
199  fileio_write
200  implicit none
201 
202  character(len=20) :: timelabel
203  character(len=H_LONG) :: basename
204  !---------------------------------------------------------------------------
205 
206  if ( atmos_phy_ch_restart_out_basename /= '' ) then
207 
208  call time_gettimelabel( timelabel )
209  write(basename,'(A,A,A)') trim(atmos_phy_ch_restart_out_basename), '_', trim(timelabel)
210 
211  if( io_l ) write(io_fid_log,*)
212  if( io_l ) write(io_fid_log,*) '*** Output restart file (ATMOS_PHY_CH) ***'
213  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
214 
215  call fileio_write( atmos_phy_ch_o3(:,:,:), basename, atmos_phy_ch_restart_out_title, & ! [IN]
216  var_name(1), var_desc(1), var_unit(1), 'ZXY', atmos_phy_ch_restart_out_dtype ) ! [IN]
217 
218  endif
219 
220  return
221  end subroutine atmos_phy_ch_vars_restart_write
222 
223 end module mod_atmos_phy_ch_vars
integer, public is
start point of inner domain: x, local
character(len=h_mid), public atmos_phy_ch_restart_out_title
title of the output file
integer, public je
end point of inner domain: y, local
subroutine, public atmos_phy_ch_vars_setup
Setup.
subroutine, public prc_mpistop
Abort MPI.
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:59
module STDIO
Definition: scale_stdio.F90:12
integer, public ke
end point of inner domain: z, local
integer, public qa
real(rp), dimension(:,:,:), allocatable, public atmos_phy_ch_o3
module FILE I/O (netcdf)
real(rp), public const_undef
Definition: scale_const.F90:43
module Statistics
module grid index
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
subroutine, public atmos_phy_ch_vars_fillhalo
HALO Communication.
integer, public ka
of z whole cells (local, with HALO)
logical, public atmos_phy_ch_restart_output
output restart file?
character(len=h_long), public atmos_phy_ch_restart_out_basename
basename of the output 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
character(len=h_mid), public atmos_phy_ch_restart_out_dtype
REAL4 or REAL8.
module CONSTANT
Definition: scale_const.F90:14
integer, public ks
start point of inner domain: z, local
real(rp), dimension(:,:,:,:), allocatable, public atmos_phy_ch_rhoq_t
module Atmosphere / Physics Chemistry
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_ch_vars_restart_write
Write restart.
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
subroutine, public atmos_phy_ch_vars_restart_read
Read restart.
character(len=h_long), public atmos_phy_ch_restart_in_basename
basename of the restart file
integer, public ja
of y whole cells (local, with HALO)