SCALE-RM
scale_ocean_dyn_slab.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
20  use scale_debug
21  !-----------------------------------------------------------------------------
22  implicit none
23  private
24  !-----------------------------------------------------------------------------
25  !
26  !++ Public procedure
27  !
28  public :: ocean_dyn_slab_setup
29  public :: ocean_dyn_slab
30 
31  !-----------------------------------------------------------------------------
32  !
33  !++ Public parameters & variables
34  !
35  real(RP), public :: ocean_dyn_slab_depth = 10.0_rp
36 
37  !-----------------------------------------------------------------------------
38  !
39  !++ Private procedure
40  !
41  !-----------------------------------------------------------------------------
42  !
43  !++ Private parameters & variables
44  !
45  real(RP), private :: ocean_dyn_slab_heatcapacity
46 
47  logical, private :: ocean_dyn_slab_nudging = .false.
48  real(DP), private :: ocean_dyn_slab_nudging_tausec
49  logical, private :: ocean_dyn_slab_offline_mode = .false.
50 
51  !-----------------------------------------------------------------------------
52 contains
53  !-----------------------------------------------------------------------------
55  subroutine ocean_dyn_slab_setup
56  use scale_prc, only: &
57  prc_abort
58  use scale_const, only: &
59  undef => const_undef, &
60  dwatr => const_dwatr, &
61  cl => const_cl
62  use scale_calendar, only: &
64  use scale_file_external_input, only: &
67  implicit none
68 
69  real(DP) :: OCEAN_DYN_SLAB_nudging_tau = 0.0_dp ! Relaxation time
70  character(len=H_SHORT) :: OCEAN_DYN_SLAB_nudging_tau_unit = "SEC"
71  character(len=H_LONG) :: OCEAN_DYN_SLAB_nudging_basename(file_external_input_file_limit) = ''
72  logical :: OCEAN_DYN_SLAB_nudging_enable_periodic_year = .false.
73  logical :: OCEAN_DYN_SLAB_nudging_enable_periodic_month = .false.
74  logical :: OCEAN_DYN_SLAB_nudging_enable_periodic_day = .false.
75  integer :: OCEAN_DYN_SLAB_nudging_step_fixed = 0
76  real(RP) :: OCEAN_DYN_SLAB_nudging_offset = 0.0_rp
77  real(RP) :: OCEAN_DYN_SLAB_nudging_defval != UNDEF
78  logical :: OCEAN_DYN_SLAB_nudging_check_coordinates = .true.
79  integer :: OCEAN_DYN_SLAB_nudging_step_limit = 0
80 
81  namelist / param_ocean_dyn_slab / &
83  ocean_dyn_slab_nudging, &
84  ocean_dyn_slab_nudging_tau, &
85  ocean_dyn_slab_nudging_tau_unit, &
86  ocean_dyn_slab_nudging_basename, &
87  ocean_dyn_slab_nudging_enable_periodic_year, &
88  ocean_dyn_slab_nudging_enable_periodic_month, &
89  ocean_dyn_slab_nudging_enable_periodic_day, &
90  ocean_dyn_slab_nudging_step_fixed, &
91  ocean_dyn_slab_nudging_offset, &
92  ocean_dyn_slab_nudging_defval, &
93  ocean_dyn_slab_nudging_check_coordinates, &
94  ocean_dyn_slab_nudging_step_limit
95 
96  integer :: ierr
97  !---------------------------------------------------------------------------
98 
99  log_newline
100  log_info("OCEAN_DYN_SLAB_setup",*) 'Setup'
101 
102  ocean_dyn_slab_nudging_defval = undef
103 
104  !--- read namelist
105  rewind(io_fid_conf)
106  read(io_fid_conf,nml=param_ocean_dyn_slab,iostat=ierr)
107  if( ierr < 0 ) then !--- missing
108  log_info("OCEAN_DYN_SLAB_setup",*) 'Not found namelist. Default used.'
109  elseif( ierr > 0 ) then !--- fatal error
110  log_error("OCEAN_DYN_SLAB_setup",*) 'Not appropriate names in namelist PARAM_OCEAN_DYN_SLAB. Check!'
111  call prc_abort
112  endif
113  log_nml(param_ocean_dyn_slab)
114 
115  ocean_dyn_slab_heatcapacity = dwatr * cl * ocean_dyn_slab_depth
116 
117  log_newline
118  log_info("OCEAN_DYN_SLAB_setup",*) 'Slab ocean depth [m] : ', ocean_dyn_slab_depth
119  log_info("OCEAN_DYN_SLAB_setup",*) 'Ocean heat capacity [J/K/m2] : ', ocean_dyn_slab_heatcapacity
120 
121  if ( ocean_dyn_slab_nudging ) then
122  call calendar_unit2sec( ocean_dyn_slab_nudging_tausec, ocean_dyn_slab_nudging_tau, ocean_dyn_slab_nudging_tau_unit )
123 
124  log_info("OCEAN_DYN_SLAB_setup",*) 'Use nudging for SST : ON'
125  log_info("OCEAN_DYN_SLAB_setup",*) 'Relaxation time Tau [sec] : ', ocean_dyn_slab_nudging_tausec
126 
127  if ( ocean_dyn_slab_nudging_tausec == 0.0_rp ) then
128  ocean_dyn_slab_offline_mode = .true.
129  log_info("OCEAN_DYN_SLAB_setup",*) 'Tau=0 means that SST is completely replaced by the external data.'
130  endif
131 
132  if ( ocean_dyn_slab_nudging_basename(1) == '' ) then
133  log_error("OCEAN_DYN_SLAB_setup",*) 'OCEAN_DYN_SLAB_nudging_basename is necessary !!'
134  call prc_abort
135  endif
136  else
137  log_info("OCEAN_DYN_SLAB_setup",*) 'Use nudging for SST : OFF'
138  endif
139 
140  if ( ocean_dyn_slab_nudging ) then
141  call file_external_input_regist( ocean_dyn_slab_nudging_basename(:), & ! [IN]
142  'OCEAN_TEMP', & ! [IN]
143  'OXY', & ! [IN]
144  ocean_dyn_slab_nudging_enable_periodic_year, & ! [IN]
145  ocean_dyn_slab_nudging_enable_periodic_month, & ! [IN]
146  ocean_dyn_slab_nudging_enable_periodic_day, & ! [IN]
147  ocean_dyn_slab_nudging_step_fixed, & ! [IN]
148  ocean_dyn_slab_nudging_offset, & ! [IN]
149  ocean_dyn_slab_nudging_defval, & ! [IN]
150  ocean_dyn_slab_nudging_check_coordinates, & ! [IN]
151  ocean_dyn_slab_nudging_step_limit ) ! [IN]
152  endif
153 
154  return
155  end subroutine ocean_dyn_slab_setup
156 
157  !-----------------------------------------------------------------------------
159  subroutine ocean_dyn_slab( &
160  OKMAX, OKS, OKE, &
161  OIA, OIS, OIE, &
162  OJA, OJS, OJE, &
163  OCEAN_TEMP_t, &
164  OCEAN_SFLX_G, &
165  OCEAN_SFLX_water, &
166  OCEAN_SFLX_ice, &
167  calc_flag, &
168  dt, NOWDAYSEC, &
169  OCEAN_TEMP )
170  use scale_prc, only: &
171  prc_abort
172  use scale_const, only: &
173  emelt => const_emelt
174  use scale_file_external_input, only: &
175  file_external_input_update
176  implicit none
177 
178  integer, intent(in) :: OKMAX, OKS, OKE
179  integer, intent(in) :: OIA, OIS, OIE
180  integer, intent(in) :: OJA, OJS, OJE
181  real(RP), intent(in) :: OCEAN_TEMP_t (okmax,oia,oja) ! tendency of ocean temperature
182  real(RP), intent(in) :: OCEAN_SFLX_G (oia,oja) ! heat flux from surface to subsurface (open ocean/sea ice)
183  real(RP), intent(in) :: OCEAN_SFLX_water(oia,oja) ! liquid water flux from surface to subsurface (open ocean/sea ice)
184  real(RP), intent(in) :: OCEAN_SFLX_ice (oia,oja) ! ice water flux from surface to subsurface (open ocean/sea ice)
185  logical, intent(in) :: calc_flag (oia,oja) ! to decide calculate or not
186  real(DP), intent(in) :: dt
187  real(DP), intent(in) :: NOWDAYSEC
188  real(RP), intent(inout) :: OCEAN_TEMP (okmax,oia,oja)
189 
190  real(RP) :: OCEAN_TEMP_t_ndg(okmax,oia,oja)
191  real(RP) :: OCEAN_TEMP_ref (okmax,oia,oja)
192  real(RP) :: rtau
193 
194  logical :: error
195  integer :: k, i, j
196  !---------------------------------------------------------------------------
197 
198  log_progress(*) 'ocean / dynamics / slab'
199 
200  if ( ocean_dyn_slab_nudging ) then
201 
202  call file_external_input_update( 'OCEAN_TEMP', nowdaysec, ocean_temp_ref(:,:,:), error )
203 
204  if ( error ) then
205  log_error("OCEAN_DYN_SLAB",*) 'Requested data is not found!'
206  call prc_abort
207  endif
208 
209  ! if OCEAN_DYN_SLAB_nudging_tau < dt, Nudging acts as quasi-prescribed boundary
210  rtau = 1.0_rp / max(ocean_dyn_slab_nudging_tausec,dt)
211 
212  do j = ojs, oje
213  do i = ois, oie
214  do k = oks, oke
215  ocean_temp_t_ndg(k,i,j) = ( ocean_temp_ref(k,i,j) - ocean_temp(k,i,j) ) * rtau
216  enddo
217  enddo
218  enddo
219 
220  else
221  ocean_temp_t_ndg(:,:,:) = 0.0_rp
222  endif
223 
224  if ( ocean_dyn_slab_offline_mode ) then
225 
226  do j = ojs, oje
227  do i = ois, oie
228  if ( calc_flag(i,j) ) then
229  ocean_temp(oks,i,j) = ocean_temp_ref(oks,i,j)
230  endif
231  enddo
232  enddo
233 
234  else
235 
236  do j = ojs, oje
237  do i = ois, oie
238  if ( calc_flag(i,j) ) then
239  ! heat flux from atm/ice at uppermost ocean layer
240  ocean_temp(oks,i,j) = ocean_temp(oks,i,j) + ocean_temp_t_ndg(oks,i,j) * dt &
241  + ( ocean_sflx_g(i,j) - ocean_sflx_ice(i,j) * emelt ) / ocean_dyn_slab_heatcapacity * dt
242  do k = oks+1, oke
243  ocean_temp(k,i,j) = ocean_temp(k,i,j) + ocean_temp_t_ndg(k,i,j) * dt
244  enddo
245  endif
246  enddo
247  enddo
248 
249  endif
250 
251  return
252  end subroutine ocean_dyn_slab
253 
254 end module scale_ocean_dyn_slab
module DEBUG
Definition: scale_debug.F90:11
subroutine, public calendar_unit2sec(second, value, unit)
Convert several units to second.
real(rp), parameter, public const_dwatr
density of water [kg/m3]
Definition: scale_const.F90:82
real(rp), parameter, public const_cl
specific heat (liquid water) [J/kg/K]
Definition: scale_const.F90:66
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:55
module file / external_input
subroutine, public file_external_input_regist(basename, varname, axistype, enable_periodic_year, enable_periodic_month, enable_periodic_day, step_fixed, offset, defval, check_coordinates, step_limit, exist)
Regist data.
real(rp), public const_undef
Definition: scale_const.F90:41
real(rp), public ocean_dyn_slab_depth
water depth of slab ocean [m]
subroutine, public ocean_dyn_slab(OKMAX, OKS, OKE, OIA, OIS, OIE, OJA, OJS, OJE, OCEAN_TEMP_t, OCEAN_SFLX_G, OCEAN_SFLX_water, OCEAN_SFLX_ice, calc_flag, dt, NOWDAYSEC, OCEAN_TEMP)
Slab ocean model.
integer, parameter, public file_external_input_file_limit
limit of file (for one item)
module PROCESS
Definition: scale_prc.F90:11
subroutine, public ocean_dyn_slab_setup
Setup.
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:338
module CONSTANT
Definition: scale_const.F90:11
real(rp), parameter, public const_emelt
Definition: scale_const.F90:72
module profiler
Definition: scale_prof.F90:11
module PRECISION
module ocean / dynamics / slab
module CALENDAR
module STDIO
Definition: scale_io.F90:10