Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sea ice column thermodynamics in MPAS-Ocean #47

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions components/mpas-ocean/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ FRAMEWORK_DIR = ../../../mpas-framework/src
OCEAN_SHARED_INCLUDES = -I$(FRAMEWORK_DIR)/framework -I$(FRAMEWORK_DIR)/external/esmf_time_f90 -I$(FRAMEWORK_DIR)/operators
OCEAN_SHARED_INCLUDES += -I$(PWD)/shared -I$(PWD)/analysis_members -I$(PWD)/mode_forward -I$(PWD)/mode_analysis
OCEAN_SHARED_INCLUDES += -I$(PWD)/BGC -I$(PWD)/MARBL/include -I$(PWD)/cvmix/src/shared -I$(PWD)/gotm/build -I$(PWD)/gotm/build/modules -I$(PWD)/SHTNS -I$(PWD)/ppr/src
ifeq "$(SEAICE_COLUMN)" "true"
OCEAN_SHARED_INCLUDES += -I$(PWD)/seaice -I$(PWD)/seaice/column -I$(PWD)/seaice/shared -I$(PWD)/seaice/analysis_members
endif
ifneq "$(EXCLUDE_INIT_MODE)" "true"
OCEAN_SHARED_INCLUDES += -I$(PWD)/mode_init
endif
Expand All @@ -22,17 +25,21 @@ ifneq "$(EXCLUDE_INIT_MODE)" "true"
OCEAN_SHARED_INCLUDES += -I$(PWD)/mode_init
endif

all: shared libcvmix analysis_members libBGC libMARBL libgotm libfftw libshtns libppr
(cd mode_forward; $(MAKE) FCINCLUDES="$(FCINCLUDES) $(OCEAN_SHARED_INCLUDES)" all )
ifeq "$(SEAICE_COLUMN)" "true"
override CPPFLAGS += -DSEAICE_COLUMN
endif

all: shared libcvmix analysis_members libBGC libMARBL libgotm libfftw libshtns libppr libseaice
(cd mode_forward; $(MAKE) CPPFLAGS="$(CPPFLAGS)" FCINCLUDES="$(FCINCLUDES) $(OCEAN_SHARED_INCLUDES)" all )
(cd mode_analysis; $(MAKE) FCINCLUDES="$(FCINCLUDES) $(OCEAN_SHARED_INCLUDES)" all )
ifneq "$(EXCLUDE_INIT_MODE)" "true"
(cd mode_init; $(MAKE) FCINCLUDES="$(FCINCLUDES) $(OCEAN_SHARED_INCLUDES)" all )
endif
(cd driver; $(MAKE) FCINCLUDES="$(FCINCLUDES) $(OCEAN_SHARED_INCLUDES)" all )
(cd driver; $(MAKE) CPPFLAGS="$(CPPFLAGS)" FCINCLUDES="$(FCINCLUDES) $(OCEAN_SHARED_INCLUDES)" all )
if [ -e libdycore.a ]; then \
($(RM) libdycore.a) \
fi
ar -ru libdycore.a `find . -type f -name "*.o"`
ar -ru libdycore.a `find -L . -type f -name "*.o"`

core_reg:
$(CPP) $(CPPFLAGS) $(CPPLOCALFLAGS) $(CPPINCLUDES) Registry.xml > Registry_processed.xml
Expand Down Expand Up @@ -138,6 +145,11 @@ libppr:
(pwd ; echo "Missing core_ocean/ppr/.git, did you forget to 'git submodule update --init --recursive' ?"; exit 1) \
fi

libseaice: shared
ifeq "$(SEAICE_COLUMN)" "true"
(cd seaice; $(MAKE) FFLAGS="${FFLAGS}" FCINCLUDES="$(FCINCLUDES) $(OCEAN_SHARED_INCLUDES)" CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" all)
endif

shared: libcvmix libBGC libMARBL libgotm libshtns libfftw libppr
(cd shared; $(MAKE) FCINCLUDES="$(FCINCLUDES) $(OCEAN_SHARED_INCLUDES)")

Expand Down Expand Up @@ -166,6 +178,9 @@ clean:
if [ -e FFTW/.git ]; then \
(cd FFTW; make clean; rm -f $(SHTNS_DIR)/lib/libfftw3*) \
fi
ifeq "$(SEAICE_COLUMN)" "true"
(cd seaice; $(MAKE) clean)
endif
(cd mode_forward; $(MAKE) clean)
(cd mode_analysis; $(MAKE) clean)
(cd mode_init; $(MAKE) clean)
Expand Down
80 changes: 79 additions & 1 deletion components/mpas-ocean/src/Registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
description="Number of wavenumbers used to reconstruct Stokes drift depth profile"
definition="6"
/>
#ifdef SEAICE_COLUMN
#include "seaice/Registry_seaice_column_dimensions.xml"
#endif
</dims>

<!--*************************************-->
Expand Down Expand Up @@ -768,7 +771,32 @@
description="Time between forcing inputs"
possible_values="'YYYY-MM-DD_HH:MM:SS"
/>
</nml_record>

<nml_option name="config_use_time_varying_surface_flux_forcing" type="logical" default_value=".false."
description="If true calculate input forcing fields."
possible_values=".true. or .false."
/>
<nml_option name="config_time_varying_surface_flux_forcing_start_time" type="character" default_value="0001-01-01_00:00:00"
description="Forcing time to use at the simulation start time"
possible_values="'YYYY-MM-DD_HH:MM:SS"
/>
<nml_option name="config_time_varying_surface_flux_forcing_reference_time" type="character" default_value="0001-01-01_00:00:00"
description="Reference time for the forcing"
possible_values="'YYYY-MM-DD_HH:MM:SS"
/>
<nml_option name="config_time_varying_surface_flux_forcing_cycle_start" type="character" default_value="0001-01-01_00:00:00"
description="Start time for the forcing cycle."
possible_values="'YYYY-MM-DD_HH:MM:SS"
/>
<nml_option name="config_time_varying_surface_flux_forcing_cycle_duration" type="character" default_value="2-00-00_00:00:00"
description="Duration of the forcing cycle."
possible_values="'YYYY-MM-DD_HH:MM:SS"
/>
<nml_option name="config_time_varying_surface_flux_forcing_interval" type="character" default_value="01:00:00"
description="Time between forcing inputs"
possible_values="'YYYY-MM-DD_HH:MM:SS"
/>
</nml_record>
<nml_record name="coupling" mode="init;forward">
<nml_option name="config_ssh_grad_relax_timescale" type="real" default_value="0.0" units="seconds"
description="Timescale for relaxation of the ssh gradient for coupling. A value of 0.0 (default) removes any relaxation and gives instantaneous response."
Expand Down Expand Up @@ -1992,6 +2020,30 @@
<var name="landIceFractionForcing"/>
<var name="landIceDraftForcing"/>
</stream>
<stream name="surface_flux_forcing"
type="input"
filename_template="surface_flux_forcing.nc"
filename_interval="none"
input_interval="none"
immutable="true">
<var name="latentHeatFlux"/>
<var name="sensibleHeatFlux"/>
<var name="longWaveHeatFluxUp"/>
<var name="longWaveHeatFluxDown"/>
<var name="seaIceHeatFlux"/>
<var name="icebergHeatFlux"/>
<var name="shortWaveHeatFlux"/>
<var name="rainFlux"/>
<var name="snowFlux"/>
<var name="iceRunoffFlux"/>
<var name="evaporationFlux"/>
<var name="seaIceFreshWaterFlux"/>
<var name="icebergFreshWaterFlux"/>
<var name="riverRunoffFlux"/>
<var name="seaIceSalinityFlux"/>
<var name="windStressZonal"/>
<var name="windStressMeridional"/>
</stream>

<!-- Diagnostics streams for forward mode -->
<stream name="additional_output"
Expand Down Expand Up @@ -2174,6 +2226,22 @@
<var name="topographic_wave_drag"/>
</stream>

#ifdef SEAICE_COLUMN
<stream name="seaice_forcing_data"
type="input"
filename_template="seaice_forcing_data.nc"
input_interval="initial_only"
runtime_format="single_file"
mode="forward">

<var name="airTemperature"/>
<var name="airSpecificHumidity"/>
<var name="uAirVelocity"/>
<var name="vAirVelocity"/>
<var name="cloudFraction"/>
<var name="rainfallRate"/>
</stream>
#endif
</streams>

<var_struct name="state" time_levs="2">
Expand Down Expand Up @@ -3988,4 +4056,14 @@
#include "mode_init/Registry.xml"
#endif

<!-- Sea ice column -->
#ifdef SEAICE_COLUMN

#include "seaice/Registry_seaice.xml"
#include "seaice/Registry_seaice_state.xml"
#include "seaice/Registry_seaice_column.xml"
#include "seaice/Registry_seaice_forcing_and_coupling.xml"
#include "seaice/analysis_members/Registry_seaice_analysis_members_in_ocean.xml"
#endif

</registry>
9 changes: 9 additions & 0 deletions components/mpas-ocean/src/driver/mpas_ocn_core_interface.F
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ end subroutine ocn_setup_domain!}}}
function ocn_setup_packages(configPool, packagePool, iocontext) result(ierr)!{{{

use ocn_analysis_driver
#ifdef SEAICE_COLUMN
use ocn_seaice_column, only: ocn_seaice_setup_packages
use seaice_analysis_driver, only: seaice_analysis_setup_packages
#endif

type (mpas_pool_type), intent(inout) :: configPool
type (mpas_pool_type), intent(inout) :: packagePool
Expand Down Expand Up @@ -504,6 +508,11 @@ function ocn_setup_packages(configPool, packagePool, iocontext) result(ierr)!{{{
! test for conflicts, i.e. package settings that are inconsistent in combination
!

#ifdef SEAICE_COLUMN
call ocn_seaice_setup_packages(configPool, packagePool, err_tmp)
ierr = ior(ierr, err_tmp)
call seaice_analysis_setup_packages(configPool, packagePool, iocontext, ierr)
#endif


call mpas_log_write( '')
Expand Down
66 changes: 66 additions & 0 deletions components/mpas-ocean/src/mode_forward/mpas_ocn_forward_mode.F
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ module ocn_forward_mode
use ocn_constants
use ocn_config

#ifdef SEAICE_COLUMN
use ocn_seaice_column
use seaice_analysis_driver
use seaice_column
#endif

implicit none
private

Expand Down Expand Up @@ -239,6 +245,9 @@ function ocn_forward_mode_init(domain, startTimeStamp) result(ierr)!{{{

! Read any analysis initialization
call ocn_analysis_bootstrap(domain, err=err_tmp)
#ifdef SEAICE_COLUMN
call seaice_analysis_bootstrap(domain, err=err_tmp)
#endif

call mpas_timer_stop('io_read')
if (ierr /= 0) return
Expand Down Expand Up @@ -363,6 +372,15 @@ function ocn_forward_mode_init(domain, startTimeStamp) result(ierr)!{{{
call mpas_log_write('An error was encountered while initializing ' &
// 'the analysis members in the MPAS-Ocean forward mode', MPAS_LOG_CRIT)
endif
#ifdef SEAICE_COLUMN
call seaice_analysis_init(domain, err_tmp)
ierr = ior(ierr, err_tmp)
if(ierr.eq.1) then
call mpas_log_write('An error was encountered while initializing ' &
// 'the sea ice analysis members in the MPAS-Ocean forward mode', MPAS_LOG_CRIT)
endif
#endif


if (config_use_surface_salinity_monthly_restoring) then
!initialize the alarm for reading salinity data for restoring
Expand Down Expand Up @@ -507,6 +525,11 @@ function ocn_forward_mode_init(domain, startTimeStamp) result(ierr)!{{{
return
endif

#ifdef SEAICE_COLUMN
! Initialize sea ice column package
call ocn_seaice_init(domain)
#endif

!--------------------------------------------------------------------

end function ocn_forward_mode_init!}}}
Expand Down Expand Up @@ -591,6 +614,11 @@ end function ocn_forward_mode_setup_clock!}}}

function ocn_forward_mode_run(domain) result(ierr)!{{{

#ifdef SEAICE_COLUMN
use seaice_initialize, only: &
seaice_init_post_clock_advance
#endif

type (domain_type), intent(inout) :: domain

integer :: itimestep, err
Expand All @@ -600,6 +628,7 @@ function ocn_forward_mode_run(domain) result(ierr)!{{{
type (MPAS_Time_Type) :: currTime
character(len=StrKIND) :: timeStamp
integer :: ierr, err_tmp
logical :: lstart

type (mpas_pool_type), pointer :: averagePool
type (mpas_pool_type), pointer :: meshPool
Expand All @@ -621,6 +650,9 @@ function ocn_forward_mode_run(domain) result(ierr)!{{{
call mpas_log_write('Initial time ' // trim(timeStamp))
#endif
call ocn_analysis_compute_startup(domain, err)
#ifdef SEAICE_COLUMN
call seaice_analysis_compute_startup(domain, err)
#endif

if (config_write_output_on_startup) then
call mpas_timer_start('io_write')
Expand Down Expand Up @@ -663,6 +695,7 @@ function ocn_forward_mode_run(domain) result(ierr)!{{{
! time step, and time level 2 stores the state advanced dt in time by timestep(...)
itimestep = 0

lstart = .true.
do while (.not. mpas_is_clock_stop_time(domain % clock))
call mpas_timer_start('io_read')
call mpas_stream_mgr_read(domain % streamManager, ierr=ierr)
Expand All @@ -679,12 +712,23 @@ function ocn_forward_mode_run(domain) result(ierr)!{{{
itimestep = itimestep + 1
call mpas_advance_clock(domain % clock)

! final seaiceinitialization after clock advance
#ifdef SEAICE_COLUMN
if (lstart) then
call seaice_init_post_clock_advance(domain, domain % clock)
lstart = .false.
endif
#endif

currTime = mpas_get_clock_time(domain % clock, MPAS_NOW, ierr)
call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr)
call mpas_log_write('Doing timestep ' // trim(timeStamp))

! pre-timestep analysis computation
call ocn_analysis_precompute(domain, ierr)
#ifdef SEAICE_COLUMN
call seaice_analysis_precompute(domain, ierr)
#endif

#ifdef MPAS_DEBUG
call mpas_log_write( ' Computing surface flux arrays')
Expand Down Expand Up @@ -722,6 +766,12 @@ function ocn_forward_mode_run(domain) result(ierr)!{{{

call mpas_timer_start("time integration")

#ifdef SEAICE_COLUMN
! Run sea ice column package time step
call mpas_log_write( ' ocn_seaice_run')
call ocn_seaice_run(domain)
#endif

#ifdef MPAS_DEBUG
call mpas_log_write( ' Computing forward time step')
#endif
Expand All @@ -742,6 +792,11 @@ function ocn_forward_mode_run(domain) result(ierr)!{{{
call ocn_analysis_compute(domain, err)
call ocn_analysis_restart(domain, err)
call ocn_analysis_write(domain, err)
#ifdef SEAICE_COLUMN
call seaice_analysis_compute(domain, err)
call seaice_analysis_restart(domain, err)
call seaice_analysis_write(domain, err)
#endif

#ifdef MPAS_DEBUG
call mpas_log_write( ' Performing I/O')
Expand Down Expand Up @@ -826,6 +881,10 @@ function ocn_forward_mode_run(domain) result(ierr)!{{{
! Validate that the state is OK to run with for the next timestep.
call ocn_validate_state(domain, timeLevel=1)

#ifdef SEAICE_COLUMN
call ocn_seaice_couple_ocn_to_ice(domain)
#endif

end do

end function ocn_forward_mode_run!}}}
Expand All @@ -848,6 +907,10 @@ function ocn_forward_mode_finalize(domain) result(iErr)!{{{

integer :: ierr

#ifdef SEAICE_COLUMN
call ocn_seaice_finalize(domain)
#endif

! destroy the ocean mesh structure
call ocn_meshDestroy(ierr)

Expand All @@ -856,6 +919,9 @@ function ocn_forward_mode_finalize(domain) result(iErr)!{{{
end if

call ocn_analysis_finalize(domain, ierr)
#ifdef SEAICE_COLUMN
call seaice_analysis_finalize(domain, ierr)
#endif

call ocn_vmix_gotm_finalize(domain, ierr)

Expand Down
Loading