SCALE-RM
mod_atmos_phy_ch_vars.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
10 !-------------------------------------------------------------------------------
11 #include "scalelib.h"
13  !-----------------------------------------------------------------------------
14  !
15  !++ used modules
16  !
17  use scale_precision
18  use scale_io
19  use scale_prof
20  use scale_debug
22  use scale_tracer
23  !-----------------------------------------------------------------------------
24  implicit none
25  private
26  !-----------------------------------------------------------------------------
27  !
28  !++ Public procedure
29  !
30  public :: atmos_phy_ch_vars_setup
34 
40 
41  !-----------------------------------------------------------------------------
42  !
43  !++ Public parameters & variables
44  !
45  logical, public :: atmos_phy_ch_restart_output = .false.
46 
47  character(len=H_LONG), public :: atmos_phy_ch_restart_in_basename = ''
49  logical, public :: atmos_phy_ch_restart_in_postfix_timelabel = .false.
50  character(len=H_LONG), public :: atmos_phy_ch_restart_out_basename = ''
52  logical, public :: atmos_phy_ch_restart_out_postfix_timelabel = .true.
53  character(len=H_MID), public :: atmos_phy_ch_restart_out_title = 'ATMOS_PHY_CH restart'
54  character(len=H_SHORT), public :: atmos_phy_ch_restart_out_dtype = 'DEFAULT'
55 
56  real(rp), public, allocatable :: atmos_phy_ch_rhoq_t(:,:,:,:) ! tendency QTRC [kg/kg/s]
57 
58  real(rp), public, allocatable :: atmos_phy_ch_o3(:,:,:) ! ozone [PPM]
59 
60  integer, public :: qa_ch = 0
61  integer, public :: qs_ch = -1
62  integer, public :: qe_ch = -2
63 
64  !-----------------------------------------------------------------------------
65  !
66  !++ Private procedure
67  !
68  !-----------------------------------------------------------------------------
69  !
70  !++ Private parameters & variables
71  !
72  integer, private, parameter :: vmax = 1
73  integer, private, parameter :: i_o3 = 1
74 
75  character(len=H_SHORT), private :: var_name(vmax)
76  character(len=H_MID), private :: var_desc(vmax)
77  character(len=H_SHORT), private :: var_unit(vmax)
78  integer, private :: var_id(vmax)
79  integer, private :: restart_fid = -1 ! file ID
80 
81  data var_name / 'O3' /
82  data var_desc / 'Ozone' /
83  data var_unit / 'PPM' /
84 
85  !-----------------------------------------------------------------------------
86 contains
87  !-----------------------------------------------------------------------------
89  subroutine atmos_phy_ch_vars_setup
90  use scale_prc, only: &
91  prc_abort
92  use scale_const, only: &
93  undef => const_undef
94  implicit none
95 
96  namelist / param_atmos_phy_ch_vars / &
106 
107  integer :: ierr
108  integer :: iv
109  !---------------------------------------------------------------------------
110 
111  log_newline
112  log_info("ATMOS_PHY_CH_vars_setup",*) 'Setup'
113 
114  allocate( atmos_phy_ch_rhoq_t(ka,ia,ja,qs_ch:qe_ch) )
115  atmos_phy_ch_rhoq_t(:,:,:,:) = undef
116 
117 !!$ allocate( ATMOS_PHY_CH_O3(KA,IA,JA) )
118 !!$ ATMOS_PHY_CH_O3(:,:,:) = UNDEF
119 
120  !--- read namelist
121  rewind(io_fid_conf)
122  read(io_fid_conf,nml=param_atmos_phy_ch_vars,iostat=ierr)
123  if( ierr < 0 ) then !--- missing
124  log_info("ATMOS_PHY_CH_vars_setup",*) 'Not found namelist. Default used.'
125  elseif( ierr > 0 ) then !--- fatal error
126  log_error("ATMOS_PHY_CH_vars_setup",*) 'Not appropriate names in namelist PARAM_ATMOS_PHY_CH_VARS. Check!'
127  call prc_abort
128  endif
129  log_nml(param_atmos_phy_ch_vars)
130 
131  log_newline
132  log_info("ATMOS_PHY_CH_vars_setup",*) '[ATMOS_PHY_CH] prognostic/diagnostic variables'
133  log_info_cont('(1x,A,A24,A,A48,A,A12,A)') &
134  ' |', 'VARNAME ','|', &
135  'DESCRIPTION ', '[', 'UNIT ', ']'
136  do iv = 1, vmax
137  log_info_cont('(1x,A,I3,A,A24,A,A48,A,A12,A)') &
138  'NO.',iv,'|',var_name(iv),'|',var_desc(iv),'[',var_unit(iv),']'
139  enddo
140 
141  log_newline
142  if ( atmos_phy_ch_restart_in_basename /= '' ) then
143  log_info("ATMOS_PHY_CH_vars_setup",*) 'Restart input? : YES, file = ', trim(atmos_phy_ch_restart_in_basename)
144  log_info("ATMOS_PHY_CH_vars_setup",*) 'Add timelabel? : ', atmos_phy_ch_restart_in_postfix_timelabel
145  else
146  log_info("ATMOS_PHY_CH_vars_setup",*) 'Restart input? : NO'
147  endif
149  .AND. atmos_phy_ch_restart_out_basename /= '' ) then
150  log_info("ATMOS_PHY_CH_vars_setup",*) 'Restart output? : YES, file = ', trim(atmos_phy_ch_restart_out_basename)
151  log_info("ATMOS_PHY_CH_vars_setup",*) 'Add timelabel? : ', atmos_phy_ch_restart_out_postfix_timelabel
152  else
153  log_info("ATMOS_PHY_CH_vars_setup",*) 'Restart output? : NO'
155  endif
156 
157  return
158  end subroutine atmos_phy_ch_vars_setup
159 
160  !-----------------------------------------------------------------------------
162  subroutine atmos_phy_ch_vars_fillhalo
163  use scale_comm_cartesc, only: &
164  comm_vars8, &
165  comm_wait
166  implicit none
167 
168  integer :: i, j
169  !---------------------------------------------------------------------------
170 
171 !!$ do j = JS, JE
172 !!$ do i = IS, IE
173 !!$ ATMOS_PHY_CH_O3( 1:KS-1,i,j) = ATMOS_PHY_CH_O3(KS,i,j)
174 !!$ ATMOS_PHY_CH_O3(KE+1:KA, i,j) = ATMOS_PHY_CH_O3(KE,i,j)
175 !!$ enddo
176 !!$ enddo
177 !!$
178 !!$ call COMM_vars8( ATMOS_PHY_CH_O3(:,:,:), 1 )
179 !!$ call COMM_wait ( ATMOS_PHY_CH_O3(:,:,:), 1 )
180 
181  return
182  end subroutine atmos_phy_ch_vars_fillhalo
183 
184  !-----------------------------------------------------------------------------
187  use scale_time, only: &
189  use scale_file_cartesc, only: &
191  implicit none
192 
193  character(len=19) :: timelabel
194  character(len=H_LONG) :: basename
195  !---------------------------------------------------------------------------
196 
197  log_newline
198  log_info("ATMOS_PHY_CH_vars_restart_open",*) 'Open restart file (ATMOS_PHY_CH) '
199 
200  if ( atmos_phy_ch_restart_in_basename /= '' ) then
201 
203  call time_gettimelabel( timelabel )
204  basename = trim(atmos_phy_ch_restart_in_basename)//'_'//trim(timelabel)
205  else
206  basename = trim(atmos_phy_ch_restart_in_basename)
207  endif
208 
209  log_info("ATMOS_PHY_CH_vars_restart_open",*) 'basename: ', trim(basename)
210 
211  call file_cartesc_open( basename, restart_fid, aggregate=atmos_phy_ch_restart_in_aggregate )
212  else
213  log_info("ATMOS_PHY_CH_vars_restart_open",*) 'restart file for ATMOS_PHY_CH is not specified.'
214  endif
215 
216  return
217  end subroutine atmos_phy_ch_vars_restart_open
218 
219  !-----------------------------------------------------------------------------
222  use scale_file, only: &
224  use scale_file_cartesc, only: &
225  file_cartesc_read, &
227  implicit none
228 
229  integer :: i, j
230  !---------------------------------------------------------------------------
231 
232  if ( restart_fid /= -1 ) then
233  log_newline
234  log_info("ATMOS_PHY_CH_vars_restart_read",*) 'Read from restart file (ATMOS_PHY_CH) '
235 
236 !!$ call FILE_CARTESC_read( restart_fid, VAR_NAME(1), 'ZXY', & ! [IN]
237 !!$ ATMOS_PHY_CH_O3(:,:,:) ) ! [OUT]
238 !!$
239 !!$ if ( FILE_get_aggregate( restart_fid) ) then
240 !!$ call FILE_CARTESC_flush( restart_fid ) ! X/Y halos have been read from file
241 !!$
242 !!$ ! fill K halos
243 !!$ do j = 1, JA
244 !!$ do i = 1, IA
245 !!$ ATMOS_PHY_CH_O3( 1:KS-1,i,j) = ATMOS_PHY_CH_O3(KS,i,j)
246 !!$ ATMOS_PHY_CH_O3(KE+1:KA, i,j) = ATMOS_PHY_CH_O3(KE,i,j)
247 !!$ enddo
248 !!$ enddo
249 !!$ else
250 !!$ call ATMOS_PHY_CH_vars_fillhalo
251 !!$ end if
252 
254 
255  else
256  log_info("ATMOS_PHY_CH_vars_restart_read",*) 'invalid restart file for ATMOS_PHY_CH.'
257  endif
258 
259  return
260  end subroutine atmos_phy_ch_vars_restart_read
261 
262  !-----------------------------------------------------------------------------
265  use scale_time, only: &
267  use scale_file_cartesc, only: &
269  implicit none
270 
271  character(len=19) :: timelabel
272  character(len=H_LONG) :: basename
273  !---------------------------------------------------------------------------
274 
275  if ( atmos_phy_ch_restart_out_basename /= '' ) then
276 
277  log_newline
278  log_info("ATMOS_PHY_CH_vars_restart_create",*) 'Create restart file (ATMOS_PHY_CH) '
279 
281  call time_gettimelabel( timelabel )
282  basename = trim(atmos_phy_ch_restart_out_basename)//'_'//trim(timelabel)
283  else
284  basename = trim(atmos_phy_ch_restart_out_basename)
285  endif
286 
287  log_info("ATMOS_PHY_CH_vars_restart_create",*) 'basename: ', trim(basename)
288 
289  call file_cartesc_create( &
291  restart_fid, & ! [OUT]
292  aggregate=atmos_phy_ch_restart_out_aggregate ) ! [IN]
293 
294  endif
295 
296  return
297  end subroutine atmos_phy_ch_vars_restart_create
298 
299  !-----------------------------------------------------------------------------
302  use scale_file_cartesc, only: &
304  implicit none
305 
306  if ( restart_fid /= -1 ) then
307  call file_cartesc_enddef( restart_fid ) ! [IN]
308  endif
309 
310  return
311  end subroutine atmos_phy_ch_vars_restart_enddef
312 
313  !-----------------------------------------------------------------------------
316  use scale_file_cartesc, only: &
318  implicit none
319  !---------------------------------------------------------------------------
320 
321  if ( restart_fid /= -1 ) then
322  log_newline
323  log_info("ATMOS_PHY_CH_vars_restart_close",*) 'Close restart file (ATMOS_PHY_CH) '
324 
325  call file_cartesc_close( restart_fid ) ! [IN]
326 
327  restart_fid = -1
328  endif
329 
330  return
331  end subroutine atmos_phy_ch_vars_restart_close
332 
333  !-----------------------------------------------------------------------------
336  use scale_file_cartesc, only: &
338  implicit none
339  !---------------------------------------------------------------------------
340 
341  if ( restart_fid /= -1 ) then
342 !!$ call FILE_CARTESC_def_var( restart_fid, VAR_NAME(1), VAR_DESC(1), VAR_UNIT(1), 'ZXY', ATMOS_PHY_CH_RESTART_OUT_DTYPE, &
343 !!$ VAR_ID(1) )
344  endif
345 
346  return
347  end subroutine atmos_phy_ch_vars_restart_def_var
348 
349  !-----------------------------------------------------------------------------
352  use scale_file_cartesc, only: &
353  file_cartesc_write_var
354  implicit none
355 
356  !---------------------------------------------------------------------------
357 
358  if ( restart_fid /= -1 ) then
359 
361 
363 
364 !!$ call FILE_CARTESC_write_var( restart_fid, VAR_ID(1), ATMOS_PHY_CH_O3(:,:,:), VAR_NAME(1), 'ZXY' ) ! [IN]
365 
366  endif
367 
368  return
369  end subroutine atmos_phy_ch_vars_restart_write
370 
371 
372  subroutine atmos_phy_ch_vars_check
373  use scale_statistics, only: &
375  statistics_total
376  use scale_atmos_grid_cartesc_real, only: &
379  implicit none
380 
381 !!$ call VALCHECK( KA, KS, KE, IA, IS, IE, JA, JS, JE, &
382 !!$ ATMOS_PHY_CH_O3(:,:,:), & ! (in)
383 !!$ 0.0_RP, 1.0E3_RP, VAR_NAME(1), & ! (in)
384 !!$ __FILE__, __LINE__ ) ! (in)
385 !!$
386 !!$ call STATISTICS_total( KA, KS, KE, IA, IS, IE, JA, JS, JE, &
387 !!$ ATMOS_PHY_CH_O3(:,:,:), VAR_NAME(1), & ! (in)
388 !!$ ATMOS_GRID_CARTESC_REAL_VOL(:,:,:), & ! (in)
389 !!$ ATMOS_GRID_CARTESC_REAL_TOTVOL ) ! (in)
390 
391  return
392  end subroutine atmos_phy_ch_vars_check
393 
394 end module mod_atmos_phy_ch_vars
mod_atmos_phy_ch_vars::atmos_phy_ch_vars_restart_create
subroutine, public atmos_phy_ch_vars_restart_create
Create restart file.
Definition: mod_atmos_phy_ch_vars.F90:265
scale_statistics
module Statistics
Definition: scale_statistics.F90:11
mod_atmos_phy_ch_vars::atmos_phy_ch_restart_in_basename
character(len=h_long), public atmos_phy_ch_restart_in_basename
Basename of the input file.
Definition: mod_atmos_phy_ch_vars.F90:47
mod_atmos_phy_ch_vars::atmos_phy_ch_vars_restart_close
subroutine, public atmos_phy_ch_vars_restart_close
Close restart file.
Definition: mod_atmos_phy_ch_vars.F90:316
mod_atmos_phy_ch_vars::atmos_phy_ch_vars_restart_open
subroutine, public atmos_phy_ch_vars_restart_open
Open restart file for read.
Definition: mod_atmos_phy_ch_vars.F90:187
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:342
mod_atmos_phy_ch_vars::atmos_phy_ch_vars_restart_enddef
subroutine, public atmos_phy_ch_vars_restart_enddef
Exit netCDF define mode.
Definition: mod_atmos_phy_ch_vars.F90:302
scale_file_cartesc::file_cartesc_enddef
subroutine, public file_cartesc_enddef(fid)
Exit netCDF file define mode.
Definition: scale_file_cartesC.F90:943
scale_file_cartesc::file_cartesc_def_var
subroutine, public file_cartesc_def_var(fid, varname, desc, unit, dim_type, datatype, vid, standard_name, timeintv, nsteps, cell_measures)
Define a variable to file.
Definition: scale_file_cartesC.F90:3307
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_atmos_grid_cartesc_index::ka
integer, public ka
Definition: scale_atmos_grid_cartesC_index.F90:47
mod_atmos_phy_ch_vars::atmos_phy_ch_vars_restart_def_var
subroutine, public atmos_phy_ch_vars_restart_def_var
Write restart.
Definition: mod_atmos_phy_ch_vars.F90:336
mod_atmos_phy_ch_vars::atmos_phy_ch_restart_in_postfix_timelabel
logical, public atmos_phy_ch_restart_in_postfix_timelabel
Add timelabel to the basename of input file?
Definition: mod_atmos_phy_ch_vars.F90:49
mod_atmos_phy_ch_vars::atmos_phy_ch_vars_setup
subroutine, public atmos_phy_ch_vars_setup
Setup.
Definition: mod_atmos_phy_ch_vars.F90:90
mod_atmos_phy_ch_vars::qa_ch
integer, public qa_ch
Definition: mod_atmos_phy_ch_vars.F90:60
mod_atmos_phy_ch_vars::qs_ch
integer, public qs_ch
Definition: mod_atmos_phy_ch_vars.F90:61
scale_atmos_grid_cartesc_real
module Atmosphere GRID CartesC Real(real space)
Definition: scale_atmos_grid_cartesC_real.F90:11
mod_atmos_phy_ch_vars::atmos_phy_ch_vars_fillhalo
subroutine, public atmos_phy_ch_vars_fillhalo
HALO Communication.
Definition: mod_atmos_phy_ch_vars.F90:163
scale_file
module file
Definition: scale_file.F90:15
mod_atmos_phy_ch_vars::atmos_phy_ch_o3
real(rp), dimension(:,:,:), allocatable, public atmos_phy_ch_o3
Definition: mod_atmos_phy_ch_vars.F90:58
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_precision::rp
integer, parameter, public rp
Definition: scale_precision.F90:41
scale_io
module STDIO
Definition: scale_io.F90:10
mod_atmos_phy_ch_vars::atmos_phy_ch_restart_out_postfix_timelabel
logical, public atmos_phy_ch_restart_out_postfix_timelabel
Add timelabel to the basename of output file?
Definition: mod_atmos_phy_ch_vars.F90:52
scale_atmos_grid_cartesc_index
module atmosphere / grid / cartesC index
Definition: scale_atmos_grid_cartesC_index.F90:12
scale_const
module CONSTANT
Definition: scale_const.F90:11
scale_atmos_grid_cartesc_index::ia
integer, public ia
Definition: scale_atmos_grid_cartesC_index.F90:48
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_vol
real(rp), dimension(:,:,:), allocatable, public atmos_grid_cartesc_real_vol
control volume (zxy) [m3]
Definition: scale_atmos_grid_cartesC_real.F90:83
mod_atmos_phy_ch_vars::atmos_phy_ch_restart_output
logical, public atmos_phy_ch_restart_output
output restart file?
Definition: mod_atmos_phy_ch_vars.F90:45
scale_file_cartesc::file_cartesc_close
subroutine, public file_cartesc_close(fid)
Close a netCDF file.
Definition: scale_file_cartesC.F90:1023
mod_atmos_phy_ch_vars::atmos_phy_ch_rhoq_t
real(rp), dimension(:,:,:,:), allocatable, public atmos_phy_ch_rhoq_t
Definition: mod_atmos_phy_ch_vars.F90:56
scale_prof
module profiler
Definition: scale_prof.F90:11
mod_atmos_phy_ch_vars::atmos_phy_ch_restart_out_dtype
character(len=h_short), public atmos_phy_ch_restart_out_dtype
REAL4 or REAL8.
Definition: mod_atmos_phy_ch_vars.F90:54
mod_atmos_phy_ch_vars
module Atmosphere / Physics Chemistry
Definition: mod_atmos_phy_ch_vars.F90:12
mod_atmos_phy_ch_vars::atmos_phy_ch_restart_out_basename
character(len=h_long), public atmos_phy_ch_restart_out_basename
Basename of the output file.
Definition: mod_atmos_phy_ch_vars.F90:50
scale_atmos_grid_cartesc_index::ja
integer, public ja
Definition: scale_atmos_grid_cartesC_index.F90:49
scale_time
module TIME
Definition: scale_time.F90:11
scale_tracer
module TRACER
Definition: scale_tracer.F90:12
mod_atmos_phy_ch_vars::atmos_phy_ch_vars_restart_write
subroutine, public atmos_phy_ch_vars_restart_write
Write restart.
Definition: mod_atmos_phy_ch_vars.F90:352
scale_debug
module DEBUG
Definition: scale_debug.F90:11
scale_file_cartesc::file_cartesc_create
subroutine, public file_cartesc_create(basename, title, datatype, fid, date, subsec, haszcoord, append, aggregate, single)
Create/open a netCDF file.
Definition: scale_file_cartesC.F90:780
scale_file_cartesc::file_cartesc_open
subroutine, public file_cartesc_open(basename, fid, aggregate)
open a netCDF file for read
Definition: scale_file_cartesC.F90:746
scale_statistics::statistics_checktotal
logical, public statistics_checktotal
calc&report variable totals to logfile?
Definition: scale_statistics.F90:64
scale_file_cartesc::file_cartesc_flush
subroutine, public file_cartesc_flush(fid)
Flush all pending requests to a netCDF file (PnetCDF only)
Definition: scale_file_cartesC.F90:997
scale_time::time_gettimelabel
subroutine, public time_gettimelabel(timelabel)
generate time label
Definition: scale_time.F90:91
scale_comm_cartesc
module COMMUNICATION
Definition: scale_comm_cartesC.F90:11
scale_file::file_get_aggregate
logical function, public file_get_aggregate(fid)
Definition: scale_file.F90:4844
mod_atmos_phy_ch_vars::atmos_phy_ch_vars_check
subroutine atmos_phy_ch_vars_check
Definition: mod_atmos_phy_ch_vars.F90:373
mod_atmos_phy_ch_vars::qe_ch
integer, public qe_ch
Definition: mod_atmos_phy_ch_vars.F90:62
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_totvol
real(rp), public atmos_grid_cartesc_real_totvol
total volume (zxy, local) [m3]
Definition: scale_atmos_grid_cartesC_real.F90:87
mod_atmos_phy_ch_vars::atmos_phy_ch_restart_in_aggregate
logical, public atmos_phy_ch_restart_in_aggregate
Switch to use aggregate file.
Definition: mod_atmos_phy_ch_vars.F90:48
scale_const::const_undef
real(rp), public const_undef
Definition: scale_const.F90:41
mod_atmos_phy_ch_vars::atmos_phy_ch_restart_out_title
character(len=h_mid), public atmos_phy_ch_restart_out_title
title of the output file
Definition: mod_atmos_phy_ch_vars.F90:53
mod_atmos_phy_ch_vars::atmos_phy_ch_restart_out_aggregate
logical, public atmos_phy_ch_restart_out_aggregate
Switch to use aggregate file.
Definition: mod_atmos_phy_ch_vars.F90:51
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:56
scale_file_cartesc
module file / cartesianC
Definition: scale_file_cartesC.F90:11
mod_atmos_phy_ch_vars::atmos_phy_ch_vars_restart_read
subroutine, public atmos_phy_ch_vars_restart_read
Read restart.
Definition: mod_atmos_phy_ch_vars.F90:222