8 use fckit_mpi_module,
only: fckit_mpi_comm
9 use mpp_mod,
only : mpp_init
10 use fms_io_mod,
only : fms_io_init, fms_io_exit
11 use fms_mod,
only : read_data, write_data, fms_init, fms_end
12 use time_interp_external_mod,
only : time_interp_external_init
13 use time_manager_mod,
only: time_type
15 use kinds,
only: kind_real
17 use mom,
only : initialize_mom, step_mom, mom_control_struct, mom_end, &
18 extract_surface_state, finish_mom_initialization, &
19 get_mom_state_elements
20 use mom_diag_mediator,
only : diag_ctrl
21 use mom_domains,
only : mom_infra_init, mom_infra_end, &
22 mom_domains_init, clone_mom_domain, mom_domain_type
23 use mom_error_handler,
only : mom_error, mom_mesg, warning, fatal, is_root_pe
24 use mom_file_parser,
only : get_param, param_file_type, close_param_file
25 use mom_forcing_type,
only : forcing, mech_forcing, forcing_diagnostics, &
26 mech_forcing_diags, mom_forcing_chksum, &
27 mom_mech_forcing_chksum
28 use mom_get_input,
only : directories, get_mom_input, directories
29 use mom_grid,
only : ocean_grid_type, mom_grid_init
30 use mom_io,
only : open_file, close_file, &
31 check_nml_error, io_infra_init, io_infra_end, &
32 ascii_file, readonly_file
33 use mom_restart,
only : mom_restart_cs
34 use mom_string_functions,
only : uppercase
35 use mom_surface_forcing,
only : set_forcing, forcing_save_restart, &
36 surface_forcing_init, surface_forcing_cs
37 use mom_time_manager,
only : time_type, set_date, get_date, &
38 real_to_time, time_type_to_real, &
39 operator(+),
operator(-),
operator(*),
operator(/), &
40 operator(>),
operator(<),
operator(>=), &
41 increment_date, set_calendar_type, month_name, &
42 julian, gregorian, noleap, thirty_day_months, &
44 use mom_tracer_flow_control,
only : tracer_flow_control_cs
45 use mom_unit_scaling,
only : unit_scale_type
46 use mom_variables,
only : surface
47 use mom_verticalgrid,
only : verticalgrid_type, &
48 verticalgridinit, verticalgridend
58 type(mech_forcing) :: forces
59 type(forcing) :: fluxes
61 type(surface) :: sfc_state
63 type(time_type) :: time_step_ocean
64 type(directories) :: dirs
65 type(time_type) :: time
66 type(unit_scale_type),
pointer :: scaling
67 type(ocean_grid_type),
pointer :: grid
68 type(verticalgrid_type),
pointer :: gv
69 type(mom_control_struct),
pointer :: mom_csp
70 type(mom_restart_cs),
pointer :: restart_csp
71 type(surface_forcing_cs),
pointer :: surface_forcing_csp => null()
72 type(fckit_mpi_comm) :: f_comm
73 type(param_file_type) :: param_file
81 type(mom_domain_type),
pointer,
intent(in) :: domain
82 integer,
intent(out) :: nk
83 type(fckit_mpi_comm),
intent(in) :: f_comm
85 type(param_file_type) :: param_file
86 type(directories) :: dirs
87 character(len=40) :: mod_name =
"soca_mom6"
89 call mpp_init(localcomm=f_comm%communicator())
98 call get_mom_input(param_file, dirs)
101 call mom_domains_init(domain, param_file)
104 call get_param(param_file, mod_name,
"NK", nk, fail_if_missing=.true.)
106 call close_param_file(param_file)
115 logical,
optional,
intent(in) :: partial_init
117 type(time_type) :: start_time
118 type(time_type) :: time_in
120 integer :: date_init(6)=0
121 integer :: years=0, months=0, days=0
122 integer :: hours=0, minutes=0, seconds=0
123 type(param_file_type) :: param_file
125 character(len=16) :: calendar =
'julian'
126 integer :: calendar_type=-1
127 integer :: unit, io_status, ierr
128 logical :: offline_tracer_mode = .false.
130 type(tracer_flow_control_cs),
pointer :: tracer_flow_csp => null()
131 type(diag_ctrl),
pointer :: diag => null()
132 character(len=4),
parameter :: vers_num =
'v2.0'
133 character(len=40) :: mod_name =
"soca_mom6"
134 integer :: ocean_nthreads = 1
135 integer :: ncores_per_node = 1
136 logical :: use_hyper_thread = .false.
138 namelist /ocean_solo_nml/ date_init, calendar, months, days, hours, minutes, seconds,&
139 ocean_nthreads, ncores_per_node, use_hyper_thread
141 logical :: a_partial_init = .false.
144 if (
present(partial_init)) a_partial_init = partial_init
146 call mom_infra_init(localcomm=mom6_config%f_comm%communicator())
150 call open_file(unit,
'input.nml', form=ascii_file, action=readonly_file)
151 read(unit, ocean_solo_nml, iostat=io_status)
152 call close_file(unit)
153 ierr = check_nml_error(io_status,
'ocean_solo_nml')
154 if (years+months+days+hours+minutes+seconds > 0)
then
155 if (is_root_pe())
write(*,ocean_solo_nml)
157 calendar = uppercase(calendar)
158 if (calendar(1:6) ==
'JULIAN')
then ; calendar_type = julian
159 elseif (calendar(1:9) ==
'GREGORIAN')
then ; calendar_type = gregorian
160 elseif (calendar(1:6) ==
'NOLEAP')
then ; calendar_type = noleap
161 elseif (calendar(1:10)==
'THIRTY_DAY')
then ; calendar_type = thirty_day_months
162 elseif (calendar(1:11)==
'NO_CALENDAR') then; calendar_type = no_calendar
163 elseif (calendar(1:1) /=
' ')
then
164 call mom_error(fatal,
'MOM_driver: Invalid namelist value '//trim(calendar)//
' for calendar')
166 call mom_error(fatal,
'MOM_driver: No namelist value for calendar')
168 call set_calendar_type(calendar_type)
170 start_time = set_date(date_init(1),date_init(2), date_init(3), &
171 date_init(4),date_init(5),date_init(6))
173 call time_interp_external_init
176 mom6_config%MOM_CSp => null()
177 mom6_config%restart_CSp => null()
178 mom6_config%grid => null()
179 mom6_config%GV => null()
182 mom6_config%Time = start_time
185 time_in = mom6_config%Time
187 call initialize_mom(mom6_config%Time, &
191 mom6_config%MOM_CSp, &
192 mom6_config%restart_CSp, &
193 offline_tracer_mode=offline_tracer_mode, diag_ptr=diag, &
194 tracer_flow_csp=tracer_flow_csp, time_in=time_in)
198 call get_mom_state_elements(mom6_config%MOM_CSp,&
201 us=mom6_config%scaling,&
202 c_p=mom6_config%fluxes%C_p)
204 mom6_config%param_file = param_file
206 if (a_partial_init)
return
209 call extract_surface_state(mom6_config%MOM_CSp, mom6_config%sfc_state)
210 call surface_forcing_init(mom6_config%Time,&
212 mom6_config%scaling,&
215 mom6_config%surface_forcing_CSp,&
219 call get_param(param_file, mod_name,
"DT", param_int, fail_if_missing=.true.)
221 mom6_config%dt_forcing = dt
222 mom6_config%Time_step_ocean = real_to_time(real(mom6_config%dt_forcing, kind=8))
225 call close_param_file(param_file)
228 call set_forcing(mom6_config%sfc_state,&
232 mom6_config%Time_step_ocean,&
234 mom6_config%scaling, &
235 mom6_config%surface_forcing_CSp)
238 call finish_mom_initialization(mom6_config%Time,&
240 mom6_config%MOM_CSp,&
241 mom6_config%restart_CSp)
257 call mom_end(mom6_config%MOM_CSp)
subroutine, public soca_mom6_init(mom6_config, partial_init)
Setup/initialize/prepare mom6 for time integration.
subroutine, public soca_mom6_end(mom6_config)
Release memory and possibly dump mom6's restart.
subroutine, public soca_geomdomain_init(Domain, nk, f_comm)
Initialize mom6's domain.
Data structure neccessary to initialize/run mom6.