Skip to content

Commit

Permalink
Merge pull request #481 from billsacks/remove_negative_runoff_land_only
Browse files Browse the repository at this point in the history
Separate the control of removing negative runoff for lnd vs glc, and set default to false for glc-derived runoff

### Description of changes

This is a follow-up to #471 .

At least for now, we want the default to be to remove negative runoff for lnd-derived runoff, but NOT for glc-derived runoff. This PR implements that change. Note that this changes behavior for the correction of glc-derived runoff, but keeps the behavior the same as before for lnd-derived runoff.

### Specific notes

Are changes expected to change answers? (specify if bfb, different at roundoff, more substantial): **Yes - changes answers substantially for runoff fields in some B compsets (or other configurations with both active land/river and active ocean) - but only for configurations that have glc-derived runoff; this can currently come from configurations with CISM in EVOLVE mode or DGLC (even in NOEVOLVE mode). Note that this change just undoes part of the answer changes that came from #471 .**

Any User Interface Changes (namelist or namelist defaults changes)? Separates the namelist item remove_negative_runoff into two separate options: remove_negative_runoff_lnd and remove_negative_runoff_glc.

### Testing performed
Please describe the tests along with the target model and machine(s) 
If possible, please also added hashes that were used in the testing

Using `cesm2_3_beta17` (with CISM at `756cfa6f0514d89977d2732ad06a4d364da5d418`, mosart at mosart1.1.02, and removing the contents of `cime_config/testmods_dirs/allactive/defaultio/user_nl_mosart`: Ran three versions of `SMS_D_Ld3.f19_g17.B1850G.derecho_intel.allactive-cism-test_coupling`:
- One with default flags
- One with `remove_negative_runoff_glc` set to true
- One with `remove_negative_runoff_lnd` set to false

I checked the behavior in these in runs with dbug_flag set to 21 so I would see diagnostics of what fields were being adjusted, and confirmed that the correct fields were being operated on in all three cases.
  • Loading branch information
billsacks authored Jul 10, 2024
2 parents c2ef06d + df46cf1 commit 1b8920c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 19 deletions.
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

0 comments on commit 1b8920c

Please sign in to comment.