function get_array1d_oc(x, flags) result(r)
class(pf_encap_t), target, intent(in) :: x
integer, intent(in ), optional :: flags
real(pfdp), pointer :: r(:)
integer :: which
which = 0
if (present(flags)) which = flags
! if(.not.present(flags)) print *, "array1d_oc without flags"
select type (x)
type is (ndarray_oc)
select case (which)
case (1)
r => x%yflatarray
case (2)
r => x%pflatarray
case default
stop "ERROR in get_array1d_oc: only 1, 2 allowed as flags"
end select
class default
stop "ERROR: get_array1d_oc type mismatch."
end select
end function get_array1d_oc