Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
8 changes: 8 additions & 0 deletions mediator/med_phases_post_atm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module med_phases_post_atm_mod

character(*), parameter :: u_FILE_u = &
__FILE__
character(len=9), parameter :: fields_to_spread_runoff(1) = &
['Faoa_rofi']

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did rofi and rofl get seperated elsewhere ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In access-esm rofl only contains the river runoff, and rofi contains both the iceberg basal and calving melt fluxes. The spreading here simultaneously does your calving flux spreading + a coastal distribution for the basal melt. Is that what you meant?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh - ah, I think it's better to have seperate steps in the mediator for basal and iceberg right ?

basal fraction, gets remapped with a fixed remapping weights file to put it along coastlines

and iceberg gets spread like this change

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if what was done was as close as possible consistent with OM3.

So that would mean splitting the iceberg and basal proportions before they leave the mediator. And having separate rofi/rofl fields to correspond to the MOM fields. It's relatively clear in the MOM diagnostics that rofi should be for the iceberg fraction - e.g. https://github.com/ACCESS-NRI/access-om3-configs/blob/b14a2797812531d5b4728f04cd67dcee19bfe439/docs/available_diags.000000#L4548, although less clear about the liquid proportion (e.g. there are lrunoff_glc fields available which OM3 doesn't use). Having separate fields for rofi and rofl means the rofi spreading input file can be the same across the two models. It also supports future/ongoing work to figure out how to spread the basal melt fraction vertically

The proposal to put the basal melt component in rofi by having a single pattern with 50% of the volume at the coastline will continue to give issues with supercooled water & excess sea ice from the large latent heat flux at the coastlines.


!-----------------------------------------------------------------------------
contains
Expand All @@ -35,6 +37,7 @@ subroutine med_phases_post_atm(gcomp, rc)
use med_utils_mod , only : chkerr => med_utils_ChkErr
use med_internalstate_mod , only : compocn, compatm, compice, complnd, compwav, coupling_mode
use perf_mod , only : t_startf, t_stopf
use med_phases_post_rof_mod, only: med_phases_post_rof_spread_rofi_field_bundle

! input/output variables
type(ESMF_GridComp) :: gcomp
Expand Down Expand Up @@ -125,6 +128,11 @@ subroutine med_phases_post_atm(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

if (trim(coupling_mode) == 'access-esm') then
Comment thread
kieranricardo marked this conversation as resolved.
call med_phases_post_rof_spread_rofi_field_bundle(gcomp, fields_to_spread_runoff, is_local%wrap%FBImp(compatm,compocn), compocn, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

if (dbug_flag > 20) then
call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO)
end if
Expand Down
125 changes: 75 additions & 50 deletions mediator/med_phases_post_rof_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module med_phases_post_rof_mod
implicit none
private

public :: med_phases_post_rof_init
public :: med_phases_post_rof_init, med_phases_post_rof_spread_rofi_field_bundle
public :: med_phases_post_rof
private :: med_phases_post_rof_create_rof_field_bundle
private :: med_phases_post_rof_remove_negative_runoff
Expand All @@ -49,7 +49,7 @@ module med_phases_post_rof_mod
logical :: remove_negative_runoff_lnd
logical :: remove_negative_runoff_glc
logical :: spread_rofi_nh, spread_rofi_sh
character(len=CL) :: rof2ocn_ice_spread
logical :: spreading_initialized = .false.
Comment thread
anton-seaice marked this conversation as resolved.
Outdated

character(len=9), parameter :: fields_to_remove_negative_runoff_lnd(2) = &
['Forr_rofl', &
Expand Down Expand Up @@ -107,21 +107,9 @@ subroutine med_phases_post_rof_init(gcomp, rc)
remove_negative_runoff_glc = .false.
end if

call NUOPC_CompAttributeGet(gcomp, name='rof2ocn_ice_spread', value=rof2ocn_ice_spread, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
spread_rofi_nh = .true.
spread_rofi_sh = .true.
else
spread_rofi_nh = .false.
spread_rofi_sh = .false.
end if

if (maintask) then
write(logunit,'(a,l7)') trim(subname)//' remove_negative_runoff_lnd = ', remove_negative_runoff_lnd
write(logunit,'(a,l7)') trim(subname)//' remove_negative_runoff_glc = ', remove_negative_runoff_glc
write(logunit,'(a,l7)') trim(subname)//' spread_rofi = ', spread_rofi_nh
if (spread_rofi_nh) write(logunit,'(a)') trim(subname)//' rof2ocn_ice_spread = '//trim(rof2ocn_ice_spread)
end if


Expand All @@ -144,7 +132,6 @@ subroutine med_phases_post_rof(gcomp, rc)
real(r8), pointer :: data_copy(:)
integer :: n
logical :: exists
logical :: first_time = .true.
character(len=*), parameter :: subname='(med_phases_post_rof)'
!---------------------------------------

Expand All @@ -155,13 +142,6 @@ subroutine med_phases_post_rof(gcomp, rc)
call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO)
end if

! unclear why this can't be in med_phases_post_rof_init, possibly pio not initialised
if ((spread_rofi_nh .or. spread_rofi_sh) .and. first_time) then
call med_phases_post_rof_init_rof_spread_rofi(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
first_time=.false.
endif

nullify(is_local%wrap)
call ESMF_GridCompGetInternalState(gcomp, is_local, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down Expand Up @@ -195,23 +175,6 @@ subroutine med_phases_post_rof(gcomp, rc)
end do
end if

if (spread_rofi_nh .or. spread_rofi_sh) then
do n = 1, size(fields_to_spread_runoff)
call ESMF_FieldBundleGet(FBrof_r, fieldName=trim(fields_to_spread_runoff(n)), isPresent=exists, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) then
call shr_log_error(string=trim(subname)//" Error checking field: "//trim(fields_to_spread_runoff(n)), line=__LINE__,file=u_FILE_u, rc=rc)
return
end if
if (exists) then
call med_phases_post_rof_spread_rofi(gcomp, fields_to_spread_runoff(n), rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else
call shr_log_error(string=trim(subname)//" Runoff field to spread: "//trim(fields_to_spread_runoff(n))//" does not exist", line=__LINE__,file=u_FILE_u, rc=rc)
return
end if
end do
end if

! map rof to lnd
if (is_local%wrap%med_coupling_active(comprof,complnd)) then
call t_startf('MED:'//trim(subname)//' map_rof2lnd')
Expand Down Expand Up @@ -252,6 +215,8 @@ subroutine med_phases_post_rof(gcomp, rc)
call t_stopf('MED:'//trim(subname)//' map_rof2ice')
end if

call med_phases_post_rof_spread_rofi_field_bundle(gcomp, fields_to_spread_runoff, is_local%wrap%FBImp(comprof,compocn), compocn, rc)

! Write rof inst, avg or aux if requested in mediator attributes
call NUOPC_MediatorGet(gcomp, driverClock=dClock, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down Expand Up @@ -459,13 +424,16 @@ subroutine med_phases_post_rof_remove_negative_runoff(gcomp, field_name, rc)

end subroutine med_phases_post_rof_remove_negative_runoff

subroutine med_phases_post_rof_init_rof_spread_rofi(gcomp, rc)
subroutine med_phases_post_rof_init_rof_spread_rofi(gcomp, fields_to_spread_runoff, rofi_spread, comp, rc)
!---------------------------------------------------------------
use med_io_mod , only : med_io_read
use shr_reprosum_mod , only : shr_reprosum_calc

! input/output variables
type(ESMF_GridComp) :: gcomp
character(len=*), intent(in) :: fields_to_spread_runoff(:)
character(len=CL) :: rofi_spread
integer, intent(in) :: comp ! the component mesh the field is being spread on
integer, intent(out) :: rc


Expand All @@ -483,8 +451,6 @@ subroutine med_phases_post_rof_init_rof_spread_rofi(gcomp, rc)
character(len=*), parameter :: subname='(med_phases_post_rof_mod: med_phases_post_rof_init_rof_spread_rofi)'
!---------------------------------------

! to do - make component configurable (could be comprof or compatm)

rc = ESMF_SUCCESS

call t_startf('MED:'//subname)
Expand All @@ -508,7 +474,7 @@ subroutine med_phases_post_rof_init_rof_spread_rofi(gcomp, rc)
! Create module fields on rof mesh
! -------------------------------

call fldbun_getmesh(is_local%wrap%FBImp(comprof,comprof), mesh_l, rc)
call fldbun_getmesh(is_local%wrap%FBImp(comp,comp), mesh_l, rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

FBrof_pattern = ESMF_FieldBundleCreate(name='FBrof_pattern', rc=rc)
Expand All @@ -530,11 +496,11 @@ subroutine med_phases_post_rof_init_rof_spread_rofi(gcomp, rc)
if (dbug_flag > dbug_threshold) then
call ESMF_LogWrite(trim(subname)//": trying to read rof2ocn_spread from file", ESMF_LOGMSG_INFO)
endif
call med_io_read(rof2ocn_ice_spread, vm, FBrof_pattern, pre='pattern', ungridded_nc=.true., rc=rc)
call med_io_read(rofi_spread, vm, FBrof_pattern, pre='pattern', ungridded_nc=.true., rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

areas => is_local%wrap%mesh_info(comprof)%areas
lats => is_local%wrap%mesh_info(comprof)%lats
areas => is_local%wrap%mesh_info(comp)%areas
lats => is_local%wrap%mesh_info(comp)%lats

allocate(rof2ocn_a_weight(size(areas),2))

Expand Down Expand Up @@ -607,14 +573,16 @@ subroutine med_phases_post_rof_init_rof_spread_rofi(gcomp, rc)

end subroutine med_phases_post_rof_init_rof_spread_rofi

subroutine med_phases_post_rof_spread_rofi(gcomp, field_name, rc)
subroutine med_phases_post_rof_spread_rofi(gcomp, field_name, field_bundle, comp, rc)
!---------------------------------------------------------------
! For one runoff field, spread runoff according to the pattern prescribed in spread_rofi_weights.
use shr_reprosum_mod , only : shr_reprosum_calc

! input/output variables
type(ESMF_GridComp) :: gcomp
character(len=*), intent(in) :: field_name ! name of runoff flux field to process
type(ESMF_FieldBundle) :: field_bundle
Comment thread
anton-seaice marked this conversation as resolved.
integer, intent(in) :: comp ! the component mesh the field is being spread on
integer, intent(out) :: rc

! local variables
Expand Down Expand Up @@ -652,10 +620,10 @@ subroutine med_phases_post_rof_spread_rofi(gcomp, field_name, rc)
call ESMF_GridCompGetInternalState(gcomp, is_local, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

areas => is_local%wrap%mesh_info(comprof)%areas
lats => is_local%wrap%mesh_info(comprof)%lats
areas => is_local%wrap%mesh_info(comp)%areas
lats => is_local%wrap%mesh_info(comp)%lats

call fldbun_getdata1d(FBrof_r, trim(field_name), runoff_flux, rc=rc)
call fldbun_getdata1d(field_bundle, trim(field_name), runoff_flux, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

allocate(rof2ocn_a_weight(size(runoff_flux),2))
Expand Down Expand Up @@ -749,4 +717,61 @@ subroutine med_phases_post_rof_spread_rofi(gcomp, field_name, rc)

end subroutine med_phases_post_rof_spread_rofi

subroutine med_phases_post_rof_spread_rofi_field_bundle(gcomp, fields_to_spread_runoff, field_bundle, comp, rc)

!---------------------------------------------------------------
! For a list of runoff fields, spread runoff according to the patterns prescribed in spread_rofi_weights.
use shr_reprosum_mod , only : shr_reprosum_calc

! input/output variables
type(ESMF_GridComp) :: gcomp
character(len=*), intent(in) :: fields_to_spread_runoff(:)
type(ESMF_FieldBundle) :: field_bundle
integer, intent(in) :: comp ! the component mesh the field is being spread on
integer, intent(out) :: rc

! local variables
character(len=CL) :: rofi_spread
integer :: n
logical :: isPresent, isSet

character(len=*), parameter :: subname='(med_phases_post_rof_mod: med_phases_post_rof_spread_rofi_field_bundle)'
!---------------------------------------

! unclear why this can't be in med_phases_post_rof_init, possibly pio not initialised
if (.not. spreading_initialized) then
call NUOPC_CompAttributeGet(gcomp, name='rofi_spread', value=rofi_spread, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
spread_rofi_nh = .true.
spread_rofi_sh = .true.
call med_phases_post_rof_init_rof_spread_rofi(gcomp, fields_to_spread_runoff, rofi_spread, comp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else
spread_rofi_nh = .false.
spread_rofi_sh = .false.
end if

spreading_initialized = .true.
endif
Comment thread
kieranricardo marked this conversation as resolved.

if (spread_rofi_nh .or. spread_rofi_sh) then
do n = 1, size(fields_to_spread_runoff)
call ESMF_FieldBundleGet(field_bundle, fieldName=trim(fields_to_spread_runoff(n)), isPresent=isPresent, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) then
call shr_log_error(string=trim(subname)//" Error checking field: "//trim(fields_to_spread_runoff(n)), line=__LINE__,file=u_FILE_u, rc=rc)
Comment thread
kieranricardo marked this conversation as resolved.
Outdated
return
end if
if (isPresent) then
call med_phases_post_rof_spread_rofi(gcomp, fields_to_spread_runoff(n), field_bundle, comp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else
call shr_log_error(string=trim(subname)//" Runoff field to spread: "//trim(fields_to_spread_runoff(n))//" does not exist", line=__LINE__,file=u_FILE_u, rc=rc)
return
end if
end do
end if

end subroutine med_phases_post_rof_spread_rofi_field_bundle

end module med_phases_post_rof_mod