SCALE-RM
scale_ocean_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 :: ocean_grid_cartesc_setup
31 
32  !-----------------------------------------------------------------------------
33  !
34  !++ Public parameters & variables
35  !
36  real(rp), public, allocatable :: ocean_grid_cartesc_cz (:)
37  real(rp), public, allocatable :: ocean_grid_cartesc_fz (:)
38  real(rp), public, allocatable :: ocean_grid_cartesc_cdz(:)
39 
40  !-----------------------------------------------------------------------------
41  !
42  !++ Private procedure
43  !
44  private :: ocean_grid_cartesc_read
45  private :: ocean_grid_cartesc_generate
46 
47  !-----------------------------------------------------------------------------
48  !
49  !++ Private parameters & variables
50  !
51  integer, private, parameter :: odz_max = 100
52  real(rp), private :: odz(odz_max) ! layer thickness for input
53 
54  character(len=H_LONG) :: ocean_grid_cartesc_in_basename = ''
55  logical :: ocean_grid_cartesc_in_aggregate
56 
57  !-----------------------------------------------------------------------------
58 contains
59  !-----------------------------------------------------------------------------
61  subroutine ocean_grid_cartesc_setup
62  use scale_prc, only: &
63  prc_abort
64  use scale_file, only: &
66  implicit none
67 
68  namelist / param_ocean_grid_cartesc / &
69  ocean_grid_cartesc_in_basename, &
70  ocean_grid_cartesc_in_aggregate, &
71  odz
72 
73  integer :: ierr
74  integer :: k
75  !---------------------------------------------------------------------------
76 
77  log_newline
78  log_info("OCEAN_GRID_CARTESC_setup",*) 'Setup'
79 
80  if ( okmax < 1 ) then
81  log_info("OCEAN_GRID_CARTESC_setup",*) 'Skip because OKMAX < 1'
82  return
83  end if
84 
85  odz(:) = 10.0_rp
86 
87  ocean_grid_cartesc_in_aggregate = file_aggregate
88 
89  !--- read namelist
90  rewind(io_fid_conf)
91  read(io_fid_conf,nml=param_ocean_grid_cartesc,iostat=ierr)
92  if( ierr < 0 ) then !--- missing
93  log_info("OCEAN_GRID_CARTESC_setup",*) 'Not found namelist. Default used.'
94  elseif( ierr > 0 ) then !--- fatal error
95  log_error("OCEAN_GRID_CARTESC_setup",*) 'Not appropriate names in namelist PARAM_OCEAN_GRID_CARTESC. Check!'
96  call prc_abort
97  endif
98  log_nml(param_ocean_grid_cartesc)
99 
100  allocate( ocean_grid_cartesc_cz(oks :oke) )
101  allocate( ocean_grid_cartesc_fz(oks-1:oke) )
102  allocate( ocean_grid_cartesc_cdz(oks :oke) )
103 
104  log_newline
105  log_info("OCEAN_GRID_CARTESC_setup",*) 'Ocean grid information '
106 
107  if ( ocean_grid_cartesc_in_basename /= '' ) then
108  call ocean_grid_cartesc_read
109  else
110  log_info("OCEAN_GRID_CARTESC_setup",*) 'Not found input grid file. Grid position is calculated.'
111 
112  call ocean_grid_cartesc_generate
113  endif
114  !$acc enter data create(OCEAN_GRID_CARTESC_CZ,OCEAN_GRID_CARTESC_FZ,OCEAN_GRID_CARTESC_CDZ)
115 
116  if ( oke == oks ) then
117  log_newline
118  log_info("OCEAN_GRID_CARTESC_setup",*) 'Single layer. ODZ = ', ocean_grid_cartesc_cdz(1)
119  else
120  log_newline
121  log_info("OCEAN_GRID_CARTESC_setup",'(1x,A)') 'Vertical Coordinate'
122  log_info_cont('(1x,A)') '| k z zh dz k |'
123  log_info_cont('(1x,A)') '| [m] [m] [m] |'
124  k = oks-1
125  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',ocean_grid_cartesc_fz(k),' ',k,' | Atmosphere interface'
126  do k = oks, oke-1
127  log_info_cont('(1x,A,I4,F8.3,A,F8.3,A)') '|',k,ocean_grid_cartesc_cz(k),' ',ocean_grid_cartesc_cdz(k),' | '
128  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',ocean_grid_cartesc_fz(k),' |',k,' | '
129  enddo
130  k = oke
131  log_info_cont('(1x,A,I4,F8.3,A,F8.3,A)') '|',k,ocean_grid_cartesc_cz(k),' ',ocean_grid_cartesc_cdz(k),' | '
132  log_info_cont('(1x,A,F8.3,A,I4,A)') '| ',ocean_grid_cartesc_fz(k),' ',k,' | layer of no motion'
133  log_info_cont('(1x,A)') '|=================================|'
134  endif
135 
136  !$acc update device(OCEAN_GRID_CARTESC_CZ,OCEAN_GRID_CARTESC_FZ,OCEAN_GRID_CARTESC_CDZ)
137 
138  return
139  end subroutine ocean_grid_cartesc_setup
140 
141  !-----------------------------------------------------------------------------
143  subroutine ocean_grid_cartesc_finalize
144  implicit none
145  !---------------------------------------------------------------------------
146 
147  log_newline
148  log_info("OCEAN_GRID_CARTESC_finalize",*) 'Finalize'
149 
150  !$acc exit data delete(OCEAN_GRID_CARTESC_CZ,OCEAN_GRID_CARTESC_FZ,OCEAN_GRID_CARTESC_CDZ)
151  deallocate( ocean_grid_cartesc_cz )
152  deallocate( ocean_grid_cartesc_fz )
153  deallocate( ocean_grid_cartesc_cdz )
154 
155  return
156  end subroutine ocean_grid_cartesc_finalize
157 
158  !-----------------------------------------------------------------------------
160  subroutine ocean_grid_cartesc_read
161  use scale_file, only: &
162  file_open, &
163  file_read
164  use scale_prc, only: &
165  prc_myrank
166  implicit none
167 
168  integer :: fid
169  !---------------------------------------------------------------------------
170 
171  log_newline
172  log_info("OCEAN_GRID_CARTESC_read",*) 'Input ocean grid file '
173 
174  call file_open( ocean_grid_cartesc_in_basename, fid, rankid=prc_myrank, aggregate=ocean_grid_cartesc_in_aggregate )
175 
176  call file_read( fid, 'OCZ', ocean_grid_cartesc_cz(:) )
177  call file_read( fid, 'OCDZ', ocean_grid_cartesc_cdz(:) )
178  call file_read( fid, 'OFZ', ocean_grid_cartesc_fz(:) )
179 
180  return
181  end subroutine ocean_grid_cartesc_read
182 
183  !-----------------------------------------------------------------------------
185  ! It uses FZ, not DZ. Note, LAND_GRID_CARTESC_generate uses DZ
186  subroutine ocean_grid_cartesc_generate
187  implicit none
188 
189  integer :: k
190  !---------------------------------------------------------------------------
191 
192  if ( oka == 1 .and. odz(1) == 0.0_rp ) then
193  odz(1) = 10.0_rp ! to avoid zero thickness (tentative)
194  end if
195 
196  do k = oks, oke
197  ocean_grid_cartesc_cdz(k) = odz(k)
198  enddo
199 
200  ocean_grid_cartesc_fz(oks-1) = 0.0_rp
201  do k = oks, oke
204  enddo
205 
206  return
207  end subroutine ocean_grid_cartesc_generate
208 
209 end module scale_ocean_grid_cartesc
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale_ocean_grid_cartesc::ocean_grid_cartesc_cz
real(rp), dimension(:), allocatable, public ocean_grid_cartesc_cz
center coordinate [m]: z, local=global
Definition: scale_ocean_grid_cartesC.F90:36
scale_ocean_grid_cartesc_index::oke
integer, public oke
Definition: scale_ocean_grid_cartesC_index.F90:39
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_ocean_grid_cartesc_index::oka
integer, public oka
Definition: scale_ocean_grid_cartesC_index.F90:37
scale_prc::prc_myrank
integer, public prc_myrank
process num in local communicator
Definition: scale_prc.F90:91
scale_ocean_grid_cartesc_index::okmax
integer, public okmax
Definition: scale_ocean_grid_cartesC_index.F90:32
scale_ocean_grid_cartesc
module ocean / grid / cartesianC
Definition: scale_ocean_grid_cartesC.F90:12
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_cartesc::ocean_grid_cartesc_finalize
subroutine, public ocean_grid_cartesc_finalize
Finalize.
Definition: scale_ocean_grid_cartesC.F90:144
scale_ocean_grid_cartesc::ocean_grid_cartesc_fz
real(rp), dimension(:), allocatable, public ocean_grid_cartesc_fz
face coordinate [m]: z, local=global
Definition: scale_ocean_grid_cartesC.F90:37
scale_atmos_grid_cartesc_index
module atmosphere / grid / cartesC index
Definition: scale_atmos_grid_cartesC_index.F90:12
scale_ocean_grid_cartesc::ocean_grid_cartesc_cdz
real(rp), dimension(:), allocatable, public ocean_grid_cartesc_cdz
z-length of control volume [m]
Definition: scale_ocean_grid_cartesC.F90:38
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_ocean_grid_cartesc_index
module ocean / grid / cartesianC / index
Definition: scale_ocean_grid_cartesC_index.F90:11
scale_file::file_aggregate
logical, public file_aggregate
Definition: scale_file.F90:196
scale_ocean_grid_cartesc::ocean_grid_cartesc_setup
subroutine, public ocean_grid_cartesc_setup
Setup.
Definition: scale_ocean_grid_cartesC.F90:62
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:57
scale_ocean_grid_cartesc_index::oks
integer, public oks
Definition: scale_ocean_grid_cartesC_index.F90:38