// Float vals[Nspin4][Ncolour][Ncolour][Ncomplex];
// Float vals[ND][Ncolour][Ncomplex];
# include <sys/types.h>
# include <stdio.h>
# include <string.h>
# include <wfm.h>
# include "bqcd_bagel.h"

extern "C" void INIT_WFM(int& lx, int& ly, int& lz, int& lt, int npe[4])
{
  WilsonArg wil;
  wil.local_latt[0] = lx;
  wil.local_latt[1] = ly;
  wil.local_latt[2] = lz;
  wil.local_latt[3] = lt;
  for(int i = 0; i < 4; i++) { 
      if ( npe[i] == 1 ){
	  wil.local_comm[i] =1;
      }
      else{
	  wil.local_comm[i] =0;
      }
  }
  wil.BGL = true;
  //  wil.SloppyPrecision = false;
  wfm_init(&wil);
}
extern "C" void BAGEL_D(Float * & chi, Float * & u, Float * & psi, int& cb, int& dag)
{
  //printf( "%s\n", "now perform wfm_dslash");
  wfm_dslash((Float *)&chi, 
	     (Float *)&u, 
	     (Float *)&psi, 
	     cb,dag);
  //printf( "%s\n", "performed wfm_dslash");
  //print_result("Chi_cb0",(Float *)Chi,24*lxyzt);
}
extern "C" void BAGEL_D_R4(float * & chi, float * & u, float * & psi, int& cb, int& dag)
{
  printf( "%s\n", "single prec wfm is not supported");
  int stat;
  QMP_abort(stat);
}
//extern "C" void END_WFM(int& lx, int& ly, int& lz, int& lt)
extern "C" void END_WFM()
{
  WilsonArg wil;
  wfm_end(&wil);  
}
