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  !-----------------------------------------------------------------------------
36  !
37  !++ Private procedure
38  !
39  !-----------------------------------------------------------------------------
40  !
41  !++ Private parameters & variables
42  !
43  real(RP), private :: OCEAN_DYN_SLAB_HeatCapacity
44 
45  logical, private :: OCEAN_DYN_SLAB_nudging = .false.
46  real(DP), private :: OCEAN_DYN_SLAB_nudging_tausec
47  logical, private :: OCEAN_DYN_SLAB_offline_mode = .false.
48 
49  !-----------------------------------------------------------------------------
50 contains
51  !-----------------------------------------------------------------------------
53  subroutine ocean_dyn_slab_setup( DEPTH )
54  use scale_prc, only: &
55  prc_abort
56  use scale_const, only: &
57  undef => const_undef, &
58  dwatr => const_dwatr
59  use scale_atmos_hydrometeor, only: &
60  cv_water
61  use scale_calendar, only: &
63  use scale_file_external_input, only: &
64  file_external_input_regist
65  implicit none
66  real(rp), intent(in) :: depth
67 
68  real(dp) :: ocean_dyn_slab_nudging_tau = 0.0_dp ! Relaxation time
69  character(len=H_SHORT) :: ocean_dyn_slab_nudging_tau_unit = "SEC"
70  character(len=H_LONG) :: ocean_dyn_slab_nudging_basename = ''
71  logical :: ocean_dyn_slab_nudging_basename_add_num = .false.
72  integer :: ocean_dyn_slab_nudging_number_of_files = 1
73  logical :: ocean_dyn_slab_nudging_enable_periodic_year = .false.
74  logical :: ocean_dyn_slab_nudging_enable_periodic_month = .false.
75  logical :: ocean_dyn_slab_nudging_enable_periodic_day = .false.
76  integer :: ocean_dyn_slab_nudging_step_fixed = 0
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  ! obsolete
82  real(rp) :: ocean_dyn_slab_depth = -1.0_rp
83 
84  namelist / param_ocean_dyn_slab / &
85  ocean_dyn_slab_nudging, &
86  ocean_dyn_slab_nudging_tau, &
87  ocean_dyn_slab_nudging_tau_unit, &
88  ocean_dyn_slab_nudging_basename, &
89  ocean_dyn_slab_nudging_basename_add_num, &
90  ocean_dyn_slab_nudging_number_of_files, &
91  ocean_dyn_slab_nudging_enable_periodic_year, &
92  ocean_dyn_slab_nudging_enable_periodic_month, &
93  ocean_dyn_slab_nudging_enable_periodic_day, &
94  ocean_dyn_slab_nudging_step_fixed, &
95  ocean_dyn_slab_nudging_defval, &
96  ocean_dyn_slab_nudging_check_coordinates, &
97  ocean_dyn_slab_nudging_step_limit, &
98  ocean_dyn_slab_depth
99 
100  integer :: ierr
101  !---------------------------------------------------------------------------
102 
103  log_newline
104  log_info("OCEAN_DYN_SLAB_setup",*) 'Setup'
105 
106  ocean_dyn_slab_nudging_defval = undef
107 
108  !--- read namelist
109  rewind(io_fid_conf)
110  read(io_fid_conf,nml=param_ocean_dyn_slab,iostat=ierr)
111  if( ierr < 0 ) then !--- missing
112  log_info("OCEAN_DYN_SLAB_setup",*) 'Not found namelist. Default used.'
113  elseif( ierr > 0 ) then !--- fatal error
114  log_error("OCEAN_DYN_SLAB_setup",*) 'Not appropriate names in namelist PARAM_OCEAN_DYN_SLAB. Check!'
115  call prc_abort
116  endif
117  log_nml(param_ocean_dyn_slab)
118 
119  if ( ocean_dyn_slab_depth >= 0.0 ) then
120  log_error("OCEAN_DYN_SLAB_setup",*) '"OCEAN_DYN_SLAB_DEPTH" is obsolete. USE "ODZ" of "PARAM_OCEAN_GRID_CARTESC"'
121  call prc_abort
122  end if
123 
124  ocean_dyn_slab_heatcapacity = dwatr * cv_water * depth
125 
126  log_newline
127  log_info("OCEAN_DYN_SLAB_setup",*) 'Slab ocean depth [m] : ', depth
128  log_info("OCEAN_DYN_SLAB_setup",*) 'Ocean heat capacity [J/K/m2] : ', ocean_dyn_slab_heatcapacity
129 
130  if ( ocean_dyn_slab_nudging ) then
131  call calendar_unit2sec( ocean_dyn_slab_nudging_tausec, ocean_dyn_slab_nudging_tau, ocean_dyn_slab_nudging_tau_unit )
132 
133  log_info("OCEAN_DYN_SLAB_setup",*) 'Use nudging for SST : ON'
134  log_info("OCEAN_DYN_SLAB_setup",*) 'Relaxation time Tau [sec] : ', ocean_dyn_slab_nudging_tausec
135 
136  if ( ocean_dyn_slab_nudging_tausec == 0.0_rp ) then
137  ocean_dyn_slab_offline_mode = .true.
138  log_info("OCEAN_DYN_SLAB_setup",*) 'Tau=0 means that SST is completely replaced by the external data.'
139  endif
140 
141  if ( ocean_dyn_slab_nudging_basename == '' ) then
142  log_error("OCEAN_DYN_SLAB_setup",*) 'OCEAN_DYN_SLAB_nudging_basename is necessary !!'
143  call prc_abort
144  endif
145  else
146  log_info("OCEAN_DYN_SLAB_setup",*) 'Use nudging for SST : OFF'
147  endif
148 
149  if ( ocean_dyn_slab_nudging ) then
150  call file_external_input_regist( ocean_dyn_slab_nudging_basename, & ! [IN]
151  ocean_dyn_slab_nudging_basename_add_num, & ! [IN]
152  ocean_dyn_slab_nudging_number_of_files, & ! [IN]
153  'OCEAN_TEMP', & ! [IN]
154  'OXY', & ! [IN]
155  ocean_dyn_slab_nudging_enable_periodic_year, & ! [IN]
156  ocean_dyn_slab_nudging_enable_periodic_month, & ! [IN]
157  ocean_dyn_slab_nudging_enable_periodic_day, & ! [IN]
158  ocean_dyn_slab_nudging_step_fixed, & ! [IN]
159  ocean_dyn_slab_nudging_defval, & ! [IN]
160  check_coordinates = ocean_dyn_slab_nudging_check_coordinates, & ! [IN]
161  step_limit = ocean_dyn_slab_nudging_step_limit, & ! [IN]
162  allow_missing = ( .not. ocean_dyn_slab_offline_mode ) ) ! [IN]
163  endif
164 
165  return
166  end subroutine ocean_dyn_slab_setup
167 
168  !-----------------------------------------------------------------------------
170  subroutine ocean_dyn_slab( &
171  OKMAX, OKS, OKE, &
172  OIA, OIS, OIE, &
173  OJA, OJS, OJE, &
174  OCEAN_TEMP_t, &
175  OCEAN_SFLX_G, &
176  OCEAN_SFLX_water, &
177  calc_flag, &
178  dt, NOWDAYSEC, &
179  OCEAN_TEMP, &
180  MASS_SUPL, &
181  ENGI_SUPL )
182  use scale_prc, only: &
183  prc_abort
184  use scale_const, only: &
185  undef => const_undef
186  use scale_file_external_input, only: &
187  file_external_input_update
188  use scale_atmos_hydrometeor, only: &
189  cv_water
190  implicit none
191 
192  integer, intent(in) :: okmax, oks, oke
193  integer, intent(in) :: oia, ois, oie
194  integer, intent(in) :: oja, ojs, oje
195  real(rp), intent(in) :: ocean_temp_t (okmax,oia,oja) ! tendency of ocean temperature
196  real(rp), intent(in) :: ocean_sflx_g (oia,oja) ! heat flux from surface to subsurface (open ocean/sea ice)
197  real(rp), intent(in) :: ocean_sflx_water(oia,oja) ! mass flux from surface to subsurface (open ocean/sea ice)
198  logical, intent(in) :: calc_flag (oia,oja) ! to decide calculate or not
199  real(dp), intent(in) :: dt
200  real(dp), intent(in) :: nowdaysec
201  real(rp), intent(inout) :: ocean_temp (okmax,oia,oja)
202  real(rp), intent(out) :: mass_supl (oia,oja)
203  real(rp), intent(out) :: engi_supl (oia,oja)
204 
205  real(rp) :: ocean_temp_t_ndg(okmax,oia,oja)
206  real(rp) :: ocean_temp_ref (okmax,oia,oja)
207  real(rp) :: rtau
208  real(rp) :: dcp
209 
210  logical :: error
211  integer :: k, i, j
212  !---------------------------------------------------------------------------
213  !$acc data copyin (OCEAN_TEMP_t,OCEAN_SFLX_G,OCEAN_SFLX_water,calc_flag) &
214  !$acc copyout(MASS_SUPL,ENGI_SUPL) &
215  !$acc copy(OCEAN_TEMP) &
216  !$acc create (OCEAN_TEMP_t_ndg,OCEAN_TEMP_ref)
217 
218 
219  log_progress(*) 'ocean / dynamics / slab'
220 
221  if ( ocean_dyn_slab_nudging ) then
222 
223  call file_external_input_update( 'OCEAN_TEMP', nowdaysec, ocean_temp_ref(:,:,:), error )
224 
225 
226  if ( error ) then
227  log_error("OCEAN_DYN_SLAB",*) 'Requested data is not found!'
228  call prc_abort
229  endif
230 
231  if ( .not. ocean_dyn_slab_offline_mode ) then
232 
233  ! if OCEAN_DYN_SLAB_nudging_tau < dt, Nudging acts as quasi-prescribed boundary
234  rtau = 1.0_rp / max(ocean_dyn_slab_nudging_tausec,dt)
235 
236  !$omp parallel do
237  !$acc kernels
238  do j = ojs, oje
239  do i = ois, oie
240  do k = oks, oke
241  if ( ocean_temp_ref(k,i,j) == undef ) then
242  ocean_temp_t_ndg(k,i,j) = 0.0_rp
243  else
244  ocean_temp_t_ndg(k,i,j) = ( ocean_temp_ref(k,i,j) - ocean_temp(k,i,j) ) * rtau
245  end if
246  enddo
247  enddo
248  enddo
249  !$acc end kernels
250 
251  end if
252 
253  else
254  !$omp parallel do
255  !$acc kernels
256  do j = ojs, oje
257  do i = ois, oie
258  do k = oks, oke
259  ocean_temp_t_ndg(k,i,j) = 0.0_rp
260  end do
261  end do
262  end do
263  !$acc end kernels
264  endif
265 
266  if ( ocean_dyn_slab_offline_mode ) then
267 
268  !$omp parallel do
269  !$acc kernels
270  do j = ojs, oje
271  do i = ois, oie
272  if ( calc_flag(i,j) ) then
273  ocean_temp(oks,i,j) = ocean_temp_ref(oks,i,j)
274  endif
275  mass_supl(i,j) = 0.0_rp
276  engi_supl(i,j) = 0.0_rp
277  enddo
278  enddo
279  !$acc end kernels
280 
281  else
282 
283  !$omp parallel do private(dCP)
284  !$acc kernels
285  do j = ojs, oje
286  do i = ois, oie
287  if ( calc_flag(i,j) ) then
288  ! heat flux from atm/ice at uppermost ocean layer
289  dcp = cv_water * ocean_sflx_water(i,j) * dt
290  ocean_temp(oks,i,j) = ocean_temp(oks,i,j) &
291  + ( ocean_sflx_g(i,j) * dt - dcp * ocean_temp(oks,i,j) ) &
292  / ( ocean_dyn_slab_heatcapacity + dcp ) &
293  + ocean_temp_t_ndg(oks,i,j) * dt
294  do k = oks+1, oke
295  ocean_temp(k,i,j) = ocean_temp(k,i,j) + ocean_temp_t_ndg(k,i,j) * dt
296  enddo
297  mass_supl(i,j) = - ocean_sflx_water(i,j)
298  engi_supl(i,j) = cv_water * mass_supl(i,j) * ocean_temp(oks,i,j)
299  else
300  mass_supl(i,j) = 0.0_rp
301  engi_supl(i,j) = 0.0_rp
302  endif
303  enddo
304  enddo
305  !$acc end kernels
306 
307  endif
308  !$acc end data
309 
310  return
311  end subroutine ocean_dyn_slab
312 
313 end module scale_ocean_dyn_slab
scale_ocean_dyn_slab::ocean_dyn_slab
subroutine, public ocean_dyn_slab(OKMAX, OKS, OKE, OIA, OIS, OIE, OJA, OJS, OJE, OCEAN_TEMP_t, OCEAN_SFLX_G, OCEAN_SFLX_water, calc_flag, dt, NOWDAYSEC, OCEAN_TEMP, MASS_SUPL, ENGI_SUPL)
Slab ocean model.
Definition: scale_ocean_dyn_slab.F90:182
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_atmos_hydrometeor
module atmosphere / hydrometeor
Definition: scale_atmos_hydrometeor.F90:12
scale_calendar
module CALENDAR
Definition: scale_calendar.F90:13
scale_ocean_dyn_slab::ocean_dyn_slab_setup
subroutine, public ocean_dyn_slab_setup(DEPTH)
Setup.
Definition: scale_ocean_dyn_slab.F90:54
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_io
module STDIO
Definition: scale_io.F90:10
scale_const
module CONSTANT
Definition: scale_const.F90:11
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_const::const_dwatr
real(rp), parameter, public const_dwatr
density of water [kg/m3]
Definition: scale_const.F90:89
scale_debug
module DEBUG
Definition: scale_debug.F90:11
scale_file_external_input
module file / external_input
Definition: scale_file_external_input.F90:12
scale_const::const_undef
real(rp), public const_undef
Definition: scale_const.F90:43
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:57
scale_atmos_hydrometeor::cv_water
real(rp), public cv_water
CV for water [J/kg/K].
Definition: scale_atmos_hydrometeor.F90:151
scale_ocean_dyn_slab
module ocean / dynamics / slab
Definition: scale_ocean_dyn_slab.F90:12
scale_calendar::calendar_unit2sec
subroutine, public calendar_unit2sec(second, value, unit)
Convert several units to second.
Definition: scale_calendar.F90:486