SCALE-RM
mod_atmos_phy_lt_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
21  use scale_tracer
22  !-----------------------------------------------------------------------------
23  implicit none
24  private
25  !-----------------------------------------------------------------------------
26  !
27  !++ Public procedure
28  !
29  public :: atmos_phy_lt_vars_setup
33 
39 
40  !-----------------------------------------------------------------------------
41  !
42  !++ Public parameters & variables
43  !
44  logical, public :: atmos_phy_lt_restart_output = .false.
45 
46  character(len=H_LONG), public :: atmos_phy_lt_restart_in_basename = ''
48  logical, public :: atmos_phy_lt_restart_in_postfix_timelabel = .false.
49  character(len=H_LONG), public :: atmos_phy_lt_restart_out_basename = ''
51  logical, public :: atmos_phy_lt_restart_out_postfix_timelabel = .true.
52  character(len=H_MID), public :: atmos_phy_lt_restart_out_title = 'ATMOS_PHY_LT restart'
53  character(len=H_SHORT), public :: atmos_phy_lt_restart_out_dtype = 'DEFAULT'
54 
55  real(rp), public, allocatable :: atmos_phy_lt_epot(:,:,:) ! tendency QTRC [kg/kg/s]
56  real(rp), public, allocatable :: atmos_phy_lt_sarea(:,:,:,:)
57 
58  integer, public :: qa_lt = 0
59  integer, public :: qs_lt = -1
60  integer, public :: qe_lt = -2
61 
62  real(rp), parameter, public :: d0_crg = 100.e-6_rp
63  real(rp), parameter, public :: v0_crg = 8.0_rp
64  logical, public :: flg_lt = .false.
65  !-----------------------------------------------------------------------------
66  !
67  !++ Private procedure
68  !
69  !-----------------------------------------------------------------------------
70  !
71  !++ Private parameters & variables
72  !
73  integer, private, parameter :: vmax = 1
74  integer, private, parameter :: i_epot = 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 / 'Epot' /
83  data var_desc / 'Electric potential' /
84  data var_unit / 'V' /
85 
86  !-----------------------------------------------------------------------------
87 contains
88  !-----------------------------------------------------------------------------
90  subroutine atmos_phy_lt_vars_setup
91  use scale_prc, only: &
92  prc_abort
93  use scale_const, only: &
94  undef => const_undef
95  use mod_atmos_phy_mp_vars, only: &
97  implicit none
98 
99  namelist / param_atmos_phy_lt_vars / &
109 
110  integer :: ierr
111  integer :: iv
112  !---------------------------------------------------------------------------
113 
114  log_newline
115  log_info("ATMOS_PHY_LT_vars_setup",*) 'Setup'
116 
117  allocate( atmos_phy_lt_epot(ka,ia,ja) )
118  atmos_phy_lt_epot(:,:,:) = undef
119 
120  !--- read namelist
121  rewind(io_fid_conf)
122  read(io_fid_conf,nml=param_atmos_phy_lt_vars,iostat=ierr)
123  if( ierr < 0 ) then !--- missing
124  log_info("ATMOS_PHY_LT_vars_setup",*) 'Not found namelist. Default used.'
125  elseif( ierr > 0 ) then !--- fatal error
126  log_error("ATMOS_PHY_LT_vars_setup",*) 'Not appropriate names in namelist PARAM_ATMOS_PHY_LT_VARS. Check!'
127  call prc_abort
128  endif
129  log_nml(param_atmos_phy_lt_vars)
130 
131  log_newline
132  log_info("ATMOS_PHY_LT_vars_setup",*) '[ATMOS_PHY_TL] 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_lt_restart_in_basename /= '' ) then
143  log_info("ATMOS_PHY_LT_vars_setup",*) 'Restart input? : YES, file = ', trim(atmos_phy_lt_restart_in_basename)
144  log_info("ATMOS_PHY_LT_vars_setup",*) 'Add timelabel? : ', atmos_phy_lt_restart_in_postfix_timelabel
145  else
146  log_info("ATMOS_PHY_LT_vars_setup",*) 'Restart input? : NO'
147  endif
149  .AND. atmos_phy_lt_restart_out_basename /= '' ) then
150  log_info("ATMOS_PHY_LT_vars_setup",*) 'Restart output? : YES, file = ', trim(atmos_phy_lt_restart_out_basename)
151  log_info("ATMOS_PHY_LT_vars_setup",*) 'Add timelabel? : ', atmos_phy_lt_restart_out_postfix_timelabel
152  else
153  log_info("ATMOS_PHY_LT_vars_setup",*) 'Restart output? : NO'
155  endif
156 
157 
158  ! for cloud microphysics
159  allocate( atmos_phy_mp_rhoc_t(ka,ia,ja,qs_lt:qe_lt) )
160  atmos_phy_mp_rhoc_t(:,:,:,:) = 0.0_rp
161 
162 
163  return
164  end subroutine atmos_phy_lt_vars_setup
165 
166  !-----------------------------------------------------------------------------
168  subroutine atmos_phy_lt_vars_fillhalo
169  use scale_comm_cartesc, only: &
170  comm_vars8, &
171  comm_wait
172  implicit none
173 
174  integer :: i, j
175  !---------------------------------------------------------------------------
176 
177  do j = js, je
178  do i = is, ie
179  atmos_phy_lt_epot( 1:ks-1,i,j) = atmos_phy_lt_epot(ks,i,j)
181  enddo
182  enddo
183 
184  call comm_vars8( atmos_phy_lt_epot(:,:,:), 1 )
185  call comm_wait ( atmos_phy_lt_epot(:,:,:), 1 )
186 
187  return
188  end subroutine atmos_phy_lt_vars_fillhalo
189 
190  !-----------------------------------------------------------------------------
193  use scale_time, only: &
195  use scale_file_cartesc, only: &
197  implicit none
198 
199  character(len=19) :: timelabel
200  character(len=H_LONG) :: basename
201  !---------------------------------------------------------------------------
202 
203  log_newline
204  log_info("ATMOS_PHY_LT_vars_restart_open",*) 'Open restart file (ATMOS_PHY_LT) '
205 
206  if ( atmos_phy_lt_restart_in_basename /= '' ) then
207 
209  call time_gettimelabel( timelabel )
210  basename = trim(atmos_phy_lt_restart_in_basename)//'_'//trim(timelabel)
211  else
212  basename = trim(atmos_phy_lt_restart_in_basename)
213  endif
214 
215  log_info("ATMOS_PHY_LT_vars_restart_open",*) 'basename: ', trim(basename)
216 
217  call file_cartesc_open( basename, restart_fid, aggregate=atmos_phy_lt_restart_in_aggregate )
218  else
219  log_info("ATMOS_PHY_LT_vars_restart_open",*) 'restart file for ATMOS_PHY_LT is not specified.'
220  endif
221 
222  return
223  end subroutine atmos_phy_lt_vars_restart_open
224 
225  !-----------------------------------------------------------------------------
228  use scale_statistics, only: &
230  statistics_total
231  use scale_file, only: &
233  use scale_file_cartesc, only: &
234  file_cartesc_read, &
236  use scale_atmos_grid_cartesc_real, only: &
239  implicit none
240 
241  integer :: i, j
242  !---------------------------------------------------------------------------
243 
244  if ( restart_fid /= -1 ) then
245  log_newline
246  log_info("ATMOS_PHY_LT_vars_restart_read",*) 'Read from restart file (ATMOS_PHY_LT) '
247 
248  call file_cartesc_read( restart_fid, var_name(1), 'ZXY', & ! [IN]
249  atmos_phy_lt_epot(:,:,:) ) ! [OUT]
250 
251  if ( file_get_aggregate( restart_fid ) ) then
252  call file_cartesc_flush( restart_fid ) ! X/Y halos have been read from file
253 
254  ! fill K halos
255  do j = 1, ja
256  do i = 1, ia
257  atmos_phy_lt_epot( 1:ks-1,i,j) = atmos_phy_lt_epot(ks,i,j)
259  enddo
260  enddo
261  else
263  end if
264 
265  if ( statistics_checktotal ) then
266  call statistics_total( ka, ks, ke, ia, is, ie, ja, js, je, &
267  atmos_phy_lt_epot(:,:,:), var_name(1), & ! (in)
268  atmos_grid_cartesc_real_vol(:,:,:), & ! (in)
270  end if
271  else
272  log_info("ATMOS_PHY_LT_vars_restart_read",*) 'invalid restart file for ATMOS_PHY_LT.'
273  endif
274 
275  return
276  end subroutine atmos_phy_lt_vars_restart_read
277 
278  !-----------------------------------------------------------------------------
281  use scale_time, only: &
283  use scale_file_cartesc, only: &
285  implicit none
286 
287  character(len=19) :: timelabel
288  character(len=H_LONG) :: basename
289  !---------------------------------------------------------------------------
290 
291  if ( atmos_phy_lt_restart_out_basename /= '' ) then
292 
293  log_newline
294  log_info("ATMOS_PHY_LT_vars_restart_create",*) 'Create restart file (ATMOS_PHY_L) '
295 
297  call time_gettimelabel( timelabel )
298  basename = trim(atmos_phy_lt_restart_out_basename)//'_'//trim(timelabel)
299  else
300  basename = trim(atmos_phy_lt_restart_out_basename)
301  endif
302 
303  log_info("ATMOS_PHY_LT_vars_restart_create",*) 'basename: ', trim(basename)
304 
305  call file_cartesc_create( &
307  restart_fid, & ! [OUT]
308  aggregate=atmos_phy_lt_restart_out_aggregate ) ! [IN]
309 
310  endif
311 
312  return
313  end subroutine atmos_phy_lt_vars_restart_create
314 
315  !-----------------------------------------------------------------------------
318  use scale_file_cartesc, only: &
320  implicit none
321 
322  if ( restart_fid /= -1 ) then
323  call file_cartesc_enddef( restart_fid ) ! [IN]
324  endif
325 
326  return
327  end subroutine atmos_phy_lt_vars_restart_enddef
328 
329  !-----------------------------------------------------------------------------
332  use scale_file_cartesc, only: &
334  implicit none
335  !---------------------------------------------------------------------------
336 
337  if ( restart_fid /= -1 ) then
338  log_newline
339  log_info("ATMOS_PHY_LT_vars_restart_close",*) 'Close restart file (ATMOS_PHY_LT) '
340 
341  call file_cartesc_close( restart_fid ) ! [IN]
342 
343  restart_fid = -1
344  endif
345 
346  return
347  end subroutine atmos_phy_lt_vars_restart_close
348 
349  !-----------------------------------------------------------------------------
352  use scale_file_cartesc, only: &
354  implicit none
355  !---------------------------------------------------------------------------
356 
357  if ( restart_fid /= -1 ) then
358  call file_cartesc_def_var( restart_fid, var_name(1), var_desc(1), var_unit(1), 'ZXY', atmos_phy_lt_restart_out_dtype, &
359  var_id(1) )
360  endif
361 
362  return
363  end subroutine atmos_phy_lt_vars_restart_def_var
364 
365  !-----------------------------------------------------------------------------
368  use scale_statistics, only: &
370  statistics_total
371  use scale_file_cartesc, only: &
372  file_cartesc_write_var
373  use scale_atmos_grid_cartesc_real, only: &
376  implicit none
377 
378  !---------------------------------------------------------------------------
379 
380  if ( restart_fid /= -1 ) then
381 
383 
384  if ( statistics_checktotal ) then
385  call statistics_total( ka, ks, ke, ia, is, ie, ja, js, je, &
386  atmos_phy_lt_epot(:,:,:), var_name(1), & ! (in)
387  atmos_grid_cartesc_real_vol(:,:,:), & ! (in)
389  end if
390 
391  call file_cartesc_write_var( restart_fid, var_id(1), atmos_phy_lt_epot(:,:,:), var_name(1), 'ZXY' ) ! [IN]
392 
393  endif
394 
395  return
396  end subroutine atmos_phy_lt_vars_restart_write
397 
398 end module mod_atmos_phy_lt_vars
scale_statistics
module Statistics
Definition: scale_statistics.F90:11
mod_atmos_phy_mp_vars
module Atmosphere / Physics Cloud Microphysics
Definition: mod_atmos_phy_mp_vars.F90:12
scale_atmos_grid_cartesc_index::ke
integer, public ke
end point of inner domain: z, local
Definition: scale_atmos_grid_cartesC_index.F90:52
mod_atmos_phy_lt_vars::atmos_phy_lt_vars_restart_write
subroutine, public atmos_phy_lt_vars_restart_write
Write restart.
Definition: mod_atmos_phy_lt_vars.F90:368
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:342
mod_atmos_phy_lt_vars::atmos_phy_lt_vars_restart_enddef
subroutine, public atmos_phy_lt_vars_restart_enddef
Exit netCDF define mode.
Definition: mod_atmos_phy_lt_vars.F90:318
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_lt_vars
module Atmosphere / Physics Chemistry
Definition: mod_atmos_phy_lt_vars.F90:12
mod_atmos_phy_lt_vars::atmos_phy_lt_restart_out_dtype
character(len=h_short), public atmos_phy_lt_restart_out_dtype
REAL4 or REAL8.
Definition: mod_atmos_phy_lt_vars.F90:53
mod_atmos_phy_lt_vars::atmos_phy_lt_restart_in_aggregate
logical, public atmos_phy_lt_restart_in_aggregate
Switch to use aggregate file.
Definition: mod_atmos_phy_lt_vars.F90:47
mod_atmos_phy_lt_vars::atmos_phy_lt_vars_setup
subroutine, public atmos_phy_lt_vars_setup
Setup.
Definition: mod_atmos_phy_lt_vars.F90:91
mod_atmos_phy_lt_vars::atmos_phy_lt_vars_restart_create
subroutine, public atmos_phy_lt_vars_restart_create
Create restart file.
Definition: mod_atmos_phy_lt_vars.F90:281
mod_atmos_phy_lt_vars::qe_lt
integer, public qe_lt
Definition: mod_atmos_phy_lt_vars.F90:60
mod_atmos_phy_lt_vars::atmos_phy_lt_vars_fillhalo
subroutine, public atmos_phy_lt_vars_fillhalo
HALO Communication.
Definition: mod_atmos_phy_lt_vars.F90:169
mod_atmos_phy_lt_vars::atmos_phy_lt_sarea
real(rp), dimension(:,:,:,:), allocatable, public atmos_phy_lt_sarea
Definition: mod_atmos_phy_lt_vars.F90:56
scale_atmos_grid_cartesc_real
module Atmosphere GRID CartesC Real(real space)
Definition: scale_atmos_grid_cartesC_real.F90:11
scale_file
module file
Definition: scale_file.F90:15
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_precision::rp
integer, parameter, public rp
Definition: scale_precision.F90:41
scale_atmos_grid_cartesc_index::ie
integer, public ie
end point of inner domain: x, local
Definition: scale_atmos_grid_cartesC_index.F90:54
scale_io
module STDIO
Definition: scale_io.F90:10
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_mp_vars::atmos_phy_mp_rhoc_t
real(rp), dimension(:,:,:,:), allocatable, public atmos_phy_mp_rhoc_t
Definition: mod_atmos_phy_mp_vars.F90:69
mod_atmos_phy_lt_vars::atmos_phy_lt_vars_restart_read
subroutine, public atmos_phy_lt_vars_restart_read
Read restart.
Definition: mod_atmos_phy_lt_vars.F90:228
mod_atmos_phy_lt_vars::v0_crg
real(rp), parameter, public v0_crg
Definition: mod_atmos_phy_lt_vars.F90:63
mod_atmos_phy_lt_vars::atmos_phy_lt_restart_out_aggregate
logical, public atmos_phy_lt_restart_out_aggregate
Switch to use aggregate file.
Definition: mod_atmos_phy_lt_vars.F90:50
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_lt_vars::atmos_phy_lt_vars_restart_def_var
subroutine, public atmos_phy_lt_vars_restart_def_var
Write restart.
Definition: mod_atmos_phy_lt_vars.F90:352
scale_prof
module profiler
Definition: scale_prof.F90:11
mod_atmos_phy_lt_vars::atmos_phy_lt_restart_out_title
character(len=h_mid), public atmos_phy_lt_restart_out_title
title of the output file
Definition: mod_atmos_phy_lt_vars.F90:52
scale_atmos_grid_cartesc_index::is
integer, public is
start point of inner domain: x, local
Definition: scale_atmos_grid_cartesC_index.F90:53
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_lt_vars::qa_lt
integer, public qa_lt
Definition: mod_atmos_phy_lt_vars.F90:58
mod_atmos_phy_lt_vars::d0_crg
real(rp), parameter, public d0_crg
Definition: mod_atmos_phy_lt_vars.F90:62
scale_atmos_grid_cartesc_index::ks
integer, public ks
start point of inner domain: z, local
Definition: scale_atmos_grid_cartesC_index.F90:51
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
mod_atmos_phy_lt_vars::atmos_phy_lt_restart_out_postfix_timelabel
logical, public atmos_phy_lt_restart_out_postfix_timelabel
Add timelabel to the basename of output file?
Definition: mod_atmos_phy_lt_vars.F90:51
scale_atmos_grid_cartesc_index::js
integer, public js
start point of inner domain: y, local
Definition: scale_atmos_grid_cartesC_index.F90:55
mod_atmos_phy_lt_vars::atmos_phy_lt_restart_out_basename
character(len=h_long), public atmos_phy_lt_restart_out_basename
Basename of the output file.
Definition: mod_atmos_phy_lt_vars.F90:49
mod_atmos_phy_lt_vars::atmos_phy_lt_restart_in_postfix_timelabel
logical, public atmos_phy_lt_restart_in_postfix_timelabel
Add timelabel to the basename of input file?
Definition: mod_atmos_phy_lt_vars.F90:48
mod_atmos_phy_lt_vars::flg_lt
logical, public flg_lt
Definition: mod_atmos_phy_lt_vars.F90:64
scale_file::file_get_aggregate
logical function, public file_get_aggregate(fid)
Definition: scale_file.F90:4844
mod_atmos_phy_lt_vars::atmos_phy_lt_restart_output
logical, public atmos_phy_lt_restart_output
output restart file?
Definition: mod_atmos_phy_lt_vars.F90:44
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_lt_vars::atmos_phy_lt_vars_restart_open
subroutine, public atmos_phy_lt_vars_restart_open
Open restart file for read.
Definition: mod_atmos_phy_lt_vars.F90:193
scale_const::const_undef
real(rp), public const_undef
Definition: scale_const.F90:41
mod_atmos_phy_lt_vars::atmos_phy_lt_vars_restart_close
subroutine, public atmos_phy_lt_vars_restart_close
Close restart file.
Definition: mod_atmos_phy_lt_vars.F90:332
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:56
scale_atmos_grid_cartesc_index::je
integer, public je
end point of inner domain: y, local
Definition: scale_atmos_grid_cartesC_index.F90:56
scale_file_cartesc
module file / cartesianC
Definition: scale_file_cartesC.F90:11
mod_atmos_phy_lt_vars::atmos_phy_lt_epot
real(rp), dimension(:,:,:), allocatable, public atmos_phy_lt_epot
Definition: mod_atmos_phy_lt_vars.F90:55
mod_atmos_phy_lt_vars::atmos_phy_lt_restart_in_basename
character(len=h_long), public atmos_phy_lt_restart_in_basename
Basename of the input file.
Definition: mod_atmos_phy_lt_vars.F90:46
mod_atmos_phy_lt_vars::qs_lt
integer, public qs_lt
Definition: mod_atmos_phy_lt_vars.F90:59