module weight
  real, dimension (:), pointer, private :: w
contains
  subroutine weight_init (wt)
    real, dimension(:), pointer :: wt
    w => wt
  end subroutine weight_init
  function weight_lop (adj, add, x, y) result (stat)
    integer              :: stat
    logical, intent (in) :: adj, add
    real, dimension (:)  :: x, y
    if (adj) then
       if (add) then
          x = x + w * y
       else
          x =     w * y
       end if
    else
       if (add) then
          y = y + w * x
       else
          y =     w * x
       end if
    end if
    stat = 0
  end function weight_lop
end module weight
