Skip to content

Commit

Permalink
Add ECCC driver for coupling with NEMO, update 'hadgem3' driver (#605)
Browse files Browse the repository at this point in the history
* drivers/hadgem3: add missing 'subname' and use existing 'subname's

* drivers/hadgem3/CICE_InitMod: update 'init_lvl' call

Add the required 'iblk' argument.

* drivers/hadgem3/CICE_RunMod: remove uneeded 'dt' arguments

The subroutines 'prep_radiation', 'zsal_diags', 'bgc_diags' and 'hbrine_diags'
do not take a 'dt' argument anymore, so remove it.

* drivers/hadgem3/CICE_RunMod: get 'Lsub' from Icepack

* drivers/hadgem3/CICE_RunMod: remove 'da_state_update' subroutine

This subroutine is inside an 'ICE_DA' CPP, which is not used in
any configuration. Remove it.

* drivers/hadgem3/CICE_RunMod: remove stray '+'

This '+' sign was copy-pasted there in error in 29b99b6 (CICE: Floe size
distribution  (#382), 2019-12-07). Remove it.

* drivers/hadgem3: remove obsolete 'check_finished_file' subroutine

Remove the call to 'check_finished_file' as well as the definition
of the subroutine, as the 'hadgem3' driver is not used on machine 'bering'
and it's unclear if machine 'bering' still exists.

* drivers/hadgem3: fix cice_init so it calls 'count_tracers'

This was forgotten back in 8b0ae03 (Refactor tracer initialization (#235), 2018-11-16)

* drivers/hadgem3/CICE_RunMod: add call to 'save_init'

The hadgem3 driver was not updated when 'save_init' was added in 83686a3
(Implement box model test from 2001 JCP paper (#151), 2018-10-22). As
this subroutine is necessary to ensure proper initialization of the
model, add it now.

* drivers/hadgem3/CICE_RunMod: tweak loop indices in 'coupling_prep'

Other drivers use 'ilo,ihi' and 'jlo,jhi' here. Do the same.

* drivers/hagdem3: update driver to new time manager

* drivers/hadgem3: pass 'mpi_comm_opa' explicitely to init_communicate

In 066070e (Fix minor issues in documentation, key_ CPPs, bfbcomp return
codes (#532), 2020-11-23), the 'ice_communicate' module was updated to
remove CPP macros relating to the OASIS coupler (key_oasis*) and to the
NEMO ocean model (key_iomput). These CPPs were used to make the correct
MPI communicator accessible to the 'init_communicate' subroutine.
However, that subroutine already accepts an optional MPI communicator as
argument and it was deemed cleaner to require the driver layer to
explicitely pass the communicator instead of making it accessible
through 'use' statements.

Update the 'hadgem3' driver, used for coupling with NEMO, to explicitely
pass the NEMO MPI communicator 'mpi_comm_opa' to 'init_communicate'.

* drivers: add 'nemo_concepts' driver

Historically the 'hadgem3' driver has been used when compiling a single
NEMO-CICE executable at ECCC.

Going forward, all driver-level adjustements will be done in our own
driver, 'nemo_concepts', 'CONCEPTS' being the name of the
multi-departmental collaboration around using the NEMO ocean model.

Copy CICE_InitMod, CICE_RunMod and CICE_FinalMod from the 'hadgem3'
directory to a new 'nemo_concepts' directory under 'drivers/direct'.

The following commits will clean up this new driver and port over some
in-house adjustments.

* drivers/nemo_concepts: remove unused 'writeout_finished_file' subroutine

This subroutine was only called on machine 'bering', which is not an
ECCC machine and probably does not exist anymore anyway. Remove it.

* drivers/nemo_concepts: call 'scale_fluxes' with 'aice_init'

Since 'merge_fluxes' is called with aice_init, it is more consistent to
also call 'scale_fluxes', in 'coupling_prep' with 'aice_init'
instead of 'aice'.

Copy this in-house change to the new 'nemo_concepts' driver.
  • Loading branch information
phil-blain committed Jun 10, 2021
1 parent c75e8ed commit a63cc1c
Show file tree
Hide file tree
Showing 6 changed files with 1,241 additions and 349 deletions.
2 changes: 1 addition & 1 deletion cicecore/drivers/direct/hadgem3/CICE_FinalMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ subroutine CICE_Finalize
!-------------------------------------------------------------------

call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message="subname", &
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__,line= __LINE__)

call ice_timer_stop(timer_total) ! stop timing entire run
Expand Down
64 changes: 18 additions & 46 deletions cicecore/drivers/direct/hadgem3/CICE_InitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ subroutine cice_init
ocean_bio_all, ice_bio_net, snow_bio_net, alloc_arrays_column
use ice_arrays_column, only: floe_rad_l, floe_rad_c, &
floe_binwidth, c_fsd_range
use ice_calendar, only: dt, dt_dyn, time, istep, istep1, write_ic, &
init_calendar, calendar
use ice_calendar, only: dt, dt_dyn, write_ic, &
init_calendar, advance_timestep, calc_timesteps
use ice_communicate, only: init_communicate, my_task, master_task
use ice_diagnostics, only: init_diags
use ice_domain, only: init_domain_blocks
Expand All @@ -83,17 +83,18 @@ subroutine cice_init
use ice_history, only: init_hist, accum_hist
use ice_restart_shared, only: restart, runid, runtype
use ice_init, only: input_data, init_state
use ice_init_column, only: init_thermo_vertical, init_shortwave, init_zbgc
use ice_init_column, only: init_thermo_vertical, init_shortwave, init_zbgc, input_zbgc, count_tracers
use ice_kinds_mod
use ice_restoring, only: ice_HaloRestore_init
use ice_timers, only: timer_total, init_ice_timers, ice_timer_start
use ice_transport_driver, only: init_transport
use lib_mpp, only: mpi_comm_opa ! NEMO MPI communicator

logical(kind=log_kind) :: tr_aero, tr_zaero, skl_bgc, z_tracers, &
tr_fsd, wave_spec
character(len=*),parameter :: subname = '(cice_init)'

call init_communicate ! initial setup for message passing
call init_communicate(mpi_comm_opa) ! initial setup for message passing
call init_fileunits ! unit numbers

call icepack_configure() ! initialize icepack
Expand All @@ -102,8 +103,8 @@ subroutine cice_init
file=__FILE__,line= __LINE__)

call input_data ! namelist variables

if (trim(runid) == 'bering') call check_finished_file
call input_zbgc ! vertical biogeochemistry namelist
call count_tracers ! count tracers

call init_domain_blocks ! set up block decomposition
call init_grid1 ! domain distribution
Expand Down Expand Up @@ -150,11 +151,9 @@ subroutine cice_init
write_diags=(my_task == master_task)) ! write diag on master only

call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message="subname", &
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)

call calendar(time) ! determine the initial date

#ifndef CICE_IN_NEMO
call init_forcing_ocn(dt) ! initialize sss and sst from data
#endif
Expand All @@ -170,6 +169,7 @@ subroutine cice_init
call init_diags ! initialize diagnostic output points
call init_history_therm ! initialize thermo history variables
call init_history_dyn ! initialize dynamic history variables
call calc_timesteps ! update timestep counter if not using npt_unit="1"

call icepack_query_tracer_flags(tr_aero_out=tr_aero, tr_zaero_out=tr_zaero)
call icepack_warnings_flush(nu_diag)
Expand All @@ -185,10 +185,8 @@ subroutine cice_init
if (trim(runtype) == 'continue' .or. restart) &
call init_shortwave ! initialize radiative transfer

istep = istep + 1 ! update time step counters
istep1 = istep1 + 1
time = time + dt ! determine the time and date
call calendar(time) ! at the end of the first timestep
! determine the time and date at the end of the first timestep
call advance_timestep()

!--------------------------------------------------------------------
! coupler communication or forcing data initialization
Expand Down Expand Up @@ -227,7 +225,7 @@ subroutine init_restart

use ice_arrays_column, only: dhsn
use ice_blocks, only: nx_block, ny_block
use ice_calendar, only: time, calendar
use ice_calendar, only: calendar
use ice_constants, only: c0
use ice_domain, only: nblocks
use ice_domain_size, only: ncat, n_aero, nfsd
Expand Down Expand Up @@ -265,6 +263,8 @@ subroutine init_restart
nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd, &
nt_iage, nt_FY, nt_aero, nt_fsd

character(len=*),parameter :: subname = '(init_restart)'

call icepack_query_tracer_sizes(ntrcr_out=ntrcr)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
Expand All @@ -280,13 +280,13 @@ subroutine init_restart
nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, &
nt_iage_out=nt_iage, nt_FY_out=nt_FY, nt_aero_out=nt_aero, nt_fsd_out=nt_fsd)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message="subname", &
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)

if (trim(runtype) == 'continue') then
! start from core restart file
call restartfile() ! given by pointer in ice_in
call calendar(time) ! update time parameters
call calendar() ! update time parameters
if (kdyn == 2) call read_restart_eap ! EAP
else if (restart) then ! ice_ic = core restart file
call restartfile (ice_ic) ! or 'default' or 'none'
Expand Down Expand Up @@ -327,7 +327,7 @@ subroutine init_restart
call read_restart_lvl
else
do iblk = 1, nblocks
call init_lvl(trcrn(:,:,nt_alvl,:,iblk), &
call init_lvl(iblk,trcrn(:,:,nt_alvl,:,iblk), &
trcrn(:,:,nt_vlvl,:,iblk))
enddo ! iblk
endif
Expand Down Expand Up @@ -452,39 +452,11 @@ subroutine init_restart
!$OMP END PARALLEL DO

call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message="subname", &
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)

end subroutine init_restart

!=======================================================================
!
! Check whether a file indicating that the previous run finished cleanly
! If so, then do not continue the current restart. This is needed only
! for runs on machine 'bering' (set using runid = 'bering').
!
! author: Adrian Turner, LANL

subroutine check_finished_file()

use ice_communicate, only: my_task, master_task
use ice_restart_shared, only: restart_dir

character(len=char_len_long) :: filename
logical :: lexist = .false.

if (my_task == master_task) then

filename = trim(restart_dir)//"finished"
inquire(file=filename, exist=lexist)
if (lexist) then
call abort_ice("subname"//"ERROR: Found already finished file - quitting")
end if

endif

end subroutine check_finished_file

!=======================================================================

end module CICE_InitMod
Expand Down
Loading

0 comments on commit a63cc1c

Please sign in to comment.