Skip to content

Commit

Permalink
fix bug in med_diag_mod for ice runoff (#497)
Browse files Browse the repository at this point in the history
* send Si_thick from cice to wav if advertised 
* fix BUDGETS correctly for BLOM
  • Loading branch information
mvertens authored Aug 12, 2024
1 parent e71a5aa commit d8b0865
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 30 deletions.
4 changes: 2 additions & 2 deletions cime_config/config_component_cesm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,10 @@
<default_value>FALSE</default_value>
<values match="last">
<value compset="DATM.*_POP\d">TRUE</value>
<value compset="DATM.*_MOM\d">TRUE</value>
<value compset="DATM.*_MOM">TRUE</value>
<value compset="DATM.*_BLOM\d">TRUE</value>
<value compset="CAM.*_MOM\d">TRUE</value>
<value compset="CAM.*_BLOM\d">TRUE</value>
<value compset="CAM.*_BLOM">TRUE</value>
<value compset="CAM.*_POP\d">TRUE</value>
<value compset="CAM.*_DOCN%SOM">TRUE</value>
</values>
Expand Down
18 changes: 8 additions & 10 deletions mediator/esmFldsExchange_cesm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3019,16 +3019,14 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
!----------------------------------------------------------
! to wav: ice thickness from ice
!----------------------------------------------------------
if (wav_coupling_to_cice) then
if (phase == 'advertise') then
call addfld_from(compice, 'Si_thick')
call addfld_to(compwav, 'Si_thick')
else
if (fldchk(is_local%wrap%FBexp(compwav) , 'Si_thick', rc=rc) .and. &
fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_thick', rc=rc)) then
call addmap_from(compice, 'Si_thick', compwav, mapbilnr, 'one', ice2wav_map)
call addmrg_to(compwav, 'Si_thick', mrg_from=compice, mrg_fld='Si_thick', mrg_type='copy')
end if
if (phase == 'advertise') then
call addfld_from(compice, 'Si_thick')
call addfld_to(compwav, 'Si_thick')
else
if ( fldchk(is_local%wrap%FBexp(compwav) , 'Si_thick', rc=rc) .and. &
fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_thick', rc=rc)) then
call addmap_from(compice, 'Si_thick', compwav, mapbilnr, 'one', ice2wav_map)
call addmrg_to(compwav, 'Si_thick', mrg_from=compice, mrg_fld='Si_thick', mrg_type='copy')
end if
end if
!----------------------------------------------------------
Expand Down
26 changes: 8 additions & 18 deletions mediator/med_diag_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ module med_diag_mod
integer :: f_heat_cond = unset_index ! heat : heat content of evaporation
integer :: f_heat_rofl = unset_index ! heat : heat content of liquid runoff
integer :: f_heat_rofi = unset_index ! heat : heat content of ice runoff
integer :: f_heat_rofl_glc = unset_index ! heat : heat content of liquid glc runoff
integer :: f_heat_rofi_glc = unset_index ! heat : heat content of ice glc runoff

integer :: f_watr_frz = unset_index ! water: freezing
integer :: f_watr_melt = unset_index ! water: melting
Expand Down Expand Up @@ -332,16 +330,14 @@ subroutine med_diag_init(gcomp, rc)
f_heat_beg = f_heat_frz ! field first index for heat
f_heat_end = f_heat_sen ! field last index for heat
else if (trim(budget_table_version) == 'v1') then
call add_to_budget_diag(budget_diags%fields, f_heat_rain ,'hrain' ) ! field heat : enthalpy of rain
call add_to_budget_diag(budget_diags%fields, f_heat_snow ,'hsnow' ) ! field heat : enthalpy of snow
call add_to_budget_diag(budget_diags%fields, f_heat_evap ,'hevap' ) ! field heat : enthalpy of evaporation
call add_to_budget_diag(budget_diags%fields, f_heat_cond ,'hcond' ) ! field heat : enthalpy of evaporation
call add_to_budget_diag(budget_diags%fields, f_heat_rofl ,'hrofl' ) ! field heat : enthalpy of liquid runoff
call add_to_budget_diag(budget_diags%fields, f_heat_rofi ,'hrofi' ) ! field heat : enthalpy of ice runoff
call add_to_budget_diag(budget_diags%fields, f_heat_rofl_glc,'hrofl_glc' ) ! field heat : enthalpy of liquid glc runoff
call add_to_budget_diag(budget_diags%fields, f_heat_rofi_glc,'hrofi_glc' ) ! field heat : enthalpy of ice glc runoff
call add_to_budget_diag(budget_diags%fields, f_heat_rain ,'hrain' ) ! field heat : enthalpy of rain
call add_to_budget_diag(budget_diags%fields, f_heat_snow ,'hsnow' ) ! field heat : enthalpy of snow
call add_to_budget_diag(budget_diags%fields, f_heat_evap ,'hevap' ) ! field heat : enthalpy of evaporation
call add_to_budget_diag(budget_diags%fields, f_heat_cond ,'hcond' ) ! field heat : enthalpy of evaporation
call add_to_budget_diag(budget_diags%fields, f_heat_rofl ,'hrofl' ) ! field heat : enthalpy of liquid runoff
call add_to_budget_diag(budget_diags%fields, f_heat_rofi ,'hrofi' ) ! field heat : enthalpy of ice runoff
f_heat_beg = f_heat_frz ! field first index for heat
f_heat_end = f_heat_rofi_glc ! field last index for heat
f_heat_end = f_heat_rofi ! field last index for heat
end if

! -----------------------------------------
Expand Down Expand Up @@ -1208,7 +1204,7 @@ subroutine med_phases_diag_rof( gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if ( fldbun_fldchk(is_local%wrap%FBImp(comprof,comprof), 'Forr_rofl_glc', rc=rc)) then
call diag_rof(is_local%wrap%FBImp(comprof,comprof), 'Forr_rofi_glc' , f_watr_roff, ic, areas, budget_local, minus=.true., rc=rc)
call diag_rof(is_local%wrap%FBImp(comprof,comprof), 'Forr_rofl_glc' , f_watr_roff, ic, areas, budget_local, minus=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
if ( fldbun_fldchk(is_local%wrap%FBImp(comprof,comprof), 'Forr_rofi_glc', rc=rc)) then
Expand Down Expand Up @@ -1365,12 +1361,10 @@ subroutine med_phases_diag_glc( gcomp, rc)
call ESMF_GridCompGetInternalState(gcomp, is_local, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return


!-------------------------------
! from glc to mediator
!-------------------------------

! TODO: this will not be correct if there is more than 1 ice sheet
ic = c_glc_recv
ip = period_inst

Expand Down Expand Up @@ -1605,10 +1599,6 @@ subroutine med_phases_diag_ocn( gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call diag_ocn(is_local%wrap%FBExp(compocn), 'Foxx_hrofi', f_heat_rofi , ic, areas, sfrac, budget_local, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call diag_ocn(is_local%wrap%FBExp(compocn), 'Foxx_hrofl_glc', f_heat_rofl_glc, ic, areas, sfrac, budget_local, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call diag_ocn(is_local%wrap%FBExp(compocn), 'Foxx_hrofi_glc', f_heat_rofi_glc , ic, areas, sfrac, budget_local, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

budget_local(f_heat_latf,ic,ip) = -budget_local(f_watr_snow,ic,ip)*shr_const_latice
budget_local(f_heat_ioff,ic,ip) = -budget_local(f_watr_ioff,ic,ip)*shr_const_latice
Expand Down

0 comments on commit d8b0865

Please sign in to comment.