Exemplo n.º 1
0
void load_in_zonked_light_ssink(int color, int spin, int k_zonked_light,
			   field_offset dest)
{
  w_prop_file *zonked_fp_in ; /*** Quark propagator IO stuff **/

  /************************************************************/

  zonked_fp_in = 
    r_open_wprop(reloadflag_zonked_light_ssink, 
		qfile_zonked_light_ssink[k_zonked_light] ); 
  node0_printf("Loading from %s\n",qfile_zonked_light_ssink[ k_zonked_light ]);
  if(reload_wprop_sc_to_site(reloadflag_zonked_light_ssink, zonked_fp_in,
		       spin, color, dest, 1) != 0 )  
    terminate(1);  

  r_close_wprop(reloadflag_zonked_light_ssink,zonked_fp_in); 

}  /***** end of load_in_zonked_light_ssink  ******/
Exemplo n.º 2
0
void load_in_zonked_heavy_local(int color, int spin, int k_zonked_heavy,
			   field_offset dest)
{
  w_prop_file *zonked_fp_in ; /*** Quark propagator IO stuff **/

  /************************************************************/

  zonked_fp_in = 
    r_open_wprop(startflag_zonked_heavy[k_zonked_heavy], 
		qfile_zonked_heavy[k_zonked_heavy] ); 
  node0_printf("Loading from %s\n",qfile_zonked_heavy[ k_zonked_heavy ]);
  if(reload_wprop_sc_to_site(startflag_zonked_heavy[k_zonked_heavy], zonked_fp_in,
		       spin, color, dest, 1) != 0 )  
    terminate(1);  

  r_close_wprop(startflag_zonked_heavy[k_zonked_heavy],zonked_fp_in); 

}  /***** end of load_in_zonked_heavy_local  ******/
Exemplo n.º 3
0
int main(int argc,char *argv[])
{
  int meascount;
  int prompt;
  Real avm_iters,avs_iters;
  
  double starttime,endtime,dclock();
  double dtime;
  
  int MinCG,MaxCG;
  Real RsdCG;
  
  register int i;
  register site *s;
  
  int spinindex,spin,color,j,k,t,t_off;
  int kh,kl;
  int nr_fb;
  char nr_fb_label[3][2] = { "0", "F", "B" };
  int flag;
  int kprop;
  int num_prop;
  Real space_vol;

  int status;

  propagator hdibar_prop[MAX_KAP][MAX_KAP][HDIPROPS];
  propagator nrbar_prop[MAX_KAP][MAX_KAP][NRPROPS];
  
  char scratch_file[MAX_KAP][MAXFILENAME];
  
  Real norm_fac[10];
  static char *mes_kind[10] = {"PION","PS505","PS055","PS0505",
			       "RHO33","RHO0303","SCALAR","SCALA0","PV35","B12"};

  complex *pmes_prop[MAX_KAP][MAX_KAP][10];
  int pmes_prop_done[MAX_KAP][MAX_KAP];

  w_prop_file *fp_in_w[MAX_KAP];  /* For reading binary propagator files */
  w_prop_file *fp_out_w[MAX_KAP]; /* For writing binary propagator files */
  w_prop_file *fp_scr[MAX_KAP];
  
  initialize_machine(&argc,&argv);
#ifdef HAVE_QDP
  QDP_initialize(&argc, &argv);
#endif
  /* Remap standard I/O */
  if(remap_stdio_from_args(argc, argv) == 1)terminate(1);
  
  g_sync();
  /* set up */
  prompt = setup_H_cl();
  

  /* loop over input sets */
  
  while( readin(prompt) == 0)
    {

      MaxCG = niter;
      starttime=dclock();

      avm_iters=0.0;
      meascount=0;
      
      /* Allocate space for relativistic meson propagator */
      for(num_prop=0;num_prop<10;num_prop++)
	for(i=0;i<num_kap;i++)for(j=0;j<=i;j++){
	  pmes_prop[i][j][num_prop] = (complex *)malloc(nt*sizeof(complex));
	  for(t=0;t<nt;t++){
	    pmes_prop[i][j][num_prop][t] = cmplx(0.0,0.0); 
	  }
	  pmes_prop_done[i][j] = 0;
	}

      /* Allocate space for non relativistic baryon propagators */
      for(kprop=0;kprop<NRPROPS;kprop++)
	for(i=0;i<num_kap;i++)for(j=0;j<num_kap;j++){
	  nrbar_prop[i][j][kprop].c
	    = (complex *)malloc(nt*sizeof(complex));
	  if(nrbar_prop[i][j][kprop].c == NULL)
	    {
	      printf("control_H_cl: Can't malloc nrbar prop %d %d %d\n",
		     i,j,kprop);
	      terminate(1);
	    }
	  for(t=0;t<nt;t++)nrbar_prop[i][j][kprop].c[t] 
	    = cmplx(0.0,0.0); 
	  nrbar_prop[i][j][kprop].label
	    = (char *)malloc(10*sizeof(char));
	  if(nrbar_prop[i][j][kprop].c == NULL)
	    {
	      printf("control_H_cl: Can't malloc nrbar prop label %d %d %d\n",
		     i,j,kprop);
	      terminate(1);
	    }
	}
      
      /* Allocate space for H-dibaryon channel propagators */
      for(kprop=0;kprop<HDIPROPS;kprop++)
	for(kh=0;kh<num_kap_heavy;kh++)for(kl=0;kl<num_kap_light;kl++){
	  /* kappa indexing scheme is consistent with baryon propagator
	     even though we compute only the propagators with
	     one heavy (s) quark and two light (u,d) quarks */
	  i = kh; j = kl + num_kap_heavy;
	  hdibar_prop[i][j][kprop].c
	    = (complex *)malloc(nt*sizeof(complex));
	  if(hdibar_prop[i][j][kprop].c == NULL)
	    {
	      printf("control_H_cl: Can't malloc baryon prop %d %d %d\n",
		     i,j,kprop);
	      terminate(1);
	    }
	  for(t=0;t<nt;t++)hdibar_prop[i][j][kprop].c[t] 
	    = cmplx(0.0,0.0); 
	  hdibar_prop[i][j][kprop].label
	    = (char *)malloc(10*sizeof(char));
	  if(hdibar_prop[i][j][kprop].label == NULL)
	    {
	      printf("control_H_cl: Can't malloc baryon prop label %d %d %d\n",
		     i,j,kprop);
	      terminate(1);
	    }
	}
      
      if( fixflag == COULOMB_GAUGE_FIX)
	{
	  if(this_node == 0) 
	    printf("Fixing to Coulomb gauge\n");
	  STARTIOTIME;
	  gaugefix(TUP,(Real)1.5,500,GAUGE_FIX_TOL);
	  STOPIOTIME("gauge fix");
	  invalidate_this_clov(gen_clov);
	}
      else
	if(this_node == 0)printf("COULOMB GAUGE FIXING SKIPPED.\n");
      
      /* save lattice if requested */
      if( saveflag != FORGET ){
	/* Note: beta, kappa are kept only for save_old_binary */
	STARTIOTIME;
	savelat_p = save_lattice( saveflag, savefile, stringLFN );
	STOPIOTIME("save lattice");
      }

      if(this_node==0)printf("END OF HEADER\n");
      
      /* Loop over all kappas to compute and store quark propagator */
      for(k=0;k<num_kap;k++){
	
	kappa = kap[k];
	source_r0=wqs[k].r0;
	RsdCG=resid[k];
	if(this_node==0)printf("Kappa=%e r0=%e residue=%e\n",
			       (double)kappa,(double)source_r0,(double)RsdCG);
	
	/* open file for kth wilson propagator */
	
	fp_in_w[k]  = r_open_wprop(startflag_w[k], startfile_w[k]);
	fp_out_w[k] = w_open_wprop(saveflag_w[k],  savefile_w[k],
				   wqs[k].type);
	
	/* Open scratch file and write header */
	sprintf(scratch_file[k],"%s_%02d",scratchstem_w,k);
	if(scratchflag == SAVE_CHECKPOINT)
	  {
	    fp_scr[k] = w_checkpoint_w_i(scratch_file[k]);
	    /* Close, temporarily */
	    w_checkpoint_w_c(fp_scr[k]);
	  }
	else
	  /* If serial, write header and leave it open */
	  fp_scr[k] = w_serial_w_i(scratch_file[k]);
	
	/* Loop over source colors */
	for(color=0;color<3;color++){
	  
	  for(spinindex=0;spinindex<n_spins;spinindex++){
	    spin = spins[spinindex];
	    
	    meascount ++;
	    if(this_node==0)printf("color=%d spin=%d\n",color,spin);

	    if(startflag_w[k] == CONTINUE)
	      {
		if(k == 0)
		  {
		    node0_printf("Can not continue propagator here! Zeroing it instead\n");
		    startflag_w[k] = FRESH;
		  }
		else
		  {
		    FORALLSITES(i,s)
		      copy_wvec(&(s->quark_propagator.c[color].d[spin]),
				&(s->psi));
		  }
	      }

	    /* Saves one multiplication by zero in cgilu */
	    if(startflag_w[k] == FRESH)flag = 0;
	    else 
	      flag = 1;      
	    
	    /* load psi if requested */
#ifdef IOTIME
	    status = reload_wprop_sc_to_site( startflag_w[k], fp_in_w[k], 
			       spin, color, F_OFFSET(psi),1);
#else
	    status = reload_wprop_sc_to_site( startflag_w[k], fp_in_w[k], 
			       spin, color, F_OFFSET(psi),0);
#endif	    
	    if(status != 0)
	      {
		node0_printf("control_H_cl: Recovering from error by resetting initial guess to zero\n");
		reload_wprop_sc_to_site( FRESH, fp_in_w[k], 
			       spin, color, F_OFFSET(psi),0);
		flag = 0;
	      }

	    
	    /* Invert to find propagator */

	    /* Complete the source structure */
	    wqs[k].color = color;
	    wqs[k].spin = spin;

	    /* For clover_info */
	    wqstmp = wqs[k];

	   /* If we are starting afresh, we set a minimum number
	      of iterations */
	   if(startflag_w[k] == FRESH || status != 0)MinCG = nt; 
	   else MinCG = 0;

	    /* Load inversion control structure */
	    qic.prec = PRECISION;
	    qic.min = MinCG;
	    qic.max = MaxCG;
	    qic.nrestart = nrestart;
	    qic.resid = RsdCG;
	    qic.start_flag = flag;
	    
	    /* Load Dirac matrix parameters */
	    dcp.Kappa = kappa;
	    dcp.Clov_c = clov_c;
	    dcp.U0 = u0;

#ifdef BI
	    /* compute the propagator.  Result in psi. */
	    avs_iters 
	      = (Real)wilson_invert_site_wqs(F_OFFSET(chi),F_OFFSET(psi),
					  w_source,&wqs[k],
					  bicgilu_cl_site,&qic,(void *)&dcp);
#else
	    /* compute the propagator.  Result in psi. */
	    avs_iters = 
	      (Real)wilson_invert_site_wqs(F_OFFSET(chi),F_OFFSET(psi),
					w_source,&wqs[k],
					cgilu_cl_site,&qic,(void *)&dcp);
#endif
	    avm_iters += avs_iters;
	    
	    FORALLSITES(i,s)
	      copy_wvec(&(s->psi),
			&(s->quark_propagator.c[color].d[spin]));
	    
	    STARTIOTIME;
	    /* Write psi to scratch disk */
	    if(scratchflag == SAVE_CHECKPOINT)
	      {
		w_checkpoint_w_o(fp_scr[k]);
		w_checkpoint_w(fp_scr[k],spin,color,F_OFFSET(psi));
		w_checkpoint_w_c(fp_scr[k]);
	      }
	    else
	      w_serial_w(fp_scr[k],spin,color,F_OFFSET(psi));
	    STOPIOTIME("do fast quark dump");
	    /* save psi if requested */
#ifdef IOTIME
	    save_wprop_sc_from_site( saveflag_w[k],fp_out_w[k],
			     spin,color,F_OFFSET(psi),1);
#else
	    save_wprop_sc_from_site( saveflag_w[k],fp_out_w[k],
			     spin,color,F_OFFSET(psi),0);
#endif
	  } /* source spins */
	} /* source colors */
	
	/* Close and release scratch file */
	if(scratchflag == SAVE_CHECKPOINT)
	  w_checkpoint_w_f(fp_scr[k]);
	else
	  w_serial_w_f(fp_scr[k]);

	if(this_node==0)printf("Saved binary wilson_vector in file  %s\n",
			       scratch_file[k]);
	
	/* close files for wilson propagators */
	r_close_wprop(startflag_w[k],fp_in_w[k]);
	w_close_wprop(saveflag_w[k],fp_out_w[k]);
	
      } /* kappas */
      
      
      /* Loop over choice forward - backward for NR source and sink */

      for(nr_fb = 1; nr_fb <= 2; nr_fb++)if(nr_fb & nr_forw_back)
	{
	  
	  /* Reset completion flags */
	    for(i=0;i<num_kap;i++)for(j=0;j<num_kap;j++){
	      for(kprop=0;kprop<NRPROPS;kprop++)
		nrbar_prop[i][j][kprop].done = 0;
	      for(kprop=0;kprop<HDIPROPS;kprop++)
		hdibar_prop[i][j][kprop].done = 0;
	    }

	  /* Loop over heavy kappas for the point sink spectrum */
	  for(k=0;k<num_kap_heavy;k++){
	    
	    /* Read the kth heavy kappa propagator from the scratch file */
	    kappa = kappa_heavy = kap[k];
	    if(scratchflag == SAVE_CHECKPOINT)
	      fp_scr[k] = r_parallel_w_i(scratch_file[k]);
	    else
	      fp_scr[k] = r_serial_w_i(scratch_file[k]);
	    
	    STARTIOTIME;
	    for(color=0;color<3;color++) for(spin=0;spin<4;spin++){
	      if(scratchflag == SAVE_CHECKPOINT)
		r_parallel_w(fp_scr[k], spin, color,
			     F_OFFSET(quark_propagator.c[color].d[spin])); 
	      else
		r_serial_w(fp_scr[k], spin, color,
			   F_OFFSET(quark_propagator.c[color].d[spin])); 
	    }
	    STOPIOTIME("to read 12 spin-color combinations");

	    if(scratchflag == SAVE_CHECKPOINT)
	      r_parallel_w_f(fp_scr[k]); 
	    else
	      r_serial_w_f(fp_scr[k]); 
	    
	    /* Convert to NR propagator */
	    
	    STARTPRTIME;
	    nr_propagator(F_OFFSET(quark_propagator),
			  F_OFFSET(nr_prop1), nr_fb);
	    diquarkprop(F_OFFSET(nr_prop1),
			F_OFFSET(diquark_prop1));
	    STOPPRTIME("make nr and diquark");
	    
	    /* Diagonal spectroscopy - not needed */
	    
/**	    w_nrbaryon(F_OFFSET(nr_prop1), F_OFFSET(nr_prop1),
		       F_OFFSET(diquark_prop1), nrbar_prop[k][k]); **/
	    
/**	    w_hdibaryon(F_OFFSET(diquark_prop1),
			F_OFFSET(diquark_prop1), hdibar_prop[k][k]); **/
	    
	    /* Heavy-light spectroscopy */
	    /* Loop over light kappas for the point sink spectrum */
	    for(j=num_kap_heavy;j<num_kap;j++){

	      /* Read the propagator from the scratch file */
	      kappa = kappa_light = kap[j];
	      if(scratchflag == SAVE_CHECKPOINT)
		fp_scr[j] = r_parallel_w_i(scratch_file[j]);
	      else
		fp_scr[j] = r_serial_w_i(scratch_file[j]);
	      
	      STARTIOTIME;
	      for(color=0;color<3;color++) for(spin=0;spin<4;spin++){
		if(scratchflag == SAVE_CHECKPOINT)
		  r_parallel_w(fp_scr[j], spin, color,
			       F_OFFSET(quark_prop2.c[color].d[spin])); 
		else
		  r_serial_w(fp_scr[j], spin, color,
			     F_OFFSET(quark_prop2.c[color].d[spin])); 
	      }
	      STOPIOTIME("do fast quark read");
	      if(scratchflag == SAVE_CHECKPOINT)
		r_parallel_w_f(fp_scr[j]);
	      else
		r_serial_w_f(fp_scr[j]);
	      
	      /* Convert to NR propagator */
	      
	      STARTPRTIME;
	      nr_propagator(F_OFFSET(quark_prop2),
			    F_OFFSET(nr_prop2),nr_fb);
	      diquarkprop(F_OFFSET(nr_prop2),
			  F_OFFSET(diquark_prop2));
	      STOPPRTIME("make nr and diquark propagators");
	      
	      /* Diagonal spectroscopy - baryons only - done if
		 any of them was not previously done */
	    
	      for(kprop=0;kprop<NRPROPS;kprop++)
		{
		  if(nrbar_prop[j][j][kprop].done == 0)
		    {
		      STARTPRTIME;
		      w_nrbaryon(F_OFFSET(nr_prop2), F_OFFSET(nr_prop2),
				 F_OFFSET(diquark_prop2), nrbar_prop[j][j]);
		      STOPPRTIME("do diagonal baryons");
		      break;
		    }
		}
	    
	      /* Heavy-light spectroscopy - baryons and H */

	      /* We don't do baryon heavy-light if the kappa values
		 are the same, since the result is the same as the
		 diagonal light propagator */
	      
	      if(kappa_heavy != kappa_light)
		{
		  /* Relativistic meson propagator: Do only once */		  
		  if(pmes_prop_done[j][k] == 0) {
		    STARTPRTIME;
		    for(color=0;color<3;color++){
		      w_meson_site(F_OFFSET(quark_propagator.c[color]),
			      F_OFFSET(quark_prop2.c[color]), pmes_prop[j][k]);
		    }
		    pmes_prop_done[j][k] = 1;
		    STOPPRTIME("do off-diagonal relativistic meson");
		  }

		  STARTPRTIME;
		  w_nrbaryon(F_OFFSET(nr_prop2),
			     F_OFFSET(nr_prop1),F_OFFSET(diquark_prop1),  
			     nrbar_prop[j][k]);
		  
		  w_nrbaryon(F_OFFSET(nr_prop1),
			     F_OFFSET(nr_prop2),F_OFFSET(diquark_prop2),  
			     nrbar_prop[k][j]);
		  STOPPRTIME("do two sets of hl baryons");
		}
	      
	      /* For H we do only the case prop2 = u (light) index j
		 and prop1 = s (heavy) index k */

	      STARTPRTIME;
	      w_hdibaryon(F_OFFSET(diquark_prop2),
			  F_OFFSET(diquark_prop1), hdibar_prop[k][j]);
	      STOPPRTIME("do one set of hl H dibaryons");
	      
	    } /* light kappas */
	  } /* heavy kappas */

	  /* Stick with same convention as clover_invert/control_cl_hl.c */
	  space_vol = (Real)(nx*ny*nz);
	  for(num_prop=0;num_prop<10;num_prop++) norm_fac[num_prop] = space_vol;
	  norm_fac[4] *= 3.0;
	  norm_fac[5] *= 3.0;
	  norm_fac[8] *= 3.0;
	  norm_fac[9] *= 3.0;

	  /* print relativistic meson propagators */
	  for(num_prop=0;num_prop<10;num_prop++)
	    for(i=0;i<num_kap;i++)
	      for(j=0;j<=i;j++)
		if(pmes_prop_done[i][j] == 1){
		  for(t = 0; t < nt; t++){
		    t_off = (t + source_time)%nt;
		    g_floatsum( &pmes_prop[i][j][num_prop][t_off].real );
		    pmes_prop[i][j][num_prop][t_off].real  /= norm_fac[num_prop];
		    g_floatsum( &pmes_prop[i][j][num_prop][t_off].imag );
		    pmes_prop[i][j][num_prop][t_off].imag  /= norm_fac[num_prop];
		    if(this_node == 0)
		      printf("POINT%s %d %d %d  %e %e\n",
			     mes_kind[num_prop],i,j,t,
			     (double)pmes_prop[i][j][num_prop][t_off].real,
			     (double)pmes_prop[i][j][num_prop][t_off].imag);
		  }
		}

	  /* Once printed, this propagator should be neither
             calculated nor printed again */
	  for(i=0;i<num_kap;i++)
	    for(j=0;j<=i;j++)
	      if(pmes_prop_done[i][j] == 1)
		pmes_prop_done[i][j] = 2;
	  

	  /* print non-relativistic baryon propagators */
	  if(this_node == 0)
	    for(kprop=0;kprop<NRPROPS;kprop++)
	      for(i=0;i<num_kap;i++){
		for(j=0;j<i;j++)
		  if(nrbar_prop[i][j][kprop].done==1){
		    for(t = 0; t < nt; t++){
		      t_off = (t + source_time)%nt;
		      /* Periodic boundary conditions - no wraparound sign */
		      printf("%s_NR%s %d %d %d %d  %e %e\n",
			     nr_fb_label[nr_fb],
			     nrbar_prop[i][j][kprop].label,i,j,j,t,
			     (double)nrbar_prop[i][j][kprop].c[t_off].real,
			     (double)nrbar_prop[i][j][kprop].c[t_off].imag);
		    }
		  }
		
		if(nrbar_prop[i][i][kprop].done==1)
		  for(t = 0; t < nt; t++){
		    t_off = (t + source_time)%nt;
		    printf("%s_NR%s %d %d %d %d  %e %e\n",
			   nr_fb_label[nr_fb],
			   nrbar_prop[i][j][kprop].label,i,i,i,t,
			   (double)nrbar_prop[i][i][kprop].c[t_off].real,
			   (double)nrbar_prop[i][i][kprop].c[t_off].imag);
		  }
		
		for(j=i+1;j<num_kap;j++)
		  if(nrbar_prop[i][j][kprop].done==1)
		    for(t = 0; t < nt; t++){
		      t_off = (t + source_time)%nt;
		      printf("%s_NR%s %d %d %d %d  %e %e\n",
			     nr_fb_label[nr_fb],
			     nrbar_prop[i][j][kprop].label,j,j,i,t,
			     (double)nrbar_prop[i][j][kprop].c[t_off].real,
			     (double)nrbar_prop[i][j][kprop].c[t_off].imag);
		    }
	      }

	  
	  /* print H-dibaryon mixed channel propagators */
	  if(this_node == 0)
	    for(kprop=0;kprop<HDIPROPS;kprop++)
	      for(i=0;i<num_kap;i++){
		for(j=0;j<num_kap;j++)if(hdibar_prop[i][j][kprop].done==1){
		  for(t = 0; t < nt; t++){
		    t_off = (t + source_time)%nt;
		    printf("%s_%s %d %d %d %d %e %e\n",
			   nr_fb_label[nr_fb],
			   hdibar_prop[i][j][kprop].label,i,j,j,t,
			   (double)hdibar_prop[i][j][kprop].c[t_off].real,
			   (double)hdibar_prop[i][j][kprop].c[t_off].imag);
		  }
		}
	      }
	} /* Loop over nr forward - backward */

      /* Cleanup */
      for(kprop=0;kprop<NRPROPS;kprop++)
	for(i=0;i<num_kap;i++)for(j=0;j<num_kap;j++){
	  free(nrbar_prop[i][j][kprop].c);
	  free(nrbar_prop[i][j][kprop].label);
	}
      
      for(kprop=0;kprop<HDIPROPS;kprop++)
	for(kh=0;kh<num_kap_heavy;kh++)for(kl=0;kl<num_kap_light;kl++){
	  i = kh; j = kl + num_kap_heavy;
	  free(hdibar_prop[i][j][kprop].c);
	  free(hdibar_prop[i][j][kprop].label);
	}
      
      if(this_node==0)printf("RUNNING COMPLETED\n");
      if(meascount>0){
	if(this_node==0)printf("total cg iters for measurement= %e\n",
			       (double)avm_iters);
	if(this_node==0)printf("cg iters for measurement= %e\n",
			       (double)avm_iters/(double)meascount);
      }
      
      endtime=dclock();
      if(this_node==0){
	printf("Time = %e seconds\n",(double)(endtime-starttime));
	printf("total_iters = %d\n",total_iters);
      }
      fflush(stdout);
      
    }
    return 0;
} /* control_H_cl */
Exemplo n.º 4
0
void load_in_zonked_light(int color, int k_zonked_light)
{
  int spin ; 
  int restart_flag_zonked_light ; 
  int MinCG;
  w_prop_file *zonked_fp_in ; /*** Quark propagator IO stuff **/

  /************************************************************/

      
  /*** load in the zonked quark propagator ********/
  kappa = kappa_zonked_light[k_zonked_light] ;
  
  /** open the light quark zonked propagator ***/
  
  zonked_fp_in = r_open_wprop(startflag_zonked_light[ k_zonked_light ],
			     qfile_zonked_light[ k_zonked_light ]);

  node0_printf("Loading from %s\n",qfile_zonked_light[ k_zonked_light ]);

  for(spin = 0 ; spin < 4 ; ++spin )
  {
    /*** load the light zonked quark propagagor from disk ***/
    if(reload_wprop_sc_to_site( startflag_zonked_light[k_zonked_light],
			 zonked_fp_in, spin, color, 
			 F_OFFSET(quark_zonked.d[spin]), 1)!=0)
      terminate(1);
    
    /**** check the wilson vector loaded in , by using it
      as a new solution to the inverter *****/
    /* Complete the definition of source structure */
    wqs_zonked_light[k_zonked_light].color = color;
    wqs_zonked_light[k_zonked_light].spin = spin;

    /* For clover_info if we ever use it */
    wqstmp = wqs_zonked_light[k_zonked_light];
    
    /* If we are starting afresh, we set a minimum number
       of iterations */
    if(startflag_zonked_light[k_zonked_light] == FRESH)MinCG = nt; 
    else MinCG = 0;

    /* Load inversion control structure */
    qic_zonked_light.prec = PRECISION;
    qic_zonked_light.min = MinCG;
    qic_zonked_light.max = niter_zonked_light;
    qic_zonked_light.nrestart = nrestart_zonked_light;
    qic_zonked_light.resid = resid_zonked_light;
    qic_zonked_light.start_flag = startflag_zonked_light[k_zonked_light];

#ifdef CLOVER
    /* Load Dirac matrix parameters */
    dcp.Kappa = kappa_zonked_light[k_zonked_light];
    dcp.Clov_c = clov_c;
    dcp.U0 = u0;

    wilson_invert_site_wqs(F_OFFSET(chi), F_OFFSET(quark_zonked.d[spin]),
		       w_source,&wqs_zonked_light[k_zonked_light],
		       bicgilu_cl_site,&qic_zonked_light,(void *)&dcp);
#else
    /* Load Dirac matrix parameters */
    dwp.Kappa = kappa_zonked_light[k_zonked_light];

    wilson_invert_site_wqs(F_OFFSET(chi), F_OFFSET(quark_zonked.d[spin]),
		       w_source,&wqs_zonked_light[k_zonked_light],
		       mrilu_w_site,&qic_zonked_light,(void *)&dwp);

#endif

  } /*** end the loop over the source spin ****/

  /** close light quark zonked propagator ***/
  r_close_wprop(startflag_zonked_light[ k_zonked_light ], zonked_fp_in);
	


}  /***** end of load_in_zonked_light  ******/
void load_in_spectator(int color, int spin, int k_spectator,
		       field_offset dest)
{
  int MinCG;
  int restart_flag_spectator ; 

  w_prop_file *spectator_fp_in ; /*** Quark propagator IO stuff **/
    
  node0_printf("Loading spectator kappa = %f\n",
	       kappa_spectator[k_spectator]);
  fflush(stdout);
  
  if( startflag_spectator[k_spectator] == FRESH )
    restart_flag_spectator = 0 ;
  else
    restart_flag_spectator = 1 ;   
  
  
  /*** open the spectator light quark file *****/
  kappa = kappa_spectator[k_spectator] ;
  
  spectator_fp_in = r_open_wprop(startflag_spectator[k_spectator], 
				qfile_spectator[k_spectator]);
  /*** Load in the spectator quark propagator ****/
  if(reload_wprop_sc_to_site(startflag_spectator[k_spectator],
		       spectator_fp_in, spin, color, dest, 1)!=0)
    terminate(1);
  
  /**** check the wilson vector loaded in, 
	by using it as a new solution to the inverter *****/
  /* Complete the definition of source structure */
  wqs_spectator[k_spectator].color = color;
  wqs_spectator[k_spectator].spin = spin;
  
  kappa = kappa_spectator[k_spectator] ;
  
  /* If we are starting afresh, we set a minimum number
     of iterations */
  if(startflag_spectator[k_spectator] == FRESH)MinCG = nt; 
  else MinCG = 0;
  
  /* Load inversion control structure */
  qic_spectator.prec = PRECISION;
  qic_spectator.min = MinCG;
  qic_spectator.max = niter_spectator;
  qic_spectator.nrestart = nrestart_spectator;
  qic_spectator.resid = resid_spectator;
  qic_spectator.start_flag = restart_flag_spectator;
  
#ifdef CLOVER
  /* Load Dirac matrix parameters */
  dcp.Kappa = kappa_spectator[k_spectator];
  dcp.Clov_c = clov_c;
  dcp.U0 = u0;
  
  wilson_invert_site_wqs(F_OFFSET(chi), dest,
		     w_source,&wqs_spectator[k_spectator],
		     bicgilu_cl_site,&qic_spectator,(void *)&dcp);
  
#else
  /* Load Dirac matrix parameters */
  dwp.Kappa = kappa_spectator[k_spectator];
  
  wilson_invert_site_wqs(F_OFFSET(chi), dest,
		     w_source,&wqs_spectator[k_spectator],
		     mrilu_w_site,&qic_spectator,(void *)&dwp);
#endif

  /*** close the spectator light quark file *****/
  r_close_wprop(startflag_spectator[k_spectator],spectator_fp_in);
      
  
}  /***** end of load_in_spectator  ******/
Exemplo n.º 6
0
int main(int argc, char *argv[])
{
int meascount;
int prompt;
Real avm_iters,avs_iters;

double ssplaq,stplaq;


double starttime,endtime;
double dtime;

int MinCG,MaxCG;
Real size_r,RsdCG;

register int i,j,l;
register site *s;

int spinindex,spin,color,k,kk,t;
int flag;
int ci,si,sf,cf;
int num_prop;
Real space_vol;

int status;

int source_chirality;

    wilson_vector **eigVec ;
    double *eigVal ;
    int total_R_iters ;
    double norm;
    Real re,im,re5,im5;
    complex cc;
    char label[20] ;

    double *grad, *err, max_error;
  Matrix Array,V ;

int key[4];
#define restrict rstrict /* C-90 T3D cludge */
int restrict[4];

Real norm_fac[10];

static char *mes_kind[10] = {"PION","PS505","PS055","PS0505",
		"RHO33","RHO0303","SCALAR","SCALA0","PV35","B12"};
static char *bar_kind[4] = {"PROTON","PROTON0","DELTA","DELTA0"};

complex *pmes_prop[MAX_MASSES][10];
complex *smes_prop[MAX_MASSES][10];
complex *bar_prop[MAX_MASSES][4];

w_prop_file *fp_in_w[MAX_MASSES];        /* For propagator files */
w_prop_file *fp_out_w[MAX_MASSES];       /* For propagator files */

    initialize_machine(&argc,&argv);

  /* Remap standard I/O */
  if(remap_stdio_from_args(argc, argv) == 1)terminate(1);

    g_sync();
    /* set up */
    prompt = setup_p();
    /* loop over input sets */


    while( readin(prompt) == 0)
    {



	starttime=dclock();
	MaxCG=niter;

	avm_iters=0.0;
	meascount=0;



	if(this_node==0)printf("END OF HEADER\n");
	setup_offset();

/*
if(this_node==0)printf("warning--no fat link\n");
*/
	monte_block_ape_b(1);
                /* call plaquette measuring process */
                d_plaquette(&ssplaq,&stplaq);
                if(this_node==0)printf("FATPLAQ  %e %e\n",
                    (double)ssplaq,(double)stplaq);




/* flip the time oriented fat links 
if(this_node==0) printf("Periodic time BC\n");
*/
if(this_node==0) printf("AP time BC\n");
boundary_flip(MINUS);





	setup_links(SIMPLE);

/*	if(this_node==0) printf("num_masses = %d\n", num_masses); */
	/* Loop over mass */
	for(k=0;k<num_masses;k++){

	  m0=mass[k];
	if(m0 <= -10.0) exit(1);
	  RsdCG=resid[k];
	  if(this_node==0)printf("mass= %g r0= %g residue= %g\n",
		(double)m0,(double)wqs[k].r0,(double)RsdCG);
	  build_params(m0);
	  make_clov1();


                eigVal = (double *)malloc(Nvecs*sizeof(double));
                eigVec = (wilson_vector **)malloc(Nvecs*sizeof(wilson_vector*));
                for(i=0;i<Nvecs;i++)
                  eigVec[i]=
                    (wilson_vector*)malloc(sites_on_node*sizeof(wilson_vector));


          /* open files for wilson propagators */
          fp_in_w[k]  = r_open_wprop(startflag_w[k], startfile_w[k]);
          fp_out_w[k] = w_open_wprop(saveflag_w[k],  savefile_w[k],
				     wqs[k].type);


                    if(startflag_w[k] == FRESH)flag = 0;
                    else
                      flag = 1;
spin=color=0; /* needed by wilson writing routines */




		/* initialize the CG vectors */
		    if(flag==0){
if(this_node==0) printf("random (but chiral) initial vectors\n");
  /* Initiallize all the eigenvectors to a random vector */
  for(j=0;j<Nvecs;j++)
    {
      if(j< Nvecs/2){ source_chirality=1;}
      else{source_chirality= -1;}
      printf("source chirality %d\n",source_chirality);
      grsource_w();
      FORALLSITES(i,s){
        copy_wvec(&(s->g_rand),&(eigVec[j][i]));
	if(source_chirality==1){
	  for(kk=2;kk<4;kk++)for(l=0;l<3;l++)
	    eigVec[j][i].d[kk].c[l]=cmplx(0.0,0.0);
	}

	if(source_chirality== -1){
	  for(kk=0;kk<2;kk++)for(l=0;l<3;l++)
	    eigVec[j][i].d[kk].c[l]=cmplx(0.0,0.0);
	}
      }
      eigVal[j]=1.0e+16;
    }
		    }
		    else{
if(this_node==0) printf("reading in %d wilson_vectors--must be <= 12\n",Nvecs);
                    /* load psi if requested */
for(j=0;j<Nvecs;j++){
printf("reading %d %d %d\n",j,spin,color);
#ifdef IOTIME
                    status = reload_wprop_sc_to_site( startflag_w[k], fp_in_w[k], 
                                      spin, color, F_OFFSET(psi),1);
#else
                    status = reload_wprop_sc_to_site( startflag_w[k], fp_in_w[k], 
                                      spin, color, F_OFFSET(psi),0);
#endif

		    /* compute eigenvalue */
		    herm_delt(F_OFFSET(psi),F_OFFSET(chi));

		  re=im=0.0;
		  FORALLSITES(i,s){
		    cc = wvec_dot( &(s->chi), &(s->psi) );
		    re += cc.real ;
		  }
		  g_floatsum(&re);
		  eigVal[j]=re;
printf("trial eigenvalue of state %d %e\n",j,eigVal[j]);
		  FORALLSITES(i,s){eigVec[j][i]=s->psi;}
spin++;
if((spin %4) == 0){spin=0;color++;}
}

		    }
Exemplo n.º 7
0
int main(int argc, char **argv)
{
  int meascount[MAX_NKAP];
  int prompt, count1, count2;
  Real avm_iters[MAX_NKAP];
  double starttime, endtime;

  int MaxMR, restart_flag;
  Real RsdMR;		/******/

  int spin, color, nk;		/******/
  int max_prop;

  int cl_cg = CL_CG;
  double ssplaq, stplaq;


  FILE *fp_m_out = NULL;  /*** meson IO stuff **/
  int fb_m_out = 0;	   /*** meson IO stuff **/

  w_prop_file *fp_in_w[MAX_NKAP];        /* For propagator files */
  w_prop_file *fp_out_w[MAX_NKAP];       /* For propagator files */
  
  double g_time ; 

  int i ;
  int MinMR;
  
/*** variables required for the static variational code ***/
  int nodata = 0 ;
  complex *meson = NULL;

/****** start of the execution of the code ************/


  initialize_machine(&argc, &argv);

  /* Remap standard I/O */
  if(remap_stdio_from_args(argc, argv) == 1)terminate(1);

  g_sync();

  /* set up */
  prompt = setup_h();

  /**DEBUG***/  
#ifdef DEBUGDEF
  light_quark_pion(0) ;
#endif

    /* loop over input sets */
  while( readin(prompt) == 0)
  {

    if( fixflag == COULOMB_GAUGE_FIX)
    {
      if(this_node == 0) 
	printf("Fixing to Coulomb gauge\n");
      g_time = -dclock();

      gaugefix(TUP,(Real)1.5,500,GAUGE_FIX_TOL);

      g_time += dclock();
      if(this_node==0)printf("Time to gauge fix = %e\n",g_time);
      invalidate_this_clov(gen_clov);
      
    }
    else
      if(this_node == 0)printf("COULOMB GAUGE FIXING SKIPPED.\n");

    /* save lattice if requested */
    if( saveflag != FORGET )
    {
      save_lattice( saveflag, savefile, stringLFN );
    }


    /* call plaquette measuring process */
    d_plaquette(&ssplaq, &stplaq);
    if (this_node == 0)
      printf("START %e %e\n",(double) ssplaq, (double) stplaq);


    /******* set up code for the static variational calculation *****/
    if( nkap == 1 )
    {
      nodata = nt*nosmear*144 ;
      /** reserve memory for the smeared meson correlators on each node ****/
      if( ( meson = (complex *) calloc( (size_t) nodata, sizeof(complex) )  ) == NULL )
      {
	printf("ERROR: could not reserve buffer space for the meson smearing functions\n");
	terminate(1);
      }
      
      /** call a number of set up routines for the static variational code ***/
      setup_vary(meson, nodata);
      
    }  /*** end of set up section for the static-variational calculation ***/

    /***DEBUG check_calc_matrix() ;   ****/  


    starttime=dclock();



    MaxMR = niter;
    RsdMR = (Real) sqrt((double) rsqprop);

    if (this_node == 0)
      printf("Residue=%e\n",(double) RsdMR);
	     

    for (nk = 0; nk < nkap; nk++)
    {
      avm_iters[nk] = 0.0;
      meascount[nk] = 0;
    }
    max_prop = 12;
    count1 = 0;
    count2 = 0;


    for (spin = start_spin; spin < 4; spin++)
    {

      for (color = 0; color < 3; color++)
      {

	count1++;
	if (count1 == 1)
	  color += start_color;

	for (nk = 0; nk < nkap; nk++)
	{

	  count2++;
	  if (count2 == 1)
	    nk += start_kap;


	  kappa = cappa[nk];

	  meascount[nk]++;

	  /* open file for wilson propagators */
	  fp_in_w[nk]  = r_open_wprop(startflag_w[nk], startfile_w[nk]);

	  if ((spin + color) == 0)
	  {
	    /*** first pass of the code  **/
	    fp_out_w[nk] = w_open_wprop(saveflag_w[nk],  savefile_w[nk],
					wqs.type);

	    /* open file for meson output and write the header */
	    if (saveflag_m == SAVE_MESON_ASCII)
	    {
	      fp_m_out = w_ascii_m_i(savefile_m[nk], max_prop);
	      fb_m_out = -1;	/* i.e. file is NOT binary */
	    }
	    else if (saveflag_m == SAVE_MESON_BINARY)
	    {
	      fb_m_out = w_binary_m_i(savefile_m[nk], max_prop);
	      fp_m_out = NULL;	/* i.e. file is NOT ascii */
	    }
	    else
	    {
	      if( this_node == 0 ) 
		printf("ERROR in main saveflag_m = %d is out of range in initial opening\n",saveflag_m)  ;
	      terminate(1); 
	    }


	  } /*** end of spin =0 && color == 0 **/
	  else
	  {
	    fp_out_w[nk] = w_open_wprop(saveflag_w[nk],  savefile_w[nk],
					wqs.type);

	    /* open file for meson output for appending output*/
	    if (saveflag_m == SAVE_MESON_ASCII)
	    {
	      fp_m_out = a_ascii_m_i(savefile_m[nk], max_prop);
	      fb_m_out = -1;	/* i.e. file is NOT binary */
	    }
	    if (saveflag_m == SAVE_MESON_BINARY)
	    {
	      fb_m_out = a_binary_m_i(savefile_m[nk], max_prop);
	      fp_m_out = NULL;	/* i.e. file is NOT ascii */
	    }
	    else
	    {
	      if( this_node == 0 ) 
		printf("ERROR in main saveflag_m = %d is out of range in appending opening\n",saveflag_m)  ;
	      terminate(1); 
	    }



	  }  /*** end of spin && color not equal to zero ***/


	  if (this_node == 0)
	    printf("color=%d spin=%d kappa=%f nk=%d\n", color, spin, (double) kappa, nk);

	  /* load psi if requested */
	  init_qs(&wqstmp2);
	  reload_wprop_sc_to_site(startflag_w[nk], fp_in_w[nk],&wqstmp2,
			    spin, color, F_OFFSET(psi),1);

	  if (nk == 0 || count2 == 1)
	    restart_flag = flag;
	  else
	    restart_flag = 1;

	  
	  /* Conjugate gradient inversion uses site structure
	     temporary"chi" */
	  
	  
	  /* Complete the source structure */
	  wqs.color = color;
	  wqs.spin = spin;
	  wqs.parity = EVENANDODD;
	  
	  /* For wilson_info */
	  wqstmp = wqs;
	  
	  /* If we are starting fresh, we want to set a mininum number of
	     iterations */
	  if(startflag_w[nk] == FRESH)MinMR = nt/2; else MinMR = 0;

	  /* Load inversion control structure */
	  qic.prec = PRECISION;
	  qic.min = MinMR;
	  qic.max = MaxMR;
	  qic.nrestart = nrestart;
	  qic.parity = EVENANDODD;
	  qic.start_flag = restart_flag;
	  qic.nsrc = 1;
	  qic.resid = RsdMR;
	  qic.relresid = 0;
	    
	  /* Load Dirac matrix parameters */
	  dwp.Kappa = kappa;
	  
	  switch (cl_cg) {
	  case CG:
	    /* Load temporaries specific to inverter */
	    
	    /* compute the propagator.  Result in psi. */
	    avm_iters[nk] += 
	      (Real)wilson_invert_site_wqs(F_OFFSET(chi),F_OFFSET(psi),
					   w_source_h,&wqs,
					   cgilu_w_site,&qic,(void *)&dwp);
	    break;
	  case MR:
	    /* Load temporaries specific to inverter */
	    
	    /* compute the propagator.  Result in psi. */
	    avm_iters[nk] += 
	      (Real)wilson_invert_site_wqs(F_OFFSET(chi),F_OFFSET(psi),
					   w_source_h,&wqs,
					   mrilu_w_site,&qic,(void *)&dwp);
		break;
	      default:
		node0_printf("main(%d): Inverter choice %d not supported\n",
			     this_node,cl_cg);
	  }
	  
	  /* save psi if requested */
	  save_wprop_sc_from_site( saveflag_w[nk],fp_out_w[nk], &wqstmp2,
			  spin,color,F_OFFSET(psi),1);


	  light_meson(F_OFFSET(psi), color, spin, wqs.type, fp_m_out, fb_m_out);

	  if (this_node == 0)
	    printf("Light mesons found\n");

	/*** calculate the correlators required for the static variational code **/
	if( nkap == 1 )
	{

	  /** calculate the smeared meson correlators required for Bparam **/
	  calc_smeared_meson(meson, F_OFFSET(psi) ,  F_OFFSET(mp), color, spin);
			 
	  /** calculate the object required for the 2-pt variational calculation ***/
	  buildup_strip(F_OFFSET(psi)   ,  color,  spin); 

	} /** end of the partial calculations for the variationl project ***/



	  /*
	   * find source again since mrilu overwrites it; for hopping
	   * expansion 
	   */
	  /* source must be of definite parity */

	  wqs.parity = source_parity;
	  w_source_h(F_OFFSET(chi), &wqs);

	  hopping(F_OFFSET(chi), F_OFFSET(mp), F_OFFSET(psi), nhop,
		  kappa_c, wqs.parity, color, spin, wqs.type,
		  fp_m_out, fb_m_out);

	  /* close files */

	  r_close_wprop(startflag_w[nk], fp_in_w[nk]);
	  w_close_wprop(saveflag_w[nk],fp_out_w[nk]);

	  if (saveflag_m == SAVE_MESON_ASCII)
	    w_ascii_m_f(fp_m_out, savefile_m[nk]);
	  else if (saveflag_m == SAVE_MESON_BINARY)
	    w_binary_m_f(fb_m_out, savefile_m[nk]);


	  if (spin == end_spin && color == end_color && nk == end_kap)
	    goto end_of_loops;


	}
      }
    }				/* end of loop over spin, color, kappa */

end_of_loops:


    if (this_node == 0)
      printf("RUNNING COMPLETED\n");

    /**DEBUG***/  
#ifdef DEBUGDEF
    light_quark_pion(2) ;
#endif

    for (nk = 0; nk < nkap; nk++)
    {
      if (meascount[nk] > 0)
      {
	if (this_node == 0)
	  printf("total mr iters for measurement= %e\n",
		 (double) avm_iters[nk]);
	if (this_node == 0)
	  printf("average mr iters per spin-color= %e\n",
		 (double) avm_iters[nk] / (double) meascount[nk]);
      }
    }


    endtime=dclock();
    node0_printf("Time = %e seconds\n", (double) (endtime - starttime));

    fflush(stdout);

    /*** calculation section for the variational code *****/
    if( nkap == 1 )
    {
      
      /** sum up the smeared meson correlators over all the nodes ***/
      for(i=0 ; i < nodata ;++i)
      {
	g_complexsum(meson + i) ;
      }
	  

      /* write the smeared correlators to a single disk file ***/
      IF_MASTER
	write_smear_mesonx(meson);
      
      free(meson);  /*** free up the memory for the b-parameter correlators ***/
      
      calc_vary_matrix() ;  /** calculate the static variational matrix **/
      node0_printf(">> The end of the static variational code <<<<\n");
      
    }/** end of the final static variational code *****/


    node0_printf("Time = %e seconds\n",(double)(endtime-starttime));


    fflush(stdout);
    
  } /* end of while(prompt) */

  return 0;

}  /* end of main() */
Exemplo n.º 8
0
int congrad_xxx(
    field_offset src,   /* type wilson_vector (where source is to be created)*/
    Real cgmass, /* unused here*/
    int source_chirality /* chirality sector for inversion (NOT USED)  */
    )
{
register int i;
register site *s;
int j,k, avs_iters, avm_iters,status,flag;
int MaxCG;
int ksource, spin,color,my_chirality,chb,che,chbo,cheo,ii,jj;
Real *RsdCG;
Real size_r,one_minus_m,r02inv;

wilson_vector **psim;

void setup_multi();

w_prop_file *fp_out_w[MAX_MASSES];       /* For propagator files */
w_prop_file *fp_in_w[MAX_MASSES];        /* For propagator files */
w_prop_file *h0_out_w[MAX_MASSES];       /* For intermediate propagator files */


#ifdef EIGO
wilson_vector wproj;
complex ctmp,cd,*cproj;

int l;
int icount, ivec;
int *chiral_check;
Real cdp, cdm;
Real *ca, *cb;
Real eps, mu, denom;
#endif

double source_norm;

RsdCG=resid;
MaxCG=niter;
avs_iters=0;
r02inv= -0.5/R0;

#ifdef MINN
  do_minn=1;
#endif

    setup_multi();

#ifdef EIGO
  if(Nvecs_hov != 0)cproj = (complex *)malloc(Nvecs_hov*sizeof(complex));
  /* check chirality of your modes (to identify zero modes) */
  if(Nvecs_hov != 0)chiral_check= (int *)malloc(Nvecs_hov*sizeof(int));
  for(j=0;j<Nvecs_hov;j++){
    cdp=0.0;
    cdm=0.0;
    FORALLSITES(i,s){
      for(l=0;l<2;l++)for(k=0;k<3;k++){
        cdp += cabs_sq(&(eigVec[j][i].d[l].c[k]));
      }
      for(l=2;l<4;l++)for(k=0;k<3;k++){
        cdm += cabs_sq(&(eigVec[j][i].d[l].c[k]));
      }
    }
    g_floatsum(&cdp);
    g_floatsum(&cdm);

    if(cdm< 1.e-6 && cdp >1.e-6)
      chiral_check[j] =1;
    else if (cdm >1.e-6 && cdp < 1.e-6)
      chiral_check[j] = -1;
    else if (cdm >1.e-6 && cdp > 1.e-6)
      chiral_check[j] =0;
    else{
      node0_printf("eigVec0[%d] is a null vector!\n",j);
      exit(1);
    }
  }
    /* the  mode  propagator matrix */
  /* I am stupid--how to do this in a 2-d array?? */
  if(Nvecs_hov != 0){
    ca= (Real *)malloc(num_masses*Nvecs_hov*sizeof(Real));
    cb= (Real *)malloc(num_masses*Nvecs_hov*sizeof(Real));
  }

  /* initialize the coefficients of the propagator matrix for modes */

  for(k=0;k<num_masses;k++)for(ivec=0;ivec<Nvecs_hov;ivec++){
    icount=Nvecs_hov*k + ivec;

    if(chiral_check[ivec]==0){
      mu=mass[k]/(2.0*R0);
      eps= sqrt(eigVal[ivec])/(2.0*R0);
      denom= (mu*mu+eps*eps*(1.0-mu*mu))*2.0*R0;
      ca[icount]= mu*(1.0-eps*eps)/denom;
      cb[icount]= eps*sqrt(1.0-eps*eps)/denom;
    }
    else{
      ca[icount]= 1.0/mass[k];
      cb[icount]= 0.0;
    }
    node0_printf("mass %e mode %d %d %e %e\n",mass[k],ivec,
                 chiral_check[ivec],ca[icount],cb[icount]);
  }
#endif


    /* open the prop files */

    for(k=0;k<num_masses;k++){
      fp_in_w[k]  = r_open_wprop(startflag_w[k], startfile_w[k]);
      fp_out_w[k] = w_open_wprop(saveflag_w[k],  savefile_w[k], wqs.type);
#ifdef H0INV
      h0_out_w[k] = w_open_wprop(saveflag_w3[k],  savefile_w3[k], wqs.type);
#endif
    }

  for(ksource = 0; ksource < wqs.nsource; ksource++){
    spin = convert_ksource_to_spin(ksource);
    color = convert_ksource_to_color(ksource);

//                /* Loop over source spins */
//    for(spin=0;spin<4;spin++){
//            /* Loop over source colors */
//    for(color=0;color<3;color++){

node0_printf("Propagator color %d spin %d\n",color,spin);
if(startflag_w[0] == FRESH){flag=0;}
else{
      /* check if there's a propagator already there--Do for all masses */
      flag=1;
      for(k=0;k<num_masses && flag==1 ;k++){
#ifdef IOTIME
      status = reload_wprop_sc_to_site( startflag_w[k], fp_in_w[k],
                                   &wqs, spin, color, F_OFFSET(psi),1);
#else
      status = reload_wprop_sc_to_site( startflag_w[k], fp_in_w[k],
                               &wqs, spin, color, F_OFFSET(psi),0);
#endif
      if(status != 0){
	node0_printf("congrad_outer_p: computing prop\n");
	/*
	reload_wprop_sc_to_site( FRESH, fp_in_w[k],
                               &wqs, spin, color, F_OFFSET(psi),0);
			       */
	flag = 0;
      }
      else{ /* status = 1--put the propagator in the new output file
so all the elements are in one place. This will fail if 
the propagator generation did not write the same number of elements
for each mass value propagator */
#ifdef IOTIME
                    save_wprop_sc_from_site( saveflag_w[k],fp_out_w[k],
                                    &wqs, spin,color,F_OFFSET(psi),1);
#else
                    save_wprop_sc_from_site( saveflag_w[k],fp_out_w[k],
                                    &wqs, spin,color,F_OFFSET(psi),0);
#endif
      }
      } /* k loop */
} /*startflag_w != FRESH */

      if(flag==0){  /* proceed to inversion */
      if(spin<2){my_chirality=1;chb=0;che=2;chbo=2;cheo=4;}
      else {my_chirality= -1;chb=2,che=4;chbo=0;cheo=2;}
      chirality_flag=my_chirality;

      /* Make source */

             /* Complete the source structure */

      /* NEEDS FIXING!! */
//            wqs.color = color;
//            wqs.spin = spin;

            /* For wilson_info */
            wqstmp = wqs;
	    //	    status = w_source_site(src,&wqs);
	    status = wv_source_site(src,&wqs);

	    /* check original source size... */
	    source_norm=0.0;
	    FORALLSITES(i,s){
	      source_norm += (double)magsq_wvec(((wilson_vector *)F_PT(s,src))  );
	    }
	    g_doublesum( &source_norm );

  if(this_node==0){
    printf("Original: source_norm = %e\n",source_norm);
    fflush(stdout);
  } 



	  FORALLSITES(i,s) copy_wvec((wilson_vector *)F_PT(s,src),&(s->chi0));
#ifdef EIGO
      /* project out the eigenvectors from the source */
node0_printf("removing %d modes from source\n",Nvecs_hov);
	  for(j=0;j<Nvecs_hov;j++){
	    cd=cmplx(0.0,0.0);
            FORALLSITES(i,s){
	      /* wproj will hold the chiral projections--
	       recall we have ``packed'' two chiralities into eigVec */
	      clear_wvec(&wproj);
	      for(ii=chb;ii<che;ii++)for(jj=0;jj<3;jj++){
		wproj.d[ii].c[jj]=eigVec[j][i].d[ii].c[jj];
	      }
	      ctmp =  wvec_dot( &(wproj),(wilson_vector *)F_PT(s,src));
	      CSUM(cd,ctmp);
	    }
	    g_complexsum(&cd);
	    cproj[j]=cd;
node0_printf("projector %d %e %e\n",j,cproj[j].real,cproj[j].imag);

	    CMULREAL(cd,-1.0,cd);

	    FORALLSITES(i,s){
	      clear_wvec(&wproj);
	      for(ii=chb;ii<che;ii++)for(jj=0;jj<3;jj++){
		wproj.d[ii].c[jj]=eigVec[j][i].d[ii].c[jj];
	      }
	      c_scalar_mult_add_wvec(&(s->chi0), &(wproj),
                             &cd, &(s->chi0) );
	    }
	  }