!===============================================================================
!
! flip_bc_schfun.F90  ---  a boundary condition for Schroedinger function
!
!-------------------------------------------------------------------------------
!
! Copyright (C) 2007 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 flip_bc1_schfun(u)
  use module_schr_bc
  use module_vol
  implicit none

  GAUGE_FIELD, intent(inout)  :: u
  integer :: count, i, eo

  do eo = EVEN,ODD

     !
     ! P+ psi(T)=0
     !

     !$omp parallel do private(i)
     do count = 1, bc_len_t_all(eo)
        i = bc_list_t_all(count, eo)
        u(:, :, i, eo, 4)=ZERO
     enddo

     !
     ! P- psi(0)=0
     !

     !$omp parallel do private(i)
     do count = 1, bc_len_b_all(eo)
        i = bc_list_b_all(count, eo)
        u(:, :, i, eo, 1:4)=ZERO
     enddo

     !
     ! out side of box
     !

     !$omp parallel do private(i)
     do count = 1, bc_len_bb(eo)
        i = bc_list_bb(count, eo)
        u(:, :, i, eo, 1:4)=ZERO
     enddo
     !$omp parallel do private(i)
     do count = 1, bc_len_tp(eo)
        i = bc_list_tp(count, eo)
        u(:, :, i, eo, 1:4)=ZERO
     enddo
  enddo

end

!-------------------------------------------------------------------------------
subroutine flip_bc2_schfun(u_flip, u)
  use module_vol
  implicit none

  GAUGE_FIELD, intent(in)  :: u
  GAUGE_FIELD, intent(out) :: u_flip

  u_flip = u
  call flip_bc1_schfun(u_flip)

end

!!!-------------------------------------------------------------------------------
!!subroutine flip_bc1_schfun_pcac(u)
!!  use module_schr_bc
!!  use module_vol
!!  implicit none
!!
!!  GAUGE_FIELD, intent(inout)  :: u
!!  integer :: mu, count, i, eo
!!
!!  mu = 4
!!  do eo = EVEN,ODD
!!
!!     !
!!     ! out side of box
!!     !
!!
!!     !$omp parallel do private(i)
!!     do count = 1, bc_len_bb(eo)
!!        i = bc_list_bb(count, eo)
!!        u(:, :, i, eo, 1:4)=ZERO
!!     enddo
!!     !$omp parallel do private(i)
!!     do count = 1, bc_len_tp(eo)
!!        i = bc_list_tp(count, eo)
!!        u(:, :, i, eo, 1:4)=ZERO
!!     enddo
!!  enddo
!!
!!end
!!
!!!-------------------------------------------------------------------------------
!!subroutine flip_bc2_schfun_pcac(u_flip, u)
!!  use module_vol
!!  implicit none
!!
!!  GAUGE_FIELD, intent(in)  :: u
!!  GAUGE_FIELD, intent(out) :: u_flip
!!
!!  u_flip = u
!!  call flip_bc1_schfun_pcac(u_flip)
!!
!!end
!!
!===============================================================================
