! ---------------------------------------------------------------------------
!  scaled_identity.f90 - Created by Morgan Brown
!           Mon Jan 14 17:43:23 2002.
! ---------------------------------------------------------------------------
!       Usage: scaled_identity.mod 
!  Parameters: 
! Description: 
! ---------------------------------------------------------------------------
module scaled_identity

use sep
use adj_mod

implicit none

integer, private, save     :: n1, n2
real, private, save        :: wt
real, dimension (:), private,  pointer   :: wtv
real, dimension (:), private,  pointer   :: wto

contains

! ---------------------------------------------------------------------------
	subroutine scaled_identity_init( wt_in )
		real :: wt_in
		wt = wt_in
	end subroutine scaled_identity_init
! ---------------------------------------------------------------------------
	subroutine scaled_identity_v_init( wtv_in )
		real , dimension (:),   pointer  :: wtv_in
		wtv => wtv_in
	end subroutine scaled_identity_v_init

	subroutine scaled_identity_wto_init( wto_in )
		real , dimension (:),   pointer  :: wto_in
		wto => wto_in
	end subroutine scaled_identity_wto_init
! ---------------------------------------------------------------------------

	integer function scaled_identity_exec( adj, add, model, data)
		logical            :: adj, add 
		real, dimension(:) :: model, data 

		call adjnull( adj, add, model, data)

		if( adj) then
			model = model + data*wt
		else
			data = data + model*wt
		end if

		scaled_identity_exec = 0

	end function scaled_identity_exec
! ---------------------------------------------------------------------------
! ---------------------------------------------------------------------------
	integer function scaled_identity_v_lop( adj, add, model, data)
		logical            :: adj, add 
		real, dimension(:) :: model, data 
		call adjnull( adj, add, model, data)
        call scaled_identity_v_exec ( adj, add, model, data)
        scaled_identity_v_lop = 0
    end function scaled_identity_v_lop

    subroutine  scaled_identity_v_exec ( adj, add, model, data)
		logical            :: adj, add 
		real, dimension(:) :: model, data
		if( adj) then
			model = model + data*wtv
		else
			data = data + model*wtv
		end if
	end subroutine

	
! ---------------------------------------------------------------------------
! ---------------------------------------------------------------------------
	integer function scaled_identity_wto_lop( adj, add, model, data)
		logical            :: adj, add 
		real, dimension(:) :: model, data 
		call adjnull( adj, add, model, data)
        call scaled_identity_wto_exec ( adj, add, model, data)
        scaled_identity_wto_lop = 0
    end function scaled_identity_wto_lop

    subroutine  scaled_identity_wto_exec ( adj, add, model, data)
		logical            :: adj, add 
		real, dimension(:) :: model, data
		if( adj) then
			model = model + data*wto
		else
			data = data + model*wto
		end if
	end subroutine

	
! ---------------------------------------------------------------------------

	integer function identity_exec( adj, add, model, data)
		logical            :: adj, add 
		real, dimension(:) :: model, data 

		call adjnull( adj, add, model, data)

		if( adj) then
			model = model + data
		else
			data = data + model
		end if

		identity_exec = 0

	end function identity_exec
! ---------------------------------------------------------------------------

end module scaled_identity
