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 1da9fb6 commit 0822b88
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 40 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
46 changes: 39 additions & 7 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 @@ -244,12 +246,15 @@ subroutine ice_init_mct( EClock, cdata_i, x2i_i, i2x_i, NLFilename )!{{{
#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 @@ -1151,21 +1168,25 @@ 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
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
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
21 changes: 17 additions & 4 deletions driver-mct/shr/seq_infodata_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ MODULE seq_infodata_mod
integer(SHR_KIND_IN) :: iac_phase ! iac phase
logical :: atm_aero ! atmosphere aerosols
logical :: glc_g2lupdate ! update glc2lnd fields in lnd model
real(shr_kind_r8) :: max_cplstep_time ! abort if cplstep time exceeds this value
real(SHR_KIND_R8) :: max_cplstep_time ! abort if cplstep time exceeds this value
real(SHR_KIND_R8) :: rmean_rmv_ice_runoff ! running mean of removed Antarctic ice runoff
!--- set from restart file ---
character(SHR_KIND_CL) :: rest_case_name ! Short case identification
!--- set by driver and may be time varying
Expand Down Expand Up @@ -761,7 +762,7 @@ SUBROUTINE seq_infodata_Init( infodata, nmlfile, ID, pioid, cpl_tag)
infodata%atm_prognostic = .false.
infodata%lnd_prognostic = .false.
infodata%rof_prognostic = .false.
infodata%rofocn_prognostic = .false.
infodata%rofocn_prognostic = .false.
infodata%ocn_prognostic = .false.
infodata%ocnrof_prognostic = .false.
infodata%ocn_c2_glcshelf = .false.
Expand Down Expand Up @@ -808,6 +809,7 @@ SUBROUTINE seq_infodata_Init( infodata, nmlfile, ID, pioid, cpl_tag)
infodata%atm_aero = .false.
infodata%glc_g2lupdate = .false.
infodata%glc_valid_input = .true.
infodata%rmean_rmv_ice_runoff = -1.0_SHR_KIND_R8

infodata%max_cplstep_time = max_cplstep_time
infodata%model_doi_url = model_doi_url
Expand Down Expand Up @@ -907,11 +909,13 @@ SUBROUTINE seq_infodata_Init( infodata, nmlfile, ID, pioid, cpl_tag)
call seq_io_read(infodata%restart_file,pioid,infodata%nextsw_cday ,'seq_infodata_nextsw_cday')
call seq_io_read(infodata%restart_file,pioid,infodata%precip_fact ,'seq_infodata_precip_fact')
call seq_io_read(infodata%restart_file,pioid,infodata%rest_case_name,'seq_infodata_case_name')
call seq_io_read(infodata%restart_file,pioid,infodata%rmean_rmv_ice_runoff,'seq_infodata_rmean_rmv_ice_runoff')
endif
!--- Send from CPLID ROOT to GLOBALID ROOT, use bcast as surrogate
call shr_mpi_bcast(infodata%nextsw_cday,mpicom,pebcast=seq_comm_gloroot(CPLID))
call shr_mpi_bcast(infodata%precip_fact,mpicom,pebcast=seq_comm_gloroot(CPLID))
call shr_mpi_bcast(infodata%rest_case_name,mpicom,pebcast=seq_comm_gloroot(CPLID))
call shr_mpi_bcast(infodata%rmean_rmv_ice_runoff,mpicom,pebcast=seq_comm_gloroot(CPLID))
endif

if (seq_comm_iamroot(ID)) then
Expand Down Expand Up @@ -1041,7 +1045,8 @@ SUBROUTINE seq_infodata_GetData_explicit( infodata, cime_model, case_name, case_
reprosum_use_ddpdd, reprosum_allow_infnan, &
reprosum_diffmax, reprosum_recompute, &
mct_usealltoall, mct_usevector, max_cplstep_time, model_doi_url, &
glc_valid_input, nlmaps_verbosity, nlmaps_exclude_fields)
glc_valid_input, nlmaps_verbosity, nlmaps_exclude_fields, &
rmean_rmv_ice_runoff)


implicit none
Expand Down Expand Up @@ -1228,6 +1233,7 @@ SUBROUTINE seq_infodata_GetData_explicit( infodata, cime_model, case_name, case_
real(shr_kind_r8), optional, intent(out) :: max_cplstep_time
character(SHR_KIND_CL), optional, intent(OUT) :: model_doi_url
logical, optional, intent(OUT) :: glc_valid_input
real(SHR_KIND_R8), optional, intent(out) :: rmean_rmv_ice_runoff

!----- local -----
character(len=*), parameter :: subname = '(seq_infodata_GetData_explicit) '
Expand Down Expand Up @@ -1427,6 +1433,7 @@ SUBROUTINE seq_infodata_GetData_explicit( infodata, cime_model, case_name, case_
if ( present(model_doi_url) ) model_doi_url = infodata%model_doi_url

if ( present(glc_valid_input)) glc_valid_input = infodata%glc_valid_input
if ( present(rmean_rmv_ice_runoff) ) rmean_rmv_ice_runoff = infodata%rmean_rmv_ice_runoff

END SUBROUTINE seq_infodata_GetData_explicit

Expand Down Expand Up @@ -1595,7 +1602,7 @@ SUBROUTINE seq_infodata_PutData_explicit( infodata, cime_model, case_name, case_
reprosum_use_ddpdd, reprosum_allow_infnan, &
reprosum_diffmax, reprosum_recompute, &
mct_usealltoall, mct_usevector, glc_valid_input, &
nlmaps_verbosity, nlmaps_exclude_fields)
nlmaps_verbosity, nlmaps_exclude_fields, rmean_rmv_ice_runoff)


implicit none
Expand Down Expand Up @@ -1778,6 +1785,7 @@ SUBROUTINE seq_infodata_PutData_explicit( infodata, cime_model, case_name, case_
logical, optional, intent(IN) :: atm_aero ! atm aerosols
logical, optional, intent(IN) :: glc_g2lupdate ! update glc2lnd fields in lnd model
logical, optional, intent(IN) :: glc_valid_input
real(SHR_KIND_R8), optional, intent(IN) :: rmean_rmv_ice_runoff ! running mean of removed Antarctic ice runoff

!EOP

Expand Down Expand Up @@ -1963,6 +1971,7 @@ SUBROUTINE seq_infodata_PutData_explicit( infodata, cime_model, case_name, case_
if ( present(atm_aero) ) infodata%atm_aero = atm_aero
if ( present(glc_g2lupdate) ) infodata%glc_g2lupdate = glc_g2lupdate
if ( present(glc_valid_input) ) infodata%glc_valid_input = glc_valid_input
if ( present(rmean_rmv_ice_runoff) ) infodata%rmean_rmv_ice_runoff = rmean_rmv_ice_runoff

END SUBROUTINE seq_infodata_PutData_explicit

Expand Down Expand Up @@ -2277,6 +2286,7 @@ subroutine seq_infodata_bcast(infodata,mpicom)
call shr_mpi_bcast(infodata%glc_valid_input, mpicom)
call shr_mpi_bcast(infodata%model_doi_url, mpicom)
call shr_mpi_bcast(infodata%constant_zenith_deg, mpicom)
call shr_mpi_bcast(infodata%rmean_rmv_ice_runoff, mpicom)

end subroutine seq_infodata_bcast

Expand Down Expand Up @@ -2617,13 +2627,15 @@ subroutine seq_infodata_Exchange(infodata,ID,type)

if (ocn2cplr) then
call shr_mpi_bcast(infodata%precip_fact, mpicom, pebcast=cmppe)
call shr_mpi_bcast(infodata%rmean_rmv_ice_runoff, mpicom, pebcast=cmppe)
endif

if (cpl2r) then
call shr_mpi_bcast(infodata%nextsw_cday, mpicom, pebcast=cplpe)
call shr_mpi_bcast(infodata%precip_fact, mpicom, pebcast=cplpe)
call shr_mpi_bcast(infodata%glc_g2lupdate, mpicom, pebcast=cplpe)
call shr_mpi_bcast(infodata%glc_valid_input, mpicom, pebcast=cplpe)
call shr_mpi_bcast(infodata%rmean_rmv_ice_runoff, mpicom, pebcast=cplpe)
endif

end subroutine seq_infodata_Exchange
Expand Down Expand Up @@ -2995,6 +3007,7 @@ SUBROUTINE seq_infodata_print( infodata )
write(logunit,F0S) subname,'iac_phase = ', infodata%iac_phase

write(logunit,F0L) subname,'glc_g2lupdate = ', infodata%glc_g2lupdate
write(logunit,F0R) subname,'rmean_rmv_ice_runoff = ', infodata%rmean_rmv_ice_runoff
! endif

END SUBROUTINE seq_infodata_print
Expand Down
Loading

0 comments on commit 0822b88

Please sign in to comment.