SCALE-RM
scale_ocean_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 :: ocean_grid_icoa_setup
30 
31  !-----------------------------------------------------------------------------
32  !
33  !++ Public parameters & variables
34  !
35  real(rp), public, allocatable :: ocean_grid_icoa_cz (:)
36  real(rp), public, allocatable :: ocean_grid_icoa_fz (:)
37  real(rp), public, allocatable :: ocean_grid_icoa_cdz(:)
38 
39  !-----------------------------------------------------------------------------
40  !
41  !++ Private procedure
42  !
43  private :: ocean_grid_icoa_read
44  private :: ocean_grid_icoa_generate
45 
46  !-----------------------------------------------------------------------------
47  !
48  !++ Private parameters & variables
49  !
50  integer, private, parameter :: fz_max = 100
51  real(rp), private :: fz(fz_max) ! face coordinate without surface (=0 m)
52 
53  character(len=H_LONG) :: ocean_grid_icoa_in_basename = ''
54  logical :: ocean_grid_icoa_in_aggregate
55 
56  !-----------------------------------------------------------------------------
57 contains
58  !-----------------------------------------------------------------------------
60  subroutine ocean_grid_icoa_setup
61  use scale_prc, only: &
62  prc_abort
63  use scale_file, only: &
65  implicit none
66 
67  namelist / param_ocean_grid_icoa / &
68  ocean_grid_icoa_in_basename, &
69  ocean_grid_icoa_in_aggregate, &
70  fz
71 
72  integer :: ierr
73  integer :: k
74  !---------------------------------------------------------------------------
75 
76  log_newline
77  log_info("OCEAN_GRID_ICOA_setup",*) 'Setup'
78 
79  if ( okmax < 1 ) then
80  log_info("OCEAN_GRID_ICOA_setup",*) 'Skip because OKMAX < 1'
81  return
82  end if
83 
84  fz(:) = 0.0_rp
85 
86  ocean_grid_icoa_in_aggregate = file_aggregate
87 
88  !--- read namelist
89  rewind(io_fid_conf)
90  read(io_fid_conf,nml=param_ocean_grid_icoa,iostat=ierr)
91  if( ierr < 0 ) then !--- missing
92  log_info("OCEAN_GRID_ICOA_setup",*) 'Not found namelist. Default used.'
93  elseif( ierr > 0 ) then !--- fatal error
94  log_error("OCEAN_GRID_ICOA_setup",*) 'Not appropriate names in namelist PARAM_OCEAN_GRID_ICOA. Check!'
95  call prc_abort
96  endif
97  log_nml(param_ocean_grid_icoa)
98 
99  allocate( ocean_grid_icoa_cz(oks :oke) )
100  allocate( ocean_grid_icoa_fz(oks-1:oke) )
101  allocate( ocean_grid_icoa_cdz(oks :oke) )
102  !$acc enter data create(OCEAN_GRID_ICOA_CZ,OCEAN_GRID_ICOA_FZ,OCEAN_GRID_ICOA_CDZ)
103 
104  log_newline
105  log_info("OCEAN_GRID_ICOA_setup",*) 'Ocean grid information '
106 
107  if ( ocean_grid_icoa_in_basename /= '' ) then
108  call ocean_grid_icoa_read
109  else
110  log_info("OCEAN_GRID_ICOA_setup",*) 'Not found input grid file. Grid position is calculated.'
111 
112  call ocean_grid_icoa_generate
113  endif
114 
115  if ( oke == oks ) then
116  log_newline
117  log_info("OCEAN_GRID_ICOA_setup",*) 'Single layer. ODZ = ', ocean_grid_icoa_cdz(1)
118  else
119  log_newline
120  log_info("OCEAN_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 = oks-1
124  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',ocean_grid_icoa_fz(k),' ',k,' | Atmosphere interface'
125  do k = oks, oke-1
126  log_info_cont('(1x,A,I4,F8.3,A,F8.3,A)') '|',k,ocean_grid_icoa_cz(k),' ',ocean_grid_icoa_cdz(k),' | '
127  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',ocean_grid_icoa_fz(k),' |',k,' | '
128  enddo
129  k = oke
130  log_info_cont('(1x,A,I4,F8.3,A,F8.3,A)') '|',k,ocean_grid_icoa_cz(k),' ',ocean_grid_icoa_cdz(k),' | '
131  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',ocean_grid_icoa_fz(k),' ',k,' | layer of no motion'
132  log_info_cont('(1x,A)') '|=================================|'
133  endif
134 
135  !$acc update device(OCEAN_GRID_ICOA_CZ,OCEAN_GRID_ICOA_FZ,OCEAN_GRID_ICOA_CDZ)
136  return
137  end subroutine ocean_grid_icoa_setup
138 
139  !-----------------------------------------------------------------------------
141  subroutine ocean_grid_icoa_read
142  use scale_file, only: &
143  file_open, &
144  file_read
145  use scale_prc, only: &
146  prc_myrank
147  implicit none
148 
149  integer :: fid
150  !---------------------------------------------------------------------------
151 
152  log_newline
153  log_info("OCEAN_GRID_ICOA_read",*) 'Input ocean grid file '
154 
155  call file_open( ocean_grid_icoa_in_basename, fid, rankid=prc_myrank, aggregate=ocean_grid_icoa_in_aggregate )
156 
157  call file_read( fid, 'OCZ', ocean_grid_icoa_cz(:) )
158  call file_read( fid, 'OCDZ', ocean_grid_icoa_cdz(:) )
159  call file_read( fid, 'OFZ', ocean_grid_icoa_fz(:) )
160 
161  return
162  end subroutine ocean_grid_icoa_read
163 
164  !-----------------------------------------------------------------------------
166  ! It uses FZ, not DZ. Note, LAND_GRID_ICOA_generate uses DZ
167  subroutine ocean_grid_icoa_generate
168  implicit none
169 
170  integer :: k
171  !---------------------------------------------------------------------------
172 
173  if ( oka == 1 .and. fz(1) == 0.0_rp ) then
174  fz(1) = 1.0_rp ! to avoid zero thickness (tentative)
175  end if
176  ocean_grid_icoa_fz(oks-1) = 0.0_rp
177  do k = oks, oke
178  ocean_grid_icoa_fz(k) = fz(k)
179  enddo
180 
181  do k = oks, oke
184  enddo
185 
186  return
187  end subroutine ocean_grid_icoa_generate
188 
189 end module scale_ocean_grid_icoa
scale_ocean_grid_icoa::ocean_grid_icoa_fz
real(rp), dimension(:), allocatable, public ocean_grid_icoa_fz
face coordinate [m]: z, local=global
Definition: scale_ocean_grid_icoA.F90:36
scale_ocean_grid_icoa_index::okmax
integer, public okmax
Definition: scale_ocean_grid_icoA_index.F90:32
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_ocean_grid_icoa_index::oks
integer, public oks
Definition: scale_ocean_grid_icoA_index.F90:38
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_ocean_grid_icoa_index::oka
integer, public oka
Definition: scale_ocean_grid_icoA_index.F90:37
scale_prc::prc_myrank
integer, public prc_myrank
process num in local communicator
Definition: scale_prc.F90:91
scale_ocean_grid_icoa_index::oke
integer, public oke
Definition: scale_ocean_grid_icoA_index.F90:39
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_ocean_grid_icoa::ocean_grid_icoa_cz
real(rp), dimension(:), allocatable, public ocean_grid_icoa_cz
center coordinate [m]: z, local=global
Definition: scale_ocean_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_ocean_grid_icoa::ocean_grid_icoa_cdz
real(rp), dimension(:), allocatable, public ocean_grid_icoa_cdz
z-length of control volume [m]
Definition: scale_ocean_grid_icoA.F90:37
scale_ocean_grid_icoa
module ocean / grid / icosahedralA
Definition: scale_ocean_grid_icoA.F90:12
scale_atmos_grid_icoa_index
module atmosphere / grid / icosahedralA / index
Definition: scale_atmos_grid_icoA_index.F90:12
scale_ocean_grid_icoa_index
module ocean / grid / icosahedralA / index
Definition: scale_ocean_grid_icoA_index.F90:11
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:57
scale_ocean_grid_icoa::ocean_grid_icoa_setup
subroutine, public ocean_grid_icoa_setup
Setup.
Definition: scale_ocean_grid_icoA.F90:61