anchor.diff:        outgoing  =  minval(incoming, mask = incoming.ne.missing .and. pressure.ge.targetPressure)
   
   end subroutine min_over_layer
  +
  +
  +!---------------------------------------------------------------------------------
  +!
  +! function: Select the value of largest magnitude within a given layer
  +!
  +!---------------------------------------------------------------------------------
  +subroutine most_influential_layer (incoming, targetPressure, pressure, nlev, missing, outgoing )
  +
  +      integer, intent(in )  ::  nlev
  +      real(8), intent(in )  ::  incoming(nlev), pressure(nlev)
  +      real(8), intent(in )  ::  targetPressure
  +      real(8), intent(in )  ::  missing
  +      real(8), intent(out)  ::  outgoing
  +
  +      real(8)               ::  minValue, maxValue
  +
  +      outgoing  =  missing
  +      call min_over_layer (incoming, targetPressure, pressure, nlev, missing, minValue )
  +      call max_over_layer (incoming, targetPressure, pressure, nlev, missing, maxValue )
  +      if     ( minValue.ge.0  .and.  maxValue.ge.0 ) then
  +         outgoing  =  maxValue
  +      else if( minValue.le.0  .and.  maxValue.le.0 ) then
  +         outgoing  =  minValue
  +      else if( abs(minValue).ge.abs(maxValue) ) then
  +         outgoing  =  minValue
  +      else
  +         outgoing  =  maxValue
  +      end if
  +      
  +end subroutine most_influential_layer
  +
   
   
   
  
positive.code:       end if
  
  end subroutine add_sensible_heat_energy
  
  
  
  
negative.code:             !-----------------------------------------------------------------------------
              tpack  =  t_updated
              qpack  =  q_updated
              ppack  =  p_updated
              pblp   =  pblp_updated
  
           end do time_of_day
  