SCALE-RM
scale_urban_grid_icoA.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
22  !-----------------------------------------------------------------------------
23  implicit none
24  private
25  !-----------------------------------------------------------------------------
26  !
27  !++ Public procedure
28  !
29  public :: urban_grid_icoa_setup
30  public :: urban_grid_icoa_finalize
31 
32  !-----------------------------------------------------------------------------
33  !
34  !++ Public parameters & variables
35  !
36  real(rp), public, allocatable :: urban_grid_icoa_cz (:)
37  real(rp), public, allocatable :: urban_grid_icoa_fz (:)
38  real(rp), public, allocatable :: urban_grid_icoa_cdz (:)
39 
40  !-----------------------------------------------------------------------------
41  !
42  !++ Private procedure
43  !
44  private :: urban_grid_icoa_read
45  private :: urban_grid_icoa_generate
46 
47  !-----------------------------------------------------------------------------
48  !
49  !++ Private parameters & variables
50  !
51  real(rp), private :: udz(200)
52 
53  character(len=H_LONG) :: urban_grid_icoa_in_basename = ''
54  logical :: urban_grid_icoa_in_aggregate
55 
56  !-----------------------------------------------------------------------------
57 contains
58  !-----------------------------------------------------------------------------
60  subroutine urban_grid_icoa_setup
61  use scale_prc, only: &
62  prc_abort
63  use scale_file, only: &
65  implicit none
66 
67  namelist / param_urban_grid_icoa / &
68  urban_grid_icoa_in_basename, &
69  urban_grid_icoa_in_aggregate, &
70  udz
71 
72  integer :: ierr
73  integer :: k
74  !---------------------------------------------------------------------------
75 
76  log_newline
77  log_info("URBAN_GRID_ICOA_setup",*) 'Setup'
78 
79  if ( ukmax < 1 ) then
80  log_info("URBAN_GRID_ICOA_setup",*) 'Skip because UKMAX < 1'
81  return
82  end if
83 
84  udz(:) = 0.0_rp
85 
86  urban_grid_icoa_in_aggregate = file_aggregate
87 
88  !--- read namelist
89  rewind(io_fid_conf)
90  read(io_fid_conf,nml=param_urban_grid_icoa,iostat=ierr)
91  if( ierr < 0 ) then !--- missing
92  log_info("URBAN_GRID_ICOA_setup",*) 'Not found namelist. Default used.'
93  elseif( ierr > 0 ) then !--- fatal error
94  log_error("URBAN_GRID_ICOA_setup",*) 'Not appropriate names in namelist PARAM_URBAN_GRID_ICOA. Check!'
95  call prc_abort
96  endif
97  log_nml(param_urban_grid_icoa)
98 
99  allocate( urban_grid_icoa_cz(uks :uke) )
100  allocate( urban_grid_icoa_fz(uks-1:uke) )
101  allocate( urban_grid_icoa_cdz(uks :uke) )
102  !$acc enter data create(URBAN_GRID_ICOA_CZ,URBAN_GRID_ICOA_FZ,URBAN_GRID_ICOA_CDZ)
103 
104  log_newline
105  log_info("URBAN_GRID_ICOA_setup",*) 'Urban grid information '
106 
107  if ( urban_grid_icoa_in_basename /= '' ) then
108  call urban_grid_icoa_read
109  else
110  log_info("URBAN_GRID_ICOA_setup",*) 'Not found input grid file. Grid position is calculated.'
111 
112  call urban_grid_icoa_generate
113  endif
114 
115  if ( uke == uks ) then
116  log_newline
117  log_info("URBAN_GRID_ICOA_setup",*) 'Single layer. LDZ = ', udz(1)
118  else
119  log_newline
120  log_info("URBAN_GRID_ICOA_setup",'(1x,A)') 'Vertical Coordinate'
121  log_info_cont('(1x,A)') '| k z zh dz k |'
122  log_info_cont('(1x,A)') '| [m] [m] [m] |'
123  k = uks-1
124  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',urban_grid_icoa_fz(k),' ',k,' | Atmosphere interface'
125  do k = uks, uke-1
126  log_info_cont('(1x,A,I4,F8.3,A,F8.3,A)') '|',k,urban_grid_icoa_cz(k),' ',urban_grid_icoa_cdz(k),' | '
127  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',urban_grid_icoa_fz(k),' |',k,' | '
128  enddo
129  k = uke
130  log_info_cont('(1x,A,I4,F8.3,A,F8.3,A)') '|',k,urban_grid_icoa_cz(k),' ',urban_grid_icoa_cdz(k),' | '
131  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',urban_grid_icoa_fz(k),' ',k,' | bedrock'
132  log_info_cont('(1x,A)') '|=================================|'
133  endif
134 
135  !$acc update device(URBAN_GRID_ICOA_CZ,URBAN_GRID_ICOA_FZ,URBAN_GRID_ICOA_CDZ)
136 
137  return
138  end subroutine urban_grid_icoa_setup
139 
140  subroutine urban_grid_icoa_finalize
141 
142  !$acc exit data delete(URBAN_GRID_ICOA_CZ,URBAN_GRID_ICOA_FZ,URBAN_GRID_ICOA_CDZ)
143  deallocate( urban_grid_icoa_cz )
144  deallocate( urban_grid_icoa_fz )
145  deallocate( urban_grid_icoa_cdz )
146 
147  return
148  end subroutine urban_grid_icoa_finalize
149 
150  !-----------------------------------------------------------------------------
152  subroutine urban_grid_icoa_read
153  use scale_file, only: &
154  file_open, &
155  file_read
156  use scale_prc, only: &
157  prc_myrank
158  implicit none
159 
160  integer :: fid
161  !---------------------------------------------------------------------------
162 
163  log_newline
164  log_info("URBAN_GRID_ICOA_read",*) 'Input urban grid file '
165 
166  call file_open( urban_grid_icoa_in_basename, fid, rankid=prc_myrank, aggregate=urban_grid_icoa_in_aggregate )
167 
168  call file_read( fid, 'UCZ', urban_grid_icoa_cz(:) )
169  call file_read( fid, 'UCDZ', urban_grid_icoa_cdz(:) )
170  call file_read( fid, 'UFZ', urban_grid_icoa_fz(:) )
171 
172  return
173  end subroutine urban_grid_icoa_read
174 
175  !-----------------------------------------------------------------------------
177  subroutine urban_grid_icoa_generate
178  implicit none
179 
180  integer :: k
181  !---------------------------------------------------------------------------
182 
183  do k = uks, uke
184  urban_grid_icoa_cdz(k) = udz(k)
185  enddo
186 
187  urban_grid_icoa_fz(uks-1) = 0.0_rp
188 
189  do k = uks, uke
192  enddo
193 
194  return
195  end subroutine urban_grid_icoa_generate
196 
197 end module scale_urban_grid_icoa
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale_urban_grid_icoa_index::ukmax
integer, public ukmax
Definition: scale_urban_grid_icoA_index.F90:32
scale_file::file_open
subroutine, public file_open(basename, fid, mode, single, allnodes, aggregate, rankid, postfix)
Definition: scale_file.F90:536
scale_urban_grid_icoa::urban_grid_icoa_cz
real(rp), dimension(:), allocatable, public urban_grid_icoa_cz
center coordinate [m]: z, local=global
Definition: scale_urban_grid_icoA.F90:36
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_urban_grid_icoa
module urban / grid / icosahedralA
Definition: scale_urban_grid_icoA.F90:12
scale_urban_grid_icoa::urban_grid_icoa_setup
subroutine, public urban_grid_icoa_setup
Setup.
Definition: scale_urban_grid_icoA.F90:61
scale_prc::prc_myrank
integer, public prc_myrank
process num in local communicator
Definition: scale_prc.F90:91
scale_urban_grid_icoa::urban_grid_icoa_cdz
real(rp), dimension(:), allocatable, public urban_grid_icoa_cdz
z-length of control volume [m]
Definition: scale_urban_grid_icoA.F90:38
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_io
module STDIO
Definition: scale_io.F90:10
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_urban_grid_icoa_index::uke
integer, public uke
Definition: scale_urban_grid_icoA_index.F90:38
scale_file::file_aggregate
logical, public file_aggregate
Definition: scale_file.F90:196
scale_atmos_grid_icoa_index
module atmosphere / grid / icosahedralA / index
Definition: scale_atmos_grid_icoA_index.F90:12
scale_urban_grid_icoa_index
module urban / grid / icosahedralA / index
Definition: scale_urban_grid_icoA_index.F90:11
scale_urban_grid_icoa::urban_grid_icoa_fz
real(rp), dimension(:), allocatable, public urban_grid_icoa_fz
face coordinate [m]: z, local=global
Definition: scale_urban_grid_icoA.F90:37
scale_urban_grid_icoa_index::uks
integer, public uks
Definition: scale_urban_grid_icoA_index.F90:37
scale_urban_grid_icoa::urban_grid_icoa_finalize
subroutine, public urban_grid_icoa_finalize
Definition: scale_urban_grid_icoA.F90:141
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:57