module myarray_mod  
use differential_off_mod
use sparse_matmult_fly_sym
!use chain_weight
use adj_mod

  implicit none
  real    ,private                           :: eps
  logical, parameter, private :: T = .true., F = .false.
  contains

  subroutine myarray_init (eps_in)
    real                           :: eps_in

    eps=eps_in
    write(0,*)"eps",eps

  end subroutine

    !---------------------------------------------------------------------------------
  integer function myarray( adj, add, model, data) 
  logical            :: adj,add
  real, dimension(:) :: model, data
   call adjnull( adj, add, model, data)
   call myarray_exe( adj, add, model, data)
   myarray= 0

  end function

  subroutine myarray_exe(adj,add, m,d)
!        ARRAY
    logical, intent(in) :: adj, add
    real, dimension(:)  :: m,d
    integer             :: st

    if (adj) then
!      st = smatmult_lop          (T, add, m, d)            
!      st = differential_off2_exec(T,   T, m, d)        
    else
!      st = smatmult_lop          (F, add, m, d)            ! d = d0 + A  m
!      st = differential_off2_exec(F,   T, m, d)            ! d = d  + B  m
    endif 



  end subroutine 

!    !---------------------------------------------------------------------------------
!  integer function myarray_prec( adj, add, model, data) 
!  logical            :: adj,add
!  real, dimension(:) :: model, data
!
!   call myarray_prec_exe( adj, add, model, data)
!   myarray= 0
!
!  end function
!
!  subroutine myarray_prec_exe(adj,add, m,d)
!!        ARRAY
!    logical, intent(in) :: adj, add
!    real, dimension(:)  :: m,d
!    integer             :: st
!      st = chain_w               (F, add, m, d)        ! d = d0 + A  m
!      st = differential_off2_exec(F,   T, eps*m, d)        ! d = d  + B  m
!  end subroutine 
end module 
