SCALE-RM
scale_urban_grid_cartesC.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_cartesc_setup
31 
32  !-----------------------------------------------------------------------------
33  !
34  !++ Public parameters & variables
35  !
36  real(rp), public, allocatable :: urban_grid_cartesc_cz (:)
37  real(rp), public, allocatable :: urban_grid_cartesc_fz (:)
38  real(rp), public, allocatable :: urban_grid_cartesc_cdz (:)
39 
40  !-----------------------------------------------------------------------------
41  !
42  !++ Private procedure
43  !
44  private :: urban_grid_cartesc_read
45  private :: urban_grid_cartesc_generate
46 
47  !-----------------------------------------------------------------------------
48  !
49  !++ Private parameters & variables
50  !
51  real(rp), private :: udz(200)
52 
53  character(len=H_LONG) :: urban_grid_cartesc_in_basename = ''
54  logical :: urban_grid_cartesc_in_aggregate
55 
56  !-----------------------------------------------------------------------------
57 contains
58  !-----------------------------------------------------------------------------
60  subroutine urban_grid_cartesc_setup
61  use scale_prc, only: &
62  prc_abort
63  use scale_file, only: &
65  implicit none
66 
67  namelist / param_urban_grid_cartesc / &
68  urban_grid_cartesc_in_basename, &
69  urban_grid_cartesc_in_aggregate, &
70  udz
71 
72  integer :: ierr
73  integer :: k
74  !---------------------------------------------------------------------------
75 
76  log_newline
77  log_info("URBAN_GRID_CARTESC_setup",*) 'Setup'
78 
79  if ( ukmax < 1 ) then
80  log_info("URBAN_GRID_CARTESC_setup",*) 'Skip because UKMAX < 1'
81  return
82  end if
83 
84  udz(:) = 0.0_rp
85 
86  urban_grid_cartesc_in_aggregate = file_aggregate
87 
88  !--- read namelist
89  rewind(io_fid_conf)
90  read(io_fid_conf,nml=param_urban_grid_cartesc,iostat=ierr)
91  if( ierr < 0 ) then !--- missing
92  log_info("URBAN_GRID_CARTESC_setup",*) 'Not found namelist. Default used.'
93  elseif( ierr > 0 ) then !--- fatal error
94  log_error("URBAN_GRID_CARTESC_setup",*) 'Not appropriate names in namelist PARAM_URBAN_GRID_CARTESC. Check!'
95  call prc_abort
96  endif
97  log_nml(param_urban_grid_cartesc)
98 
99  allocate( urban_grid_cartesc_cz(uks :uke) )
100  allocate( urban_grid_cartesc_fz(uks-1:uke) )
101  allocate( urban_grid_cartesc_cdz(uks :uke) )
102  !$acc enter data create(URBAN_GRID_CARTESC_CZ,URBAN_GRID_CARTESC_FZ,URBAN_GRID_CARTESC_CDZ)
103 
104  log_newline
105  log_info("URBAN_GRID_CARTESC_setup",*) 'Urban grid information '
106 
107  if ( urban_grid_cartesc_in_basename /= '' ) then
108  call urban_grid_cartesc_read
109  else
110  log_info("URBAN_GRID_CARTESC_setup",*) 'Not found input grid file. Grid position is calculated.'
111 
112  call urban_grid_cartesc_generate
113  endif
114 
115  if ( uke == uks ) then
116  log_newline
117  log_info("URBAN_GRID_CARTESC_setup",*) 'Single layer. LDZ = ', udz(1)
118  else
119  log_newline
120  log_info("URBAN_GRID_CARTESC_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_cartesc_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_cartesc_cz(k),' ',urban_grid_cartesc_cdz(k),' | '
127  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',urban_grid_cartesc_fz(k),' |',k,' | '
128  enddo
129  k = uke
130  log_info_cont('(1x,A,I4,F8.3,A,F8.3,A)') '|',k,urban_grid_cartesc_cz(k),' ',urban_grid_cartesc_cdz(k),' | '
131  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',urban_grid_cartesc_fz(k),' ',k,' | bedrock'
132  log_info_cont('(1x,A)') '|=================================|'
133  endif
134 
135  !$acc update device(URBAN_GRID_CARTESC_CZ,URBAN_GRID_CARTESC_FZ,URBAN_GRID_CARTESC_CDZ)
136 
137  return
138  end subroutine urban_grid_cartesc_setup
139 
140  !-----------------------------------------------------------------------------
142  subroutine urban_grid_cartesc_finalize
143  implicit none
144  !---------------------------------------------------------------------------
145 
146  log_newline
147  log_info("URBAN_GRID_CARTESC_finalize",*) 'Finalize'
148 
149  !$acc exit data delete(URBAN_GRID_CARTESC_CZ,URBAN_GRID_CARTESC_FZ,URBAN_GRID_CARTESC_CDZ)
150  deallocate( urban_grid_cartesc_cz )
151  deallocate( urban_grid_cartesc_fz )
152  deallocate( urban_grid_cartesc_cdz )
153 
154  return
155  end subroutine urban_grid_cartesc_finalize
156 
157  !-----------------------------------------------------------------------------
159  subroutine urban_grid_cartesc_read
160  use scale_file, only: &
161  file_open, &
162  file_read
163  use scale_prc, only: &
164  prc_myrank
165  implicit none
166 
167  integer :: fid
168  !---------------------------------------------------------------------------
169 
170  log_newline
171  log_info("URBAN_GRID_CARTESC_read",*) 'Input urban grid file '
172 
173  call file_open( urban_grid_cartesc_in_basename, fid, rankid=prc_myrank, aggregate=urban_grid_cartesc_in_aggregate )
174 
175  call file_read( fid, 'UCZ', urban_grid_cartesc_cz(:) )
176  call file_read( fid, 'UCDZ', urban_grid_cartesc_cdz(:) )
177  call file_read( fid, 'UFZ', urban_grid_cartesc_fz(:) )
178 
179  return
180  end subroutine urban_grid_cartesc_read
181 
182  !-----------------------------------------------------------------------------
184  subroutine urban_grid_cartesc_generate
185  implicit none
186 
187  integer :: k
188  !---------------------------------------------------------------------------
189 
190  do k = uks, uke
191  urban_grid_cartesc_cdz(k) = udz(k)
192  enddo
193 
194  urban_grid_cartesc_fz(uks-1) = 0.0_rp
195 
196  do k = uks, uke
199  enddo
200 
201  return
202  end subroutine urban_grid_cartesc_generate
203 
204 end module scale_urban_grid_cartesc
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale_urban_grid_cartesc::urban_grid_cartesc_cdz
real(rp), dimension(:), allocatable, public urban_grid_cartesc_cdz
z-length of control volume [m]
Definition: scale_urban_grid_cartesC.F90:38
scale_file::file_open
subroutine, public file_open(basename, fid, mode, single, allnodes, aggregate, rankid, postfix)
Definition: scale_file.F90:536
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_prc::prc_myrank
integer, public prc_myrank
process num in local communicator
Definition: scale_prc.F90:91
scale_urban_grid_cartesc_index
module urban / grid / icosahedralA / index
Definition: scale_urban_grid_cartesC_index.F90:11
scale_urban_grid_cartesc::urban_grid_cartesc_cz
real(rp), dimension(:), allocatable, public urban_grid_cartesc_cz
center coordinate [m]: z, local=global
Definition: scale_urban_grid_cartesC.F90:36
scale_file
module file
Definition: scale_file.F90:15
scale_urban_grid_cartesc_index::ukmax
integer, public ukmax
Definition: scale_urban_grid_cartesC_index.F90:32
scale_urban_grid_cartesc::urban_grid_cartesc_finalize
subroutine, public urban_grid_cartesc_finalize
Finalize.
Definition: scale_urban_grid_cartesC.F90:143
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_atmos_grid_cartesc_index
module atmosphere / grid / cartesC index
Definition: scale_atmos_grid_cartesC_index.F90:12
scale_urban_grid_cartesc
module urban / grid / cartesianC
Definition: scale_urban_grid_cartesC.F90:12
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_urban_grid_cartesc_index::uks
integer, public uks
Definition: scale_urban_grid_cartesC_index.F90:38
scale_file::file_aggregate
logical, public file_aggregate
Definition: scale_file.F90:196
scale_urban_grid_cartesc::urban_grid_cartesc_setup
subroutine, public urban_grid_cartesc_setup
Setup.
Definition: scale_urban_grid_cartesC.F90:61
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:57
scale_urban_grid_cartesc_index::uke
integer, public uke
Definition: scale_urban_grid_cartesC_index.F90:39
scale_urban_grid_cartesc::urban_grid_cartesc_fz
real(rp), dimension(:), allocatable, public urban_grid_cartesc_fz
face coordinate [m]: z, local=global
Definition: scale_urban_grid_cartesC.F90:37