function get_array3d_oc(x, flags) result(r)
class(pf_encap_t), intent(in) :: x
integer, intent(in ), optional :: flags
real(pfdp), pointer :: r(:,:,:)
integer :: which
which = 0
if (present(flags)) which = flags
select type (x)
type is (ndarray_oc)
select case (which)
case (1)
r(1:x%shape(1),1:x%shape(2),1:x%shape(3)) => x%yflatarray
case (2)
r(1:x%shape(1),1:x%shape(2),1:x%shape(3)) => x%pflatarray
case default
stop "ERROR in get_array2d_oc: only 1, 2 allowed as flags"
end select
class default
stop "ERROR: get_array2d_oc type mismatch."
end select
end function get_array3d_oc