Skip to content

Commit

Permalink
Add ocn-->ice coupling of runningMeanRemovedIceRunoff
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Aug 9, 2024
1 parent 04cf293 commit 835e6ff
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 62 deletions.
37 changes: 33 additions & 4 deletions components/mpas-ocean/driver/ocn_comp_mct.F
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )!{{{
character(len=StrKIND) :: iotype
logical :: streamsExists
integer :: mesh_iotype
logical :: ocn_c2_glcshelf

logical, pointer :: tempLogicalConfig
character(len=StrKIND), pointer :: tempCharConfig
Expand All @@ -223,11 +224,14 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )!{{{
logical, pointer :: config_use_CFCTracers
logical, pointer :: config_use_activeTracers_surface_restoring
logical, pointer :: config_use_surface_salinity_monthly_restoring
logical, pointer :: config_scale_dismf_by_removed_ice_runoff
character (len=StrKIND), pointer :: config_land_ice_flux_mode

! ssh coupling interval initialization
integer, pointer :: index_avgZonalSSHGradient, index_avgMeridionalSSHGradient
real (kind=RKIND), dimension(:,:), pointer :: avgSSHGradient
real (kind=RKIND), pointer :: &
runningMeanRemovedIceRunoff ! the area integrated, running mean of removed ice runoff from the ocean

#ifdef HAVE_MOAB
character*100 outfile, wopts
Expand Down Expand Up @@ -876,14 +880,25 @@ end subroutine xml_stream_get_attributes
trim(config_land_ice_flux_mode) == 'pressure_only' .or. &
trim(config_land_ice_flux_mode) == 'data' .or. &
trim(config_land_ice_flux_mode) == 'standalone' ) then
call seq_infodata_PutData( infodata, ocn_prognostic=.true., ocnrof_prognostic=.true., &
ocn_c2_glcshelf=.false.)
ocn_c2_glcshelf = .false.
else if ( trim(config_land_ice_flux_mode) .eq. 'coupled' ) then
call seq_infodata_PutData( infodata, ocn_prognostic=.true., ocnrof_prognostic=.true., &
ocn_c2_glcshelf=.true.)
ocn_c2_glcshelf = .true.
else
call mpas_log_write('ERROR: unknown land_ice_flux_mode: ' // trim(config_land_ice_flux_mode), MPAS_LOG_CRIT)
end if
call seq_infodata_PutData(infodata, ocn_prognostic=.true., ocnrof_prognostic=.true., &
ocn_c2_glcshelf=ocn_c2_glcshelf)

call mpas_pool_get_config(domain % configs, 'config_scale_dismf_by_removed_ice_runoff', &
config_scale_dismf_by_removed_ice_runoff)
if (config_scale_dismf_by_removed_ice_runoff) then
! independent of space so should be no need to loop over blocks
block_ptr => domain % blocklist
call mpas_pool_get_subpool(block_ptr % structs, 'forcing', forcingPool)
call MPAS_pool_get_array(forcingPool, "runningMeanRemovedIceRunoff", &
runningMeanRemovedIceRunoff)
call seq_infodata_PutData(infodata, rmean_rmv_ice_runoff=runningMeanRemovedIceRunoff)
end if

!-----------------------------------------------------------------------
!
Expand Down Expand Up @@ -994,12 +1009,15 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
logical, pointer :: config_use_CFCTracers
logical, pointer :: config_use_activeTracers_surface_restoring
logical, pointer :: config_use_surface_salinity_monthly_restoring
logical, pointer :: config_scale_dismf_by_removed_ice_runoff
character (len=StrKIND), pointer :: config_restart_timestamp_name
character (len=StrKIND), pointer :: config_sw_absorption_type
! Added for coupling interval initialization
integer, pointer :: index_avgZonalSSHGradient, index_avgMeridionalSSHGradient
real (kind=RKIND), dimension(:,:), pointer :: avgSSHGradient
real (kind=RKIND), pointer :: &
runningMeanRemovedIceRunoff ! the area integrated, running mean of removed ice runoff from the ocean
#ifdef HAVE_MOAB
#ifdef MOABCOMP
Expand Down Expand Up @@ -1302,6 +1320,17 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
#endif
call check_clocks_sync(domain % clock, Eclock, ierr)

call mpas_pool_get_config(domain % configs, 'config_scale_dismf_by_removed_ice_runoff', &
config_scale_dismf_by_removed_ice_runoff)
if (config_scale_dismf_by_removed_ice_runoff) then
! independent of space so should be no need to loop over blocks
block_ptr => domain % blocklist
call mpas_pool_get_subpool(block_ptr % structs, 'forcing', forcingPool)
call MPAS_pool_get_array(forcingPool, "runningMeanRemovedIceRunoff", &
runningMeanRemovedIceRunoff)
call seq_infodata_PutData(infodata, rmean_rmv_ice_runoff=runningMeanRemovedIceRunoff)
end if

! Reset I/O logs
call shr_file_setLogUnit (shrlogunit)
call shr_file_setLogLevel(shrloglev)
Expand Down
90 changes: 61 additions & 29 deletions components/mpas-seaice/driver/ice_comp_mct.F
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ subroutine ice_init_mct( EClock, cdata_i, x2i_i, i2x_i, NLFilename )!{{{
type (MPAS_TimeInterval_Type) :: alarmTimeStep
type (block_type), pointer :: block

type (MPAS_Pool_Type), pointer :: shortwave
type (MPAS_Pool_Type), pointer :: &
shortwave, &
berg_forcing

logical :: exists
logical :: verbose_taskmap_output ! true then use verbose task-to-node mapping format
Expand Down Expand Up @@ -241,15 +243,18 @@ subroutine ice_init_mct( EClock, cdata_i, x2i_i, i2x_i, NLFilename )!{{{
integer :: size_list, index_list
type(mct_string) :: mctOStr !
character(CXX) :: mct_field, modelStr
#endif
#endif

#endif
logical, pointer :: tempLogicalConfig
logical, pointer :: &
tempLogicalConfig, &
config_scale_dib_by_removed_ice_runoff
character(len=StrKIND), pointer :: tempCharConfig
real (kind=RKIND), pointer :: tempRealConfig

real(kind=RKIND), pointer :: &
dayOfNextShortwaveCalculation ! needed for CESM like coupled simulations
dayOfNextShortwaveCalculation, & ! needed for CESM like coupled simulations
runningMeanRemovedIceRunoff ! the area integrated, running mean of removed ice runoff from the ocean

interface
subroutine xml_stream_parser(xmlname, mgr_p, comm, ierr) bind(c)
Expand Down Expand Up @@ -505,6 +510,9 @@ end subroutine xml_stream_get_attributes

end if

call MPAS_pool_get_config(domain % configs, "config_scale_dib_by_removed_ice_runoff", &
config_scale_dib_by_removed_ice_runoff)

! Setup MPASSI simulation clock
ierr = domain % core % setup_clock(domain % clock, domain % configs)
if ( ierr /= 0 ) then
Expand Down Expand Up @@ -636,6 +644,15 @@ end subroutine xml_stream_get_attributes
! Determine coupling type
call seq_infodata_GetData(infodata, cpl_seq_option=cpl_seq_option)

if (config_scale_dib_by_removed_ice_runoff) then
! independent of space so should be no need to loop over blocks
block => domain % blocklist
call MPAS_pool_get_subpool(block % structs, "berg_forcing", berg_forcing)
call MPAS_pool_get_array(berg_forcing, "runningMeanRemovedIceRunoff", &
runningMeanRemovedIceRunoff)
call seq_infodata_GetData(infodata, rmean_rmv_ice_runoff=runningMeanRemovedIceRunoff )
end if

! Determine time of next atmospheric shortwave calculation
block => domain % blocklist
do while (associated(block))
Expand Down Expand Up @@ -730,7 +747,7 @@ end subroutine xml_stream_get_attributes
allocate (x2i_im(lsize, nrecv) )
i2x_im = 0._r8
x2i_im = 0._r8
! define tags according to the seq_flds_i2x_fields
! define tags according to the seq_flds_i2x_fields
! also zero them out
tagtype = 1 ! dense, double
numco = 1 ! one value per cell / entity
Expand Down Expand Up @@ -763,7 +780,7 @@ end subroutine xml_stream_get_attributes
endif

#endif


!-----------------------------------------------------------------------
!
Expand Down Expand Up @@ -827,10 +844,10 @@ end subroutine xml_stream_get_attributes
else if (trim(tempCharConfig) == "column_package") then
call seaice_column_coupling_prep(domain)
endif ! config_column_physics_type

call MPAS_pool_get_config(domain % configs, "config_use_floe_size_distribution", tempLogicalConfig)
if (tempLogicalConfig) then
call mpas_log_write('FloeSizeDistribution coming online soon. Turn FSD off for now.', MPAS_LOG_CRIT)
call mpas_log_write('FloeSizeDistribution coming online soon. Turn FSD off for now.', MPAS_LOG_CRIT)
endif
!-----------------------------------------------------------------------
!
Expand All @@ -854,15 +871,15 @@ end subroutine xml_stream_get_attributes
!
! get intial state from driver
!
call ice_import_mct(x2i_i, errorCode)
call ice_import_mct(x2i_i, errorCode)
if (errorCode /= 0) then
call mpas_log_write('Error in ice_import_mct', MPAS_LOG_CRIT)
endif
!-----------------------------------------------------------------------
#ifdef HAVE_MOAB

#ifdef MOABCOMP
mpicom_moab = mpicom_i ! save it for run method
mpicom_moab = mpicom_i ! save it for run method
! loop over all fields in seq_flds_x2i_fields
call mct_list_init(temp_list ,seq_flds_x2i_fields)
size_list=mct_list_nitem (temp_list)
Expand All @@ -879,8 +896,8 @@ end subroutine xml_stream_get_attributes
#endif

call ice_import_moab(Eclock)
#endif
#endif


currTime = mpas_get_clock_time(domain % clock, MPAS_NOW, ierr)
call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr)
Expand Down Expand Up @@ -1151,29 +1168,33 @@ subroutine ice_run_mct( EClock, cdata_i, x2i_i, i2x_i)!{{{
! Variable related to MPASSI
type (block_type), pointer :: block
type (MPAS_Pool_type), pointer :: &
shortwave
shortwave, &
berg_forcing
real (kind=RKIND) :: current_wallclock_time
type (MPAS_Time_Type) :: currTime
character(len=StrKIND) :: timeStamp, streamName, WCstring
type (MPAS_timeInterval_type) :: timeStep
integer :: ierr, streamDirection, iam
logical :: streamActive, debugOn
logical, pointer :: config_write_output_on_startup
logical, pointer :: &
config_write_output_on_startup, &
config_scale_dib_by_removed_ice_runoff
logical, save :: first=.true.
character (len=StrKIND), pointer :: &
config_restart_timestamp_name, &
config_column_physics_type
real(kind=RKIND), pointer :: &
dayOfNextShortwaveCalculation ! needed for CESM like coupled simulations
dayOfNextShortwaveCalculation, & ! needed for CESM like coupled simulations
runningMeanRemovedIceRunoff ! the area integrated, running mean of removed ice runoff from the ocean
#ifdef MOABCOMP
real(r8) :: difference
type(mct_list) :: temp_list
integer :: size_list, index_list, ent_type
type(mct_string) :: mctOStr !
character(CXX) :: mct_field, modelStr, tagname
#endif
#endif
iam = domain % dminfo % my_proc_id
Expand All @@ -1187,8 +1208,10 @@ subroutine ice_run_mct( EClock, cdata_i, x2i_i, i2x_i)!{{{
mpas_log_info => domain % logInfo
if (debugOn) call mpas_log_write("=== Beginning ice_run_mct ===")
call mpas_pool_get_config(domain % configs, 'config_restart_timestamp_name', config_restart_timestamp_name)
call MPAS_pool_get_config(domain % configs, 'config_restart_timestamp_name', config_restart_timestamp_name)
call MPAS_pool_get_config(domain % configs, "config_column_physics_type", config_column_physics_type)
call MPAS_pool_get_config(domain % configs, "config_scale_dib_by_removed_ice_runoff", &
config_scale_dib_by_removed_ice_runoff)
! Setup log information.
call shr_file_getLogUnit (shrlogunit)
Expand Down Expand Up @@ -1225,6 +1248,15 @@ subroutine ice_run_mct( EClock, cdata_i, x2i_i, i2x_i)!{{{
! Post coupling calls
block => domain % blocklist
if (config_scale_dib_by_removed_ice_runoff) then
! independent of space so should be no need to loop over blocks
call MPAS_pool_get_subpool(block % structs, "berg_forcing", berg_forcing)
call MPAS_pool_get_array(berg_forcing, "runningMeanRemovedIceRunoff", &
runningMeanRemovedIceRunoff)
call seq_infodata_GetData(infodata, rmean_rmv_ice_runoff=runningMeanRemovedIceRunoff )
end if
do while (associated(block))
! Determine time of next atmospheric shortwave calculation
Expand Down Expand Up @@ -2998,8 +3030,8 @@ subroutine frazil_mass(freezingPotential, frazilMassFlux, seaSurfaceSalinity)
qi0new, &
vi0new
call MPAS_pool_get_config(domain % configs, "config_thermodynamics_type", config_thermodynamics_type)
call MPAS_pool_get_config(domain % configs, "config_column_physics_type", config_column_physics_type)
call MPAS_pool_get_config(domain % configs, "config_thermodynamics_type", config_thermodynamics_type)
call MPAS_pool_get_config(domain % configs, "config_column_physics_type", config_column_physics_type)
if (freezingPotential > 0.0_RKIND) then
Expand Down Expand Up @@ -3479,15 +3511,15 @@ subroutine ice_import_moab(Eclock)!{{{
! o dhdx -- ocn surface slope, zonal
! o dhdy -- ocn surface slope, meridional
! o lwdn -- downward lw heat flux
! o rain -- prec: liquid
! o snow -- prec: frozen
! o rain -- prec: liquid
! o snow -- prec: frozen
! o swndr -- sw: nir direct downward
! o swvdr -- sw: vis direct downward
! o swndf -- sw: nir diffuse downward
! o swvdf -- sw: vis diffuse downward
! o swnet -- sw: net
! o q -- ocn frazil heat flux(+) / melt potential(-)
! o frazil -- ocn frazil mass flux
! o frazil -- ocn frazil mass flux
! o bcphidry -- Black Carbon hydrophilic dry deposition flux
! o bcphodry -- Black Carbon hydrophobic dry deposition flux
! o bcphiwet -- Black Carbon hydrophilic wet deposition flux
Expand All @@ -3502,10 +3534,10 @@ subroutine ice_import_moab(Eclock)!{{{
! o dstdry2 -- Size 2 dust -- dry deposition flux
! o dstdry3 -- Size 3 dust -- dry deposition flux
! o dstdry4 -- Size 4 dust -- dry deposition flux
!
!
! The following fields are sometimes received from the coupler,
! depending on model options:
!
!
! o algae1 --
! o algae2 --
! o algae3 --
Expand All @@ -3530,7 +3562,7 @@ subroutine ice_import_moab(Eclock)!{{{
! o zaer4 --
! o zaer5 --
! o zaer6 --
!
!
!-----------------------------------------------------------------------
!
! !REVISION HISTORY:
Expand All @@ -3550,7 +3582,7 @@ subroutine ice_import_moab(Eclock)!{{{
character (len=StrKIND) :: &
label, &
message
integer :: &
i,n
Expand Down Expand Up @@ -3687,10 +3719,10 @@ subroutine ice_import_moab(Eclock)!{{{
if (ierr > 0 ) then
write(iceLogUnit,*) 'Fail to write ice state '
endif
#endif
!-----------------------------------------------------------------------
#endif
!-----------------------------------------------------------------------
!
! zero out padded cells
! zero out padded cells
!
!-----------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions driver-mct/main/seq_rest_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ subroutine seq_rest_write(EClock_d, seq_SyncClock, infodata, &
call seq_io_write(rest_file,rvar,'seq_infodata_precip_fact',whead=whead,wdata=wdata)
call seq_infodata_GetData(infodata,case_name=cvar)
call seq_io_write(rest_file,trim(cvar),'seq_infodata_case_name',whead=whead,wdata=wdata)
call seq_infodata_GetData(infodata,rmean_rmv_ice_runoff=rvar)
call seq_io_write(rest_file,rvar,'seq_infodata_rmean_rmv_ice_runoff',whead=whead,wdata=wdata)

call seq_timemgr_EClockGetData( EClock_d, start_ymd=ivar)
call seq_io_write(rest_file,ivar,'seq_timemgr_start_ymd',whead=whead,wdata=wdata)
Expand Down
Loading

0 comments on commit 835e6ff

Please sign in to comment.