SCALE-RM
scale_land_grid_icoA.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
9 !-------------------------------------------------------------------------------
10 #include "scalelib.h"
12  !-----------------------------------------------------------------------------
13  !
14  !++ used modules
15  !
16  use scale_precision
17  use scale_io
18  use scale_prof
21  !-----------------------------------------------------------------------------
22  implicit none
23  private
24  !-----------------------------------------------------------------------------
25  !
26  !++ Public procedure
27  !
28  public :: land_grid_icoa_setup
29  public :: land_grid_icoa_finalize
30 
31  !-----------------------------------------------------------------------------
32  !
33  !++ Public parameters & variables
34  !
35  real(rp), public, allocatable :: land_grid_icoa_cz (:)
36  real(rp), public, allocatable :: land_grid_icoa_fz (:)
37  real(rp), public, allocatable :: land_grid_icoa_cdz(:)
38 
39  !-----------------------------------------------------------------------------
40  !
41  !++ Private procedure
42  !
43  private :: land_grid_icoa_read
44  private :: land_grid_icoa_generate
45 
46  !-----------------------------------------------------------------------------
47  !
48  !++ Private parameters & variables
49  !
50  real(rp), private :: ldz(100)
51 
52  character(len=H_LONG) :: land_grid_icoa_in_basename = ''
53  logical :: land_grid_icoa_in_aggregate
54 
55  !-----------------------------------------------------------------------------
56 contains
57  !-----------------------------------------------------------------------------
59  subroutine land_grid_icoa_setup
60  use scale_prc, only: &
61  prc_abort
62  use scale_file, only: &
64  implicit none
65 
66  namelist / param_land_grid_icoa / &
67  land_grid_icoa_in_basename, &
68  land_grid_icoa_in_aggregate, &
69  ldz
70 
71  integer :: ierr
72  integer :: k
73  !---------------------------------------------------------------------------
74 
75  log_newline
76  log_info("LAND_GRID_ICOA_setup",*) 'Setup'
77 
78  if ( lkmax < 1 ) then
79  log_info("LAND_GRID_ICOA_setup",*) 'Skip because LKMAX < 1'
80  return
81  end if
82 
83  ldz(:) = 0.0_rp
84 
85  land_grid_icoa_in_aggregate = file_aggregate
86 
87  !--- read namelist
88  rewind(io_fid_conf)
89  read(io_fid_conf,nml=param_land_grid_icoa,iostat=ierr)
90  if( ierr < 0 ) then !--- missing
91  log_info("LAND_GRID_ICOA_setup",*) 'Not found namelist. Default used.'
92  elseif( ierr > 0 ) then !--- fatal error
93  log_error("LAND_GRID_ICOA_setup",*) 'Not appropriate names in namelist PARAM_LAND_GRID_ICOA. Check!'
94  call prc_abort
95  endif
96  log_nml(param_land_grid_icoa)
97 
98  allocate( land_grid_icoa_cz(lks :lke) )
99  allocate( land_grid_icoa_fz(lks-1:lke) )
100  allocate( land_grid_icoa_cdz(lks :lke) )
101  !$acc enter data create(LAND_GRID_ICOA_CZ, LAND_GRID_ICOA_FZ, LAND_GRID_ICOA_CDZ) async
102 
103  log_newline
104  log_info("LAND_GRID_ICOA_setup",*) 'Land grid information '
105 
106  if ( land_grid_icoa_in_basename /= '' ) then
107  call land_grid_icoa_read
108  else
109  log_info("LAND_GRID_ICOA_setup",*) 'Not found input grid file. Grid position is calculated.'
110 
111  call land_grid_icoa_generate
112  endif
113 
114  if ( lke == lks ) then
115  log_newline
116  log_info("LAND_GRID_ICOA_setup",*) 'Single layer. LDZ = ', ldz(1)
117  else
118  log_newline
119  log_info_cont('(1x,A)') 'Vertical Coordinate'
120  log_info_cont('(1x,A)') '| k z zh dz k |'
121  log_info_cont('(1x,A)') '| [m] [m] [m] |'
122  k = lks-1
123  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',land_grid_icoa_fz(k),' ',k,' | Atmosphere interface'
124  do k = lks, lke-1
125  log_info_cont('(1x,A,I4,F8.3,A,F8.3,A)') '|',k,land_grid_icoa_cz(k),' ',land_grid_icoa_cdz(k),' | '
126  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',land_grid_icoa_fz(k),' |',k,' | '
127  enddo
128  k = lke
129  log_info_cont('(1x,A,I4,F8.3,A,F8.3,A)') '|',k,land_grid_icoa_cz(k),' ',land_grid_icoa_cdz(k),' | '
130  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',land_grid_icoa_fz(k),' ',k,' | bedrock'
131  log_info_cont('(1x,A)') '|=================================|'
132  endif
133 
134  return
135  end subroutine land_grid_icoa_setup
136 
137  !-----------------------------------------------------------------------------
139  subroutine land_grid_icoa_finalize
140  implicit none
141  !---------------------------------------------------------------------------
142 
143  log_newline
144  log_info("LAND_GRID_ICOA_finalize",*) 'Finalize'
145 
146  !$acc exit data delete(LAND_GRID_ICOA_CZ, LAND_GRID_ICOA_FZ, LAND_GRID_ICOA_CDZ)
147  deallocate( land_grid_icoa_cz )
148  deallocate( land_grid_icoa_fz )
149  deallocate( land_grid_icoa_cdz )
150 
151  return
152  end subroutine land_grid_icoa_finalize
153 
154  !-----------------------------------------------------------------------------
156  subroutine land_grid_icoa_read
157  use scale_file, only: &
158  file_open, &
159  file_read
160  use scale_prc, only: &
161  prc_myrank
162  implicit none
163 
164  integer :: fid
165  !---------------------------------------------------------------------------
166 
167  log_newline
168  log_info("LAND_GRID_ICOA_read",*) 'Input land grid file '
169 
170  call file_open( land_grid_icoa_in_basename, fid, rankid=prc_myrank, aggregate=land_grid_icoa_in_aggregate )
171 
172  call file_read( fid, 'LCZ', land_grid_icoa_cz(:) )
173  call file_read( fid, 'LCDZ', land_grid_icoa_cdz(:) )
174  call file_read( fid, 'LFZ', land_grid_icoa_fz(:) )
175  !$acc update device(LAND_GRID_ICOA_CZ, LAND_GRID_ICOA_CDZ, LAND_GRID_ICOA_FZ)
176 
177  return
178  end subroutine land_grid_icoa_read
179 
180  !-----------------------------------------------------------------------------
182  subroutine land_grid_icoa_generate
183  implicit none
184 
185  integer :: k
186  !---------------------------------------------------------------------------
187 
188  do k = lks, lke
189  land_grid_icoa_cdz(k) = ldz(k)
190  enddo
191  !$acc update device(LAND_GRID_ICOA_CDZ) async
192 
193  land_grid_icoa_fz(lks-1) = 0.0_rp
194 
195  do k = lks, lke
198  enddo
199  !$acc update device(LAND_GRID_ICOA_CZ, LAND_GRID_ICOA_FZ) async
200 
201  !$acc wait
202 
203  return
204  end subroutine land_grid_icoa_generate
205 
206 end module scale_land_grid_icoa
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale_file::file_open
subroutine, public file_open(basename, fid, mode, single, allnodes, aggregate, rankid, postfix)
Definition: scale_file.F90:536
scale_land_grid_icoa_index::lks
integer, public lks
Definition: scale_land_grid_icoA_index.F90:40
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_land_grid_icoa_index::lke
integer, public lke
Definition: scale_land_grid_icoA_index.F90:41
scale_land_grid_icoa::land_grid_icoa_setup
subroutine, public land_grid_icoa_setup
Setup.
Definition: scale_land_grid_icoA.F90:60
scale_prc::prc_myrank
integer, public prc_myrank
process num in local communicator
Definition: scale_prc.F90:91
scale_land_grid_icoa::land_grid_icoa_cdz
real(rp), dimension(:), allocatable, public land_grid_icoa_cdz
z-length of control volume [m]
Definition: scale_land_grid_icoA.F90:37
scale_land_grid_icoa
module land / grid / icosahedralA
Definition: scale_land_grid_icoA.F90:11
scale_file
module file
Definition: scale_file.F90:15
scale_land_grid_icoa::land_grid_icoa_finalize
subroutine, public land_grid_icoa_finalize
Finalize.
Definition: scale_land_grid_icoA.F90:140
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_land_grid_icoa::land_grid_icoa_cz
real(rp), dimension(:), allocatable, public land_grid_icoa_cz
center coordinate [m]: z, local=global
Definition: scale_land_grid_icoA.F90:35
scale_prof
module profiler
Definition: scale_prof.F90:11
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_land_grid_icoa::land_grid_icoa_fz
real(rp), dimension(:), allocatable, public land_grid_icoa_fz
face coordinate [m]: z, local=global
Definition: scale_land_grid_icoA.F90:36
scale_land_grid_icoa_index
module land / grid / icosahedralA / index
Definition: scale_land_grid_icoA_index.F90:11
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:57
scale_land_grid_icoa_index::lkmax
integer, public lkmax
Definition: scale_land_grid_icoA_index.F90:32