Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate the control of removing negative runoff for lnd vs glc, and set default to false for glc-derived runoff #481

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 13 additions & 2 deletions cime_config/namelist_definition_drv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -872,17 +872,28 @@
<value COMP_LND="xlnd">off</value>
</values>
</entry>
<entry id="remove_negative_runoff">
<entry id="remove_negative_runoff_lnd">
<type>logical</type>
<category>control</category>
<group>MED_attributes</group>
<desc>
If true, remove negative runoff by downweighting all positive runoff globally.
If true, remove negative runoff generated from the land component by downweighting all positive runoff globally.
</desc>
<values>
<value>.true.</value>
</values>
</entry>
<entry id="remove_negative_runoff_glc">
<type>logical</type>
<category>control</category>
<group>MED_attributes</group>
<desc>
If true, remove negative runoff generated from the glc (ice sheet) component by downweighting all positive runoff globally.
</desc>
<values>
<value>.false.</value>
</values>
</entry>

<entry id="info_debug" modify_via_xml="INFO_DBUG">
<type>integer</type>
Expand Down
55 changes: 38 additions & 17 deletions mediator/med_phases_post_rof_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ module med_phases_post_rof_mod
integer :: num_rof_fields
character(len=CS), allocatable :: rof_field_names(:)

logical :: remove_negative_runoff

character(len=13), parameter :: fields_to_remove_negative_runoff(4) = &
['Forr_rofl ', &
'Forr_rofi ', &
'Forr_rofl_glc', &
logical :: remove_negative_runoff_lnd
logical :: remove_negative_runoff_glc

character(len=9), parameter :: fields_to_remove_negative_runoff_lnd(2) = &
['Forr_rofl', &
'Forr_rofi']
character(len=13), parameter :: fields_to_remove_negative_runoff_glc(2) = &
['Forr_rofl_glc', &
'Forr_rofi_glc']

character(*) , parameter :: u_FILE_u = &
__FILE__

Expand Down Expand Up @@ -77,12 +79,20 @@ subroutine med_phases_post_rof_init(gcomp, rc)
call med_phases_post_rof_create_rof_field_bundle(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompAttributeGet(gcomp, name='remove_negative_runoff', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
call NUOPC_CompAttributeGet(gcomp, name='remove_negative_runoff_lnd', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) remove_negative_runoff_lnd
else
remove_negative_runoff_lnd = .false.
end if

call NUOPC_CompAttributeGet(gcomp, name='remove_negative_runoff_glc', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) remove_negative_runoff
read(cvalue,*) remove_negative_runoff_glc
else
remove_negative_runoff = .false.
remove_negative_runoff_glc = .false.
end if

! remove_negative_runoff isn't yet set up to handle isotope fields, so ensure that
Expand All @@ -94,12 +104,13 @@ subroutine med_phases_post_rof_init(gcomp, rc)
else
flds_wiso = .false.
end if
if (remove_negative_runoff .and. flds_wiso) then
call shr_sys_abort('remove_negative_runoff must be set to false when flds_wiso is true')
if ((remove_negative_runoff_lnd .or. remove_negative_runoff_glc) .and. flds_wiso) then
call shr_sys_abort('remove_negative_runoff_lnd and remove_negative_runoff_glc must be set to false when flds_wiso is true')
end if

if (maintask) then
write(logunit,'(a,l7)') trim(subname)//' remove_negative_runoff = ', remove_negative_runoff
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
end if

if (dbug_flag > 20) then
Expand Down Expand Up @@ -143,12 +154,22 @@ subroutine med_phases_post_rof(gcomp, rc)
data_copy(:) = data_orig(:)
end do

if (remove_negative_runoff) then
do n = 1, size(fields_to_remove_negative_runoff)
call ESMF_FieldBundleGet(FBrof_r, fieldName=trim(fields_to_remove_negative_runoff(n)), isPresent=exists, rc=rc)
if (remove_negative_runoff_lnd) then
do n = 1, size(fields_to_remove_negative_runoff_lnd)
call ESMF_FieldBundleGet(FBrof_r, fieldName=trim(fields_to_remove_negative_runoff_lnd(n)), isPresent=exists, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (exists) then
call med_phases_post_rof_remove_negative_runoff(gcomp, fields_to_remove_negative_runoff_lnd(n), rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
end do
end if
if (remove_negative_runoff_glc) then
do n = 1, size(fields_to_remove_negative_runoff_glc)
call ESMF_FieldBundleGet(FBrof_r, fieldName=trim(fields_to_remove_negative_runoff_glc(n)), isPresent=exists, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (exists) then
call med_phases_post_rof_remove_negative_runoff(gcomp, fields_to_remove_negative_runoff(n), rc)
call med_phases_post_rof_remove_negative_runoff(gcomp, fields_to_remove_negative_runoff_glc(n), rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
end do
Expand Down
Loading