SCALE-RM
mod_atmos_dyn_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_dyn_vars_setup
32  public :: atmos_dyn_vars_fillhalo
35 
36  !-----------------------------------------------------------------------------
37  !
38  !++ Public parameters & variables
39  !
40  logical, public :: atmos_dyn_restart_output = .false.
41 
42  character(len=H_LONG), public :: atmos_dyn_restart_in_basename = ''
43  character(len=H_LONG), public :: atmos_dyn_restart_out_basename = ''
44  character(len=H_MID), public :: atmos_dyn_restart_out_title = 'ATMOS_DYN restart'
45  character(len=H_MID), public :: atmos_dyn_restart_out_dtype = 'DEFAULT'
46 
47  ! prognostic variables
48  real(RP), public, allocatable :: prog(:,:,:,:)
49 
50  !-----------------------------------------------------------------------------
51  !
52  !++ Private procedure
53  !
54  !-----------------------------------------------------------------------------
55  !
56  !++ Private parameters & variables
57  !
58  integer, private, parameter :: vmax = 100
59  integer, private :: va = 0
60  character(len=H_SHORT), private :: var_name(vmax)
61  character(len=H_MID), private :: var_desc(vmax)
62  character(len=H_SHORT), private :: var_unit(vmax)
63 
64  !-----------------------------------------------------------------------------
65 contains
66  !-----------------------------------------------------------------------------
68  subroutine atmos_dyn_vars_setup
69  use scale_process, only: &
71  use scale_const, only: &
72  undef => const_undef
73  use mod_atmos_admin, only: &
75  use scale_atmos_dyn_tstep_short, only: &
77  implicit none
78 
79  namelist / param_atmos_dyn_vars / &
85 
86  integer :: ierr
87  integer :: iv
88  !---------------------------------------------------------------------------
89 
90  if( io_l ) write(io_fid_log,*)
91  if( io_l ) write(io_fid_log,*) '++++++ Module[VARS] / Categ[ATMOS DYN] / Origin[SCALE-RM]'
92 
93  !--- read namelist
94  rewind(io_fid_conf)
95  read(io_fid_conf,nml=param_atmos_dyn_vars,iostat=ierr)
96  if( ierr < 0 ) then !--- missing
97  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
98  elseif( ierr > 0 ) then !--- fatal error
99  write(*,*) 'xxx Not appropriate names in namelist PARAM_ATMOS_DYN_VARS. Check!'
100  call prc_mpistop
101  endif
102  if( io_lnml ) write(io_fid_log,nml=param_atmos_dyn_vars)
103 
105  va, & ! [OUT]
106  var_name, & ! [OUT]
107  var_desc, & ! [OUT]
108  var_unit ) ! [OUT]
109 
110  if ( va > 0 ) then ! additional prognostic variables
111 
112  if ( va > vmax ) then
113  write(*,*) 'xxx number of the prognostic variables is exceed the limit', va, ' > ', vmax
114  call prc_mpistop
115  endif
116  allocate( prog(ka,ia,ja,va) )
117  prog(:,:,:,:) = undef
118 
119  if( io_l ) write(io_fid_log,*)
120  if( io_l ) write(io_fid_log,*) '*** [ATMOS_DYN] prognostic/diagnostic variables'
121  if( io_l ) write(io_fid_log,'(1x,A,A15,A,A32,3(A))') &
122  '*** |','VARNAME ','|', 'DESCRIPTION ','[', 'UNIT ',']'
123  do iv = 1, va
124  if( io_l ) write(io_fid_log,'(1x,A,i3,A,A15,A,A32,3(A))') &
125  '*** NO.',iv,'|',var_name(iv),'|',var_desc(iv),'[',var_unit(iv),']'
126  enddo
127 
128  if( io_l ) write(io_fid_log,*)
129 
130  if ( atmos_dyn_restart_in_basename /= '' ) then
131  if( io_l ) write(io_fid_log,*) '*** Restart input? : ', trim(atmos_dyn_restart_in_basename)
132  else
133  if( io_l ) write(io_fid_log,*) '*** Restart input? : NO'
134  endif
135 
137  .AND. atmos_dyn_restart_out_basename /= '' ) then
138  if( io_l ) write(io_fid_log,*) '*** Restart output? : ', trim(atmos_dyn_restart_out_basename)
139  else
140  if( io_l ) write(io_fid_log,*) '*** Restart output? : NO'
141  atmos_dyn_restart_output = .false.
142  endif
143 
144  else ! no additional prognostic variables
145 
146  allocate( prog(ka,ia,ja,1) ) ! for safety
147  prog(:,:,:,:) = undef
148  atmos_dyn_restart_output = .false.
149 
150  endif
151 
152  return
153  end subroutine atmos_dyn_vars_setup
154 
155  !-----------------------------------------------------------------------------
157  subroutine atmos_dyn_vars_fillhalo
158  use scale_comm, only: &
159  comm_vars8, &
160  comm_wait
161  implicit none
162 
163  integer :: i, j, iv
164  !---------------------------------------------------------------------------
165 
166  do iv = 1, va
167  do j = js, je
168  do i = is, ie
169  prog( 1:ks-1,i,j,iv) = prog(ks,i,j,iv)
170  prog(ke+1:ka, i,j,iv) = prog(ke,i,j,iv)
171  enddo
172  enddo
173 
174  call comm_vars8( prog(:,:,:,iv), iv )
175  enddo
176 
177  do iv = 1, va
178  call comm_wait ( prog(:,:,:,iv), iv )
179  enddo
180 
181  return
182  end subroutine atmos_dyn_vars_fillhalo
183 
184  !-----------------------------------------------------------------------------
186  subroutine atmos_dyn_vars_restart_read
187  use scale_fileio, only: &
188  fileio_read
189  use scale_rm_statistics, only: &
190  stat_total
191  implicit none
192 
193  real(RP) :: total
194  integer :: iv
195  !---------------------------------------------------------------------------
196 
197  if( io_l ) write(io_fid_log,*)
198  if( io_l ) write(io_fid_log,*) '*** Input restart file (ATMOS_DYN) ***'
199 
200  if ( atmos_dyn_restart_in_basename /= '' ) then
201  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(atmos_dyn_restart_in_basename)
202 
203  do iv = 1, va
204  call fileio_read( prog(:,:,:,iv), & ! [OUT]
205  atmos_dyn_restart_in_basename, var_name(iv), 'ZXY', step=1 ) ! [IN]
206 
207  enddo
208 
210 
211  do iv = 1, va
212  call stat_total( total, prog(:,:,:,iv), var_name(iv) )
213  enddo
214  else
215  if( io_l ) write(io_fid_log,*) '*** restart file for ATMOS_DYN is not specified.'
216  endif
217 
218  return
219  end subroutine atmos_dyn_vars_restart_read
220 
221  !-----------------------------------------------------------------------------
224  use scale_time, only: &
226  use scale_fileio, only: &
227  fileio_write
228  implicit none
229 
230  character(len=20) :: timelabel
231  character(len=H_LONG) :: basename
232  integer :: iv
233  !---------------------------------------------------------------------------
234 
235  if ( atmos_dyn_restart_out_basename /= '' ) then
236 
237  call time_gettimelabel( timelabel )
238  write(basename,'(A,A,A)') trim(atmos_dyn_restart_out_basename), '_', trim(timelabel)
239 
240  if( io_l ) write(io_fid_log,*)
241  if( io_l ) write(io_fid_log,*) '*** Output restart file (ATMOS_DYN) ***'
242  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
243 
244  do iv = 1, va
245  call fileio_write( prog(:,:,:,iv), basename, atmos_dyn_restart_out_title, & ! [IN]
246  var_name(iv), var_desc(iv), var_unit(iv), 'ZXY', atmos_dyn_restart_out_dtype ) ! [IN]
247  enddo
248 
249  endif
250 
251  return
252  end subroutine atmos_dyn_vars_restart_write
253 
254 end module mod_atmos_dyn_vars
module ATMOS admin
integer, public is
start point of inner domain: x, local
integer, public je
end point of inner domain: y, local
subroutine, public prc_mpistop
Abort MPI.
module Atmosphere / Dynamical scheme
character(len=h_long), public atmos_dyn_restart_in_basename
basename of the restart file
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:59
module Atmosphere / Dynamics
module STDIO
Definition: scale_stdio.F90:12
integer, public ke
end point of inner domain: z, local
subroutine, public atmos_dyn_vars_restart_write
Write restart.
module FILE I/O (netcdf)
subroutine, public atmos_dyn_vars_fillhalo
HALO Communication.
character(len=h_mid), public atmos_dyn_restart_out_title
title of the output file
real(rp), public const_undef
Definition: scale_const.F90:43
module Statistics
module grid index
module TRACER
integer, public ia
of x whole cells (local, with HALO)
subroutine, public time_gettimelabel(timelabel)
generate time label
Definition: scale_time.F90:90
integer, public ka
of z whole cells (local, with HALO)
logical, public atmos_dyn_restart_output
output restart 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
subroutine, public atmos_dyn_vars_restart_read
Read restart.
module PROCESS
subroutine, public atmos_dyn_tstep_short_regist(ATMOS_DYN_TYPE, VA_out, VAR_NAME, VAR_DESC, VAR_UNIT)
Register.
real(rp), dimension(:,:,:,:), allocatable, public prog
module CONSTANT
Definition: scale_const.F90:14
integer, public ks
start point of inner domain: z, local
subroutine, public atmos_dyn_vars_setup
Setup.
module profiler
Definition: scale_prof.F90:10
integer, public ie
end point of inner domain: x, local
logical, public io_lnml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:60
module PRECISION
character(len=h_short), public atmos_dyn_type
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_mid), public atmos_dyn_restart_out_dtype
REAL4 or REAL8.
character(len=h_long), public atmos_dyn_restart_out_basename
basename of the output file
integer, public ja
of y whole cells (local, with HALO)