Skip to content

Commit

Permalink
Merge pull request #20 from andrew-c-ross/runoff-addition-fix
Browse files Browse the repository at this point in the history
Keep track of whether runoff has been added to stf
  • Loading branch information
nikizadehgfdl authored Jan 11, 2023
2 parents 1cf5f21 + 389e8de commit edbe781
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion generic_tracers/generic_tracer_utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ module g_tracer_utils
logical :: flux_drydep = .false. !Is there a dry deposition?
logical :: flux_bottom = .false. !Is there a flux through bottom?
logical :: has_btm_reservoir = .false. !Is there a flux bottom reservoir?
logical :: runoff_added_to_stf = .false. ! Has flux in from runoff been added to stf?

! Flux identifiers to be set by aof_set_coupler_flux()
integer :: flux_gas_ind = -1
Expand Down Expand Up @@ -2089,7 +2090,16 @@ subroutine g_tracer_set_2D(g_tracer_list,name,member,array,isd,jsd,weight)
case ('sc_no')
g_tracer%sc_no = w0*g_tracer%sc_no + w1*array
case ('stf')
g_tracer%stf = w0*g_tracer%stf + w1*array
! Check for edge case where the new value is a weighted combination of old and new values
! and the old value had runoff added to it later. In this case, the result would be
! invalid if the new value did not also have runoff added to it (which is not known).
if (w1 < 1 .and. g_tracer%runoff_added_to_stf) then
call mpp_error(FATAL, trim(sub_name)//&
": Cannot set stf to a weighted combination of values with and without runoff.")
else
g_tracer%stf = w0*g_tracer%stf + w1*array
g_tracer%runoff_added_to_stf = .false.
endif
case ('stf_gas')
g_tracer%stf_gas= w0*g_tracer%stf_gas + w1*array
case ('deltap')
Expand Down Expand Up @@ -2234,6 +2244,7 @@ subroutine g_tracer_set_real(g_tracer_list,name,member,value)
g_tracer%sc_no = value
case ('stf')
g_tracer%stf = value
g_tracer%runoff_added_to_stf = .false.
case ('stf_gas')
g_tracer%stf_gas = value
case ('deltap')
Expand Down

0 comments on commit edbe781

Please sign in to comment.