module dotest 

  implicit none

  logical, parameter, private ::  T = .true.,  F = .false.

  contains

  subroutine dot_est( oper, n_mod, n_dat)
	! subroutine paramters
    integer,             intent (in)  :: n_mod, n_dat 

	! operator interface
    interface  
      function oper( adj, add, mod, dat) result(stat)
        integer              :: stat
        logical, intent (in) :: adj, add
        real, dimension (:)  :: mod, dat
      end function
    end interface 

	! local variables
    real, dimension( n_mod)           :: mod1, mod2
    real, dimension( n_dat)           :: dat1, dat2
    integer                           :: stat
    real, dimension (2) :: dot

	! Fill vectors with random numbers
    call random_number( mod1)
    call random_number( dat2)

	! Do dot product test for the add=0 option
    stat = oper( F, F, mod1, dat1)
    dot( 1) = dot_product( dat1, dat2)
    stat = oper( T, F, mod2, dat2)
    dot( 2) = dot_product( mod1, mod2)
    write (0,'(1x,f20.10)') dot

	! Do dot product test for the add=1 option
    stat = oper( F, T, mod1, dat1)
    dot( 1) = dot_product( dat1, dat2)
    stat = oper( T, T, mod2, dat2)
    dot( 2) = dot_product( mod1, mod2)
    write (0,'(1x,f20.10)') dot

  end subroutine 

end module 
