SCALE-RM
scale_urban_grid.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
12 !-------------------------------------------------------------------------------
14  !-----------------------------------------------------------------------------
15  !
16  !++ used modules
17  !
18  use scale_precision
19  use scale_stdio
20  use scale_prof
23  !-----------------------------------------------------------------------------
24  implicit none
25  private
26  !-----------------------------------------------------------------------------
27  !
28  !++ Public procedure
29  !
30  public :: urban_grid_setup
31 
32  !-----------------------------------------------------------------------------
33  !
34  !++ Public parameters & variables
35  !
36  real(RP), public, allocatable :: grid_ucz (:)
37  real(RP), public, allocatable :: grid_ufz (:)
38  real(RP), public, allocatable :: grid_ucdz (:)
39 
40  !-----------------------------------------------------------------------------
41  !
42  !++ Private procedure
43  !
44  private :: urban_grid_read
45  private :: urban_grid_generate
46 
47  !-----------------------------------------------------------------------------
48  !
49  !++ Private parameters & variables
50  !
51  real(RP), private :: udz(200)
52 
53  character(len=H_LONG), private :: urban_grid_in_basename = ''
54  character(len=H_LONG), private :: urban_grid_out_basename = ''
55 
56  !-----------------------------------------------------------------------------
57 contains
58  !-----------------------------------------------------------------------------
60  subroutine urban_grid_setup
61  use scale_process, only: &
63  implicit none
64 
65  namelist / param_urban_grid / &
66  urban_grid_in_basename, &
67  urban_grid_out_basename, &
68  udz
69 
70  integer :: ierr
71  integer :: k
72  !---------------------------------------------------------------------------
73 
74  if( io_l ) write(io_fid_log,*)
75  if( io_l ) write(io_fid_log,*) '++++++ Module[GRID] / Categ[URBAN GRID] / Origin[SCALElib]'
76 
77  udz(:) = 0.0_rp
78 
79  !--- read namelist
80  rewind(io_fid_conf)
81  read(io_fid_conf,nml=param_urban_grid,iostat=ierr)
82  if( ierr < 0 ) then !--- missing
83  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
84  elseif( ierr > 0 ) then !--- fatal error
85  write(*,*) 'xxx Not appropriate names in namelist PARAM_URBAN_GRID. Check!'
86  call prc_mpistop
87  endif
88  if( io_nml ) write(io_fid_nml,nml=param_urban_grid)
89 
90  allocate( grid_ucz(uks :uke) )
91  allocate( grid_ufz(uks-1:uke) )
92  allocate( grid_ucdz(uks :uke) )
93 
94  if( io_l ) write(io_fid_log,*)
95  if( io_l ) write(io_fid_log,*) '*** Urban grid information ***'
96 
97  if ( urban_grid_in_basename /= '' ) then
98  call urban_grid_read
99  else
100  if( io_l ) write(io_fid_log,*) '*** Not found input grid file. Grid position is calculated.'
101 
102  call urban_grid_generate
103  endif
104 
105  if ( uke == uks ) then
106  if( io_l ) write(io_fid_log,*)
107  if( io_l ) write(io_fid_log,*) '*** Single layer. LDZ = ', udz(1)
108  else
109  if( io_l ) write(io_fid_log,*)
110  if( io_l ) write(io_fid_log,'(1x,A)') &
111  '|====== Vertical Coordinate ======|'
112  if( io_l ) write(io_fid_log,'(1x,A)') &
113  '| k z zh dz k |'
114  if( io_l ) write(io_fid_log,'(1x,A)') &
115  '| [m] [m] [m] |'
116  k = uks-1
117  if( io_l ) write(io_fid_log,'(1x,A,F8.3,A,I4,A)') &
118  '| ',grid_ufz(k),' ',k,' | Atmosphere interface'
119  do k = uks, uke-1
120  if( io_l ) write(io_fid_log,'(1x,A,I4,F8.3,A,F8.3,A)') &
121  '|',k,grid_ucz(k),' ',grid_ucdz(k),' | '
122  if( io_l ) write(io_fid_log,'(1x,A,F8.3,A,I4,A)') &
123  '| ',grid_ufz(k),' |',k,' | '
124  enddo
125  k = uke
126  if( io_l ) write(io_fid_log,'(1x,A,I4,F8.3,A,F8.3,A)') &
127  '|',k,grid_ucz(k),' ',grid_ucdz(k),' | '
128  if( io_l ) write(io_fid_log,'(1x,A,F8.3,A,I4,A)') &
129  '| ',grid_ufz(k),' ',k,' | bedrock'
130  if( io_l ) write(io_fid_log,'(1x,A)') &
131  '|=================================|'
132  endif
133 
134  return
135  end subroutine urban_grid_setup
136 
137  !-----------------------------------------------------------------------------
139  subroutine urban_grid_read
140  use gtool_file, only: &
141  fileread
142  use scale_process, only: &
143  prc_myrank
144  implicit none
145 
146  character(len=H_LONG) :: bname
147  !---------------------------------------------------------------------------
148 
149  if( io_l ) write(io_fid_log,*)
150  if( io_l ) write(io_fid_log,*) '*** Input urban grid file ***'
151 
152  write(bname,'(A,A,F15.3)') trim(urban_grid_in_basename)
153 
154  call fileread( grid_ucz(:), bname, 'UCZ', 1, prc_myrank )
155  call fileread( grid_ucdz(:), bname, 'UCDZ', 1, prc_myrank )
156  call fileread( grid_ufz(:), bname, 'UFZ', 1, prc_myrank )
157 
158  return
159  end subroutine urban_grid_read
160 
161  !-----------------------------------------------------------------------------
163  subroutine urban_grid_generate
164  implicit none
165 
166  integer :: k
167  !---------------------------------------------------------------------------
168 
169  do k = uks, uke
170  grid_ucdz(k) = udz(k)
171  enddo
172 
173  grid_ufz(uks-1) = 0.0_rp
174 
175  do k = uks, uke
176  grid_ucz(k) = grid_ucdz(k) / 2.0_rp + grid_ufz(k-1)
177  grid_ufz(k) = grid_ucdz(k) + grid_ufz(k-1)
178  enddo
179 
180  return
181  end subroutine urban_grid_generate
182 
183 end module scale_urban_grid
module GTOOL_FILE
Definition: gtool_file.f90:17
subroutine, public prc_mpistop
Abort MPI.
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:61
module STDIO
Definition: scale_stdio.F90:12
module grid index
real(rp), dimension(:), allocatable, public grid_ucdz
z-length of control volume [m]
logical, public io_nml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:62
subroutine, public urban_grid_setup
Setup.
module GRID (cartesian) for urban
real(rp), dimension(:), allocatable, public grid_ufz
face coordinate [m]: z, local=global
module PROCESS
real(rp), dimension(:), allocatable, public grid_ucz
center coordinate [m]: z, local=global
integer, public prc_myrank
process num in local communicator
module profiler
Definition: scale_prof.F90:10
module PRECISION
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
integer, public io_fid_nml
Log file ID (only for output namelist)
Definition: scale_stdio.F90:57
module urban grid index