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 :: fz_max = 100
51  real(RP), private :: fz(fz_max) ! face coordinate without surface (=0 m)
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  fz
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  fz(:) = 0.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. fz(1) == 0.0_rp ) then
172  fz(1) = 1.0_rp ! to avoid zero thickness (tentative)
173  end if
174  ocean_grid_cartesc_fz(oks-1) = 0.0_rp
175  do k = oks, oke
176  ocean_grid_cartesc_fz(k) = fz(k)
177  enddo
178 
179  do k = oks, oke
182  enddo
183 
184  return
185  end subroutine ocean_grid_cartesc_generate
186 
187 end module scale_ocean_grid_cartesc
real(rp), dimension(:), allocatable, public ocean_grid_cartesc_cdz
z-length of control volume [m]
logical, public file_aggregate
Definition: scale_file.F90:171
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:55
subroutine, public file_open(basename, fid, mode, single, aggregate, rankid, postfix)
Definition: scale_file.F90:464
module file
Definition: scale_file.F90:15
module atmosphere / grid / cartesC index
module PROCESS
Definition: scale_prc.F90:11
real(rp), dimension(:), allocatable, public ocean_grid_cartesc_cz
center coordinate [m]: z, local=global
integer, public prc_myrank
process num in local communicator
Definition: scale_prc.F90:89
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:338
module ocean / grid / cartesianC / index
module profiler
Definition: scale_prof.F90:11
module PRECISION
real(rp), dimension(:), allocatable, public ocean_grid_cartesc_fz
face coordinate [m]: z, local=global
module STDIO
Definition: scale_io.F90:10
subroutine, public ocean_grid_cartesc_setup
Setup.
module ocean / grid / cartesianC