SCALE-RM
scale_ocean_dyn_offline.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_offline_setup
29  public :: ocean_dyn_offline
30 
31  !-----------------------------------------------------------------------------
32  !
33  !++ Public parameters & variables
34  !
35  !-----------------------------------------------------------------------------
36  !
37  !++ Private procedure
38  !
39  !-----------------------------------------------------------------------------
40  !
41  !++ Private parameters & variables
42  !
43  !-----------------------------------------------------------------------------
44 contains
45  !-----------------------------------------------------------------------------
47  subroutine ocean_dyn_offline_setup
48  use scale_prc, only: &
49  prc_abort
50  use scale_const, only: &
51  undef => const_undef
52  use scale_file_external_input, only: &
53  file_external_input_regist
54  implicit none
55 
56  character(len=H_LONG) :: ocean_dyn_offline_basename = ''
57  logical :: ocean_dyn_offline_basename_add_num = .false.
58  integer :: ocean_dyn_offline_number_of_files = 1
59  logical :: ocean_dyn_offline_enable_periodic_year = .false.
60  logical :: ocean_dyn_offline_enable_periodic_month = .false.
61  logical :: ocean_dyn_offline_enable_periodic_day = .false.
62  integer :: ocean_dyn_offline_step_fixed = 0
63  real(rp) :: ocean_dyn_offline_defval != UNDEF
64  logical :: ocean_dyn_offline_check_coordinates = .true.
65  integer :: ocean_dyn_offline_step_limit = 0
66 
67  namelist / param_ocean_dyn_offline / &
68  ocean_dyn_offline_basename, &
69  ocean_dyn_offline_basename_add_num, &
70  ocean_dyn_offline_number_of_files, &
71  ocean_dyn_offline_enable_periodic_year, &
72  ocean_dyn_offline_enable_periodic_month, &
73  ocean_dyn_offline_enable_periodic_day, &
74  ocean_dyn_offline_step_fixed, &
75  ocean_dyn_offline_defval, &
76  ocean_dyn_offline_check_coordinates, &
77  ocean_dyn_offline_step_limit
78 
79  integer :: ierr
80  !---------------------------------------------------------------------------
81 
82  log_newline
83  log_info("OCEAN_DYN_OFFLINE_setup",*) 'Setup'
84 
85  ocean_dyn_offline_defval = undef
86 
87  !--- read namelist
88  rewind(io_fid_conf)
89  read(io_fid_conf,nml=param_ocean_dyn_offline,iostat=ierr)
90  if( ierr < 0 ) then !--- missing
91  log_info("OCEAN_DYN_OFFLINE_setup",*) 'Not found namelist. Default used.'
92  elseif( ierr > 0 ) then !--- fatal error
93  log_error("OCEAN_DYN_OFFLINE_setup",*) 'Not appropriate names in namelist PARAM_OCEAN_DYN_OFFLINE. Check!'
94  call prc_abort
95  endif
96  log_nml(param_ocean_dyn_offline)
97 
98  log_info("OCEAN_DYN_OFFLINE_setup",*) 'Use offline ocean'
99 
100  if ( ocean_dyn_offline_basename == '' ) then
101  log_error("OCEAN_DYN_OFFLINE_setup",*) 'OCEAN_DYN_OFFLINE_basename is necessary !!'
102  call prc_abort
103  endif
104 
105  call file_external_input_regist( ocean_dyn_offline_basename, & ! [IN]
106  ocean_dyn_offline_basename_add_num, & ! [IN]
107  ocean_dyn_offline_number_of_files, & ! [IN]
108  'OCEAN_TEMP', & ! [IN]
109  'OXY', & ! [IN]
110  ocean_dyn_offline_enable_periodic_year, & ! [IN]
111  ocean_dyn_offline_enable_periodic_month, & ! [IN]
112  ocean_dyn_offline_enable_periodic_day, & ! [IN]
113  ocean_dyn_offline_step_fixed, & ! [IN]
114  ocean_dyn_offline_defval, & ! [IN]
115  check_coordinates = ocean_dyn_offline_check_coordinates, & ! [IN]
116  step_limit = ocean_dyn_offline_step_limit ) ! [IN]
117 
118  return
119  end subroutine ocean_dyn_offline_setup
120 
121  !-----------------------------------------------------------------------------
123  subroutine ocean_dyn_offline( &
124  OKMAX, OKS, OKE, &
125  OIA, OIS, OIE, &
126  OJA, OJS, OJE, &
127  calc_flag, &
128  dt, NOWDAYSEC, &
129  OCEAN_TEMP )
130  use scale_prc, only: &
131  prc_abort
132  use scale_file_external_input, only: &
133  file_external_input_update
134  implicit none
135 
136  integer, intent(in) :: okmax, oks, oke
137  integer, intent(in) :: oia, ois, oie
138  integer, intent(in) :: oja, ojs, oje
139  logical, intent(in) :: calc_flag (oia,oja) ! to decide calculate or not
140  real(dp), intent(in) :: dt
141  real(dp), intent(in) :: nowdaysec
142  real(rp), intent(inout) :: ocean_temp(okmax,oia,oja)
143 
144  real(rp) :: ocean_temp_ref(okmax,oia,oja)
145 
146  logical :: error
147  integer :: i, j
148  !---------------------------------------------------------------------------
149  !$acc data copyin(calc_flag) copy(OCEAN_TEMP) create(OCEAN_TEMP_ref)
150 
151  log_progress(*) 'ocean / dynamics / offline'
152 
153  call file_external_input_update( 'OCEAN_TEMP', nowdaysec, ocean_temp_ref(:,:,:), error )
154 
155  if ( error ) then
156  log_error("OCEAN_DYN_OFFLINE",*) 'Requested data is not found!'
157  call prc_abort
158  endif
159 
160  !$acc kernels
161  do j = ojs, oje
162  do i = ois, oie
163  if ( calc_flag(i,j) ) then
164  ocean_temp(oks,i,j) = ocean_temp_ref(oks,i,j)
165  endif
166  enddo
167  enddo
168  !$acc end kernels
169 
170  !$acc end data
171  return
172  end subroutine ocean_dyn_offline
173 
174 end module scale_ocean_dyn_offline
scale_ocean_dyn_offline::ocean_dyn_offline_setup
subroutine, public ocean_dyn_offline_setup
Setup.
Definition: scale_ocean_dyn_offline.F90:48
scale_ocean_dyn_offline
module ocean / dynamics / offline
Definition: scale_ocean_dyn_offline.F90:12
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_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_const
module CONSTANT
Definition: scale_const.F90:11
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_precision::dp
integer, parameter, public dp
Definition: scale_precision.F90:32
scale_ocean_dyn_offline::ocean_dyn_offline
subroutine, public ocean_dyn_offline(OKMAX, OKS, OKE, OIA, OIS, OIE, OJA, OJS, OJE, calc_flag, dt, NOWDAYSEC, OCEAN_TEMP)
Slab ocean model.
Definition: scale_ocean_dyn_offline.F90:130
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