!===============================================================================
!
! copy
!
!-------------------------------------------------------------------------------
!
! Copyright (C) 2008 Hinnerk Stueben
!               2009 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"

# define GAUGE_FIELD_R4 complex(4), dimension (NCOL, NCOL, volh_tot, EVEN:ODD, DIM)
!-------------------------------------------------------------------------------
subroutine gauge_copy_r8_to_r4(u4, u8)

  use module_vol
  implicit none
  GAUGE_FIELD_R4, intent(out) :: u4
  GAUGE_FIELD   , intent(in)  :: u8
  integer        :: i, mu, eo, c1, c2

  do mu = 1, DIM
     do eo = EVEN, ODD
        !$omp parallel do private(c1, c2)
        do i = 1, volh_tot
           do c2 = 1, NCOL
              do c1 = 1, NCOL
                 u4(c1, c2, i, eo, mu) = u8(c1, c2, i, eo, mu)
              enddo
           enddo
        enddo
     enddo
  enddo

end

!-------------------------------------------------------------------------------
subroutine copy_r8_to_r4(out, in, n)
  implicit none
  REAL4, intent(out)  :: out(*)
  REAL8, intent(in)   :: in(*)
  integer, intent(in) :: n
  integer             :: i

  !$omp parallel do
  do i = 1, n
     out(i) = in(i)
  enddo
end

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