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 
41 
42  !-----------------------------------------------------------------------------
43  !
44  !++ Public parameters & variables
45  !
46  logical, public :: atmos_phy_ch_restart_output = .false.
47 
48  character(len=H_LONG), public :: atmos_phy_ch_restart_in_basename = ''
49  character(len=H_LONG), public :: atmos_phy_ch_restart_out_basename = ''
50  character(len=H_MID), public :: atmos_phy_ch_restart_out_title = 'ATMOS_PHY_CH restart'
51  character(len=H_MID), public :: atmos_phy_ch_restart_out_dtype = 'DEFAULT'
52 
53  real(RP), public, allocatable :: atmos_phy_ch_rhoq_t(:,:,:,:) ! tendency QTRC [kg/kg/s]
54 
55  real(RP), public, allocatable :: atmos_phy_ch_o3(:,:,:) ! ozone [PPM]
56 
57  !-----------------------------------------------------------------------------
58  !
59  !++ Private procedure
60  !
61  !-----------------------------------------------------------------------------
62  !
63  !++ Private parameters & variables
64  !
65  integer, private, parameter :: vmax = 1
66  integer, private, parameter :: i_o3 = 1
67 
68  character(len=H_SHORT), private :: var_name(vmax)
69  character(len=H_MID), private :: var_desc(vmax)
70  character(len=H_SHORT), private :: var_unit(vmax)
71  integer, private :: var_id(vmax)
72  integer, private :: restart_fid = -1 ! file ID
73 
74  data var_name / 'O3' /
75  data var_desc / 'Ozone' /
76  data var_unit / 'PPM' /
77 
78  !-----------------------------------------------------------------------------
79 contains
80  !-----------------------------------------------------------------------------
82  subroutine atmos_phy_ch_vars_setup
83  use scale_process, only: &
85  use scale_const, only: &
86  undef => const_undef
87  implicit none
88 
89  namelist / param_atmos_phy_ch_vars / &
95 
96  integer :: ierr
97  integer :: iv
98  !---------------------------------------------------------------------------
99 
100  if( io_l ) write(io_fid_log,*)
101  if( io_l ) write(io_fid_log,*) '++++++ Module[VARS] / Categ[ATMOS PHY_CH] / Origin[SCALE-RM]'
102 
103  allocate( atmos_phy_ch_rhoq_t(ka,ia,ja,qa) )
104  atmos_phy_ch_rhoq_t(:,:,:,:) = undef
105 
106  allocate( atmos_phy_ch_o3(ka,ia,ja) )
107  atmos_phy_ch_o3(:,:,:) = undef
108 
109  !--- read namelist
110  rewind(io_fid_conf)
111  read(io_fid_conf,nml=param_atmos_phy_ch_vars,iostat=ierr)
112  if( ierr < 0 ) then !--- missing
113  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
114  elseif( ierr > 0 ) then !--- fatal error
115  write(*,*) 'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_CH_VARS. Check!'
116  call prc_mpistop
117  endif
118  if( io_lnml ) write(io_fid_log,nml=param_atmos_phy_ch_vars)
119 
120  if( io_l ) write(io_fid_log,*)
121  if( io_l ) write(io_fid_log,*) '*** [ATMOS_PHY_CH] prognostic/diagnostic variables'
122  if( io_l ) write(io_fid_log,'(1x,A,A15,A,A32,3(A))') &
123  '*** |','VARNAME ','|', 'DESCRIPTION ','[', 'UNIT ',']'
124  do iv = 1, vmax
125  if( io_l ) write(io_fid_log,'(1x,A,i3,A,A15,A,A32,3(A))') &
126  '*** NO.',iv,'|',var_name(iv),'|',var_desc(iv),'[',var_unit(iv),']'
127  enddo
128 
129  if( io_l ) write(io_fid_log,*)
130  if ( atmos_phy_ch_restart_in_basename /= '' ) then
131  if( io_l ) write(io_fid_log,*) '*** Restart input? : ', trim(atmos_phy_ch_restart_in_basename)
132  else
133  if( io_l ) write(io_fid_log,*) '*** Restart input? : NO'
134  endif
136  .AND. atmos_phy_ch_restart_out_basename /= '' ) then
137  if( io_l ) write(io_fid_log,*) '*** Restart output? : ', trim(atmos_phy_ch_restart_out_basename)
138  else
139  if( io_l ) write(io_fid_log,*) '*** Restart output? : NO'
141  endif
142 
143  return
144  end subroutine atmos_phy_ch_vars_setup
145 
146  !-----------------------------------------------------------------------------
148  subroutine atmos_phy_ch_vars_fillhalo
149  use scale_comm, only: &
150  comm_vars8, &
151  comm_wait
152  implicit none
153 
154  integer :: i, j
155  !---------------------------------------------------------------------------
156 
157  do j = js, je
158  do i = is, ie
159  atmos_phy_ch_o3( 1:ks-1,i,j) = atmos_phy_ch_o3(ks,i,j)
160  atmos_phy_ch_o3(ke+1:ka, i,j) = atmos_phy_ch_o3(ke,i,j)
161  enddo
162  enddo
163 
164  call comm_vars8( atmos_phy_ch_o3(:,:,:), 1 )
165  call comm_wait ( atmos_phy_ch_o3(:,:,:), 1 )
166 
167  return
168  end subroutine atmos_phy_ch_vars_fillhalo
169 
170  !-----------------------------------------------------------------------------
173  use scale_fileio, only: &
174  fileio_read
175  use scale_rm_statistics, only: &
176  stat_total
177  implicit none
178 
179  real(RP) :: total
180  !---------------------------------------------------------------------------
181 
182  if( io_l ) write(io_fid_log,*)
183  if( io_l ) write(io_fid_log,*) '*** Input restart file (ATMOS_PHY_CH) ***'
184 
185  if ( atmos_phy_ch_restart_in_basename /= '' ) then
186  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(atmos_phy_ch_restart_in_basename)
187 
188  call fileio_read( atmos_phy_ch_o3(:,:,:), & ! [OUT]
189  atmos_phy_ch_restart_in_basename, var_name(1), 'ZXY', step=1 ) ! [IN]
190 
192 
193  call stat_total( total, atmos_phy_ch_o3(:,:,:), var_name(1) )
194  else
195  if( io_l ) write(io_fid_log,*) '*** restart file for ATMOS_PHY_CH is not specified.'
196  endif
197 
198  return
199  end subroutine atmos_phy_ch_vars_restart_read
200 
201  !-----------------------------------------------------------------------------
204  use scale_time, only: &
206  use scale_fileio, only: &
207  fileio_write
208  implicit none
209 
210  character(len=20) :: timelabel
211  character(len=H_LONG) :: basename
212  !---------------------------------------------------------------------------
213 
214  if ( atmos_phy_ch_restart_out_basename /= '' ) then
215 
216  call time_gettimelabel( timelabel )
217  write(basename,'(A,A,A)') trim(atmos_phy_ch_restart_out_basename), '_', trim(timelabel)
218 
219  if( io_l ) write(io_fid_log,*)
220  if( io_l ) write(io_fid_log,*) '*** Output restart file (ATMOS_PHY_CH) ***'
221  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
222 
223  call fileio_write( atmos_phy_ch_o3(:,:,:), basename, atmos_phy_ch_restart_out_title, & ! [IN]
224  var_name(1), var_desc(1), var_unit(1), 'ZXY', atmos_phy_ch_restart_out_dtype ) ! [IN]
225 
226  endif
227 
228  return
229  end subroutine atmos_phy_ch_vars_restart_write
230 
231  !-----------------------------------------------------------------------------
234  use scale_time, only: &
236  use scale_fileio, only: &
238  implicit none
239 
240  character(len=20) :: timelabel
241  character(len=H_LONG) :: basename
242  !---------------------------------------------------------------------------
243 
244  if ( atmos_phy_ch_restart_out_basename /= '' ) then
245 
246  call time_gettimelabel( timelabel )
247  write(basename,'(A,A,A)') trim(atmos_phy_ch_restart_out_basename), '_', trim(timelabel)
248 
249  if( io_l ) write(io_fid_log,*)
250  if( io_l ) write(io_fid_log,*) '*** Output restart file (ATMOS_PHY_CH) ***'
251  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
252 
253  call fileio_create(restart_fid, basename, atmos_phy_ch_restart_out_title, &
255 
256  endif
257 
258  return
259  end subroutine atmos_phy_ch_vars_restart_create
260 
261  !-----------------------------------------------------------------------------
264  use scale_fileio, only: &
266  implicit none
267 
268  if ( restart_fid .NE. -1 ) then
269  call fileio_enddef( restart_fid ) ! [IN]
270  endif
271 
272  return
273  end subroutine atmos_phy_ch_vars_restart_enddef
274 
275  !-----------------------------------------------------------------------------
278  use scale_fileio, only: &
280  implicit none
281 
282  if ( restart_fid .NE. -1 ) then
283  call fileio_close( restart_fid ) ! [IN]
284  restart_fid = -1
285  endif
286 
287  return
288  end subroutine atmos_phy_ch_vars_restart_close
289 
290  !-----------------------------------------------------------------------------
293  use scale_fileio, only: &
295  implicit none
296 
297  !---------------------------------------------------------------------------
298 
299  if ( restart_fid .NE. -1 ) then
300  call fileio_def_var( restart_fid, var_id(1), var_name(1), var_desc(1), &
301  var_unit(1), 'ZXY', atmos_phy_ch_restart_out_dtype ) ! [IN]
302  endif
303 
304  return
305  end subroutine atmos_phy_ch_vars_restart_def_var
306 
307  !-----------------------------------------------------------------------------
310  use scale_fileio, only: &
311  fileio_write_var
312  implicit none
313 
314  !---------------------------------------------------------------------------
315 
316  if ( restart_fid .NE. -1 ) then
317  call fileio_write_var( restart_fid, var_id(1), atmos_phy_ch_o3(:,:,:), &
318  var_name(1), 'ZXY' ) ! [IN]
319  endif
320 
321  return
323 
324 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.
subroutine, public atmos_phy_ch_vars_restart_close
Close restart file.
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:59
module STDIO
Definition: scale_stdio.F90:12
subroutine, public atmos_phy_ch_vars_restart_enddef
Exit netCDF define mode.
subroutine, public atmos_phy_ch_vars_restart_def_var
Write restart.
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
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
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
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
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
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
subroutine, public atmos_phy_ch_vars_restart_write_var
Write restart.
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.
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_ch_vars_restart_create
Create restart file.
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)