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
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 = ''
50  logical, public :: atmos_phy_ch_restart_in_postfix_timelabel = .false.
51  character(len=H_LONG), public :: atmos_phy_ch_restart_out_basename = ''
53  logical, public :: atmos_phy_ch_restart_out_postfix_timelabel = .true.
54  character(len=H_MID), public :: atmos_phy_ch_restart_out_title = 'ATMOS_PHY_CH restart'
55  character(len=H_SHORT), public :: atmos_phy_ch_restart_out_dtype = 'DEFAULT'
56 
57  real(rp), public, allocatable :: atmos_phy_ch_rhoq_t(:,:,:,:) ! tendency QTRC [kg/kg/s]
58 
59  real(rp), public, allocatable :: atmos_phy_ch_o3(:,:,:) ! ozone [PPM]
60 
61  integer, public :: qa_ch = 0
62  integer, public :: qs_ch = -1
63  integer, public :: qe_ch = -2
64 
65  !-----------------------------------------------------------------------------
66  !
67  !++ Private procedure
68  !
69  !-----------------------------------------------------------------------------
70  !
71  !++ Private parameters & variables
72  !
73  integer, private, parameter :: vmax = 1
74  integer, private, parameter :: i_o3 = 1
75 
76  character(len=H_SHORT), private :: var_name(vmax)
77  character(len=H_MID), private :: var_desc(vmax)
78  character(len=H_SHORT), private :: var_unit(vmax)
79  integer, private :: var_id(vmax)
80  integer, private :: restart_fid = -1 ! file ID
81 
82  data var_name / 'O3' /
83  data var_desc / 'Ozone' /
84  data var_unit / 'PPM' /
85 
86  !-----------------------------------------------------------------------------
87 contains
88  !-----------------------------------------------------------------------------
90  subroutine atmos_phy_ch_vars_setup
91  use scale_prc, only: &
92  prc_abort
93  use scale_const, only: &
94  undef => const_undef
95  implicit none
96 
97  namelist / param_atmos_phy_ch_vars / &
107 
108  integer :: ierr
109  integer :: iv
110  !---------------------------------------------------------------------------
111 
112  log_newline
113  log_info("ATMOS_PHY_CH_vars_setup",*) 'Setup'
114 
115  allocate( atmos_phy_ch_rhoq_t(ka,ia,ja,qs_ch:qe_ch) )
116  atmos_phy_ch_rhoq_t(:,:,:,:) = undef
117  !$acc enter data create(ATMOS_PHY_CH_RHOQ_t)
118 
119 !!$ allocate( ATMOS_PHY_CH_O3(KA,IA,JA) )
120 !!$ ATMOS_PHY_CH_O3(:,:,:) = UNDEF
121 
122  !--- read namelist
123  rewind(io_fid_conf)
124  read(io_fid_conf,nml=param_atmos_phy_ch_vars,iostat=ierr)
125  if( ierr < 0 ) then !--- missing
126  log_info("ATMOS_PHY_CH_vars_setup",*) 'Not found namelist. Default used.'
127  elseif( ierr > 0 ) then !--- fatal error
128  log_error("ATMOS_PHY_CH_vars_setup",*) 'Not appropriate names in namelist PARAM_ATMOS_PHY_CH_VARS. Check!'
129  call prc_abort
130  endif
131  log_nml(param_atmos_phy_ch_vars)
132 
133  log_newline
134  log_info("ATMOS_PHY_CH_vars_setup",*) '[ATMOS_PHY_CH] prognostic/diagnostic variables'
135  log_info_cont('(1x,A,A24,A,A48,A,A12,A)') &
136  ' |', 'VARNAME ','|', &
137  'DESCRIPTION ', '[', 'UNIT ', ']'
138  do iv = 1, vmax
139  log_info_cont('(1x,A,I3,A,A24,A,A48,A,A12,A)') &
140  'NO.',iv,'|',var_name(iv),'|',var_desc(iv),'[',var_unit(iv),']'
141  enddo
142 
143  log_newline
144  if ( atmos_phy_ch_restart_in_basename /= '' ) then
145  log_info("ATMOS_PHY_CH_vars_setup",*) 'Restart input? : YES, file = ', trim(atmos_phy_ch_restart_in_basename)
146  log_info("ATMOS_PHY_CH_vars_setup",*) 'Add timelabel? : ', atmos_phy_ch_restart_in_postfix_timelabel
147  else
148  log_info("ATMOS_PHY_CH_vars_setup",*) 'Restart input? : NO'
149  endif
151  .AND. atmos_phy_ch_restart_out_basename /= '' ) then
152  log_info("ATMOS_PHY_CH_vars_setup",*) 'Restart output? : YES, file = ', trim(atmos_phy_ch_restart_out_basename)
153  log_info("ATMOS_PHY_CH_vars_setup",*) 'Add timelabel? : ', atmos_phy_ch_restart_out_postfix_timelabel
154  else
155  log_info("ATMOS_PHY_CH_vars_setup",*) 'Restart output? : NO'
157  endif
158 
159  return
160  end subroutine atmos_phy_ch_vars_setup
161 
162  !-----------------------------------------------------------------------------
164  subroutine atmos_phy_ch_vars_finalize
165  implicit none
166 
167  log_newline
168  log_info("ATMOS_PHY_CH_vars_finalize",*) 'Finalize'
169 
170  !$acc exit data delete(ATMOS_PHY_CH_RHOQ_t)
171  deallocate( atmos_phy_ch_rhoq_t )
172 
173  return
174  end subroutine atmos_phy_ch_vars_finalize
175 
176  !-----------------------------------------------------------------------------
178  subroutine atmos_phy_ch_vars_fillhalo
179  use scale_comm_cartesc, only: &
180  comm_vars8, &
181  comm_wait
182  implicit none
183 
184  integer :: i, j
185  !---------------------------------------------------------------------------
186 
187 !!$ do j = JS, JE
188 !!$ do i = IS, IE
189 !!$ ATMOS_PHY_CH_O3( 1:KS-1,i,j) = ATMOS_PHY_CH_O3(KS,i,j)
190 !!$ ATMOS_PHY_CH_O3(KE+1:KA, i,j) = ATMOS_PHY_CH_O3(KE,i,j)
191 !!$ enddo
192 !!$ enddo
193 !!$
194 !!$ call COMM_vars8( ATMOS_PHY_CH_O3(:,:,:), 1 )
195 !!$ call COMM_wait ( ATMOS_PHY_CH_O3(:,:,:), 1 )
196 
197  return
198  end subroutine atmos_phy_ch_vars_fillhalo
199 
200  !-----------------------------------------------------------------------------
203  use scale_time, only: &
205  use scale_file_cartesc, only: &
207  implicit none
208 
209  character(len=19) :: timelabel
210  character(len=H_LONG) :: basename
211  !---------------------------------------------------------------------------
212 
213  log_newline
214  log_info("ATMOS_PHY_CH_vars_restart_open",*) 'Open restart file (ATMOS_PHY_CH) '
215 
216  if ( atmos_phy_ch_restart_in_basename /= '' ) then
217 
219  call time_gettimelabel( timelabel )
220  basename = trim(atmos_phy_ch_restart_in_basename)//'_'//trim(timelabel)
221  else
222  basename = trim(atmos_phy_ch_restart_in_basename)
223  endif
224 
225  log_info("ATMOS_PHY_CH_vars_restart_open",*) 'basename: ', trim(basename)
226 
227  call file_cartesc_open( basename, restart_fid, aggregate=atmos_phy_ch_restart_in_aggregate )
228  else
229  log_info("ATMOS_PHY_CH_vars_restart_open",*) 'restart file for ATMOS_PHY_CH is not specified.'
230  endif
231 
232  return
233  end subroutine atmos_phy_ch_vars_restart_open
234 
235  !-----------------------------------------------------------------------------
238  use scale_file, only: &
240  use scale_file_cartesc, only: &
241  file_cartesc_read, &
243  implicit none
244 
245  integer :: i, j
246  !---------------------------------------------------------------------------
247 
248  if ( restart_fid /= -1 ) then
249  log_newline
250  log_info("ATMOS_PHY_CH_vars_restart_read",*) 'Read from restart file (ATMOS_PHY_CH) '
251 
252 !!$ call FILE_CARTESC_read( restart_fid, VAR_NAME(1), 'ZXY', & ! [IN]
253 !!$ ATMOS_PHY_CH_O3(:,:,:) ) ! [OUT]
254 !!$
255 !!$ if ( FILE_get_aggregate( restart_fid) ) then
256 !!$ call FILE_CARTESC_flush( restart_fid ) ! X/Y halos have been read from file
257 !!$ !$acc update device(ATMOS_PHY_CH_O3)
258 !!$
259 !!$ ! fill K halos
260 !!$ !$acc kernels
261 !!$ do j = 1, JA
262 !!$ do i = 1, IA
263 !!$ ATMOS_PHY_CH_O3( 1:KS-1,i,j) = ATMOS_PHY_CH_O3(KS,i,j)
264 !!$ ATMOS_PHY_CH_O3(KE+1:KA, i,j) = ATMOS_PHY_CH_O3(KE,i,j)
265 !!$ enddo
266 !!$ enddo
267 !!$ !$acc end kernels
268 !!$ else
269 !!$ call ATMOS_PHY_CH_vars_fillhalo
270 !!$ end if
271 
273 
274  else
275  log_info("ATMOS_PHY_CH_vars_restart_read",*) 'invalid restart file for ATMOS_PHY_CH.'
276  endif
277 
278  return
279  end subroutine atmos_phy_ch_vars_restart_read
280 
281  !-----------------------------------------------------------------------------
284  use scale_time, only: &
286  use scale_file_cartesc, only: &
288  implicit none
289 
290  character(len=19) :: timelabel
291  character(len=H_LONG) :: basename
292  !---------------------------------------------------------------------------
293 
294  if ( atmos_phy_ch_restart_out_basename /= '' ) then
295 
296  log_newline
297  log_info("ATMOS_PHY_CH_vars_restart_create",*) 'Create restart file (ATMOS_PHY_CH) '
298 
300  call time_gettimelabel( timelabel )
301  basename = trim(atmos_phy_ch_restart_out_basename)//'_'//trim(timelabel)
302  else
303  basename = trim(atmos_phy_ch_restart_out_basename)
304  endif
305 
306  log_info("ATMOS_PHY_CH_vars_restart_create",*) 'basename: ', trim(basename)
307 
308  call file_cartesc_create( &
310  restart_fid, & ! [OUT]
311  aggregate=atmos_phy_ch_restart_out_aggregate ) ! [IN]
312 
313  endif
314 
315  return
316  end subroutine atmos_phy_ch_vars_restart_create
317 
318  !-----------------------------------------------------------------------------
321  use scale_file_cartesc, only: &
323  implicit none
324 
325  if ( restart_fid /= -1 ) then
326  call file_cartesc_enddef( restart_fid ) ! [IN]
327  endif
328 
329  return
330  end subroutine atmos_phy_ch_vars_restart_enddef
331 
332  !-----------------------------------------------------------------------------
335  use scale_file_cartesc, only: &
337  implicit none
338  !---------------------------------------------------------------------------
339 
340  if ( restart_fid /= -1 ) then
341  log_newline
342  log_info("ATMOS_PHY_CH_vars_restart_close",*) 'Close restart file (ATMOS_PHY_CH) '
343 
344  call file_cartesc_close( restart_fid ) ! [IN]
345 
346  restart_fid = -1
347  endif
348 
349  return
350  end subroutine atmos_phy_ch_vars_restart_close
351 
352  !-----------------------------------------------------------------------------
355  use scale_file_cartesc, only: &
357  implicit none
358  !---------------------------------------------------------------------------
359 
360  if ( restart_fid /= -1 ) then
361 !!$ call FILE_CARTESC_def_var( restart_fid, VAR_NAME(1), VAR_DESC(1), VAR_UNIT(1), 'ZXY', ATMOS_PHY_CH_RESTART_OUT_DTYPE, &
362 !!$ VAR_ID(1) )
363  endif
364 
365  return
366  end subroutine atmos_phy_ch_vars_restart_def_var
367 
368  !-----------------------------------------------------------------------------
371  use scale_file_cartesc, only: &
372  file_cartesc_write_var
373  implicit none
374 
375  !---------------------------------------------------------------------------
376 
377  if ( restart_fid /= -1 ) then
378 
380 
382 
383 !!$ call FILE_CARTESC_write_var( restart_fid, VAR_ID(1), ATMOS_PHY_CH_O3(:,:,:), VAR_NAME(1), 'ZXY' ) ! [IN]
384 
385  endif
386 
387  return
388  end subroutine atmos_phy_ch_vars_restart_write
389 
390 
391  subroutine atmos_phy_ch_vars_check
392  use scale_statistics, only: &
394  statistics_total
395  use scale_atmos_grid_cartesc_real, only: &
398  implicit none
399 
400 !!$ call VALCHECK( KA, KS, KE, IA, IS, IE, JA, JS, JE, &
401 !!$ ATMOS_PHY_CH_O3(:,:,:), & ! (in)
402 !!$ 0.0_RP, 1.0E3_RP, VAR_NAME(1), & ! (in)
403 !!$ __FILE__, __LINE__ ) ! (in)
404 !!$
405 !!$ call STATISTICS_total( KA, KS, KE, IA, IS, IE, JA, JS, JE, &
406 !!$ ATMOS_PHY_CH_O3(:,:,:), VAR_NAME(1), & ! (in)
407 !!$ ATMOS_GRID_CARTESC_REAL_VOL(:,:,:), & ! (in)
408 !!$ ATMOS_GRID_CARTESC_REAL_TOTVOL ) ! (in)
409 
410  return
411  end subroutine atmos_phy_ch_vars_check
412 
413 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:284
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:48
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:335
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:203
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
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:321
scale_file_cartesc::file_cartesc_enddef
subroutine, public file_cartesc_enddef(fid)
Exit netCDF file define mode.
Definition: scale_file_cartesC.F90:964
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:3360
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:355
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:50
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:91
mod_atmos_phy_ch_vars::qa_ch
integer, public qa_ch
Definition: mod_atmos_phy_ch_vars.F90:61
mod_atmos_phy_ch_vars::qs_ch
integer, public qs_ch
Definition: mod_atmos_phy_ch_vars.F90:62
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:179
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:59
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:53
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:84
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:46
scale_file_cartesc::file_cartesc_close
subroutine, public file_cartesc_close(fid)
Close a netCDF file.
Definition: scale_file_cartesC.F90:1044
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:57
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:55
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:51
mod_atmos_phy_ch_vars::atmos_phy_ch_vars_finalize
subroutine, public atmos_phy_ch_vars_finalize
Finalize.
Definition: mod_atmos_phy_ch_vars.F90:165
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:371
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:796
scale_statistics::statistics_checktotal
logical, public statistics_checktotal
calc&report variable totals to logfile?
Definition: scale_statistics.F90:109
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:1018
scale_time::time_gettimelabel
subroutine, public time_gettimelabel(timelabel)
generate time label
Definition: scale_time.F90:93
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:6316
scale_file_cartesc::file_cartesc_open
subroutine, public file_cartesc_open(basename, fid, single, aggregate)
open a netCDF file for read
Definition: scale_file_cartesC.F90:760
mod_atmos_phy_ch_vars::atmos_phy_ch_vars_check
subroutine atmos_phy_ch_vars_check
Definition: mod_atmos_phy_ch_vars.F90:392
mod_atmos_phy_ch_vars::qe_ch
integer, public qe_ch
Definition: mod_atmos_phy_ch_vars.F90:63
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:88
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:49
scale_const::const_undef
real(rp), public const_undef
Definition: scale_const.F90:43
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:54
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:52
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:57
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:238