B.4.7 InInterval Procedure

The main documentation of the InInterval Procedure contains additional explanation of this code listing.

  define([IN_INTERVAL_ROUTINE],[
    pushdef([TYPE], [$1])
    pushdef([DIM], [$2])
    pushdef([InInterval_TYPE_DIM], expand(InInterval_TYPE_DIM))

    function InInterval_TYPE_DIM (X, Interval) result(InInterval)
  
      ! Input variables.
  
      type(TYPE,DIM,np), intent(in) :: X              ! Variable to be checked.
      type(TYPE), dimension(2), intent(in) :: Interval ! Interval to check.
  
      ! Output variable.
  
      type(logical) :: InInterval                      ! Result of check.
  
      !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
      ! Verify requirements.
  
      VERIFY(Interval(1) <= Interval(2),7)   ! Interval should be well-formed.
  
      ! InInterval is true if X is in the interval.
  
      InInterval = ALL(X >= Interval(1) .and. &
                       X <= Interval(2))
  
      ! Verify guarantees -- none.

      return
    end function InInterval_TYPE_DIM

    popdef([TYPE])
    popdef([DIM])
    popdef([InInterval_TYPE_DIM])
  ])

  forloop([Dim],[0],[7],[
    fortext([Type],[real integer],[
      IN_INTERVAL_ROUTINE(Type, Dim)
    ])
  ])



Michael L. Hall