check_target_reached Subroutine

private subroutine check_target_reached(target_reached)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
logical, intent(out) :: target_reached

Contents

Source Code


Source Code

  subroutine check_target_reached(target_reached)
    use parameter_scan_arrays, only: hflux_tot, momflux_tot, phi2_tot, nout
    implicit none
    logical, intent (out) :: target_reached
    logical, save :: first = .true.
    real, save :: last_value = 0.0
    target_reached = .false.
    last_value = current_target_value

    select case (target_parameter_switch)
    case (target_parameter_hflux_tot)
       current_target_value = hflux_tot(nout)
    case (target_parameter_momflux_tot)
       current_target_value = momflux_tot(nout)
    case (target_parameter_phi2_tot)
       current_target_value = phi2_tot(nout)
    end select

    if (first) then
       last_value = current_target_value
       first = .false.
       return
    end if

    ! Check if last and current values bracket the target
    if ((last_value < target_val .and. current_target_value > target_val) .or. &
         (last_value > target_val .and. current_target_value < target_val)) &
         target_reached = .true.
  end subroutine check_target_reached