!===============================================================================
!
! module_sc.F90
!
!-------------------------------------------------------------------------------
!
! Copyright (C) 2008 Yoshifumi Nakamura
!
! This file is part of BQCD -- Berlin Quantum ChromoDynamics program
!
! BQCD is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! BQCD is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with BQCD.  If not, see <http://www.gnu.org/licenses/>.
!
!-------------------------------------------------------------------------------
! Added 'sc_cxpby' for PFHMC
!
! Editor: Taylor Haar
! Last modified: 03/12/2014
!-------------------------------------------------------------------------------
# include "defs.h"

# define OR4      real(4), intent(out) :: out(*)
# define OR8      real(8), intent(out) :: out(*)
# define OC4   complex(4), intent(out) :: out(*)
# define OC8   complex(8), intent(out) :: out(*)
# define IR4      real(4), intent(in) :: in(*)
# define IR8      real(8), intent(in) :: in(*)
# define IR4_2    real(4), intent(in) :: in1(*), in2(*)
# define IR8_2    real(8), intent(in) :: in1(*), in2(*)
# define IC4   complex(4), intent(in) :: in(*)
# define IC8   complex(8), intent(in) :: in(*)
# define IC4_2 complex(4), intent(in) :: in1(*), in2(*)
# define IC8_2 complex(8), intent(in) :: in1(*), in2(*)
# define IOR4     real(4), intent(inout) :: inout(*)
# define IOR8     real(8), intent(inout) :: inout(*)
# define IOC4  complex(4), intent(inout) :: inout(*)
# define IOC8  complex(8), intent(inout) :: inout(*)

# define OS4   complex(4), dimension(4, 3, *), intent(out) :: out
# define OS8   complex(8), dimension(4, 3, *), intent(out) :: out
# define IS4   complex(4), dimension(4, 3, *), intent(in) :: in
# define IS8   complex(8), dimension(4, 3, *), intent(in) :: in
# define IS4_2 complex(4), dimension(4, 3, *), intent(in) :: in1, in2
# define IS8_2 complex(8), dimension(4, 3, *), intent(in) :: in1, in2
# define IOS4  complex(4), dimension(4, 3, *), intent(inout) :: inout
# define IOS8  complex(8), dimension(4, 3, *), intent(inout) :: inout

# define FR4      real(4), intent(in) :: a
# define FR8      real(8), intent(in) :: a
# define FR4_2    real(4), intent(in) :: a1, a2
# define FR8_2    real(8), intent(in) :: a1, a2
# define FC4   complex(4), intent(in) :: a
# define FC8   complex(8), intent(in) :: a
# define FC4_2 complex(4), intent(in) :: a1, a2
# define FC8_2 complex(8), intent(in) :: a1, a2

!-------------------------------------------------------------------------------
module module_sc

!subroutine sc_zero(out)

  interface     sc_zero 
subroutine sc_zero(   out)
OR8
end
     subroutine sc_zero_r4(out)
OR4
end
     subroutine sc_zero_spincol_field(   out)
OS8
end
     subroutine sc_zero_spincol_field_r4(out)
OS4 ; end
  end interface sc_zero

!subroutine sc_copy(out, in)

  interface     sc_copy
     subroutine sc_copy(         out, in)
 OR8 
 IR8 ; end
     subroutine sc_copy_r4(      out, in) 
 OR4 
 IR4 ; end
     subroutine sc_copy_r8_to_r4(out, in) 
 OR4 
 IR8 ; end
     subroutine sc_copy_r4_to_r8(out, in) 
 OR8 
 IR4 ; end

     subroutine sc_copy_spincol_field(         out, in) 
 OS8 
 IS8 ; end
     subroutine sc_copy_spincol_field_r4(      out, in) 
 OS4 
 IS4 ; end
     subroutine sc_copy_r8_to_r4_spincol_field(out, in) 
 OS4 
 IS8 ; end
     subroutine sc_copy_r4_to_r8_spincol_field(out, in) 
 OS8 
 IS4 ; end
  end interface sc_copy

!subroutine sc_scale(inout, a)

  interface     sc_scale
     subroutine sc_scale(   inout, a) 
 IOR8 
 FR8 ; end
     subroutine sc_scale_r4(inout, a) 
 IOR4 
 FR4 
 end
     subroutine sc_scale_spincol_field(   inout, a) 
 IOS8 
 FR8 
 end
     subroutine sc_scale_spincol_field_r4(inout, a) 
 IOS4 
 FR4 
 end
  end interface sc_scale


!subroutine sc_cscale(inout, a)

  interface     sc_cscale
     subroutine sc_cscale(   inout, a)
 IOC8
 FC8
 end
     subroutine sc_cscale_r4(inout, a)
 IOC4
 FC4
 end
     subroutine sc_cscale_spincol_field(   inout, a)
 IOS8
 FC8
 end
     subroutine sc_cscale_spincol_field_r4(inout, a)
 IOS4
 FC4
 end
  end interface sc_cscale


!subroutine sc_axpy(inout, in, a)

  interface     sc_axpy
     subroutine sc_axpy(   inout, in, a) 
 IOR8 
 IR8 
 FR8 
 end
     subroutine sc_axpy_r4(inout, in, a) 
 IOR4 
 IR4 
 FR4 
 end
     subroutine sc_axpy_spincol_field(   inout, in, a) 
 IOS8 
 IS8 
 FR8 
 end
     subroutine sc_axpy_spincol_field_r4(inout, in, a) 
 IOS4 
 IS4 
 FR4 
 end
  end interface sc_axpy

!subroutine sc_cax2(out, in1, a1, in2, a2)

  interface     sc_cax2
     subroutine sc_cax2(   out, in1, a1, in2, a2) 
 OC8 
 IC8_2 
 FC8_2 
 end
     subroutine sc_cax2_r4(out, in1, a1, in2, a2) 
 OC4 
 IC4_2 
 FC4_2 
 end
     subroutine sc_cax2_spincol_field(   out, in1, a1, in2, a2) 
 OS8 
 IS8_2 
 FC8_2 
 end
     subroutine sc_cax2_spincol_field_r4(out, in1, a1, in2, a2) 
 OS4 
 IS4_2 
 FC4_2 
 end
  end interface sc_cax2

!subroutine sc_caxpy(inout, in, a)

  interface     sc_caxpy
     subroutine sc_caxpy(   inout, in, a) 
 IOC8 
 IC8 
 FC8 
 end
     subroutine sc_caxpy_r4(inout, in, a) 
 IOC4 
 IC4 
 FC4 
 end
     subroutine sc_caxpy_spincol_field(   inout, in, a) 
 IOS8 
 IS8 
 FC8 
 end
     subroutine sc_caxpy_spincol_field_r4(inout, in, a) 
 IOS4 
 IS4 
 FC4 
 end
  end interface sc_caxpy

!subroutine sc_cxpby(inout, in, a)

  interface     sc_cxpby
     subroutine sc_cxpby(   inout, in, a)
 IOC8
 IC8
 FC8
 end
     subroutine sc_cxpby_r4(inout, in, a)
 IOC4
 IC4
 FC4
 end
     subroutine sc_cxpby_spincol_field(   inout, in, a)
 IOS8
 IS8
 FC8
 end
     subroutine sc_cxpby_spincol_field_r4(inout, in, a)
 IOS4
 IS4
 FC4
 end
  end interface sc_cxpby

 
!subroutine sc_caxpy2(inout, in1, a1, in2, a2)

  interface     sc_caxpy2
     subroutine sc_caxpy2(   inout, in1, a1, in2, a2) 
 IOC8 
 IC8_2 
 FC8_2 
 end
     subroutine sc_caxpy2_r4(inout, in1, a1, in2, a2) 
 IOC4 
 IC4_2 
 FC4_2 
 end
     subroutine sc_caxpy2_spincol_field(   inout, in1, a1, in2, a2) 
 IOS8 
 IS8_2 
 FC8_2 
 end
     subroutine sc_caxpy2_spincol_field_r4(inout, in1, a1, in2, a2) 
 IOS4 
 IS4_2 
 FC4_2 
 end
  end interface sc_caxpy2

!subroutine sc_caxpby(inout, in, a1, a2)

  interface     sc_caxpby
     subroutine sc_caxpby(   inout, in, a1, a2)
 IOC8
 IC8
 FC8_2
 end
     subroutine sc_caxpby_r4(inout, in, a1, a2)
 IOC4
 IC4
 FC4_2
 end
     subroutine sc_caxpby_spincol_field(   inout, in, a1, a2)
 IOS8
 IS8
 FC8_2
 end
     subroutine sc_caxpby_spincol_field_r4(inout, in, a1, a2)
 IOS4
 IS4
 FC4_2
 end
  end interface sc_caxpby

!subroutine sc_xpby(inout, in, a)

  interface     sc_xpby
     subroutine sc_xpby(   inout, in, a) 
 IOR8 
 IR8 
 FR8 
 end
     subroutine sc_xpby_r4(inout, in, a) 
 IOR4 
 IR4 
 FR4 
 end
     subroutine sc_xpby_spincol_field(   inout, in, a) 
 IOS8 
 IS8 
 FR8 
 end
     subroutine sc_xpby_spincol_field_r4(inout, in, a) 
 IOS4 
 IS4 
 FR4 
 end
  end interface sc_xpby

!subroutine sc_axpby(inout, in, a1, a2)

  interface     sc_axpby
     subroutine sc_axpby(   inout, in, a1, a2) 
 IOR8 
 IR8 
 FR8_2 
 end
     subroutine sc_axpby_r4(inout, in, a1, a2) 
 IOR4 
 IR4 
 FR4_2 
 end
     subroutine sc_axpby_spincol_field(   inout, in, a1, a2) 
 IOS8 
 IS8 
 FR8_2 
 end
     subroutine sc_axpby_spincol_field_r4(inout, in, a1, a2) 
 IOS4 
 IS4 
 FR4_2 
 end
  end interface sc_axpby

!subroutine sc_xmy(inout, in)

  interface     sc_xmy
     subroutine sc_xmy(   inout, in) 
 IOR8 
 IR8 
 end
     subroutine sc_xmy_r4(inout, in) 
 IOR4 
 IR4 
 end
     subroutine sc_xmy_spincol_field(   inout, in) 
 IOS8 
 IS8 
 end
     subroutine sc_xmy_spincol_field_r4(inout, in) 
 IOS4 
 IS4 
 end
  end interface sc_xmy

!!!REAL function sc_norm2(in)
!!
!!  interface     sc_norm2
!!     real(8)    function sc_norm2(   in) ; IR8 ; end
!!     real(4)    function sc_norm2_r4(in) ; IR4 ; end
!!     real(8)    function sc_norm2_spincol_field(   in) ; IS8 ; end
!!     real(4)    function sc_norm2_spincol_field_r4(in) ; IS4 ; end
!!  end interface sc_norm2
!!
!!!REAL function sc_dot(in1, in2)
!!
!!  interface     sc_dot
!!     real(8)    function sc_dot(   in1, in2) ; IR8_2 ; end
!!     real(4)    function sc_dot_r4(in1, in2) ; IR4_2 ; end
!!     real(8)    function sc_dot_spincol_field(   in1, in2) ; IS8_2 ; end
!!     real(4)    function sc_dot_spincol_field_r4(in1, in2) ; IS4_2 ; end
!!  end interface sc_dot
!!
!!!COMPLEX function sc_cdotc(in1, in2)
!!
!!  interface     sc_cdotc
!!     complex(8) function sc_cdotc(   in1, in2) ; IC8_2 ; end
!!     complex(4) function sc_cdotc_r4(in1, in2) ; IC4_2 ; end
!!     complex(8) function sc_cdotc_spincol_field(   in1, in2) ; IS8_2 ; end
!!     complex(4) function sc_cdotc_spincol_field_r4(in1, in2) ; IS4_2 ; end
!!  end interface sc_cdotc

end

!===============================================================================
