ndarray_oc_axpy Subroutine

public subroutine ndarray_oc_axpy(this, a, x, flags)

Subroutine to compute y = a x + y where a is a scalar and x and y are arrays

Arguments

Type IntentOptional AttributesName
class(ndarray_oc), intent(inout) :: this
real(kind=pfdp), intent(in) :: a
class(pf_encap_t), intent(in) :: x
integer, intent(in), optional :: flags

Contents

Source Code


Source Code

  subroutine ndarray_oc_axpy(this, a, x, flags)
    class(ndarray_oc), intent(inout) :: this    
    class(pf_encap_t), intent(in   )     :: x
    real(pfdp),  intent(in   )           :: a
    integer,     intent(in   ), optional :: flags
    integer :: which

    which = 0
    if (present(flags)) which = flags
!     if (.not.present(flags)) stop "axpy without flags" 
    
    select type(x)
    type is (ndarray_oc)
      select case (which)
      case (0)
        this%yflatarray = a * x%yflatarray + this%yflatarray
        this%pflatarray = a * x%pflatarray + this%pflatarray
      case (1)
        this%yflatarray = a * x%yflatarray + this%yflatarray
      case (2)
        this%pflatarray = a * x%pflatarray + this%pflatarray
      case default
        stop "ERROR in ndarray_oc_axpy: only 0, 1, 2 allowed as flags"
      end select
    class default
      stop "TYPE ERROR in ndarray_oc_axpy"
    end select  
  end subroutine ndarray_oc_axpy