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