!===============================================================================
!
! sc_copy.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/>.
!
!-------------------------------------------------------------------------------
# include "defs.h"

!-------------------------------------------------------------------------------
subroutine sc_copy_r4_to_r8(out, in)

  use module_sc_size
  implicit none
  integer :: i
  real(8), intent(out) :: out(*)
  real(4), intent(in) :: in(*)

  TIMING_START(timing_bin_sc_copy)

  !$omp parallel do
  do i = 1, sc_n_real
     out(i) = real(in(i), kind=8)
  enddo

  TIMING_STOP(timing_bin_sc_copy)

end

!-------------------------------------------------------------------------------
subroutine sc_copy_r8_to_r4(out, in)

  use module_sc_size
  implicit none
  integer :: i
  real(4), intent(out) :: out(*)
  real(8), intent(in) :: in(*)

  TIMING_START(timing_bin_sc_copy)

  !$omp parallel do
  do i = 1, sc_n_real
     out(i) = real(in(i), kind=4)
  enddo

  TIMING_STOP(timing_bin_sc_copy)

end

!-------------------------------------------------------------------------------
subroutine sc_copy_r4_to_r8_spincol_field(out, in)
  use module_vol
  implicit none
  complex(8), dimension(NDIRAC, NCOL, volh_tot), intent(out) :: out(*)
  complex(4), dimension(NDIRAC, NCOL, volh_tot), intent(in) :: in(*)

  call sc_copy_r4_to_r8(out, in)

end

!-------------------------------------------------------------------------------
subroutine sc_copy_r8_to_r4_spincol_field(out, in)
  use module_vol
  implicit none
  complex(4), dimension(NDIRAC, NCOL, volh_tot), intent(out) :: out(*)
  complex(8), dimension(NDIRAC, NCOL, volh_tot), intent(in) :: in(*)

  call sc_copy_r8_to_r4(out, in)

end

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