Skip to content
This repository was archived by the owner on Oct 23, 2020. It is now read-only.
Open
24 changes: 13 additions & 11 deletions src/core_atmosphere/Registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@
<package name="cu_tiedtke_in" description="parameterization of Tiedtke convection."/>
<package name="bl_ysu_in" description="parameterization of YSU Planetary Boundary Layer."/>
<package name="bl_mynn_in" description="parameterization of MYNN Planetary Boundary Layer."/>

<package name="sfc_update" description="Surface Update"/>
<package name="iau" description="Incremental Analysis Update"/>
</packages>

Expand Down Expand Up @@ -1029,16 +1029,18 @@
<var name="hv_oml"/>
</stream>

<stream name="surface"
type="input"
filename_template="x1.40962.sfc_update.nc"
input_interval="none"
filename_interval="none"
runtime_format="separate_file">

<var name="sst"/>
<var name="xice"/>
</stream>
<stream name="surface"
type="input"
filename_template="x1.40962.sfc_update.nc"
input_interval="none"
filename_interval="none"
packages="sfc_update"
immutable="true">

<var name="xtime"/>
<var name="sst"/>
<var name="xice"/>
</stream>

<stream name="iau"
type="input"
Expand Down
73 changes: 73 additions & 0 deletions src/core_atmosphere/mpas_atm_core.F
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,79 @@ subroutine atm_mpas_init_block(dminfo, stream_manager, block, mesh, dt)
end subroutine atm_mpas_init_block


!-----------------------------------------------------------------------
! routine atm_sanity_check_sfc_update
!
!> \brief Checks for consistency of sfc update namelist/stream list settings
!> \author Dom Heinzeller
!> \date 01 December 2016
!> \details
!> This routine checks for consistency between the surface update settings
!> in the namelist (config_sst_update) and the stream list settings. If
!> config_sst_update is true, the surface update stream 'surface' must be
!> present in streams.atmosphere. As an immutable stream, the 'surface'
!> stream is automatically added to the list of streams, even if it is not
!> included in streams.atmosphere; however, its input/output intervals are
!> set to 'none'. Thus, if config_sst_update is true and input_interval is
!> 'none' the code will abort.
!> Similarily, if config_sst_update is false, the 'surface' stream is set
!> to inactive to avoid reading the stream. This is necessary because
!> reading the stream without performing the necessary adjustments triggered
!> by config_sst_update can cause the model to crash/segfault.
!
!-----------------------------------------------------------------------
subroutine atm_sanity_check_sfc_update(domain)

use mpas_derived_types, only : MPAS_STREAM_MGR_NOERR, &
MPAS_STREAM_PROPERTY_ACTIVE
use mpas_stream_manager, only : MPAS_stream_mgr_get_property, &
MPAS_stream_mgr_set_property, &
MPAS_stream_mgr_begin_iteration, &
MPAS_stream_mgr_get_next_stream
use mpas_pool_routines, only : mpas_pool_get_config

implicit none

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

logical, pointer :: config_sst_update
character (len=StrKIND) :: stream_id
character (len=StrKIND) :: input_interval
logical :: is_active
logical :: found_stream
integer :: ierr

call mpas_pool_get_config(domain%blocklist%configs, 'config_sst_update', config_sst_update)
found_stream =.false.

call MPAS_stream_mgr_begin_iteration(domain % streamManager)
do while (MPAS_stream_mgr_get_next_stream(domain % streamManager, streamID=stream_id, inputIntervalProperty=input_interval))
call MPAS_stream_mgr_get_property(domain % streamManager, stream_id, MPAS_STREAM_PROPERTY_ACTIVE, is_active, ierr=ierr)
if (stream_id == 'surface' .and. (.not. config_sst_update)) then
call MPAS_stream_mgr_get_property(domain % streamManager, stream_id, MPAS_STREAM_PROPERTY_ACTIVE, is_active, ierr=ierr)
if (.not. ierr == MPAS_STREAM_MGR_NOERR) then
call mpas_dmpar_global_abort("ERROR while checking if surface update stream 'surface' is active")
end if
if (is_active) then
write(0,*) " ** Setting surface update stream 'surface' to inactive since sst updates are disabled"
call MPAS_stream_mgr_set_property(domain % streamManager, stream_id, MPAS_STREAM_PROPERTY_ACTIVE, .false., ierr=ierr)
if (.not. ierr == MPAS_STREAM_MGR_NOERR) then
call mpas_dmpar_global_abort("ERROR while deactivating surface update stream 'surface'")
end if
end if
found_stream = .true.
else if (stream_id == 'surface' .and. trim(input_interval) /= 'none') then
found_stream = .true.
end if
end do

if ((.not. found_stream) .and. config_sst_update) then
call mpas_dmpar_global_abort("ERROR: sst updates requested, but surface update stream 'surface' not found")
end if

end subroutine atm_sanity_check_sfc_update


function atm_core_run(domain) result(ierr)

use mpas_timekeeping
Expand Down
4 changes: 3 additions & 1 deletion src/core_atmosphere/physics/mpas_atmphys_manager.F
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ subroutine physics_timetracker(domain,dt,clock,itimestep,xtime_s)
!sea-ice coverage:
if(mpas_is_alarm_ringing(clock,sfcbdyAlarmID,ierr=ierr)) then
call mpas_reset_clock_alarm(clock,sfcbdyAlarmID,ierr=ierr)
if(config_sst_update) &
if (config_sst_update) then
write(0,*) '--- time to update surface information from surface update file.'
call physics_update_sst(domain%dminfo,config_frac_seaice,mesh,sfc_input,diag_physics)
end if
endif

!apply a diurnal cycle to the sea-surface temperature:
Expand Down
9 changes: 8 additions & 1 deletion src/driver/mpas_subdriver.F
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ subroutine mpas_init()
use mpas_c_interfacing, only : mpas_f_to_c_string, mpas_c_to_f_string
use mpas_timekeeping, only : mpas_get_clock_time, mpas_get_time
use mpas_bootstrapping, only : mpas_bootstrap_framework_phase1, mpas_bootstrap_framework_phase2

#ifdef CORE_ATMOSPHERE
use atm_core, only: atm_sanity_check_sfc_update
#endif

implicit none

integer :: iArg, nArgs
Expand Down Expand Up @@ -298,6 +301,10 @@ end subroutine xml_stream_get_attributes
if (c_ierr /= 0) then
call mpas_dmpar_abort(domain_ptr % dminfo)
end if
#ifdef CORE_ATMOSPHERE
write(0,*) " ** Performing sanity check of surface update stream properties for atmosphere core"
call atm_sanity_check_sfc_update(domain_ptr)
#endif

!
! Finalize the setup of blocks and fields
Expand Down
3 changes: 3 additions & 0 deletions src/framework/mpas_stream_list_types.inc
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@
type (MPAS_stream_list_type), pointer :: xref => null()
type (MPAS_stream_list_type), pointer :: next => null()

character(len=StrKIND) :: interval_in
character(len=StrKIND) :: interval_out

end type MPAS_stream_list_type

Loading