fixed_array_dp_as_array Function

private pure function fixed_array_dp_as_array(self) result(arr)

Copy of the live elements as a plain array of extent size(), not capacity(). Returns a zero-length array when empty. This is how the contents are handed to ordinary Fortran routines; note that it is the one operation here that does allocate, so keep it out of the hot path.

Type Bound

fixed_array_dp_t

Arguments

Type IntentOptional Attributes Name
class(fixed_array_dp_t), intent(in) :: self

Return Value real(kind=dp), allocatable, (:)


Source Code

   pure function fixed_array_dp_as_array(self) result(arr)
      !! Copy of the live elements as a plain array of extent `size()`,
      !! not `capacity()`. Returns a zero-length array when empty. This is
      !! how the contents are handed to ordinary Fortran routines; note
      !! that it is the one operation here that does allocate, so keep it
      !! out of the hot path.
      class(fixed_array_dp_t), intent(in) :: self
      real(dp), allocatable :: arr(:)

      allocate (arr(self%n_items))
      arr(1:self%n_items) = self%items(1:self%n_items)
   end function fixed_array_dp_as_array