anchor.diff:    use bitmasks
     implicit none
   
  -  integer(1), intent(in) :: phasemask(N_int*bit_kind_size, 2)
  +  integer(1), intent(in) :: phasemask(2,*)
     integer, intent(in) :: s1, s2, h1, h2, p1, p2
     logical :: change
  -  integer(1) :: np
  -  double precision, parameter :: res(0:1) = (/1d0, -1d0/)
  -
  -  np = phasemask(h1,s1) + phasemask(p1,s1) + phasemask(h2,s2) + phasemask(p2,s2)
  -  if(p1 < h1) np = np + 1_1
  -  if(p2 < h2) np = np + 1_1
  -  
  -  if(s1 == s2 .and. max(h1, p1) > min(h2, p2)) np = np + 1_1
  -  get_phase_bi = res(iand(np,1_1))
  +  integer(1) :: np1
  +  integer :: np
  +  double precision, save :: res(0:1) = (/1d0, -1d0/)
  +
  +  np1 = phasemask(s1,h1) + phasemask(s1,p1) + phasemask(s2,h2) + phasemask(s2,p2)
  +  np = np1
  +  if(p1 < h1) np = np + 1
  +  if(p2 < h2) np = np + 1
  +  
  +  if(s1 == s2 .and. max(h1, p1) > min(h2, p2)) np = np + 1
  +  get_phase_bi = res(iand(np,1))
   end 
   
   
  
positive.code:   implicit none
  
    integer(bit_kind), intent(in) :: gen(N_int, 2), mask(N_int, 2)
    integer(1), intent(in) :: phasemask(N_int*bit_kind_size, 2)
    logical, intent(in) :: bannedOrb(mo_tot_num, 2), banned(mo_tot_num, mo_tot_num,2)
    integer(bit_kind) :: det(N_int, 2)
    double precision, intent(in) :: coefs(N_states)
  
negative.code:   implicit none
  
    integer(bit_kind), intent(in) :: mask(N_int, 2), gen(N_int, 2)
    integer(1),intent(in) :: phasemask(2,N_int*bit_kind_size)
    logical, intent(in) :: bannedOrb(mo_tot_num, 2), banned(mo_tot_num, mo_tot_num,2)
    integer(bit_kind) :: det(N_int, 2)
    double precision, intent(in) :: coefs(N_states)
  