SCALE-RM
mod_atmos_phy_tb_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_tb_vars_setup
35 
41 
42  !-----------------------------------------------------------------------------
43  !
44  !++ Public parameters & variables
45  !
46  logical, public :: atmos_phy_tb_restart_output = .false.
47 
48  character(len=H_LONG), public :: atmos_phy_tb_restart_in_basename = ''
49  logical, public :: atmos_phy_tb_restart_in_postfix_timelabel = .false.
50  character(len=H_LONG), public :: atmos_phy_tb_restart_out_basename = ''
51  logical, public :: atmos_phy_tb_restart_out_postfix_timelabel = .true.
52  character(len=H_MID), public :: atmos_phy_tb_restart_out_title = 'ATMOS_PHY_TB restart'
53  character(len=H_SHORT), public :: atmos_phy_tb_restart_out_dtype = 'DEFAULT'
54 
55  real(RP), public, allocatable :: atmos_phy_tb_momz_t(:,:,:) ! tendency MOMZ [kg/m2/s2]
56  real(RP), public, allocatable :: atmos_phy_tb_momx_t(:,:,:) ! tendency MOMX [kg/m2/s2]
57  real(RP), public, allocatable :: atmos_phy_tb_momy_t(:,:,:) ! tendency MOMY [kg/m2/s2]
58  real(RP), public, allocatable :: atmos_phy_tb_rhot_t(:,:,:) ! tendency RHOT [K*kg/m3/s]
59  real(RP), public, allocatable :: atmos_phy_tb_rhoq_t(:,:,:,:) ! tendency rho*QTRC [kg/kg/s]
60 
61  !-----------------------------------------------------------------------------
62  !
63  !++ Private procedure
64  !
65  !-----------------------------------------------------------------------------
66  !
67  !++ Private parameters & variables
68  !
69 ! integer, private, parameter :: VMAX = 0 !< number of the variables
70 ! character(len=H_SHORT), private :: VAR_NAME(VMAX) !< name of the variables
71 ! character(len=H_MID), private :: VAR_DESC(VMAX) !< desc. of the variables
72 ! character(len=H_SHORT), private :: VAR_UNIT(VMAX) !< unit of the variables
73 ! integer, private :: VAR_ID(VMAX) !< ID of the variables
74 ! integer, private :: restart_fid = -1 ! file ID
75 
76  !-----------------------------------------------------------------------------
77 contains
78  !-----------------------------------------------------------------------------
80  subroutine atmos_phy_tb_vars_setup
81  use scale_process, only: &
83  use scale_const, only: &
84  undef => const_undef
85  implicit none
86 
87  namelist / param_atmos_phy_tb_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_TB] / Origin[SCALE-RM]'
102 
103  allocate( atmos_phy_tb_momz_t(ka,ia,ja) )
104  allocate( atmos_phy_tb_momx_t(ka,ia,ja) )
105  allocate( atmos_phy_tb_momy_t(ka,ia,ja) )
106  allocate( atmos_phy_tb_rhot_t(ka,ia,ja) )
107  allocate( atmos_phy_tb_rhoq_t(ka,ia,ja,qa) )
108  atmos_phy_tb_momz_t(:,:,:) = undef
109  atmos_phy_tb_momx_t(:,:,:) = undef
110  atmos_phy_tb_momy_t(:,:,:) = undef
111  atmos_phy_tb_rhot_t(:,:,:) = undef
112  atmos_phy_tb_rhoq_t(:,:,:,:) = undef
113 
114  !--- read namelist
115  rewind(io_fid_conf)
116  read(io_fid_conf,nml=param_atmos_phy_tb_vars,iostat=ierr)
117  if( ierr < 0 ) then !--- missing
118  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
119  elseif( ierr > 0 ) then !--- fatal error
120  write(*,*) 'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_TB_VARS. Check!'
121  call prc_mpistop
122  endif
123  if( io_nml ) write(io_fid_nml,nml=param_atmos_phy_tb_vars)
124 
125 ! if( IO_L ) write(IO_FID_LOG,*)
126 ! if( IO_L ) write(IO_FID_LOG,*) '*** [ATMOS_PHY_TB] prognostic/diagnostic variables'
127 ! if( IO_L ) write(IO_FID_LOG,'(1x,A,A24,A,A48,A,A12,A)') &
128 ! '*** |', 'VARNAME ','|', &
129 ! 'DESCRIPTION ', '[', 'UNIT ', ']'
130 ! do iv = 1, VMAX
131 ! if( IO_L ) write(IO_FID_LOG,'(1x,A,I3,A,A24,A,A48,A,A12,A)') &
132 ! '*** NO.',iv,'|',VAR_NAME(iv),'|',VAR_DESC(iv),'[',VAR_UNIT(iv),']'
133 ! enddo
134 
135 ! if( IO_L ) write(IO_FID_LOG,*)
136 ! if ( ATMOS_PHY_TB_RESTART_IN_BASENAME /= '' ) then
137 ! if( IO_L ) write(IO_FID_LOG,*) '*** Restart input? : YES, file = ', trim(ATMOS_PHY_TB_RESTART_IN_BASENAME)
138 ! if( IO_L ) write(IO_FID_LOG,*) '*** Add timelabel? : ', ATMOS_PHY_TB_RESTART_IN_POSTFIX_TIMELABEL
139 ! else
140 ! if( IO_L ) write(IO_FID_LOG,*) '*** Restart input? : NO'
141 ! endif
142 ! if ( ATMOS_PHY_TB_RESTART_OUTPUT &
143 ! .AND. ATMOS_PHY_TB_RESTART_OUT_BASENAME /= '' ) then
144 ! if( IO_L ) write(IO_FID_LOG,*) '*** Restart output? : YES, file = ', trim(ATMOS_PHY_TB_RESTART_OUT_BASENAME)
145 ! if( IO_L ) write(IO_FID_LOG,*) '*** Add timelabel? : ', ATMOS_PHY_TB_RESTART_OUT_POSTFIX_TIMELABEL
146 ! else
147 ! if( IO_L ) write(IO_FID_LOG,*) '*** Restart output? : NO'
148 ! ATMOS_PHY_TB_RESTART_OUTPUT = .false.
149 ! endif
150 
151  return
152  end subroutine atmos_phy_tb_vars_setup
153 
154  !-----------------------------------------------------------------------------
156  subroutine atmos_phy_tb_vars_fillhalo
157  use scale_comm, only: &
158  comm_vars8, &
159  comm_wait
160  implicit none
161  !---------------------------------------------------------------------------
162 
163 ! do j = 1, JA
164 ! do i = 1, IA
165 ! ATMOS_PHY_TB_??( 1:KS-1,i,j) = ATMOS_PHY_TB_??(KS,i,j)
166 ! ATMOS_PHY_TB_??(KE+1:KA, i,j) = ATMOS_PHY_TB_??(KE,i,j)
167 ! enddo
168 ! enddo
169 
170 ! call COMM_vars8( ATMOS_PHY_TB_??(:,:,:), 1 )
171 ! call COMM_wait ( ATMOS_PHY_TB_??(:,:,:), 1 )
172 
173  return
174  end subroutine atmos_phy_tb_vars_fillhalo
175 
176  !-----------------------------------------------------------------------------
179  use scale_time, only: &
181  use scale_fileio, only: &
183  implicit none
184 
185  character(len=19) :: timelabel
186  character(len=H_LONG) :: basename
187  !---------------------------------------------------------------------------
188 
189 ! if( IO_L ) write(IO_FID_LOG,*)
190 ! if( IO_L ) write(IO_FID_LOG,*) '*** Open restart file (ATMOS_PHY_TB) ***'
191 
192 ! if ( ATMOS_PHY_TB_RESTART_IN_BASENAME /= '' ) then
193 
194 ! if ( ATMOS_PHY_TB_RESTART_IN_POSTFIX_TIMELABEL ) then
195 ! call TIME_gettimelabel( timelabel )
196 ! basename = trim(ATMOS_PHY_TB_RESTART_IN_BASENAME)//'_'//trim(timelabel)
197 ! else
198 ! basename = trim(ATMOS_PHY_TB_RESTART_IN_BASENAME)
199 ! endif
200 
201 ! if( IO_L ) write(IO_FID_LOG,*) '*** basename: ', trim(basename)
202 
203 ! call FILEIO_open( restart_fid, basename )
204 ! else
205 ! if( IO_L ) write(IO_FID_LOG,*) '*** restart file for ATMOS_PHY_TB is not specified.'
206 ! endif
207 
208  return
209  end subroutine atmos_phy_tb_vars_restart_open
210 
211  !-----------------------------------------------------------------------------
214  use scale_rm_statistics, only: &
216  stat_total
217  use scale_fileio, only: &
218  fileio_read, &
220  implicit none
221 
222  real(RP) :: total
223  integer :: i, j
224  !---------------------------------------------------------------------------
225 
226 ! if ( restart_fid /= -1 ) then
227 ! if( IO_L ) write(IO_FID_LOG,*)
228 ! if( IO_L ) write(IO_FID_LOG,*) '*** Read from restart file (ATMOS_PHY_TB) ***'
229 !
230 ! call FILEIO_read( ATMOS_PHY_TB_??(:,:,:), & ! [OUT]
231 ! restart_fid, VAR_NAME(1), 'ZXY', step=1 ) ! [IN]
232 !
233 ! if ( IO_AGGREGATE ) then
234 ! call FILEIO_flush( restart_fid ) ! X/Y halos have been read from file
235 !
236 ! ! fill k halos
237 ! do j = 1, JA
238 ! do i = 1, IA
239 ! ATMOS_PHY_TB_??( 1:KS-1,i,j) = ATMOS_PHY_TB_??(KS,i,j)
240 ! ATMOS_PHY_TB_??(KE+1:KA, i,j) = ATMOS_PHY_TB_??(KE,i,j)
241 ! enddo
242 ! enddo
243 ! else
244 ! call ATMOS_PHY_TB_vars_fillhalo
245 ! end if
246 !
247 ! if ( STATISTICS_checktotal ) then
248 ! call STAT_total( total, ATMOS_PHY_TB_??(:,:,:), VAR_NAME(1) )
249 ! endif
250 ! else
251 ! if( IO_L ) write(IO_FID_LOG,*) '*** invalid restart file ID for ATMOS_PHY_TB.'
252 ! endif
253 
254  return
255  end subroutine atmos_phy_tb_vars_restart_read
256 
257  !-----------------------------------------------------------------------------
260  use scale_time, only: &
262  use scale_fileio, only: &
264  implicit none
265 
266  character(len=19) :: timelabel
267  character(len=H_LONG) :: basename
268  !---------------------------------------------------------------------------
269 
270 ! if ( ATMOS_PHY_TB_RESTART_OUT_BASENAME /= '' ) then
271 !
272 ! if( IO_L ) write(IO_FID_LOG,*)
273 ! if( IO_L ) write(IO_FID_LOG,*) '*** Create restart file (ATMOS_PHY_AE) ***'
274 !
275 ! if ( ATMOS_PHY_TB_RESTART_OUT_POSTFIX_TIMELABEL ) then
276 ! call TIME_gettimelabel( timelabel )
277 ! basename = trim(ATMOS_PHY_TB_RESTART_OUT_BASENAME)//'_'//trim(timelabel)
278 ! else
279 ! basename = trim(ATMOS_PHY_TB_RESTART_OUT_BASENAME)
280 ! endif
281 !
282 ! if( IO_L ) write(IO_FID_LOG,*) '*** basename: ', trim(basename)
283 !
284 ! call FILEIO_create( restart_fid, & ! [OUT]
285 ! basename, ATMOS_PHY_TB_RESTART_OUT_TITLE, ATMOS_PHY_TB_RESTART_OUT_DTYPE ) ! [IN]
286 ! endif
287 
288  return
289  end subroutine atmos_phy_tb_vars_restart_create
290 
291  !-----------------------------------------------------------------------------
294  use scale_fileio, only: &
296  implicit none
297 
298 ! if ( restart_fid /= -1 ) then
299 ! call FILEIO_enddef( restart_fid ) ! [IN]
300 ! endif
301 
302  return
303  end subroutine atmos_phy_tb_vars_restart_enddef
304 
305  !-----------------------------------------------------------------------------
308  use scale_fileio, only: &
310  implicit none
311  !---------------------------------------------------------------------------
312 
313 ! if ( restart_fid /= -1 ) then
314 ! if( IO_L ) write(IO_FID_LOG,*)
315 ! if( IO_L ) write(IO_FID_LOG,*) '*** Close restart file (ATMOS_PHY_TB) ***'
316 !
317 ! call FILEIO_close( restart_fid ) ! [IN]
318 !
319 ! restart_fid = -1
320 ! endif
321 
322  return
323  end subroutine atmos_phy_tb_vars_restart_close
324 
325  !-----------------------------------------------------------------------------
328  use scale_fileio, only: &
330  implicit none
331  !---------------------------------------------------------------------------
332 
333 ! if ( restart_fid /= -1 ) then
334 
335 ! call FILEIO_def_var( restart_fid, VAR_ID(1), VAR_NAME(1), VAR_DESC(1), &
336 ! VAR_UNIT(1), 'ZXY', ATMOS_PHY_TB_RESTART_OUT_DTYPE ) ! [IN]
337 
338 ! endif
339 
340  return
341  end subroutine atmos_phy_tb_vars_restart_def_var
342 
343  !-----------------------------------------------------------------------------
346  use scale_rm_statistics, only: &
348  stat_total
349  use scale_fileio, only: &
350  fileio_write_var
351  implicit none
352 
353  real(RP) :: total
354  !---------------------------------------------------------------------------
355 
356 ! if ( restart_fid /= -1 ) then
357 !
358 ! call ATMOS_PHY_TB_vars_fillhalo
359 !
360 ! if ( STATISTICS_checktotal ) then
361 ! call STAT_total( total, ATMOS_PHY_TB_??(:,:,:), VAR_NAME(1) )
362 ! endif
363 !
364 ! call FILEIO_write_var( restart_fid, VAR_ID(1), ATMOS_PHY_TB_??(:,:,:), &
365 ! VAR_NAME(1), 'ZXY' ) ! [IN]
366 !
367 ! endif
368 
369  return
370  end subroutine atmos_phy_tb_vars_restart_write
371 
372 end module mod_atmos_phy_tb_vars
logical, public statistics_checktotal
calc&report variable totals to logfile?
subroutine, public atmos_phy_tb_vars_restart_enddef
Exit netCDF define mode.
subroutine, public atmos_phy_tb_vars_restart_read
Read restart.
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_momx_t
subroutine, public prc_mpistop
Abort MPI.
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_rhot_t
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:61
subroutine, public atmos_phy_tb_vars_restart_write
Write restart.
subroutine, public fileio_flush(fid)
Flush all pending requests to a netCDF file (PnetCDF only)
module STDIO
Definition: scale_stdio.F90:12
integer, public qa
logical, public atmos_phy_tb_restart_in_postfix_timelabel
Add timelabel to the basename of input file?
character(len=h_mid), public atmos_phy_tb_restart_out_title
title of the output file
module FILE I/O (netcdf)
real(rp), public const_undef
Definition: scale_const.F90:43
subroutine, public atmos_phy_tb_vars_restart_create
Create restart file.
module Statistics
module grid index
character(len=h_long), public atmos_phy_tb_restart_in_basename
Basename of the input file.
logical, public io_nml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:62
module TRACER
logical, public atmos_phy_tb_restart_out_postfix_timelabel
Add timelabel to the basename of output file?
integer, public ia
of whole cells: x, local, with HALO
subroutine, public time_gettimelabel(timelabel)
generate time label
Definition: scale_time.F90:90
integer, public ka
of whole cells: z, local, with HALO
subroutine, public fileio_create(fid, basename, title, datatype, date, subsec, append, nozcoord)
Create/open a netCDF file.
module COMMUNICATION
Definition: scale_comm.F90:23
subroutine, public atmos_phy_tb_vars_setup
Setup.
module TIME
Definition: scale_time.F90:15
module PROCESS
module Atmosphere / Physics Turbulence
module CONSTANT
Definition: scale_const.F90:14
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_momy_t
subroutine, public fileio_enddef(fid)
Exit netCDF file define mode.
module profiler
Definition: scale_prof.F90:10
character(len=h_long), public atmos_phy_tb_restart_out_basename
Basename of the output file.
logical, public atmos_phy_tb_restart_output
output restart file?
subroutine, public atmos_phy_tb_vars_restart_def_var
Write restart.
subroutine, public atmos_phy_tb_vars_fillhalo
HALO Communication.
subroutine, public fileio_open(fid, basename)
open a netCDF file for read
module PRECISION
subroutine, public fileio_def_var(fid, vid, varname, desc, unit, axistype, datatype, timeintv, nsteps)
Define a variable to file.
real(rp), dimension(:,:,:,:), allocatable, public atmos_phy_tb_rhoq_t
subroutine, public fileio_close(fid)
Close a netCDF file.
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
character(len=h_short), public atmos_phy_tb_restart_out_dtype
REAL4 or REAL8.
subroutine, public atmos_phy_tb_vars_restart_open
Open restart file for read.
integer, public io_fid_nml
Log file ID (only for output namelist)
Definition: scale_stdio.F90:57
subroutine, public atmos_phy_tb_vars_restart_close
Close restart file.
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_momz_t
integer, public ja
of whole cells: y, local, with HALO