SCALE-RM
scale_land_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 :: land_grid_setup
31 
32  !-----------------------------------------------------------------------------
33  !
34  !++ Public parameters & variables
35  !
36  real(RP), public, allocatable :: grid_lcz (:)
37  real(RP), public, allocatable :: grid_lfz (:)
38  real(RP), public, allocatable :: grid_lcdz (:)
39 
40  !-----------------------------------------------------------------------------
41  !
42  !++ Private procedure
43  !
44  private :: land_grid_read
45  private :: land_grid_generate
46 
47  !-----------------------------------------------------------------------------
48  !
49  !++ Private parameters & variables
50  !
51  real(RP), private :: ldz(100)
52 
53  character(len=H_LONG), private :: land_grid_in_basename = ''
54  character(len=H_LONG), private :: land_grid_out_basename = ''
55 
56  !-----------------------------------------------------------------------------
57 contains
58  !-----------------------------------------------------------------------------
60  subroutine land_grid_setup
61  use scale_process, only: &
63  implicit none
64 
65  namelist / param_land_grid / &
66  land_grid_in_basename, &
67  land_grid_out_basename, &
68  ldz
69 
70  integer :: ierr
71  integer :: k
72 
73  !---------------------------------------------------------------------------
74 
75  if( io_l ) write(io_fid_log,*)
76  if( io_l ) write(io_fid_log,*) '++++++ Module[GRID] / Categ[LAND GRID] / Origin[SCALElib]'
77 
78  ldz(:) = 0.0_rp
79 
80  !--- read namelist
81  rewind(io_fid_conf)
82  read(io_fid_conf,nml=param_land_grid,iostat=ierr)
83  if( ierr < 0 ) then !--- missing
84  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
85  elseif( ierr > 0 ) then !--- fatal error
86  write(*,*) 'xxx Not appropriate names in namelist PARAM_LAND_GRID. Check!'
87  call prc_mpistop
88  endif
89  if( io_nml ) write(io_fid_nml,nml=param_land_grid)
90 
91  allocate( grid_lcz(lks :lke) )
92  allocate( grid_lfz(lks-1:lke) )
93  allocate( grid_lcdz(lks :lke) )
94 
95  if( io_l ) write(io_fid_log,*)
96  if( io_l ) write(io_fid_log,*) '*** Land grid information ***'
97 
98  if ( land_grid_in_basename /= '' ) then
99  call land_grid_read
100  else
101  if( io_l ) write(io_fid_log,*) '*** Not found input grid file. Grid position is calculated.'
102 
103  call land_grid_generate
104  endif
105 
106  if ( lke == lks ) then
107  if( io_l ) write(io_fid_log,*)
108  if( io_l ) write(io_fid_log,*) '*** Single layer. LDZ = ', ldz(1)
109  else
110  if( io_l ) write(io_fid_log,*)
111  if( io_l ) write(io_fid_log,'(1x,A)') &
112  '|====== Vertical Coordinate ======|'
113  if( io_l ) write(io_fid_log,'(1x,A)') &
114  '| k z zh dz k |'
115  if( io_l ) write(io_fid_log,'(1x,A)') &
116  '| [m] [m] [m] |'
117  k = lks-1
118  if( io_l ) write(io_fid_log,'(1x,A,F8.3,A,I4,A)') &
119  '| ',grid_lfz(k),' ',k,' | Atmosphere interface'
120  do k = lks, lke-1
121  if( io_l ) write(io_fid_log,'(1x,A,I4,F8.3,A,F8.3,A)') &
122  '|',k,grid_lcz(k),' ',grid_lcdz(k),' | '
123  if( io_l ) write(io_fid_log,'(1x,A,F8.3,A,I4,A)') &
124  '| ',grid_lfz(k),' |',k,' | '
125  enddo
126  k = lke
127  if( io_l ) write(io_fid_log,'(1x,A,I4,F8.3,A,F8.3,A)') &
128  '|',k,grid_lcz(k),' ',grid_lcdz(k),' | '
129  if( io_l ) write(io_fid_log,'(1x,A,F8.3,A,I4,A)') &
130  '| ',grid_lfz(k),' ',k,' | bedrock'
131  if( io_l ) write(io_fid_log,'(1x,A)') &
132  '|=================================|'
133  endif
134 
135  return
136  end subroutine land_grid_setup
137 
138  !-----------------------------------------------------------------------------
140  subroutine land_grid_read
141  use gtool_file, only: &
142  fileread
143  use scale_process, only: &
144  prc_myrank, &
146  use scale_grid, only: &
147  grid_cbfz, &
148  grid_cbfx, &
149  grid_cbfy
150  implicit none
151 
152  character(len=H_LONG) :: bname
153  real(RP) :: tmp_cbfz(ka), tmp_cbfx(ia), tmp_cbfy(ja)
154  integer :: i, j, k
155  !---------------------------------------------------------------------------
156 
157  if( io_l ) write(io_fid_log,*)
158  if( io_l ) write(io_fid_log,*) '*** Input land grid file ***'
159 
160  write(bname,'(A,A,F15.3)') trim(land_grid_in_basename)
161 
162  call fileread( grid_lcz(:), bname, 'LCZ', 1, prc_myrank )
163  call fileread( grid_lcdz(:), bname, 'LCDZ', 1, prc_myrank )
164  call fileread( grid_lfz(:), bname, 'LFZ', 1, prc_myrank )
165 
166  call fileread( tmp_cbfz(:), bname, 'CBFZ', 1, prc_myrank )
167  call fileread( tmp_cbfx(:), bname, 'CBFX', 1, prc_myrank )
168  call fileread( tmp_cbfy(:), bname, 'CBFY', 1, prc_myrank )
169 
170  do i = 1, ia
171  if( tmp_cbfx(i) /= grid_cbfx(i) ) then
172  write(*,*) 'xxx Buffer layer in LAND_GRID_IN_BASENAME is different from GRID_IN_BASENAME'
173  call prc_mpistop
174  endif
175  enddo
176 
177  do j = 1, ja
178  if( tmp_cbfy(j) /= grid_cbfy(j) ) then
179  write(*,*) 'xxx Buffer layer in LAND_GRID_IN_BASENAME is different from GRID_IN_BASENAME'
180  call prc_mpistop
181  endif
182  enddo
183 
184  do k = 1, ka
185  if ( tmp_cbfz(k) /= grid_cbfz(k) ) then
186  write(*,*) 'xxx Buffer layer in LAND_GRID_IN_BASENAME is different from GRID_IN_BASENAME'
187  call prc_mpistop
188  endif
189  enddo
190 
191  return
192  end subroutine land_grid_read
193 
194  !-----------------------------------------------------------------------------
196  subroutine land_grid_generate
197  implicit none
198 
199  integer :: k
200  !---------------------------------------------------------------------------
201 
202  do k = lks, lke
203  grid_lcdz(k) = ldz(k)
204  enddo
205 
206  grid_lfz(lks-1) = 0.0_rp
207 
208  do k = lks, lke
209  grid_lcz(k) = grid_lcdz(k) / 2.0_rp + grid_lfz(k-1)
210  grid_lfz(k) = grid_lcdz(k) + grid_lfz(k-1)
211  enddo
212 
213  return
214  end subroutine land_grid_generate
215 
216 end module scale_land_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 (cartesian) for land
real(rp), dimension(:), allocatable, public grid_lfz
face coordinate [m]: z, local=global
module grid index
logical, public io_nml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:62
integer, public ia
of whole cells: x, local, with HALO
integer, public ka
of whole cells: z, local, with HALO
real(rp), dimension(:), allocatable, public grid_cbfx
center buffer factor (0-1): x
module PROCESS
subroutine, public land_grid_setup
Setup.
real(rp), dimension(:), allocatable, public grid_cbfz
center buffer factor (0-1): z
integer, public prc_myrank
process num in local communicator
module GRID (cartesian)
module profiler
Definition: scale_prof.F90:10
real(rp), dimension(:), allocatable, public grid_lcdz
z-length of control volume [m]
module PRECISION
real(rp), dimension(:), allocatable, public grid_lcz
center coordinate [m]: z, local=global
real(rp), dimension(:), allocatable, public grid_cbfy
center buffer factor (0-1): y
module land grid index
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
integer, public ja
of whole cells: y, local, with HALO