!===============================================================================
! 
! hmc_init_phi.F90  -  initialises phi and calculates actions
!
!-------------------------------------------------------------------------------
!
! Copyright (C) 2006-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 hmc_init_phi(sf1, sf2, sf3)
  use module_action
  use module_switches
  implicit none
  integer :: i
  REAL, intent(out)             :: sf1, sf2, sf3


  if (.not. switches%dynamical) return

  TIMING_START(timing_bin_hmc_init_phi)
  DEBUG2S("Start : hmc_init_phi")

  sf1 = ZERO ; sf2 = ZERO ; sf3 = ZERO
  call calc_fermi_action(.true.)
!!  call hmc_sum_sf3(sf1,sf2,sf3)


  sf1 = action%pfermi(1)%sf
  sf2 = action%pfermi(2)%sf

  sf3 = 0
  do i = 3, n_pfermi
     sf3 = sf3 + action%pfermi(i)%sf
  enddo

  DEBUG2S("End : hmc_init_phi")
  TIMING_STOP(timing_bin_hmc_init_phi)

end

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