get_partial_unpack_mask Function

function get_partial_unpack_mask(this, upstream_grad) result(output)

Arguments

Type IntentOptional Attributes Name
class(array_type), intent(inout) :: this
type(array_type), intent(in) :: upstream_grad

Return Value type(array_type)


Source Code

  function get_partial_unpack_mask(this, upstream_grad) result(output)
    implicit none
    class(array_type), intent(inout) :: this
    type(array_type), intent(in) :: upstream_grad
    type(array_type) :: output
    type(array_type), pointer :: ptr

    logical, dimension(:), allocatable :: mask

    if(allocated(this%indices))then
       allocate(mask(size(upstream_grad%val,this%adj_ja(1,1))))
       mask = .false.
       mask(this%indices) = .true.
       ptr => pack(upstream_grad, this%adj_ja(1,1), mask)
    else
       ptr => pack(upstream_grad, this%adj_ja(1,1))
    end if

    call output%assign_and_deallocate_source(ptr)
  end function get_partial_unpack_mask