Ejemplo n.º 1
0
double d_action(){
double hmom_action(),fermion_action();
    double ssplaq,stplaq,g_action,h_action,f_action;

    d_plaquette(&ssplaq,&stplaq);
    ssplaq *= -1.0; stplaq *= -1.0;
    g_action = -beta*volume*(ssplaq+stplaq);
    node0_printf("PLAQUETTE ACTION: %e\n",g_action);

    rephase(OFF);
    g_action = (beta/3.0)*imp_gauge_action();
    rephase(ON);
    h_action = hmom_action();
    f_action = fermion_action();

    node0_printf("ACTION: g,h,f = %e  %e  %e  %e\n",
    g_action, h_action, f_action, g_action+h_action+f_action );

/*DEBUG*/
node0_printf("DG = %e, DH = %e, DF = %e, D = %e\n",
g_action-old_g, h_action-old_h, f_action-old_f,
g_action+h_action+f_action-old_a);
old_g=g_action; old_h=h_action; old_f=f_action;
old_a=g_action+h_action+f_action;
/*ENDDEBUG*/

    return(g_action+h_action+f_action);
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])  {
int meascount,todo;
int prompt;
double dssplaq,dstplaq;
complex plp;
double dtime;

initialize_machine(&argc,&argv);

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

 g_sync();
    /* set up */
    prompt = setup();

#ifdef GBALL
    make_glueball_ops();
#endif

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

        /* perform warmup trajectories */
        dtime = -dclock();
 
#ifdef FUZZ
if(this_node==0)printf("Fat Polyakov loop parameter %f\n",ALPHA_FUZZ);
#endif

        for(todo=warms; todo > 0; --todo ){
            update();
        }
        if(this_node==0)printf("WARMUPS COMPLETED\n");

        /* perform measuring trajectories, reunitarizing and measuring  */
        meascount=0;            /* number of measurements               */
        plp = cmplx(99.9,99.9);
        for(todo=trajecs; todo > 0; --todo ){ 

            /* do the trajectories */
            update();

            /* measure every "propinterval" trajectories */
            if((todo%propinterval) == 0){
            
                /* call plaquette measuring process */
                d_plaquette(&dssplaq,&dstplaq);

                /* don't bother to */
                /* call the Polyakov loop measuring program */
                /* plp = ploop(); */
#ifdef FUZZ
                plp_fuzzy = ploop_staple((Real)ALPHA_FUZZ);
#endif

                ++meascount;
                if(this_node==0)printf("GMES %e %e %e %e %e\n",
                    (double)plp.real,(double)plp.imag,99.9,dssplaq,dstplaq);
                /* Re(Polyakov) Im(Poyakov) cg_iters ss_plaq st_plaq */

#ifdef FUZZ
		if(this_node==0)printf("GFUZZ %e %e\n",
		    (double)plp_fuzzy.real,(double)plp_fuzzy.imag);
#endif
#ifdef GBALL
		measure_glueball_ops();
#endif

                fflush(stdout);
            }
        }       /* end loop over trajectories */

#ifdef ORA_ALGORITHM
       /* gaugefix if requested */
       if( fixflag == COULOMB_GAUGE_FIX){
	 gaugefix(TUP,(Real)1.8,600,(Real)GAUGE_FIX_TOL);
           if(this_node==0)printf("FIXED TO COULOMB GAUGE\n");
           fflush(stdout);
       }
       else if( fixflag == LANDAU_GAUGE_FIX){
	 gaugefix(8,(Real)1.8,600,(Real)GAUGE_FIX_TOL);
           if(this_node==0)printf("FIXED TO LANDAU GAUGE\n");
           fflush(stdout);
       }
#endif


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

        dtime += dclock();
        if(this_node==0){
            printf("Time = %e seconds\n",dtime);
        }
        fflush(stdout);
	dtime = -dclock();

        /* save lattice if requested */
        if( saveflag != FORGET ){
	  save_lattice( saveflag, savefile, stringLFN );
        }
    }
    return 0;
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])  {
int meascount,todo;
int prompt;
double dssplaq,dstplaq;
int m_iters,s_iters,avm_iters,avs_iters,avspect_iters;
#ifdef SPECTRUM
int spect_iters;
#endif
complex plp;
double dtime;

 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();

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

/* set up loop tables */
        make_loop_table2();

	/* perform warmup trajectories */
	dtime = -dclock();

	/* call plaquette measuring process */
/* Check: compute initial plaquette (T. D.) */
                d_plaquette(&dssplaq,&dstplaq);
                if(this_node==0)printf("START %e %e %e\n",
                    dssplaq,dstplaq, 
                        dssplaq+dstplaq);

	for(todo=warms; todo > 0; --todo ){
	    update();
	}
	if(this_node==0)printf("WARMUPS COMPLETED\n");

	/* perform measuring trajectories, reunitarizing and measuring 	*/
	meascount=0;		/* number of measurements 		*/
	plp = cmplx(99.9,99.9);
	avspect_iters = avm_iters = avs_iters = 0;
	for(todo=trajecs; todo > 0; --todo ){ 

	    /* do the trajectories */
	    s_iters=update();

	    /* Do "local" measurements every trajectory! */
            /* The action from the RG trans */
            gauge_action(&dssplaq);
            if(this_node==0)printf("ACTION_V  %e  %e\n",
                dssplaq,(dssplaq)/(double)(volume*6));

	    /* call plaquette measuring process */
	    d_plaquette(&dssplaq,&dstplaq);

	    /* call the Polyakov loop measuring program */
	    plp = ploop();

            /* generate a pseudofermion configuration */
	    boundary_flip(MINUS);
	    m_iters = f_measure_cl();
	    boundary_flip(PLUS);

	    ++meascount;
	    avm_iters += m_iters;
	    avs_iters += s_iters;
	           
	    if(this_node==0)printf("GMES %e %e %e %e %e\n",
		(double)plp.real,(double)plp.imag,(double)m_iters,
		dssplaq,dstplaq);
	    /* Re(Polyakov) Im(Poyakov) cg_iters ss_plaq st_plaq */

	    /* measure other stuff every "propinterval" trajectories */
	    if(((todo-1)%propinterval) == 0){

	      fixflag = NO_GAUGE_FIX;
#ifdef SPECTRUM 
#ifdef SCREEN 
	      gaugefix(ZUP,(Real)1.5,500,(Real)GAUGE_FIX_TOL);
	      invalidate_this_clov(gen_clov);
		fixflag = COULOMB_GAUGE_FIX;
		boundary_flip(MINUS);
		spect_iters = s_props_cl();
		avspect_iters += spect_iters;
		boundary_flip(PLUS);
#else	/* spectrum in time direction */
		gaugefix(TUP,(Real)1.5,500,(Real)GAUGE_FIX_TOL);
		invalidate_this_clov(gen_clov);
		fixflag = COULOMB_GAUGE_FIX;
/* commented 15 OCT 95, MBW....we'll use periodic b.c. for spect. */
/*		boundary_flip(MINUS); */
/* Don't need t_props if we are doing w_spectrum  - C. DeTar */
/*		spect_iters = t_props_cl();
		avspect_iters += spect_iters; */
		spect_iters = w_spectrum_cl();
		avspect_iters += spect_iters;
/*		boundary_flip(PLUS); */
#endif	/* end ifndef SCREEN */
#endif	/* end ifdef SPECTRUM */

	    }
	    fflush(stdout);

	}	/* end loop over trajectories */

	if(this_node==0)printf("RUNNING COMPLETED\n");
/* Check: compute final plaquette (T. D.) */
                d_plaquette(&dssplaq,&dstplaq);
                if(this_node==0)printf("STOP %e %e %e\n",
                    dssplaq,dstplaq,
                        dssplaq+dstplaq);

	if(meascount>0)  {
	    if(this_node==0)printf("average cg iters for step= %e\n",
		(double)avs_iters/meascount);
	    if(this_node==0)printf("average cg iters for measurement= %e\n",
		(double)avm_iters/meascount);
#ifdef SPECTRUM
	    if(this_node==0)printf("average cg iters for spectrum = %e\n",
		(double)avspect_iters/meascount);
#endif
	}

	dtime += dclock();
	if(this_node==0){
	    printf("Time = %e seconds\n",dtime);
	    printf("total_iters = %d\n",total_iters);
	}
	fflush(stdout);
	dtime = -dclock();

	/* save lattice if requested */
        if( saveflag != FORGET ){
	  save_lattice( saveflag, savefile, stringLFN );
        }
    }
    return 0;
}
Ejemplo n.º 4
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++;}
}

		    }
Ejemplo n.º 5
0
int main(int argc, char *argv[])  {
int meascount,todo;
int prompt;
double dssplaq,dstplaq,ds_deta,bd_plaq;
double dtime;

initialize_machine(&argc,&argv);

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

 g_sync();
    /* set up */
    prompt = setup();

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

	/* perform warmup trajectories */
	dtime = -dclock();
 
	for(todo=warms; todo > 0; --todo ){
	    update();
	}
	if(this_node==0)printf("WARMUPS COMPLETED\n");

	/* perform measuring trajectories, reunitarizing and measuring  */
	meascount=0;            /* number of measurements               */
	ds_deta = 0.0;
	bd_plaq = 0.0;
	for(todo=trajecs; todo > 0; --todo ){ 

	    /* do the trajectories */
	    update();

	    /* measure every "propinterval" trajectories */
	    if((todo%propinterval) == 0){
            
		/* call plaquette measuring process */
		d_plaquette(&dssplaq,&dstplaq);

		/* call the coupling measuring process */
		if(bc_flag > 0){
		    coupling(&ds_deta,&bd_plaq);
		}
		++meascount;
		if(this_node==0)printf("GMES %e %e %e %e %e\n",
		    ds_deta,bd_plaq,99.9,dssplaq,dstplaq);
		/* dS/deta bd_plaq dummy ss_plaq st_plaq */

		fflush(stdout);
	    }
	}       /* end loop over trajectories */

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

	dtime += dclock();
	if(this_node==0){
	    printf("Time = %e seconds\n",dtime);
	}
	fflush(stdout);
	dtime = -dclock();

	/* save lattice if requested */
	if( saveflag != FORGET ){
	  save_lattice( saveflag, savefile, stringLFN );
	}
    }
    return 0;
}
Ejemplo n.º 6
0
int main(int argc, char *argv[]){
int meascount,todo;
int prompt;
double ssplaq,stplaq;
int m_iters,s_iters,avm_iters,avs_iters,avspect_iters;
#ifdef SPECTRUM
int spect_iters;
#endif
#ifdef QUARK
int disp_iters;
#endif
complex plp;
double dtime;

 initialize_machine(&argc,&argv);

  /* Remap standard I/O */
  if(remap_stdio_from_args(argc, argv) == 1)terminate(1);
 g_sync();
    /* set up */
    prompt = setup();

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

	/* perform warmup trajectories */
	dtime = -dclock();
	for(todo=warms; todo > 0; --todo ){
	    update();
	}
	if(this_node==0)printf("WARMUPS COMPLETED\n");

	/* perform measuring trajectories, reunitarizing and measuring 	*/
	meascount=0;		/* number of measurements 		*/
	plp = cmplx(99.9,99.9);
	avspect_iters = avm_iters = avs_iters = 0;
	for(todo=trajecs; todo > 0; --todo ){ 

	    /* do the trajectories */
	    if(steps>0)s_iters=update(); else s_iters=-99;

	    /* measure every "propinterval" trajectories */
	    if((todo%propinterval) == 0){
	    
                /* generate a pseudofermion configuration */
		boundary_flip(MINUS);
		m_iters = f_measure2();

#ifdef SPECTRUM 
#ifdef SCREEN 
		boundary_flip(PLUS);
		gaugefix(ZUP,(Real)1.5,100,(Real)GAUGE_FIX_TOL);
		boundary_flip(MINUS);
		spect_iters = s_props();
		avspect_iters += spect_iters;
		spect_iters = w_spectrum_z();
		avspect_iters += spect_iters;
#ifdef QUARK
		boundary_flip(PLUS);
		/* Lorentz gauge*/
		gaugefix(8,(Real)1.5,100,(Real)GAUGE_FIX_TOL);
		boundary_flip(MINUS);
                disp_iters = quark();
                avspect_iters += disp_iters;
#endif /* ifdef QUARK */
#else	/* spectrum in time direction */
		boundary_flip(PLUS);
		gaugefix(TUP,(Real)1.5,100,(Real)GAUGE_FIX_TOL);
		boundary_flip(MINUS);
		spect_iters = t_props();
		avspect_iters += spect_iters;
		spect_iters = w_spectrum();
		avspect_iters += spect_iters;
#endif	/* end ifndef SCREEN */
#endif	/* end ifdef SPECTRUM */
		boundary_flip(PLUS);

	        /* call plaquette measuring process */
		d_plaquette(&ssplaq,&stplaq);

		/* call the Polyakov loop measuring program */
		plp = ploop();

		avm_iters += m_iters;
		avs_iters += s_iters;
	           
	        ++meascount;
	        if(this_node==0)printf("GMES %e %e %e %e %e\n",
		    (double)plp.real,(double)plp.imag,(double)m_iters,
		    (double)ssplaq,(double)stplaq);
		/* Re(Polyakov) Im(Poyakov) cg_iters ss_plaq st_plaq */

		fflush(stdout);
	    }
	}	/* end loop over trajectories */

	if(this_node==0)printf("RUNNING COMPLETED\n");
	if(meascount>0)  {
	    if(this_node==0)printf("average cg iters for step= %e\n",
		(double)avs_iters/meascount);
	    if(this_node==0)printf("average cg iters for measurement= %e\n",
		(double)avm_iters/meascount);
#ifdef SPECTRUM
	    if(this_node==0)printf("average cg iters for spectrum = %e\n",
		(double)avspect_iters/meascount);
#endif
	}

	dtime += dclock();
	if(this_node==0){
	    printf("Time = %e seconds\n",dtime);
	    printf("total_iters = %d\n",total_iters);
	}
	fflush(stdout);

	/* save lattice if requested */
        if( saveflag != FORGET ){
	  save_lattice( saveflag, savefile, stringLFN );
        }
    }
    return 0;
}
Ejemplo n.º 7
0
int main(int argc, char *argv[])
{
   int meascount;
   int todo;
   int prompt;
   double ssplaq;
   double stplaq;
   complex plp;
   double dtime;

   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();
   make_loop_table2();

   if(startflag != CONTINUE)total_sweeps = 0;

   /* loop over input sets */
   while ( readin(prompt) == 0 )
   {
      total_sweeps += sweeps;
      dtime = -dclock();

      /* perform smoothing sweeps, reunitarizing and measuring */

      meascount = 0;   /* number of measurements */
      for (todo=sweeps; todo > 0; --todo )
      {
         /* do one smoothing sweep */
         smooth();

         /* measure every "measinterval" trajectories */
         if ((todo%measinterval) == 0)
         {
            /* call plaquette measuring process */
            d_plaquette(&ssplaq, &stplaq);

            /* don't bother to */
            /* call the Polyakov loop measuring program */
            /* plp = ploop(); */
            plp = cmplx(99.9, 99.9);

            ++meascount;
            if (this_node==0)
            {
               /* Re(Polyakov) Im(Poyakov) cg_iters ss_plaq st_plaq */
               printf("GMES %e %e %e %e %e\n",
                      (double)plp.real, (double)plp.imag, 99.9,
                      (double)ssplaq, (double)stplaq);
            }

            fflush(stdout);
         }
      }       /* end loop over sweeps */


      /* perform gauge fixing after smoothing if requested */

      if ( fixflag == COULOMB_GAUGE_FIX )
      {
         if (this_node == 0)
         {
            printf("Fixing to Coulomb gauge\n");
         }
         gaugefix(TUP, (Real)1.5, 500, GAUGE_FIX_TOL);
      }
      else if (this_node == 0)
      {
         printf("GAUGE FIXING SKIPPED.\n");
      }

      /* measure the instanton charge on the fitted config */
      instanton_density();
	  
      if (this_node==0)
	{
	  printf("RUNNING COMPLETED\n");
	}
      
      dtime += dclock();
      if (this_node==0)
	{
	  printf("Time = %e seconds\n", dtime);
	}
      fflush(stdout);
      
      /* save FFdual */
      if(savetopoflag != FORGET) save_topo(topofile);

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

   return 0;
}
Ejemplo n.º 8
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() */