fixed_array_dp_at Subroutine

private pure subroutine fixed_array_dp_at(self, index, value, err)

Bounds-checked element access, 1-based. Any index outside 1:size() (including indices that are within the capacity but beyond the live elements) sets value to zero and err to ERROR_VALIDATION. On success err is left untouched.

Type Bound

fixed_array_dp_t

Arguments

Type IntentOptional Attributes Name
class(fixed_array_dp_t), intent(in) :: self
integer(kind=default_int), intent(in) :: index
real(kind=dp), intent(out) :: value
type(error_t), intent(inout) :: err

Calls

proc~~fixed_array_dp_at~~CallsGraph proc~fixed_array_dp_at fixed_array_dp_t%fixed_array_dp_at proc~error_set error_t%error_set proc~fixed_array_dp_at->proc~error_set

Source Code

   pure subroutine fixed_array_dp_at(self, index, value, err)
      !! Bounds-checked element access, 1-based. Any index outside
      !! `1:size()` (including indices that are within the capacity but
      !! beyond the live elements) sets `value` to zero and `err` to
      !! `ERROR_VALIDATION`. On success `err` is left untouched.
      class(fixed_array_dp_t), intent(in) :: self
      integer(default_int), intent(in) :: index
      real(dp), intent(out) :: value
      type(error_t), intent(inout) :: err

      if (index < 1_default_int .or. index > self%n_items) then
         value = 0.0_dp
         call err%set(ERROR_VALIDATION, MSG_OUT_OF_RANGE)
         return
      end if

      value = self%items(index)
   end subroutine fixed_array_dp_at