Ejemplo n.º 1
0
// -----------------------------------------------------------------
// Close the file and write the info file
void w_serial_f(gauge_file *gf) {
  g_sync();
  if (this_node == 0) {
    fclose(gf->fp);
    write_gauge_info_file(gf);
  }
  // Do not free gf and gf->header so calling program can use them
}
Ejemplo n.º 2
0
// -----------------------------------------------------------------
// Close the file on node0
void r_serial_f(gauge_file *gf) {
  g_sync();
  if (this_node == 0)
    fclose(gf->fp);

  if (gf->rank2rcv != NULL)
    free(gf->rank2rcv);

  // Do not free gf and gf->header so calling program can use them
}
Ejemplo n.º 3
0
// -----------------------------------------------------------------
// Return file descriptor for opened file
gauge_file* r_serial_i(char *filename) {
  gauge_header *gh;
  gauge_file *gf;
  FILE *fp;
  int byterevflag;
  char editfilename[513];

  /* All nodes set up a gauge file and gauge header structure for reading */
  gf = setup_input_gauge_file(filename);
  gh = gf->header;

  /* Node 0 alone opens the file and reads the header */
  g_sync();
  if (this_node == 0) {
    fp = fopen(filename, "rb");
    if (fp == NULL) {
      /* If this is a partition format SciDAC file the node0 name
         has an extension ".vol0000".  So try again. */
      printf("r_serial_i: Node %d can't open file %s, error %d\n",
          this_node,filename,errno);fflush(stdout);
      strncpy(editfilename,filename,504);
      editfilename[504] = '\0';  /* Just in case of truncation */
      strcat(editfilename,".vol0000");
      printf("r_serial_i: Trying SciDAC partition volume %s\n",editfilename);
      fp = fopen(editfilename, "rb");
      if (fp == NULL) {
        printf("r_serial_i: Node %d can't open file %s, error %d\n",
               this_node,editfilename,errno);fflush(stdout);terminate(1);
      }
      printf("r_serial_i: Open succeeded\n");
    }

    gf->fp = fp;

    byterevflag = read_gauge_hdr(gf);
  }

  else gf->fp = NULL;  /* The other nodes don't know about this file */

  // Broadcast the byterevflag and header structure from node0 to all nodes
  broadcast_bytes((char *)&byterevflag, sizeof(byterevflag));
  gf->byterevflag = byterevflag;
  broadcast_bytes((char *)gh,sizeof(gauge_header));

  // No further processing here if this is a SciDAC file
  if (gh->magic_number == LIME_MAGIC_NO)
    return gf;

  // Read site list and broadcast to all nodes
  read_site_list(gf);

  return gf;
}
Ejemplo n.º 4
0
static void 
r_source_cmplx_fm_f(cmplx_source_file *csf)

/* Close the file and free associated structures */
{
  g_sync();
  if(this_node==0)
    {
      if(csf->fp != NULL)g_close(csf->fp);
      fflush(stdout);
    }
  free(csf->header);
  free(csf);
  
} /* r_source_cmplx_fm_f */
Ejemplo n.º 5
0
int main(int argc, char *argv[]) {
  register int i;
  register site *s;
  int prompt;
  double ss_plaq, st_plaq, td;

  // Setup
  setlinebuf(stdout); // DEBUG
  initialize_machine(&argc, &argv);
  // Remap standard I/O
  if (remap_stdio_from_args(argc, argv) == 1)
    terminate(1);

  g_sync();
  prompt = setup();

  // Load input and run (loop removed)
  if (readin(prompt) != 0) {
    node0_printf("ERROR in readin, aborting\n");
    terminate(1);
  }

  // Serial code!
  if (this_node != 0) {
    node0_printf("ERROR: run this thing in serial!\n");
    terminate(1);
  }

  // Check plaquette
  plaquette(&ss_plaq, &st_plaq);
  td = 0.5 * (ss_plaq + st_plaq);
  node0_printf("START %.8g %.8g %.8g\n", ss_plaq, st_plaq, td);

  // Compute field strength tensor at each site
  make_field_strength(F_OFFSET(link), F_OFFSET(FS));
  FORALLSITES(i, s) {
    // TODO...
  }

  fflush(stdout);
  return 0;
}
Ejemplo n.º 6
0
// Only load completed diagonal elements on node0
void load_diag(complex *diag, int ckpt_load) {
  int i;
  char infile[80];
  FILE *fp = NULL;

  if (this_node == 0) {
    sprintf(infile, "%s.diag%d", startfile, ckpt_load);
    fp = fopen(infile, "r");    // Open to read
    if (fp == NULL) {
      printf("load_diag: node0 can't open file %s\n", infile);
      fflush(stdout);
      terminate(1);
    }

    for (i = 1; i < ckpt_load; i += 2)  // Every other is trivial
      fscanf(fp, "%lg\n%lg\n", &(diag[i].real), &(diag[i].imag));
    fclose(fp);
  }
  g_sync();   // Don't let other nodes race ahead
}
Ejemplo n.º 7
0
// Only save completed diagonal elements on node0
void save_diag(complex *diag, int ckpt_save) {
  int i;
  char outfile[80];
  FILE *fp = NULL;

  if (this_node == 0) {
    sprintf(outfile, "%s.diag%d", startfile, ckpt_save);
    fp = fopen(outfile, "w");    // Open to write
    if (fp == NULL) {
      printf("save_diag: node%d can't open file %s\n", this_node, outfile);
      fflush(stdout);
      terminate(1);
    }

    for (i = 1; i < ckpt_save; i += 2)  // Every other is trivial
      fprintf(fp, "%.16g\n%.16g\n", diag[i].real, diag[i].imag);
    fflush(fp);
    fclose(fp);
  }
  g_sync();   // Don't let other nodes race ahead
}
Ejemplo n.º 8
0
void gluon_prop( void ) {
register int i,dir;
register int pmu;
register site *s;
anti_hermitmat ahtmp;
Real pix, piy, piz, pit;
Real sin_pmu, sin_pmu2, prop_s, prop_l, ftmp1, ftmp2;
complex ctmp;
su3_matrix mat;
struct {
  Real f1, f2;
} msg;
double trace, dmuAmu;
int px, py, pz, pt;
int currentnode,newnode;

    pix = PI / (Real)nx;
    piy = PI / (Real)ny;
    piz = PI / (Real)nz;
    pit = PI / (Real)nt;

    trace = 0.0;
    /* Make A_mu as anti-hermition traceless part of U_mu */
    /* But store as SU(3) matrix for call to FFT */
    for(dir=XUP; dir<=TUP; dir++)
    {
	FORALLSITES(i,s){
	    trace += (double)(trace_su3( &(s->link[dir]))).real;
	    make_anti_hermitian( &(s->link[dir]), &ahtmp);
	    uncompress_anti_hermitian( &ahtmp, &(s->a_mu[dir]));
	}

	g_sync();
	/* Now Fourier transform */
	restrict_fourier_site(F_OFFSET(a_mu[dir]),
			      sizeof(su3_matrix), FORWARDS);
    }
Ejemplo n.º 9
0
// Only save non-zero elements of remaining columns of Q
// Write from node0 only -- transfer data from all other nodes one by one
void saveQ(complex **Q, int ckpt_save) {
  int i, j, Ndat = 4 * DIMF, mynode, Nlines = 0, Qlen;
  char outfile[80];
  FILE *fp = NULL;

  // Total length of each column of Q
  Qlen = sites_on_node * Ndat * sizeof(complex);

  if (this_node == 0) {
    printf("Dumping columns %d--%d\n", ckpt_save + 1, volume * Ndat);
    sprintf(outfile, "%s.Q%d", startfile, ckpt_save);
    fp = fopen(outfile, "w");    // Open to write
    if (fp == NULL) {
      printf("saveQ: node%d can't open file %s\n", this_node, outfile);
      fflush(stdout);
      terminate(1);
    }

    // node0 data ready to go
    for (i = ckpt_save; i < volume * Ndat; i++) {
      for (j = 0; j < sites_on_node * Ndat; j++)
        if (Q[i][j].real != 0.0 || Q[i][j].real != 0.0) { // Loose condition
          fprintf(fp, "0\t%d\t%d\t%.16g\t%.16g\n",
                      i, j, Q[i][j].real, Q[i][j].imag);
          Nlines++;
      }
    }
    fflush(fp);
  }
  g_sync();   // Don't let other nodes race ahead

  // Overwrite node0 Q with elements of Q on mynode
  for (mynode = 1; mynode < numnodes(); mynode++) {
    for (i = ckpt_save; i < volume * Ndat; i++) {
      if (this_node == mynode)
        send_field((char *)Q[i], Qlen, 0);
      else if (this_node == 0)
        get_field((char *)Q[i], Qlen, mynode);

      g_sync();   // To be cautious
    }
    if (this_node == 0) {   // Now print, as above
      for (i = ckpt_save; i < volume * Ndat; i++) {
        for (j = 0; j < sites_on_node * Ndat; j++)
          if (Q[i][j].real != 0.0 || Q[i][j].real != 0.0) { // Loose condition
            fprintf(fp, "%d\t%d\t%d\t%.16g\t%.16g\n",
                        mynode, i, j, Q[i][j].real, Q[i][j].imag);
            Nlines++;
        }
      }
      fflush(fp);
    }
    g_sync();   // Don't let other nodes race ahead
  }

  if (this_node == 0) {
    // Add a last line containing a unique tag (-1)
    // and the number of elements that were written,
    // so we can check that the correct number were reloaded
    fprintf(fp, "-1\t%d\t-1\t-1\t-1\n", Nlines);
    fflush(fp);
    fclose(fp);
  }
  g_sync();   // Don't let other nodes race ahead
}
Ejemplo n.º 10
0
int main(int argc, char *argv[])
{
  int meascount;
  int prompt;
  Real avm_iters,avs_iters;
  
  double starttime,endtime;
#ifdef IOTIME
  double dtime;
  int iotime = 1;
#else
  int iotime = 0;
#endif
  
  int MaxCG;
  Real RsdCG, RRsdCG;
  
  int spin,color,k;
  int flag;

  int status;

  int cl_cg = CL_CG;

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

  wilson_vector *psi = NULL;
  wilson_prop_field quark_propagator = NULL;
  
  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_cl();
  /* loop over input sets */

  psi = create_wv_field();
  quark_propagator = create_wp_field();
  
  while( readin(prompt) == 0)
    {
      
      starttime=dclock();
      MaxCG=niter;
      wqstmp = wqs;  /* For clover_info.c */
      
      avm_iters=0.0;
      meascount=0;
      
      if( fixflag == COULOMB_GAUGE_FIX)
	{
	  if(this_node == 0) 
	    printf("Fixing to Coulomb gauge\n");
#ifdef IOTIME
	  dtime = -dclock();
#endif
	  gaugefix(TUP,(Real)1.5,500,GAUGE_FIX_TOL);
#ifdef IOTIME
	  dtime += dclock();
	  if(this_node==0)printf("Time to gauge fix = %e\n",dtime);
#endif
	  invalidate_this_clov(gen_clov);
	}
      else
	if(this_node == 0)printf("COULOMB GAUGE FIXING SKIPPED.\n");
      
      /* save lattice if requested */
      if( saveflag != FORGET ){
	savelat_p = save_lattice( saveflag, savefile, stringLFN );
      }
      
      if(this_node==0)printf("END OF HEADER\n");
      
      /*	if(this_node==0) printf("num_kap = %d\n", num_kap); */
      /* Loop over kappas */
      for(k=0;k<num_kap;k++){
	
	kappa=kap[k];
	RsdCG=resid[k];
	RRsdCG=relresid[k];
	if(this_node==0)printf("Kappa= %g r0= %g residue= %g rel= %g\n",
			       (double)kappa,(double)wqs.r0,(double)RsdCG,
			       (double)RRsdCG);
	
	/* open files for wilson propagators */
	
#ifdef IOTIME
	dtime = -dclock();
#endif
	fp_in_w[k]  = r_open_wprop(startflag_w[k], startfile_w[k]);
#ifdef IOTIME
	dtime += dclock();
	if(startflag_w[k] != FRESH)
	node0_printf("Time to open prop = %e\n",dtime);
#endif
	fp_out_w[k] = w_open_wprop(saveflag_w[k],  savefile_w[k],
				   wqs.type);
	
	
	/* Loop over source spins */
	for(spin=0;spin<4;spin++){
	  /* Loop over source colors */
	  for(color=0;color<3;color++){
	  
	    meascount ++;
	    /*if(this_node==0)printf("color=%d spin=%d\n",color,spin); */
	    if(startflag_w[k] == CONTINUE)
	      {
		node0_printf("Can not continue propagator here! Zeroing it instead\n");
		startflag_w[k] = FRESH;
	      }
	    
	    /* Saves one multiplication by zero in cgilu */
	    if(startflag_w[k] == FRESH)flag = 0;
	    else 
	      flag = 1;      
	    
	    /* load psi if requested */
	    status = reload_wprop_sc_to_field( startflag_w[k], fp_in_w[k], 
				       &wqs, spin, color, psi, iotime);

	    if(status != 0)
	      {
		node0_printf("control_cl: Recovering from error by resetting initial guess to zero\n");
		reload_wprop_sc_to_field( FRESH, fp_in_w[k], &wqs,
			       spin, color, psi, 0);
		flag = 0;
	      }

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

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


	    /* compute the propagator.  Result in psi. */
	    
	    switch (cl_cg) {
	      case BICG:
		avs_iters =
		  (Real)wilson_invert_field_wqs(&wqs, w_source_field, psi,
						bicgilu_cl_field,
						&qic,(void *)&dcp);
		break;
	      case HOP:
		avs_iters = 
		  (Real)wilson_invert_field_wqs(&wqs, w_source_field, psi,
						hopilu_cl_field,
						&qic,(void *)&dcp);
		break;
	      case MR:
		avs_iters = 
		  (Real)wilson_invert_field_wqs(&wqs, w_source_field, psi,
						mrilu_cl_field,
						&qic,(void *)&dcp);
		break;
	      case CG:
		avs_iters = 
		  (Real)wilson_invert_field_wqs(&wqs, w_source_field, psi,
						cgilu_cl_field,
						&qic,(void *)&dcp);
		break;
	      default:
		node0_printf("main(%d): Inverter choice %d not supported\n",
			     this_node,cl_cg);
	      }

	    avm_iters += avs_iters;

	    copy_wp_from_wv(quark_propagator, psi, color, spin);
	    
	    /* save psi if requested */
	    save_wprop_sc_from_field( saveflag_w[k],fp_out_w[k], &wqs,
			     spin,color,psi,"Fill in record info here",iotime);
	  } /* source spins */
	} /* source colors */
	
	/* close files for wilson propagators */
	r_close_wprop(startflag_w[k],fp_in_w[k]);
#ifdef IOTIME
	dtime = -dclock();
#endif
	w_close_wprop(saveflag_w[k],fp_out_w[k]);
#ifdef IOTIME
      dtime += dclock();
      if(saveflag_w[k] != FORGET)
	node0_printf("Time to close prop = %e\n",dtime);
#endif
	
	/* spectrum, if requested */

	if(strstr(spectrum_request,",spectrum,") != NULL)
	  spectrum_cl(quark_propagator, wqs.t0, k);

      } /* kappas */


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

  destroy_wv_field(psi);
  destroy_wp_field(quark_propagator);
  return 0;
}
Ejemplo n.º 11
0
void light_baryon_spectrum(field_offset quark, int t_source)
{
  static char *bar_kind[4] = {"PROTON","PROTON0","DELTA","DELTA0"};
  wilson_prop_field *wp;

  int num_prop ;
  Real  space_vol = (Real)(nx*ny*nz);
  int t ;
  int c,i;
  site *s;

  complex *bar_prop[4];
  double t_total ; 
  /***--****************************************--****/

  t_total = dclock() ; 

  for(num_prop=0;num_prop<4;num_prop++)
  {
    if( (bar_prop[num_prop] = (complex *)malloc(nt*sizeof(complex)) ) == NULL )
    {
      if( this_node == 0 ) 
	printf("light_baryon_spectrum:: Error could not reserve the memory for the baryon correlators\n") ; 
      terminate(1); 
    }

    for(t=0;t<nt;t++)
      bar_prop[num_prop][t] = cmplx(0.0,0.0); 
  }

  /*** calculate the baryon spectrum ****/

  /* Create the appropriate field for w_baryon and copy */
  wp = create_wp_field(3);
  for(c = 0; c < 3; c++){
    FORALLSITES(i,s){
      wp->swv[c][i] = ((wilson_propagator *)F_PT(s,quark))->c[c];
    }
  }

  w_baryon(wp, wp, wp, bar_prop );

  destroy_wp_field(wp);

  /**
      print baryon propagators 
   **/

  for(num_prop=0;num_prop<4;num_prop++)
    for(t=0; t<nt; t++)
    {
      g_floatsum( &bar_prop[num_prop][t].real );
      bar_prop[num_prop][t].real  /= space_vol;
      g_floatsum( &bar_prop[num_prop][t].imag );
      bar_prop[num_prop][t].imag  /= space_vol;
    }

  g_sync() ; 


  if(this_node == 0)
  {
    for(num_prop=0;num_prop<4;num_prop++)
      for(t=0; t<nt; t++)
      {
	
	printf("POINT%s %d   %e %e\n",bar_kind[num_prop],t,
	       (double)bar_prop[num_prop][(t+t_source)%nt].real,
	       (double)bar_prop[num_prop][(t+t_source)%nt].imag);
      }
  } /*** end of node 0 ****/


  /**
   **   free up the memory
   **/

      for(num_prop=0;num_prop<4;num_prop++)
      {
	free(bar_prop[num_prop]);
      }

  IF_VERBOSE_ON(2)
    printf("Time to calculate baryon spectrum = %g sec\n",dclock() - t_total) ; 


} /**** end of the light baryon spectrum function ***/
Ejemplo n.º 12
0
int main(int argc,char *argv[])
{
    int prompt , k, ns, i;
    site *s;
    double inv_space_vol;

    int color,spin, color1, spin1;

    int key[4];
    int dummy[4];
    FILE *corr_fp;

    complex pr_tmp;
    wilson_propagator *qdest;
    wilson_propagator qtemp1;

    wilson_vector *psi = NULL;
    w_prop_file *wpf;
    quark_source wqs;

    key[XUP] = 1;
    key[YUP] = 1;
    key[ZUP] = 1;
    key[TUP] = 0;

    initialize_machine(&argc,&argv);

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

    g_sync();
    prompt = setup();
    setup_restrict_fourier(key, dummy);

    psi = create_wv_field();

    /* Initialize the source type */
    init_qs(&wqs);

    while( readin(prompt) == 0) {


        /**************************************************************/
        /*load staggered propagator*/

        reload_ksprop_to_site3(ks_prop_startflag,
                               start_ks_prop_file, &ksqs, F_OFFSET(prop), 1);

        FORALLSITES(i,s) {
            for(color = 0; color < 3; color++)for(k = 0; k < 3; k++)
                    s->stag_propagator.e[color][k] = s->prop[color].c[k];
        }

        /* Initialize FNAL correlator file */

        corr_fp = open_fnal_meson_file(savefile_c);

        /* Load Wilson propagator for each kappa */

        for(k=0; k<num_kap; k++) {
            kappa = kap[k];
            wpf = r_open_wprop(startflag_w[k], startfile_w[k]);
            for(spin=0; spin<4; spin++)
                for(color=0; color<3; color++) {
                    if(reload_wprop_sc_to_field(startflag_w[k], wpf,
                                                &wqs, spin, color, psi, 1) != 0)
                        terminate(1);
                    FORALLSITES(i,s) {
                        copy_wvec(&psi[i],&lattice[i].quark_propagator.c[color].d[spin]);
                    }
                }
            r_close_wprop(startflag_w[k],wpf);

            /*******************************************************************/
            /* Rotate the heavy quark */

            rotate_w_quark(F_OFFSET(quark_propagator),
                           F_OFFSET(quark_propagator_copy), d1[k]);
            // result in quark_propagator_copy


            /**************************************************************/
            /*Calculate and print out the spectrum with the rotated heavy
              quark propagators*/

            spectrum_hl_rot(corr_fp, F_OFFSET(stag_propagator),
                            F_OFFSET(quark_propagator_copy), k);


            /**************************************************************/
            /*Smear quarks, calculate and print out the spectrum with the
              smeared heavy quark propagators*/

            for(color=0; color<3; color++)for(spin=0; spin<4; spin++) {
                    restrict_fourier_site(F_OFFSET(quark_propagator.c[color].d[spin]),
                                          sizeof(wilson_vector), FORWARDS);
                }

            for(ns=0; ns<num_smear; ns++) {
                if(strcmp(smearfile[ns],"none")==0) continue;

                inv_space_vol = 1./((double)nx*ny*nz);

                /* Either read a smearing file, or take it to be a point sink */
                if(strlen(smearfile[ns]) != 0) {

                    get_smearings_bi_serial(smearfile[ns]);

                    restrict_fourier_site(F_OFFSET(w),
                                          sizeof(complex), FORWARDS);

                    FORALLSITES(i,s) {
                        for(color=0; color<3; color++)for(spin=0; spin<4; spin++)
                                for(color1=0; color1<3; color1++)for(spin1=0; spin1<4; spin1++) {
                                        pr_tmp =
                                            s->quark_propagator.c[color].d[spin].d[spin1].c[color1];

                                        s->quark_propagator_copy.c[color].d[spin].d[spin1].c[color1].real =
                                            pr_tmp.real * s->w.real - pr_tmp.imag * s->w.imag;

                                        s->quark_propagator_copy.c[color].d[spin].d[spin1].c[color1].imag =
                                            pr_tmp.real * s->w.imag + pr_tmp.imag * s->w.real;
                                    }
                    }
                } else { /* Point sink */
                    FORALLSITES(i,s) {
                        for(color=0; color<3; color++)for(spin=0; spin<4; spin++)
                                for(color1=0; color1<3; color1++)for(spin1=0; spin1<4; spin1++) {
                                        pr_tmp =
                                            s->quark_propagator.c[color].d[spin].d[spin1].c[color1];

                                        s->quark_propagator_copy.c[color].d[spin].d[spin1].c[color1].real =
                                            pr_tmp.real;

                                        s->quark_propagator_copy.c[color].d[spin].d[spin1].c[color1].imag =
                                            pr_tmp.imag;
                                    }
                    }
                }

                for(color=0; color<3; color++)for(spin=0; spin<4; spin++) {
                        restrict_fourier_site(F_OFFSET(quark_propagator_copy.c[color].d[spin]),
                                              sizeof(wilson_vector), BACKWARDS);
                    }

                FORALLSITES(i,s)
                {
                    qdest = &(s->quark_propagator_copy);
                    qtemp1 = s->quark_propagator_copy;
                    for(spin=0; spin<4; spin++)for(color=0; color<3; color++)
                            for(spin1=0; spin1<4; spin1++)for(color1=0; color1<3; color1++)
                                {
                                    qdest->c[color].d[spin1].d[spin].c[color1].real =
                                        qtemp1.c[color].d[spin].d[spin1].c[color1].real;
                                    qdest->c[color].d[spin1].d[spin].c[color1].imag =
                                        qtemp1.c[color].d[spin].d[spin1].c[color1].imag;
                                }
                }
Ejemplo n.º 13
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.º 14
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.º 15
0
int main( int argc, char **argv ){
  int prompt;
  char *filexml;
  
  initialize_machine(&argc,&argv);

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

  /* loop over input sets */
  while( readin(prompt) == 0){
    
    node0_printf("BEGIN\n");
#ifdef CHECK_INVERT
    
    check_ks_invert( srcfile, srcflag, F_OFFSET(phi), 
		     ansfile, ansflag, F_OFFSET(xxx), 
		     F_OFFSET(g_rand), mass);
    
#else
#ifndef HAVE_QIO
BOMB Checking the fermion force requires QIO compilation
#endif
    
    check_fermion_force( srcfile, srcflag, F_OFFSET(xxx), 
			 ansfile, ansflag, mass);
    node0_printf("Done checking fermion force\n");
#endif
    
    /* save lattice if requested */
    if( saveflag != FORGET ){
      rephase( OFF );
      node0_printf("Saving the lattice\n");
      save_lattice( saveflag, savefile, NULL );
      rephase( ON );
    }
    
#ifdef FN
    /* save longlinks if requested */
    if (savelongflag != FORGET ){
#ifdef HAVE_QIO
      filexml = create_QCDML();
      node0_printf("Saving the long links\n");
      save_color_matrix_scidac_from_field( savelongfile, filexml, 
         "Long links", QIO_SINGLEFILE, get_lnglinks(get_fm_links(fn_links)[0]), 4);
      free_QCDML(filexml);
#else
      printf("ERROR: Can't save the longlinks.  Recompile with QIO\n");
#endif
    }
    
    /* save fatlinks if requested */
    if (savefatflag != FORGET ){
#ifdef HAVE_QIO
      filexml = create_QCDML();
      node0_printf("Saving the fat links\n");
      save_color_matrix_scidac_from_field( savefatfile, filexml, 
	   "Fat links", QIO_SINGLEFILE, get_fatlinks(get_fm_links(fn_links)[0]), 4);
      free_QCDML(filexml);
#else
      printf("ERROR: Can't save the fatlinks.  Recompile with QIO\n");
#endif
    }
#endif
    
  }
  node0_printf("RUNNING COMPLETED\n");
  return 0;
}
Ejemplo n.º 16
0
void r_check(gauge_file *gf, float *max_deviation)
{
  /* gf  = gauge configuration file structure */

  FILE *fp;
  gauge_header *gh;
  char *filename;
  int byterevflag;

  off_t offset ;            /* File stream pointer */
  off_t gauge_check_size;   /* Size of gauge configuration checksum record */
  off_t coord_list_size;    /* Size of coordinate list in bytes */
  off_t head_size;          /* Size of header plus coordinate list */
  off_t checksum_offset;    /* Where we put the checksum */
  int rcv_rank, rcv_coords;
  int destnode;
  int i,k;
  int x,y,z,t;
  int buf_length,where_in_buf;
  gauge_check test_gc;
  u_int32type *val;
  int rank29,rank31;
  su3_matrix *lbuf;
  su3_matrix work[4];
  float deviation;

  char myname[] = "r_check";

  fp = gf->fp;
  gh = gf->header;
  filename = gf->filename;
  byterevflag = gf->byterevflag;

  if(this_node == 0)
    {
      /* Compute offset for reading gauge configuration */

      /* (1996 gauge configuration files had a 32-bit unused checksum 
	 record before the gauge link data) */
      if(gh->magic_number == GAUGE_VERSION_NUMBER)
	gauge_check_size = sizeof(gf->check.sum29) + 
	  sizeof(gf->check.sum31);
      else if(gh->magic_number == GAUGE_VERSION_NUMBER_1996)
	gauge_check_size =  4;
      else
	gauge_check_size = 0;
      
      if(gf->header->order == NATURAL_ORDER)coord_list_size = 0;
      else coord_list_size = sizeof(int32type)*volume;
      checksum_offset = gf->header->header_bytes + coord_list_size;
      head_size = checksum_offset + gauge_check_size;
      
      /* Allocate space for read buffer */

      if(gf->parallel)
	printf("%s: Attempting serial read from parallel file \n",myname);

      lbuf = (su3_matrix *)malloc(MAX_BUF_LENGTH*4*sizeof(su3_matrix));
      if(lbuf == NULL)
	{
	  printf("%s: Node %d can't malloc lbuf\n",myname,this_node);
	  fflush(stdout);
	  terminate(1);
	}
  
      /* Position file for reading gauge configuration */
      
      offset = head_size;

      if( g_seek(fp,offset,SEEK_SET) < 0 ) 
	{
	  printf("%s: Node 0 g_seek %ld failed error %d file %s\n",
		 myname,(long)offset,errno,filename);
	  fflush(stdout);terminate(1);   
	}

      buf_length = 0;
      where_in_buf = 0;
      
    }

  /* all nodes initialize checksums */
  test_gc.sum29 = 0;
  test_gc.sum31 = 0;
  /* counts 32-bit words mod 29 and mod 31 in order of appearance
     on file */
  /* Here all nodes see the same sequence because we read serially */
  rank29 = 0;
  rank31 = 0;
  *max_deviation = 0;

  g_sync();

  /* Node 0 reads and deals out the values */

  for(rcv_rank=0; rcv_rank<volume; rcv_rank++)
    {
      /* If file is in coordinate natural order, receiving coordinate
         is given by rank. Otherwise, it is found in the table */

      if(gf->header->order == NATURAL_ORDER)
	rcv_coords = rcv_rank;
      else
	rcv_coords = gf->rank2rcv[rcv_rank];

      x = rcv_coords % nx;   rcv_coords /= nx;
      y = rcv_coords % ny;   rcv_coords /= ny;
      z = rcv_coords % nz;   rcv_coords /= nz;
      t = rcv_coords % nt;

      /* The node that gets the next set of gauge links */
      destnode=node_number(x,y,z,t);
      
      if(this_node==0){
	/* Node 0 fills its buffer, if necessary */
	if(where_in_buf == buf_length)
	  {  /* get new buffer */
	    /* new buffer length  = remaining sites, but never bigger 
	       than MAX_BUF_LENGTH */
	    buf_length = volume - rcv_rank;
	    if(buf_length > MAX_BUF_LENGTH)buf_length = MAX_BUF_LENGTH;
	    /* then do read */
	    
	    if( (int)g_read(lbuf,4*sizeof(su3_matrix),buf_length,fp) != buf_length)
	      {
		printf("%s: node %d gauge configuration read error %d file %s\n",
		       myname,this_node,errno,filename); 
		fflush(stdout); terminate(1);
	      }
	    where_in_buf = 0;  /* reset counter */
	  }  /*** end of the buffer read ****/

	if(destnode==0){	/* just copy links */
	  i = node_index(x,y,z,t);
	  memcpy((void *)&work[0],
		 (void *)&lbuf[4*where_in_buf], 4*sizeof(su3_matrix));
	}
	else {		/* send to correct node */
	  send_field((char *)&lbuf[4*where_in_buf],
		     4*sizeof(su3_matrix),destnode);
	}
	where_in_buf++;
      }
      
      /* The node which contains this site reads message */
      else {	/* for all nodes other than node 0 */
	if(this_node==destnode){
	  i = node_index(x,y,z,t);
	  get_field((char *)&work[0],4*sizeof(su3_matrix),0);
	}
      }

      /* The receiving node does the byte reversal and then checksum,
         if needed */

      if(this_node==destnode)
	{
	  if(byterevflag==1)
	    byterevn((int32type *)&work[0],
		     4*sizeof(su3_matrix)/sizeof(int32type));
	  /* Accumulate checksums */
	  for(k = 0, val = (u_int32type *)&work[0]; 
	      k < 4*(int)sizeof(su3_matrix)/(int)sizeof(int32type); k++, val++)
	    {
	      test_gc.sum29 ^= (*val)<<rank29 | (*val)>>(32-rank29);
	      test_gc.sum31 ^= (*val)<<rank31 | (*val)>>(32-rank31);
	      rank29++; if(rank29 >= 29)rank29 = 0;
	      rank31++; if(rank31 >= 31)rank31 = 0;
	    }
	  deviation = ck_unitarity(work,x,y,z,t);
	  if(deviation > *max_deviation)*max_deviation = deviation;
	}
      else
	{
	  rank29 += 4*sizeof(su3_matrix)/sizeof(int32type);
	  rank31 += 4*sizeof(su3_matrix)/sizeof(int32type);
	  rank29 %= 29;
	  rank31 %= 31;
	}
    }
Ejemplo n.º 17
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 */
Ejemplo n.º 18
0
MUST COMPILE WITH QIO FOR THE SCRATCH FILE
#endif

/* Comment these out if you want to suppress detailed timing */
/*#define IOTIME*/
/*#define PRTIME*/

int main(int argc, char *argv[])
{
  int meascount;
  int prompt;
  Real avm_iters,avs_iters;
  
  double starttime,endtime;
#ifdef IOTIME
  double dtime;
  int iotime = 1;
#else
  int iotime = 0;
#endif
  
  int MinCG,MaxCG;
  Real RsdCG, RRsdCG;
  
  int spin,color,j,k;
  int flag;
  int status;
  
  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];
  quark_source wqs_scr;  /* scratch file */
  char scratch_file[MAX_KAP][MAXFILENAME];
  
  wilson_vector *psi = NULL;
  wilson_prop_field *quark_propagator = NULL;
  wilson_prop_field *quark_prop2 = NULL;
  int cg_cl = CL_CG;
  int source_type;
  
  initialize_machine(&argc,&argv);

  /* Remap standard I/O */
  if(remap_stdio_from_args(argc, argv) == 1)terminate(1);
  
  g_sync();
  /* set up */
  prompt = setup_cl();
  /* loop over input sets */
  
  psi = create_wv_field();
  quark_propagator = create_wp_field(3);
  quark_prop2 = create_wp_field(3);

  while( readin(prompt) == 0)
    {
      
      starttime=dclock();
      MaxCG=niter;
      
      avm_iters=0.0;
      meascount=0;
      
      spectrum_cl_hl_init();
  
      if( fixflag == COULOMB_GAUGE_FIX)
	{
	  if(this_node == 0) 
	    printf("Fixing to Coulomb gauge\n");
#ifdef IOTIME
	  dtime = -dclock();
#endif
	  gaugefix(TUP,(Real)1.5,500,GAUGE_FIX_TOL);
#ifdef IOTIME
	  dtime += dclock();
	  if(this_node==0)printf("Time to gauge fix = %e\n",dtime);
#endif
	  invalidate_this_clov(gen_clov);
	}
      else
	if(this_node == 0)printf("COULOMB GAUGE FIXING SKIPPED.\n");
      
      /* save lattice if requested */
      if( saveflag != FORGET ){
	savelat_p = save_lattice( saveflag, savefile, stringLFN );
      }
      
      if(this_node==0)printf("END OF HEADER\n");
      
      /*	if(this_node==0) printf("num_kap = %d\n", num_kap); */
      /* Loop over kappas to compute and store quark propagator */
      for(k=0;k<num_kap;k++){
	
	kappa=kap[k];
	RsdCG=resid[k];
	RRsdCG=relresid[k];
	if(this_node==0)printf("Kappa= %g r0= %g residue= %g rel= %g\n",
			       (double)kappa,(double)wqs.r0,(double)RsdCG,
			       (double)RRsdCG);
	
	/* open files for wilson propagators */
	
#ifdef IOTIME
	dtime = -dclock();
#endif
	wqstmp = wqs;  /* For clover_info.c */
	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 IOTIME
	dtime += dclock();
	if(startflag_w[k] != FRESH)
	  node0_printf("Time to open prop = %e\n",dtime);
#endif
	
	/* Open scratch file and write header */
	sprintf(scratch_file[k],"%s_%02d",scratchstem_w,k);
	source_type = UNKNOWN;
	fp_scr[k] = w_open_wprop(scratchflag, scratch_file[k], source_type);
	init_qs(&wqs_scr);

	  
	/* Loop over source spins */
	for(spin=0;spin<4;spin++){
	  /* Loop over source colors */
	  for(color=0;color<3;color++){
	    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
		  {
		    copy_wv_from_wp(psi, quark_propagator, color, spin);
		  }
	      }
	    
	    /* Saves one multiplication by zero in cgilu */
	    if(startflag_w[k] == FRESH)flag = 0;
	    else 
	      flag = 1;      
	    
	    /* load psi if requested */
	    status = reload_wprop_sc_to_field( startflag_w[k], fp_in_w[k], 
					       &wqs, spin, color, psi, iotime);
	    if(status != 0)
	      {
		node0_printf("control_cl_hl: Recovering from error by resetting initial guess to zero\n");
		reload_wprop_sc_to_field( FRESH, fp_in_w[k], &wqs,
					  spin, color, psi,0);
		flag = 0;
	      }
	    
	    /* Complete the source structure */
	    wqs.color = color;
	    wqs.spin = spin;
	    
	    /* If we are starting afresh, we set a minimum number
	       of iterations */
	    if(startflag_w[k] == FRESH || status != 0)MinCG = nt/2; 
	    else MinCG = 0;
	    
	    /* Load inversion control structure */
	    qic.prec = PRECISION;
	    qic.min = 0;
	    qic.max = MaxCG;
	    qic.nrestart = nrestart;
	    qic.parity = EVENANDODD;
	    qic.start_flag = flag;
	    qic.nsrc = 1;
	    qic.resid = RsdCG;
	    qic.relresid = RRsdCG;
	    
	    /* Load Dirac matrix parameters */
	    dcp.Kappa = kappa;
	    dcp.Clov_c = clov_c;
	    dcp.U0 = u0;
	    
	    switch (cg_cl) {
	    case BICG:
	      avs_iters =
		(Real)wilson_invert_field_wqs(&wqs, w_source_field, psi,
					      bicgilu_cl_field,
					      &qic,(void *)&dcp);
	      break;
	    case HOP:
	      avs_iters = 
		(Real)wilson_invert_field_wqs(&wqs, w_source_field, psi,
					      hopilu_cl_field,
					      &qic,(void *)&dcp);
	      break;
	    case MR:
	      avs_iters = 
		(Real)wilson_invert_field_wqs(&wqs, w_source_field, psi,
					      mrilu_cl_field,
					      &qic,(void *)&dcp);
		break;
	    case CG:
	      avs_iters = 
		(Real)wilson_invert_field_wqs(&wqs, w_source_field, psi,
					      cgilu_cl_field,
					      &qic,(void *)&dcp);
	      break;
	    default:
	      node0_printf("main(%d): Inverter choice %d not supported\n",
			   cg_cl, this_node);
	    }
	    
	    avm_iters += avs_iters;
	    
	    copy_wp_from_wv(quark_propagator, psi, color, spin);
	    
	    /* Write psi to scratch disk */
#ifdef IOTIME
	    dtime = -dclock();
#endif
	    save_wprop_sc_from_field(scratchflag, fp_scr[k], &wqs_scr,
				     spin, color, psi, "Scratch record", iotime);
#ifdef IOTIME
	    dtime += dclock();
	    if(this_node==0) 
	      printf("Time to dump prop spin %d color %d %e\n",
		     spin,color,dtime);
#endif
	    
	    /* save psi if requested */
	    save_wprop_sc_from_field( saveflag_w[k],fp_out_w[k], &wqs,
				      spin,color,psi,"", iotime);
	    
	  } /* source colors */
	} /* source spins */
	
	/* Close and release scratch file */
	w_close_wprop(scratchflag, fp_scr[k]);
	
	/*if(this_node==0)printf("Dumped prop to file  %s\n",
	  scratch_file[k]); */
	
	/* close files for wilson propagators */
#ifdef IOTIME
	dtime = -dclock();
#endif
	r_close_wprop(startflag_w[k],fp_in_w[k]);
	w_close_wprop(saveflag_w[k],fp_out_w[k]);
#ifdef IOTIME
	dtime += dclock();
	if(saveflag_w[k] != FORGET)
	  node0_printf("Time to close prop = %e\n",dtime);
#endif
	
      } /* kappas */
      
      
      /* Loop over heavy kappas for the point sink spectrum */
      for(k=0;k<num_kap;k++){
	
	/* Read the propagator from the scratch file */

#ifdef IOTIME
	dtime = -dclock();
#endif
	kappa=kap[k];
	init_qs(&wqs_scr);
	reload_wprop_to_wp_field(scratchflag, scratch_file[k], &wqs_scr,
				 quark_propagator, iotime);
#ifdef IOTIME
	dtime += dclock();
	if(this_node==0) 
	  {
	    printf("Time to read 12 spin,color combinations %e\n",dtime);
	    fflush(stdout);
	  }
#endif
	
	/*if(this_node==0)
	  printf("Closed scratch file %s\n",scratch_file[k]);
	  fflush(stdout); */
	
	/* Diagonal spectroscopy */
	spectrum_cl_hl_diag_baryon(quark_propagator, k);
	spectrum_cl_hl_diag_meson(quark_propagator, k);
	spectrum_cl_hl_diag_rot_meson(quark_propagator, k);
	if(strstr(spectrum_request,",sink_smear,") != NULL){
	  spectrum_cl_hl_diag_smeared_meson(quark_propagator, k);
	}
	
	/* Heavy-light spectroscopy */
	/* Loop over light kappas for the point sink spectrum */
	for(j=k+1;j<num_kap;j++){

#ifdef IOTIME
	  dtime = -dclock();
#endif
	  /* Read the propagator from the scratch file */
	  kappa=kap[j];
	  init_qs(&wqs_scr);
	  reload_wprop_to_wp_field(scratchflag,  scratch_file[j], &wqs_scr,
				   quark_prop2, iotime);
#ifdef IOTIME
	  dtime += dclock();
	  if(this_node==0) 
	    {
	      printf("Time to read 12 spin,color combinations %e\n",dtime);
	      fflush(stdout);
	    }
#endif
#ifdef PRTIME
	  dtime = -dclock();
#endif
	  spectrum_cl_hl_offdiag_baryon( quark_propagator, quark_prop2, 
					 j, k);
	  spectrum_cl_hl_offdiag_meson( quark_propagator, quark_prop2, 
					j, k);
	  spectrum_cl_hl_offdiag_rot_meson( quark_propagator, quark_prop2, 
					    j, k);
	  
#ifdef PRTIME
	  dtime = -dclock();
#endif
	} /* light kappas */
	
	/* Smear the heavy propagator in place */
	sink_smear_prop( quark_propagator );
	
	/* Write the smeared propagator to the scratch file (overwriting)*/
	
	kappa=kap[k];

#ifdef IOTIME
	dtime = -dclock();
#endif
	save_wprop_from_wp_field(scratchflag, scratch_file[k], &wqs_scr,
				 quark_propagator, "Scratch propagator", 
				 iotime);
	
#ifdef IOTIME
	dtime += dclock();
	if(this_node==0) 
	  {
	    printf("Time to dump convolution %d %e\n",k,dtime);
	    fflush(stdout);
	  }
#endif
      } /* heavy kappas */
      
      /* Loop over heavy kappas for the shell sink spectrum */
      if(strstr(spectrum_request,",sink_smear,") != NULL)
	for(k=0;k<num_kap;k++){
	  
#ifdef IOTIME
	  dtime = -dclock();
#endif
	  /* Read the propagator from the scratch file */
	  kappa=kap[k];
	  init_qs(&wqs_scr);
	  reload_wprop_to_wp_field(scratchflag,  scratch_file[k], &wqs_scr,
				   quark_propagator, iotime);
#ifdef IOTIME
	  dtime += dclock();
	  if(this_node==0) 
	    {
	      printf("Time to read convolution %d %e\n",k,dtime);
	      fflush(stdout);
	    }
#endif
	  
	  /* Diagonal spectroscopy */
	  spectrum_cl_hl_diag_smeared_meson(quark_propagator, k);
	  
	  /* Heavy-light spectroscopy */
	  /* Loop over light kappas for the shell sink spectrum */
	  for(j=k+1;j<num_kap;j++){
#ifdef PRTIME
	    dtime = -dclock();
#endif
	    /* Read the propagator from the scratch file */
	    kappa=kap[j];
	    init_qs(&wqs_scr);
	    reload_wprop_to_wp_field(scratchflag,  scratch_file[j], &wqs_scr,
				     quark_prop2, iotime);
	      
	    /* Compute the spectrum */
	    spectrum_cl_hl_offdiag_smeared_meson( quark_propagator,
						  quark_prop2, j, k);
	    
#ifdef PRTIME
	    dtime += dclock();
	    if(this_node==0) 
	      {
		printf("Time to read and do off diagonal mesons %d %d %e\n",
		       j,k,dtime);
		fflush(stdout);
	      }
#endif
	} /* light kappas */
	
      } /* heavy kappas */
      
      spectrum_cl_hl_print(wqs.t0);
      spectrum_cl_hl_cleanup();

      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);
    }
      
  destroy_wv_field(psi);
  destroy_wp_field(quark_propagator);
  
  return 0;
}
Ejemplo n.º 19
0
static void 
r_source_cmplx_fm(cmplx_source_file *csf, 
	      field_offset dest_site, 
	      complex *dest_field, int t0)
{
  int rcv_rank, rcv_coords, status;
  int destnode;
  int x,y,z,t,i=0, byterevflag,a;
  int tmin, tmax;

  struct {
    fcomplex q;
    char pad[PAD_SEND_BUF];    /* Introduced because some switches
				  perform better if message lengths
				  are longer */
  } cmsg;

  int buf_length=0, where_in_buf=0;
  fcomplex *cbuff=NULL;
  complex *c;
  fcomplex cfix;
  int vol3 = nx*ny*nz;
  int source_type;

  byterevflag = csf->byterevflag;
  source_type = csf->type;

  if(this_node == 0)
    {
      if(source_type == COMPLEX_FIELD_FM_FILE)
	cbuff = (fcomplex *)malloc(MAX_BUF_LENGTH*sizeof(fcomplex));
      else {
	printf("r_source_cmplx_fm: Unknown source type %d\n", source_type);
	fflush(stdout);
	terminate(1);
      }
      
      buf_length = 0;
      where_in_buf = 0;

    } /* end of if(this_node == 0)*/

  g_sync();

  /* If requested, we replicate the source function on ALL time slices */
  /* Otherwise we read only to time slice t0 */

  if(t0 == ALL_T_SLICES){ tmin = 0; tmax = nt-1; }
  else      { tmin = t0; tmax = t0; }

  /* Node 0 reads and deals out the values */
  status = 0;

  /* Iterate only over timeslice t0 */
  for(rcv_rank=0; rcv_rank<vol3; rcv_rank++)
    {
      /* We do only natural (lexicographic) order here */
      rcv_coords = rcv_rank;
      
      x = rcv_coords % nx;   rcv_coords /= nx;
      y = rcv_coords % ny;   rcv_coords /= ny;
      z = rcv_coords % nz;
      
      if(this_node==0){
	/* Node 0 fills its buffer, if necessary */
	if(where_in_buf == buf_length)
	  {  /* get new buffer */
	    /* new buffer length  = remaining sites, but never bigger 
	       than MAX_BUF_LENGTH */
	    buf_length = vol3 - rcv_rank;
	    if(buf_length > MAX_BUF_LENGTH) buf_length = MAX_BUF_LENGTH;
	    /* then do read */
	    a=(int)g_read(cbuff,sizeof(fcomplex),buf_length,csf->fp);
	    
	    if( a != buf_length)
	      {
		if(status == 0)
		  printf(" node %d source file read error %d file %s\n",
			 this_node, errno, csf->filename); 
		fflush(stdout); 
		status = 1;
	      }
	    where_in_buf = 0;  /* reset counter */
	  }  /*** end of the buffer read ****/
	
	/* Save data in msg.q for further processing */
	cmsg.q = cbuff[where_in_buf];
      }
      
      /* Loop either over all time slices or just one time slice */
      for(t = tmin; t <= tmax; t++){
	
	destnode=node_number(x,y,z,t);
	
	if(this_node == 0){
	  /* node 0 doesn't send to itself */
	  if(destnode != 0){
	    /* send to correct node */
	    send_field((char *)&cmsg, sizeof(cmsg), destnode);
	  }
	} /* if(this_node==0) */
	else {	/* for all nodes other than node 0 */
	  if(this_node==destnode){
	    get_field((char *)&cmsg, sizeof(cmsg),0);
	  }
	}
	
	/* The receiving node does the byte reversal.  At this point msg
	   contains the input vectors and i points to the destination
	   site structure */
	
	if(this_node==destnode)
	{
	    /* Byte reverse a copy, since we may need to reuse cmsg.q */
	    cfix = cmsg.q;
	    if(byterevflag==1){
		byterevn((int32type *)&cfix, 
			 sizeof(fcomplex)/sizeof(int32type));
	    }
	    
	    /* Now copy the site data into the destination converting
	       to generic precision if needed */
	    
	    i = node_index(x,y,z,t);
	    
	    if(dest_site == (field_offset)(-1))
		c = dest_field + i;
	    else
		c = (complex *)F_PT(&lattice[i],dest_site);
	    
	    c->real = cfix.real;
	    c->imag = cfix.imag;
	    //printf("C %d %d %d %g %g\n", 
	    //	       x, y, z, cmsg.q.real, cmsg.q.imag);
	} /* if this_node == destnode */
      } /* t */
      
      where_in_buf++;
      
    }  /* rcv_rank, irecord */
  
  if(cbuff != NULL)free(cbuff); cbuff = NULL;
}
Ejemplo n.º 20
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.º 21
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.º 22
0
int main(int argc, char *argv[])
{
  int prompt;
  int i, j, iq0, iq1;
#ifdef CLOV_LEAN
  int oldiq0, oldiq1, oldip0;
#endif
  double starttime, endtime;
#ifdef PRTIME
  double dtime;
#endif
  wilson_prop_field *prop[MAX_PROP];
  wilson_prop_field *quark[MAX_QK];
  
  initialize_machine(&argc,&argv);

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

  /* loop over input sets */

  while( readin(prompt) == 0){

    if(prompt == 2)continue;
    
    total_iters=0;
    
#ifdef HISQ_SVD_COUNTER
    hisq_svd_counter = 0;
#endif
    
    /**************************************************************/
    /* Set up gauge field */
    
    if( param.fixflag == COULOMB_GAUGE_FIX)
      {
	if(this_node == 0) 
	  printf("Fixing to Coulomb gauge\n");

	STARTTIME;
	gaugefix(TUP,(Real)1.5,500,GAUGE_FIX_TOL);
	ENDTIME("gauge fix");

	/* (Re)construct APE smeared links after gauge fixing.  
	   No KS phases here! */
	destroy_ape_links_3D(ape_links);
	ape_links = ape_smear_3D( param.staple_weight, param.ape_iter );

	invalidate_this_clov(gen_clov);
      }
    else
      if(this_node == 0)printf("COULOMB GAUGE FIXING SKIPPED.\n");
    
    /* save lattice if requested */
    if( param.saveflag != FORGET ){
      savelat_p = save_lattice( param.saveflag, param.savefile, 
				param.stringLFN );
    } else {
      savelat_p = NULL;
    }

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


    /* Loop over the propagators */

    STARTTIME;
    for(i=0; i<param.num_prop; i++){
      node0_printf("******* Creating propagator %d ********\n",i);fflush(stdout);
      
      /**************************************************************/
      /* Read and/or generate quark propagator */

      if(param.prop_type[i] == CLOVER_TYPE)
	{
	  int ncolor = convert_ksource_to_color(param.src_qs[i].nsource);
	  
	  prop[i] = create_wp_field(ncolor);
      
	  node0_printf("Generate Dirac propagator\n");
	  node0_printf("Kappa= %g source %s residue= %g rel= %g\n",
		       (double)param.dcp[i].Kappa,
		       param.src_qs[i].descrp,
		       (double)param.qic[i].resid,
		       (double)param.qic[i].relresid);
	  
	  /* For clover_info */
	  wqstmp = param.src_qs[i];
	  dcptmp = param.dcp[i];

	  total_iters += get_wprop_to_wp_field(param.prop_type[i],
					       param.startflag_w[i], 
					       param.startfile_w[i], 
					       param.saveflag_w[i], 
					       param.savefile_w[i],
					       prop[i], 
					       &param.src_qs[i],
					       &param.qic[i], 
					       (void *)&param.dcp[i],
					       param.bdry_phase[i],
					       param.coord_origin,
					       param.check[i]);
#ifdef CLOV_LEAN
	  /* Free clover prop memory if we have saved the prop to disk */
	  if(param.saveflag_w[i] != FORGET){
	    free_wp_field(prop[i]);
	    clear_qs(&param.src_qs[i]);
	    node0_printf("destroy prop[%d]\n",i);
	  }
#endif
	}
	
      /* ------------------------------------------- */
      else if(param.prop_type[i] == IFLA_TYPE)
	{
	  int ncolor = convert_ksource_to_color(param.src_qs[i].nsource);
	  

	  prop[i] = create_wp_field(ncolor);
      
	  node0_printf("Generate Dirac IFLA propagator\n");
	  if(this_node==0)printf("Kappa= %g source %s residue= %g rel= %g\n",
				 (double)param.nap[i].kapifla,
				 param.src_qs[i].descrp,
				 (double)param.qic[i].resid,
				 (double)param.qic[i].relresid);
	 
	  /* For clover_info */
	  wqstmp = param.src_qs[i];
	  naptmp = param.nap[i];
	  
	  total_iters += get_wprop_to_wp_field(param.prop_type[i],
					       param.startflag_w[i], 
					       param.startfile_w[i], 
					       param.saveflag_w[i], 
					       param.savefile_w[i],
					       prop[i], 
					       &param.src_qs[i], 
					       &param.qic[i], 
					       (void *)&param.nap[i],
					       param.bdry_phase[i],
					       param.coord_origin,
					       param.check[i]);
#ifdef CLOV_LEAN
	  /* Free clover prop memory if we have saved the prop to disk */
	  if(param.saveflag_w[i] != FORGET){
	    free_wp_field(prop[i]);
	    clear_qs(&param.src_qs[i]);
	    node0_printf("destroy prop[%d]\n",i);
	  }
#endif
	}
      else if(param.prop_type[i] == KS_TYPE || param.prop_type[i] == KS0_TYPE ) /* KS_TYPE */
	{
	  prop[i] = create_wp_field(param.src_qs[i].ncolor);

	  if(this_node==0)printf("Mass= %g source %s residue= %g rel= %g\n",
				 (double)param.ksp[i].mass,
				 param.src_qs[i].descrp,
				 (double)param.qic[i].resid,
				 (double)param.qic[i].relresid);
	  
	  total_iters += get_ksprop_to_wp_field(param.startflag_ks[i], 
						param.startfile_ks[i], 
						param.saveflag_ks[i], 
						param.savefile_ks[i],
						prop[i], 
						&param.src_qs[i],
						&param.qic[i], 
						&param.ksp[i],
						param.bdry_phase[i],
						param.coord_origin,
						param.check[i],
						param.prop_type[i] == KS0_TYPE);
#ifdef CLOV_LEAN
	  /* (We don't free naive prop memory, since we don't save it
	     as a clover prop in get_ksprop_to_wp_field) */
#endif
	}
      else /* KS4_TYPE */
	{
	  prop[i] = create_wp_field(param.src_qs[i].ncolor);

	  if(this_node==0)printf("Mass= %g source %s residue= %g rel= %g\n",
				 (double)param.ksp[i].mass,
				 param.src_qs[i].descrp,
				 (double)param.qic[i].resid,
				 (double)param.qic[i].relresid);
	  
	  total_iters += get_ksprop4_to_wp_field(param.startflag_w[i], 
						 param.startfile_w[i], 
						 param.saveflag_w[i], 
						 param.savefile_w[i],
						 prop[i], 
						 &param.src_qs[i],
						 &param.qic[i], 
						 &param.ksp[i],
						 param.bdry_phase[i],
						 param.coord_origin,
						 param.check[i]);
	}
      
    } /* propagators */
    ENDTIME("compute propagators");

    /*****************************************************************/
    /* Complete the quark propagators by applying the sink operators
       to either the raw propagator or by building on an existing quark
       propagator */
    
    STARTTIME;
#ifdef CLOV_LEAN
    oldip0 = -1;
    oldiq0 = -1;
    oldiq1 = -1;
#endif
    for(j=0; j<param.num_qk; j++){
      node0_printf("******* Creating quark %d ********\n",j); fflush(stdout);
      i = param.prop_for_qk[j];

      if(param.parent_type[j] == PROP_TYPE){
#ifdef CLOV_LEAN
	/* Restore clover prop[i] from file. */
	/* But first destroy the old one, unless we still need it */
	if(oldip0 >= 0 && oldip0 != i)
	  if(param.prop_type[oldip0] == CLOVER_TYPE &&
	     param.saveflag_w[oldip0] != FORGET){
	    free_wp_field(prop[oldip0]);
	    node0_printf("destroy prop[%d]\n",oldip0);
	  }
	
	/* In this case we won't need any old quarks */
	if(oldiq0 >= 0)
	  if(param.saveflag_q[oldiq0] != FORGET){
	    free_wp_field(quark[oldiq0]);
	    node0_printf("destroy quark[%d]\n",oldiq0);
	  }

	if(oldiq1 >= 0)
	  if(param.saveflag_q[oldiq1] != FORGET){
	    free_wp_field(quark[oldiq1]);
	    node0_printf("destroy quark[%d]\n",oldiq1);
	  }

	if(prop[i]->swv[0] == NULL)
	  reread_wprop_to_wp_field(param.saveflag_w[i], param.savefile_w[i], prop[i]);
#endif
	/* Before applying operator, apply momentum twist to
	   ape_links.  Use the momentum twist of the parent
	   propagator */
	momentum_twist_ape_links(i, +1);
	/* Apply sink operator quark[j] <- Op[j] prop[i] */
	quark[j] = create_wp_field_copy(prop[i]);
	wp_sink_op(&param.snk_qs_op[j], quark[j]);
	/* Remove twist */
	momentum_twist_ape_links(i, -1);
#ifdef CLOV_LEAN
	oldip0 = i;
	oldiq0 = -1;
#endif
      }
      else if(param.parent_type[j] == QUARK_TYPE) { /* QUARK_TYPE */
#ifdef CLOV_LEAN
	/* Restore quark[i] from file */
	/* But first destroy the old ones, unless we still need one of them */
	
	/* In this case we won't need the old prop */
	if(oldip0 >= 0)
	   if(param.prop_type[oldip0] == CLOVER_TYPE &&
	      param.saveflag_w[oldip0] != FORGET){
	     free_wp_field(prop[oldip0]);
	     node0_printf("destroy prop[%d]\n",oldip0);
	   }

	if(oldiq0 >= 0 && oldiq0 != i)
	  if(param.saveflag_q[oldiq0] != FORGET){
	    free_wp_field(quark[oldiq0]);
	    node0_printf("destroy quark[%d]\n",oldiq0);
	  }

	if(oldiq1 >= 0 && oldiq1 != i)
	  if(param.saveflag_q[oldiq1] != FORGET){
	    free_wp_field(quark[oldiq1]);
	    node0_printf("destroy quark[%d]\n",oldiq1);
	  }

	if(quark[i]->swv[0] == NULL)
	  reread_wprop_to_wp_field(param.saveflag_q[i], param.savefile_q[i], quark[i]);
	
#endif
	/* Apply sink operator quark[j] <- Op[j] quark[i] */
	momentum_twist_ape_links(i, +1);
	quark[j] = create_wp_field_copy(quark[i]);
	wp_sink_op(&param.snk_qs_op[j], quark[j]);
	momentum_twist_ape_links(i, -1);
#ifdef CLOV_LEAN
	oldip0 = -1;
	oldiq0 = i;
#endif
      } else { /* COMBO_TYPE */
	int k;
	int nc = quark[param.combo_qk_index[j][0]]->nc;
	/* Create a zero field */
	quark[j] = create_wp_field(nc);
	/* Compute the requested linear combination */
	for(k = 0; k < param.num_combo[j]; k++){
	  wilson_prop_field *q = quark[param.combo_qk_index[j][k]];
	  if(nc != q->nc){
	    printf("Error: Attempting to combine an inconsistent number of colors: %d != %d\n",nc, q->nc);
	    terminate(1);
	  }
	  scalar_mult_add_wprop_field(quark[j], q, param.combo_coeff[j][k], quark[j]);
	}
      }
	
      /* Save the resulting quark[j] if requested */
      dump_wprop_from_wp_field( param.saveflag_q[j], param.savetype_q[j],
				param.savefile_q[j], quark[j]);

      /* Can we delete any props and quarks now? */
      /* If nothing later depends on a prop or quark, free it up. */
      for(i = 0; i < param.num_prop; i++)
	if( prop[i]->swv[0] != NULL  &&  param.prop_dep_qkno[i] < j ){
	  free_wp_field(prop[i]);
	  node0_printf("free prop[%d]\n",i);
	}
      
      for(i = 0; i < j; i++)
	if( quark[i]->swv[0] != NULL  &&  param.quark_dep_qkno[i] < j ){
	  free_wp_field(quark[i]);
	  node0_printf("free quark[%d]\n",i);
	}
#ifdef CLOV_LEAN
      oldiq1 = j;
#endif
    }

#ifdef CLOV_LEAN
    /* Free remaining memory */
    if(oldip0 >= 0)
       if(param.prop_type[oldip0] == CLOVER_TYPE &&
	  param.saveflag_w[oldip0] != FORGET){
	 free_wp_field(prop[oldip0]);
	 node0_printf("destroy prop[%d]\n",oldip0);
       }
    
    if(oldiq0 >= 0)
      if(param.saveflag_q[oldiq0] != FORGET){
	free_wp_field(quark[oldiq0]);
	node0_printf("destroy quark[%d]\n",oldiq0);
      }
    
    if(oldiq1 >= 0)
      if(param.saveflag_q[oldiq1] != FORGET){
	free_wp_field(quark[oldiq1]);
	node0_printf("destroy quark[%d]\n",oldiq1);
      }
#endif

    /* Now destroy all remaining propagator fields */

    for(i = 0; i < param.num_prop; i++){
      if(prop[i] != NULL)node0_printf("destroy prop[%d]\n",i);
      destroy_wp_field(prop[i]);
      prop[i] = NULL;
    }
    ENDTIME("generate quarks");
    
    /****************************************************************/
    /* Compute the meson propagators */

    STARTTIME;
    for(i = 0; i < param.num_pair; i++){

      /* Index for the quarks making up this meson */
      iq0 = param.qkpair[i][0];
      iq1 = param.qkpair[i][1];

      node0_printf("Mesons for quarks %d and %d\n",iq0,iq1);

#ifdef CLOV_LEAN
      /* Restore quarks from file and free old memory */
      /* We try to reuse props that are already in memory, so we don't
         destroy them immediately, but wait to see if we need
         them again for the next pair. */
      if(i > 0 && oldiq0 != iq0 && oldiq0 != iq1)
	if(param.saveflag_q[oldiq0] != FORGET){
	  free_wp_field(quark[oldiq0]);
	  node0_printf("destroy quark[%d]\n",oldiq0);
	}
      
      if(i > 0 && oldiq1 != iq0 && oldiq1 != iq1)
	if(param.saveflag_q[oldiq1] != FORGET){
	  free_wp_field(quark[oldiq1]);
	  node0_printf("destroy quark[%d]\n",oldiq1);
	}

      if(quark[iq0]->swv[0] == NULL)
	reread_wprop_to_wp_field(param.saveflag_q[iq0], param.savefile_q[iq0], quark[iq0]);

      if(quark[iq1]->swv[0] == NULL){
	reread_wprop_to_wp_field(param.saveflag_q[iq1], param.savefile_q[iq1], quark[iq1]);
      }
#endif

      /* Tie together to generate hadron spectrum */
      spectrum_cl(quark[iq0], quark[iq1], i);

      /* Remember, in case we need to free memory */
#ifdef CLOV_LEAN
      oldiq0 = iq0;
      oldiq1 = iq1;
#endif
    }
#ifdef CLOV_LEAN
    /* Free any remaining quark prop memory */
    if(quark[oldiq0]->swv[0] != NULL)
      if(param.saveflag_q[oldiq0] != FORGET){
	free_wp_field(quark[oldiq0]);
	node0_printf("destroy quark[%d]\n",oldiq0);
      }
    if(quark[oldiq1]->swv[0] != NULL)
      if(param.saveflag_q[oldiq1] != FORGET){
	free_wp_field(quark[oldiq1]);
	node0_printf("destroy quark[%d]\n",oldiq1);
      }
#endif
    ENDTIME("tie hadron correlators");

    node0_printf("RUNNING COMPLETED\n");
    endtime=dclock();

    node0_printf("Time = %e seconds\n",(double)(endtime-starttime));
    node0_printf("total_iters = %d\n",total_iters);
#ifdef HISQ_SVD_COUNTER
    printf("hisq_svd_counter = %d\n",hisq_svd_counter);
#endif
    fflush(stdout);

    for(i = 0; i < param.num_qk; i++){
      if(quark[i] != NULL)node0_printf("destroy quark[%d]\n",i);
      destroy_wp_field(quark[i]);
      quark[i] = NULL;
    }

    destroy_ape_links_3D(ape_links);

    /* Destroy fermion links (possibly created in make_prop()) */

#if FERM_ACTION == HISQ
    destroy_fermion_links_hisq(fn_links);
#else
    destroy_fermion_links(fn_links);
#endif
    fn_links = NULL;

  } /* readin(prompt) */

#ifdef HAVE_QUDA
  qudaFinalize();
#endif
  normal_exit(0);

  return 0;
}
Ejemplo n.º 23
0
// Only load non-zero elements of remaining columns of Q
// Read from node0 only -- transfer data to all other nodes one by one
void loadQ(complex **Q, int ckpt_load) {
  int i, j, savi = 0, savj = 0, ret = 1, Ndat = 4 * DIMF, Qlen;
  int mynode = 0, destnode = 0, Nlines = 0;
  char infile[80];
  Real re, im;
  complex **tbuf = NULL;   // Only malloc on node0 if numnodes() > 1
  FILE *fp = NULL;

  // Total length of each column of Q
  Qlen = sites_on_node * Ndat * sizeof(complex);

  if (this_node == 0) {
    node0_printf("Reloading columns %d--%d\n", ckpt_load + 1, volume * Ndat);
    sprintf(infile, "%s.Q%d", startfile, ckpt_load);
    fp = fopen(infile, "r");    // Open to read
    if (fp == NULL) {
      printf("loadQ: node%d can't open file %s\n", this_node, infile);
      fflush(stdout);
      terminate(1);
    }

    // Allocate temporary storage to be passed to other nodes
    // Only need if numnodes() > 1, but hard-code it in any case
    // to suppress compiler warnings
    tbuf = malloc(sizeof(complex*) * volume * Ndat);
    for (i = ckpt_load; i < volume * Ndat; i++) {
      tbuf[i] = malloc(sizeof(complex) * sites_on_node * Ndat);
      for (j = 0; j < sites_on_node * Ndat; j++)
        tbuf[i][j] = cmplx(0.0, 0.0);
    }
    if (tbuf[volume * Ndat - 1] == NULL) {
      printf("loadQ: can't malloc tbuf\n");
      fflush(stdout);
      terminate(1);
    }

    // Fill Q[i][j] on node0
    while (ret != EOF && i > 0) {
      ret = fscanf(fp, "%d\t%d\t%d\t%lg\t%lg\n", &mynode, &i, &j, &re, &im);
      Nlines++;
      if (mynode == 1) {
        tbuf[i][j] = cmplx(re, im);   // So we don't lose this
        break;
      }
      else if (mynode == -1) {
        savi = i;
        break;
      }
      Q[i][j] = cmplx(re, im);
    }
  }
  g_sync();   // Don't let other nodes race ahead

  // Now fill in each other node in turn
  for (destnode = 1; destnode < numnodes(); destnode++) {
    // Fill rest of buffer on node0
    if (this_node == 0) {
      while (ret != EOF && i > 0) {
        ret = fscanf(fp, "%d\t%d\t%d\t%lg\t%lg\n", &mynode, &i, &j, &re, &im);
        Nlines++;
        if (mynode != destnode) {
          savi = i;   // May still need to write below
          savj = j;
          break;
        }
        tbuf[i][j] = cmplx(re, im);
      }
    }
    g_sync();   // Don't let other nodes race ahead

    // Now send buffer to destnode
    for (i = ckpt_load; i < volume * Ndat; i++) {
      if (this_node == 0)
        send_field((char *)tbuf[i], Qlen, destnode);
      else if (this_node == destnode)
        get_field((char *)Q[i], Qlen, 0);

      g_sync();   // To be cautious
    }

    // Reset tbuf if we have another node to do
    if (this_node == 0 && mynode != -1) {
      for (i = ckpt_load; i < volume * Ndat; i++) {
        for (j = 0; j < sites_on_node * Ndat; j++)
          tbuf[i][j] = cmplx(0.0, 0.0);
      }

      tbuf[savi][savj] = cmplx(re, im);
    }
    g_sync();   // Don't let other nodes race ahead
  }

  // Now we should be done
  if (this_node == 0) {
    if (mynode != -1) {
      printf("loadQ: should be done but tag = %d\n", mynode);
      fflush(stdout);
      terminate(1);
    }

      // Check that the correct number of elements were read
    if (Nlines - 1 != savi) {   // End of file key
      printf("loadQ: read %d elements but should have had %d\n",
             Nlines - 1, savi);
      fflush(stdout);
      terminate(1);
    }

    fclose(fp);
    for (i = ckpt_load; i < volume * Ndat; i++)
      free(tbuf[i]);
    free(tbuf);
  }
  g_sync();   // Don't let other nodes race ahead
}
Ejemplo n.º 24
0
int main( int argc, char **argv ){
  int prompt;
  char *filexml;
  
  initialize_machine(&argc,&argv);

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

  /* loop over input sets */
  while( readin(prompt) == 0){
    
    if(prompt == 2)continue;
    
    node0_printf("BEGIN\n");
#ifdef CHECK_INVERT
    
    check_ks_invert( par_buf.srcfile[0], srcflag, par_buf.ansfile, par_buf.ansflag, 
		     par_buf.nmass, par_buf.ksp, par_buf.qic);
    
#else
#ifndef HAVE_QIO
    BOMB Checking the fermion force requires QIO compilation;
#endif
    
    check_fermion_force( par_buf.srcfile, srcflag, par_buf.ansfile[0], 
			 par_buf.ansflag[0], par_buf.nmass, par_buf.ksp);
    node0_printf("Done checking fermion force\n");
#endif
    
    /* save lattice if requested */
    if( saveflag != FORGET ){
      rephase( OFF );
      node0_printf("Saving the lattice\n");
      save_lattice( saveflag, savefile, NULL );
      rephase( ON );
    }
    
#ifdef FN
    /* save longlinks if requested */
    if (savelongflag != FORGET ){
#ifdef HAVE_QIO
      filexml = create_QCDML();
      node0_printf("Saving the long links\n");
      save_color_matrix_scidac_from_field( savelongfile, filexml, 
		   "Long links", QIO_SINGLEFILE, 
		   get_lnglinks(get_fm_links(fn_links)[0]), 4, PRECISION);
      /* REMOVE NEXT STATEMENT */
      //      save_color_matrix_scidac_from_field( "lngback.scidac", filexml, 
      //		   "Long back links", QIO_SINGLEFILE, 
      //                   get_lngbacklinks(get_fm_links(fn_links)[0]), 4, PRECISION);
      free_QCDML(filexml);
#else
      printf("ERROR: Can't save the longlinks.  Recompile with QIO\n");
#endif
    }
    
    /* save fatlinks if requested */
    if (savefatflag != FORGET ){
#ifdef HAVE_QIO
      filexml = create_QCDML();
      node0_printf("Saving the fat links\n");
      save_color_matrix_scidac_from_field( savefatfile, filexml, 
            "Fat links", QIO_SINGLEFILE, 
	    get_fatlinks(get_fm_links(fn_links)[0]), 4, PRECISION);
      /* REMOVE NEXT STATEMENT */
      //      save_color_matrix_scidac_from_field( "fatback.scidac", filexml, 
      //	   "Fat back links", QIO_SINGLEFILE, 
      //	    get_fatbacklinks(get_fm_links(fn_links)[0]), 4, PRECISION);
      free_QCDML(filexml);
#else
      printf("ERROR: Can't save the fatlinks.  Recompile with QIO\n");
#endif
    }
#endif
    
  }
  node0_printf("RUNNING COMPLETED\n");

#ifndef CHECK_INVERT

#ifdef HISQ_SVD_COUNTER
  printf("hisq_svd_counter = %d\n", hisq_svd_counter);
#endif
  
#ifdef HISQ_FORCE_FILTER_COUNTER
  printf("hisq_force_filter_counter = %d\n", hisq_force_filter_counter);
#endif

#endif

  return 0;
}
Ejemplo n.º 25
0
int main( int argc, char **argv ){
  register site *s;
  int i,si;
  int prompt;
  double dtime;
  su3_vector **eigVec ;
  su3_vector *tmp ;
  double *eigVal ;
  int total_R_iters ;
  double chirality ;

  initialize_machine(&argc,&argv);
#ifdef HAVE_QDP
  QDP_initialize(&argc, &argv);
#ifndef QDP_PROFILE
  QDP_profcontrol(0);
#endif
#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){
    
    dtime = -dclock();
    invalidate_all_ferm_links(&fn_links);
    make_path_table(&ks_act_paths, &ks_act_paths_dmdu0);
    /* Load fat and long links for fermion measurements if needed */
    load_ferm_links(&fn_links, &ks_act_paths);
    /* call fermion_variable measuring routines */
    /* results are printed in output file */
    f_meas_imp( F_OFFSET(phi), F_OFFSET(xxx), mass,
		&fn_links, &fn_links_dmdu0);
    eigVal = (double *)malloc(Nvecs*sizeof(double));
    eigVec = (su3_vector **)malloc(Nvecs*sizeof(su3_vector*));
    for(i=0;i<Nvecs;i++)
      eigVec[i]=
	(su3_vector*)malloc(sites_on_node*sizeof(su3_vector));
    
    total_R_iters=Kalkreuter(eigVec, eigVal, eigenval_tol, 
			     error_decr, Nvecs, MaxIter, Restart, 
			     Kiters, EVEN, &fn_links) ;
    tmp = (su3_vector*)malloc(sites_on_node*sizeof(su3_vector));
    for(i=0;i<Nvecs;i++)
      { 
	/* Construct to odd part of the vector.                 *
	 * Note that the true odd part of the eigenvector is    *
	 *  i/sqrt(eigVal) Dslash Psi. But since I only compute *
	 * the chirality the i factor is irrelevant (-i)*i=1!!  */
	dslash_fn_field(eigVec[i], tmp, ODD, &fn_links) ;
	FORSOMEPARITY(si,s,ODD){ 
	  scalar_mult_su3_vector( &(tmp[si]),
				  1.0/sqrt(eigVal[i]), 
				  &(eigVec[i][si]) ) ;
	}
	
	measure_chirality(eigVec[i], &chirality, EVENANDODD);
	/* Here I divide by 2 since the EVEN vector is normalized to
	 * 1. The EVENANDODD vector is normalized to 2. I could have
	 * normalized the EVENANDODD vector to 1 and then not devide
	 * by to.  The measure_chirality routine assumes vectors
	 * normalized to 1.  */
	node0_printf("Chirality(%i): %g\n",i,chirality/2) ;
      }
    free(tmp);
    /**
       for(i=0;i<Nvecs;i++)
       {
       sprintf(label,"DENSITY(%i)",i) ;
       print_densities(eigVec[i], label, ny/2,nz/2,nt/2, EVEN) ;
       }
    **/
    for(i=0;i<Nvecs;i++)
      free(eigVec[i]) ;
    free(eigVec) ;
    free(eigVal) ;
#ifdef FN
    invalidate_all_ferm_links(&fn_links);
#endif
    fflush(stdout);
    
    node0_printf("RUNNING COMPLETED\n"); fflush(stdout);
    dtime += dclock();
    if(this_node==0){
      printf("Time = %e seconds\n",dtime);
      printf("total_iters = %d\n",total_iters);
      printf("total Rayleigh iters = %d\n",total_R_iters);
    }
    fflush(stdout);
  }
Ejemplo n.º 26
0
int
main( int argc, char **argv )
{
  int meascount,traj_done;
  int prompt;
  int s_iters, avs_iters, avspect_iters, avbcorr_iters;
  double dtime, dclock();
  
  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();

//  restore_random_state_scidac_to_site("randsave", F_OFFSET(site_prn));
//  restore_color_vector_scidac_to_site("xxx1save", F_OFFSET(xxx1),1);
//  restore_color_vector_scidac_to_site("xxx2save", F_OFFSET(xxx2),1);

  /* loop over input sets */
  while( readin(prompt) == 0) {
    
    /* perform warmup trajectories */
    dtime = -dclock();
    for( traj_done=0; traj_done < warms; traj_done++ ){
      update();
    }
    node0_printf("WARMUPS COMPLETED\n"); fflush(stdout);
    
    /* perform measuring trajectories, reunitarizing and measuring 	*/
    meascount=0;		/* number of measurements 		*/
    avspect_iters = avs_iters = avbcorr_iters = 0;
    for( traj_done=0; traj_done < trajecs; traj_done++ ){ 
      
      /* do the trajectories */
      s_iters=update();
      
      /* measure every "propinterval" trajectories */
      if( (traj_done%propinterval)==(propinterval-1) ){
	
	/* call gauge_variable fermion_variable measuring routines */
	/* results are printed in output file */
	rephase(OFF);
	g_measure( );
	rephase(ON);

	/* Load fat and long links for fermion measurements */
	load_ferm_links(&fn_links, &ks_act_paths);
#ifdef DM_DU0
	load_ferm_links(&fn_links_dmdu0, &ks_act_paths_dmdu0);
#endif

	/* Measure pbp, etc */
#ifdef ONEMASS
	f_meas_imp(F_OFFSET(phi),F_OFFSET(xxx),mass, &fn_links, 
		   &fn_links_dmdu0);
#else
	f_meas_imp( F_OFFSET(phi1), F_OFFSET(xxx1), mass1, 
		    &fn_links, &fn_links_dmdu0);
	f_meas_imp( F_OFFSET(phi2), F_OFFSET(xxx2), mass2,
		    &fn_links, &fn_links_dmdu0);
#endif

	/* Measure derivatives wrto chemical potential */
#ifdef D_CHEM_POT
#ifdef ONEMASS
	Deriv_O6( F_OFFSET(phi1), F_OFFSET(xxx1), F_OFFSET(xxx2), mass,
		  &fn_links, &fn_links_dmdu0);
#else
	Deriv_O6( F_OFFSET(phi1), F_OFFSET(xxx1), F_OFFSET(xxx2), mass1,
		  &fn_links, &fn_links_dmdu0);
	Deriv_O6( F_OFFSET(phi1), F_OFFSET(xxx1), F_OFFSET(xxx2), mass2,
		  &fn_links, &fn_links_dmdu0);
#endif
#endif

#ifdef SPECTRUM 
	/* Fix TUP Coulomb gauge - gauge links only*/
	rephase( OFF );
	gaugefix(TUP,(Real)1.8,500,(Real)GAUGE_FIX_TOL);
	rephase( ON );
#ifdef FN
	invalidate_all_ferm_links(&fn_links);
#ifdef DM_DU0
	invalidate_all_ferm_links(&fn_links_dmdu0);
#endif
#endif
	/* Load fat and long links for fermion measurements */
	load_ferm_links(&fn_links, &ks_act_paths);
#ifdef DM_DU0
	load_ferm_links(&fn_links_dmdu0, &ks_act_paths_dmdu0);
#endif	
	if(strstr(spectrum_request,",spectrum,") != NULL){
#ifdef ONEMASS
	  avspect_iters += spectrum2(mass,F_OFFSET(phi),F_OFFSET(xxx),
				     &fn_links);
#else
	  avspect_iters += spectrum2( mass1, F_OFFSET(phi1),
				      F_OFFSET(xxx1), &fn_links);
	  avspect_iters += spectrum2( mass2, F_OFFSET(phi1),
				      F_OFFSET(xxx1), &fn_links);
#endif
	}
	
	if(strstr(spectrum_request,",spectrum_point,") != NULL){
#ifdef ONEMASS
	  avspect_iters += spectrum_fzw(mass,F_OFFSET(phi),F_OFFSET(xxx),
					&fn_links);
#else
	  avspect_iters += spectrum_fzw( mass1, F_OFFSET(phi1),
					 F_OFFSET(xxx1), &fn_links);
	  avspect_iters += spectrum_fzw( mass2, F_OFFSET(phi1),
					 F_OFFSET(xxx1), &fn_links);
#endif
	}
	
	if(strstr(spectrum_request,",nl_spectrum,") != NULL){
#ifdef ONEMASS
	  avspect_iters += nl_spectrum(mass,F_OFFSET(phi),F_OFFSET(xxx),
				       F_OFFSET(tempmat1),F_OFFSET(staple),
				       &fn_links);
#else
	  avspect_iters += nl_spectrum( mass1, F_OFFSET(phi1), 
		F_OFFSET(xxx1), F_OFFSET(tempmat1),F_OFFSET(staple),
					&fn_links);
#endif
	}
	
	if(strstr(spectrum_request,",spectrum_mom,") != NULL){
#ifdef ONEMASS
	  avspect_iters += spectrum_mom(mass,mass,F_OFFSET(phi),5e-3,
					&fn_links);
#else
	  avspect_iters += spectrum_mom( mass1, mass1, 
					 F_OFFSET(phi1), 1e-1,
					 &fn_links);
#endif
	}
	
	if(strstr(spectrum_request,",spectrum_multimom,") != NULL){
#ifdef ONEMASS
	  avspect_iters += spectrum_multimom(mass,
					     spectrum_multimom_low_mass,
					     spectrum_multimom_mass_step,
					     spectrum_multimom_nmasses,
					     5e-3, &fn_links);
#else
	  avspect_iters += spectrum_multimom(mass1,
					     spectrum_multimom_low_mass,
					     spectrum_multimom_mass_step,
					     spectrum_multimom_nmasses,
					     5e-3, &fn_links);

#endif
	}
	
#ifndef ONEMASS
	if(strstr(spectrum_request,",spectrum_nd,") != NULL){
	  avspect_iters += spectrum_nd( mass1, mass2, 1e-1,
					&fn_links);
	}
#endif
	if(strstr(spectrum_request,",spectrum_nlpi2,") != NULL){
#ifdef ONEMASS
	  avspect_iters += spectrum_nlpi2(mass,mass,F_OFFSET(phi),5e-3,
					  &fn_links );
#else
	  avspect_iters += spectrum_nlpi2( mass1, mass1, 
					   F_OFFSET(phi1),1e-1,
					   &fn_links );
	  avspect_iters += spectrum_nlpi2( mass2, mass2, 
					   F_OFFSET(phi1),1e-1,
					   &fn_links );
#endif
	}
	
	if(strstr(spectrum_request,",spectrum_singlets,") != NULL){
#ifdef ONEMASS
	  avspect_iters += spectrum_singlets(mass, 5e-3, F_OFFSET(phi),
					     &fn_links);
#else
	  avspect_iters += spectrum_singlets(mass1, 5e-3, F_OFFSET(phi1),
					     &fn_links );
	  avspect_iters += spectrum_singlets(mass2, 5e-3, F_OFFSET(phi1),
					     &fn_links );
#endif
	}

	if(strstr(spectrum_request,",fpi,") != NULL)
	  {
	    avspect_iters += fpi_2( fpi_mass, fpi_nmasses, 2e-3,
				    &fn_links );
	  }
	
#ifdef HYBRIDS
	if(strstr(spectrum_request,",spectrum_hybrids,") != NULL){
#ifdef ONEMASS
	  avspect_iters += spectrum_hybrids( mass,F_OFFSET(phi),1e-1,
					     &fn_links);
#else
	  avspect_iters += spectrum_hybrids( mass1, F_OFFSET(phi1), 5e-3,
					     &fn_links);
	  avspect_iters += spectrum_hybrids( mass2, F_OFFSET(phi1), 2e-3,
					     &fn_links);
#endif
	}
#endif
	if(strstr(spectrum_request,",hvy_pot,") != NULL){
	  rephase( OFF );
	  hvy_pot( F_OFFSET(link[XUP]) );
	  rephase( ON );
	}
#endif /* SPECTRUM */
	avs_iters += s_iters;
	++meascount;
	fflush(stdout);
      }
    }	/* end loop over trajectories */
    
    node0_printf("RUNNING COMPLETED\n"); fflush(stdout);
    if(meascount>0)  {
      node0_printf("average cg iters for step= %e\n",
		   (double)avs_iters/meascount);
#ifdef SPECTRUM
      node0_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 ){
      rephase( OFF );
      save_lattice( saveflag, savefile, stringLFN );
      rephase( ON );
#ifdef HAVE_QIO
//       save_random_state_scidac_from_site("randsave", "Dummy file XML",
//        "Random number state", QIO_SINGLEFILE, F_OFFSET(site_prn));
//       save_color_vector_scidac_from_site("xxx1save", "Dummy file XML",
//        "xxx vector", QIO_SINGLEFILE, F_OFFSET(xxx1),1);
//       save_color_vector_scidac_from_site("xxx2save", "Dummy file XML",
//        "xxx vector", QIO_SINGLEFILE, F_OFFSET(xxx2),1);
#endif
    }
  }
#ifdef HAVE_QDP
  QDP_finalize();
#endif  
  normal_exit(0);
  return 0;
}
Ejemplo n.º 27
0
void load_smearing(field_offset where_smear, char filename[])
{
  Real *wave_func ;
  complex lbuf ;
  int nxyz = nx*ny*nz ;
  int x,y,z,t ;
  int newnode , currentnode ;
  int where ;
  int where_space ;
  int i ;
  double starttime,endtime ; 

  /****---------------------------------------*****/
  starttime = dclock() ; 

  /** Reserve space for the smearing function on the master node ***/
  if(mynode()==0)
  {
    if( (wave_func = (Real *) calloc( (size_t) nxyz, sizeof(Real) )  ) == NULL )
    {
      printf("ERROR: load_smearing: could not reserve buffer space for wave function on the master node \n");
      terminate(1);
    }

  }


  /** load in the smearing function into the master node buffer  **/
  if(mynode()==0)  
  {
    /** load the smearing function ****/
    load_scalar_smear(wave_func, nxyz, filename);
  }

  
  g_sync();
  currentnode = 0 ;

  /*** send the smearing function to the correct nodes **/
  for(t=0;t<nt;t++)
    for(z=0;z<nz;z++)
      for(y=0;y<ny;y++)
	for(x=0;x<nx;x++)
	{
	  where = x + nx*(y + ny*( z + nz*t)) ;
	  where_space = x + nx*(y + ny*z) ;


	  newnode=node_number(x,y,z,t);
	  if(newnode != currentnode)
	  {
	    g_sync();
	    currentnode=newnode;
	  }
 
	  /* Node 0 reads, and sends site to correct node */
	  if(this_node==0)
	  {
	    lbuf.real = *(wave_func + where_space ) ;
	    lbuf.imag = 0.0 ;

	    if(currentnode==0)
	    {			/* just copy links */
	      i = node_index(x,y,z,t);
	      *( (complex *)F_PT( &(lattice[i]), where_smear ) )=lbuf;
	    }
	    else 
	    {			/* send to correct node */
	      send_field((char *)&lbuf,sizeof(complex),currentnode);
	    }
	  }
 
	  /* The node which contains this site reads message */
	  else
	  { 
	    /* for all nodes other than node 0 */
	    if(this_node==currentnode)
	    {
	      get_field((char *)&lbuf,sizeof(complex),0);
	      i = node_index(x,y,z,t);
	      *( (complex *)F_PT( &(lattice[i]), where_smear ) )=lbuf;
	    }
	  }
	  
	} /** end the loop over the spatial lattice ****/




  /** free up the memory buffer on the master node ***/
  if(mynode()==0)  
    free(wave_func);

  endtime = dclock() - starttime ;

  node0_printf("Time to load smearing functions = %g sec \n",endtime );

}
Ejemplo n.º 28
0
void r_prop_w_fm(char *filename, field_offset dest)
{

  FILE *fp;
  int destnode;
  int x,y,z,t,i, byterevflag, c0,s0,c1,s1;
  wilson_matrix q;
  int32type tmp, magic_number,elements_per_site; 
  int32type  size_of_element, order, dims[4]; 
  int32type   t_stamp;
  site *s;
  wilson_propagator *qp;

  /*READING FILE HEADER*/

  if(this_node==0){
    fp = fopen(filename,"rb");
    if(fp==NULL){
      printf("Can't open propagator file %s, error %d\n",filename,errno);
      terminate(1);
    }

    if(fread(&magic_number,sizeof(int32type),1,fp) != 1)
      {
	printf("error in reading magic number from file %s\n", filename);
	terminate(1);
      }
    tmp=magic_number;
    if(magic_number == IO_UNI_MAGIC) byterevflag=0;
    else 
      {
	byterevn((int32type *)&magic_number,1);
      if(magic_number == IO_UNI_MAGIC) 
	{
	  byterevflag=1; 
	  printf("Reading with byte reversal\n");
	  if( sizeof(float) != sizeof(int32type)) {
	    printf("%s: Can't byte reverse\n", filename);
	    printf("requires size of int32type(%d) = size of float(%d)\n",
		   (int)sizeof(int32type),(int)sizeof(float));
	    terminate(1);
	  }
	}
      else
	{
	  /* Restore magic number as originally read */
	  magic_number = tmp;
	  
	  /* End of the road. */
	  printf("%s: Unrecognized magic number in prop file header.\n",
		 filename);
	  printf("Expected %x but read %x\n",
		 IO_UNI_MAGIC,tmp);
	  terminate(1);
	}
    };
    if(fread(&t_stamp,sizeof(t_stamp),1,fp) != 1)
     {	
       printf("error in reading time stamp from file %s\n", filename);
       terminate(1);
     }

    if(fread(&size_of_element,sizeof(int32type),1,fp) != 1)
     {	
       printf("error in reading size of element from file %s\n", filename);
       terminate(1);
     }

    if(fread(&elements_per_site,sizeof(int32type),1,fp) != 1)
      {	
	printf("error in reading elements per site from file %s\n", filename);
	terminate(1);
      }
    if(psread_byteorder(byterevflag,0,fp,dims,sizeof(dims),
		       filename,"dimensions")!=0) terminate(1);

    if( dims[0]!=nx || dims[1]!=ny || 
	dims[2]!=nz || dims[3]!=nt )
      {
	printf(" Incorrect lattice size %d,%d,%d,%d\n",
	       dims[0], dims[1], dims[2], dims[3]);
	terminate(1);
      }
    if( size_of_element != sizeof(float) ||
	elements_per_site != 288 /* wilson_propagator */)
      {	
	printf(" file %s is not a wilson propagator in arch_fm format\n",
	       filename);
	terminate(1);
      }
    
    if(psread_byteorder(byterevflag,0,fp,&order,sizeof(int32type),
			filename,"order parameter")!=0) terminate(1);
  } /*if this_node==0*/

  printf("fm prop header\n magic number %x\n timestamp %x\n size of elem %d\n el per site %d\n dim %d, %d, %d, %d\n order %d\nbyterevflag %d\n\n", magic_number, t_stamp, size_of_element, elements_per_site,
	 dims[0],dims[1],dims[2],dims[3], order,byterevflag);
	 

  
  for(t=0;t<nt;t++)for(z=0;z<nz;z++)for(y=0;y<ny;y++)for(x=0;x<nx;x++){
    destnode=node_number(x,y,z,t);
    
    /* Node 0 reads, and sends site to correct node */
    if(this_node==0){
      if(psread_byteorder(byterevflag,0,fp,&q,sizeof(wilson_matrix),
			  filename,"reading the wilson propagator\n")!=0) terminate(1);
  
      
      
      if(destnode==0){	/* just copy links */
	i = node_index(x,y,z,t);
	for(s0=0;s0<4;s0++)for(c0=0;c0<3;c0++)
	  for(s1=0;s1<4;s1++)for(c1=0;c1<3;c1++)
	    { 
	      s = &lattice[i];
	      qp = (wilson_propagator *)F_PT(s,dest);
	      qp->c[c0].d[s0].d[s1].c[c1].real 
	      = q.d[s0].c[c0].d[s1].c[c1].real;
	      qp->c[c0].d[s0].d[s1].c[c1].imag 
	      = q.d[s0].c[c0].d[s1].c[c1].imag;
	    }
      }
      else {		/* send to correct node */
	send_field((char *)&q, sizeof(wilson_matrix),destnode);
      }
  
    }
    /* The node which contains this site reads message */
    else {	/* for all nodes other than node 0 */
      if(this_node==destnode){
	get_field((char *)&q, sizeof(wilson_matrix),0);
	i = node_index(x,y,z,t);
       	for(s0=0;s0<4;s0++)for(c0=0;c0<3;c0++)
	  for(s1=0;s1<4;s1++)for(c1=0;c1<3;c1++)
	    {
	      s = &lattice[i];
	      qp = (wilson_propagator *)F_PT(s,dest);
	      qp->c[c0].d[s0].d[s1].c[c1].real 
	      = q.d[s0].c[c0].d[s1].c[c1].real;
	      qp->c[c0].d[s0].d[s1].c[c1].imag 
	      = q.d[s0].c[c0].d[s1].c[c1].imag;	      
	    }
      }
    }
  }
  
  g_sync();
 
  if(this_node==0){
    printf("Restored wilson propagator from binary file  %s, magic number %x\n",
	   filename, IO_UNI_MAGIC);
    fclose(fp);
    fflush(stdout);
  }
}
Ejemplo n.º 29
0
int main( int argc, char **argv ){
  register site *s;
  int i,si;
  int prompt;
  double dtime;
  su3_vector **eigVec ;
  su3_vector *tmp ;
  double *eigVal ;
  int total_R_iters ;
  double chirality, chir_ev, chir_od ;
  imp_ferm_links_t **fn;

  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){
    dtime = -dclock();
#ifdef HISQ_SVD_COUNTER
    hisq_svd_counter = 0;
#endif
    restore_fermion_links_from_site(fn_links, PRECISION);
    /* call fermion_variable measuring routines */
    /* results are printed in output file */
    f_meas_imp( 1, PRECISION, F_OFFSET(phi), F_OFFSET(xxx), mass,
		0, fn_links);

    eigVal = (double *)malloc(Nvecs*sizeof(double));
    eigVec = (su3_vector **)malloc(Nvecs*sizeof(su3_vector*));
    for(i=0;i<Nvecs;i++)
      eigVec[i]=
	(su3_vector*)malloc(sites_on_node*sizeof(su3_vector));
    
    fn = get_fm_links(fn_links);
    active_parity = EVEN;
    total_R_iters=Kalkreuter(eigVec, eigVal, eigenval_tol, 
			     error_decr, Nvecs, MaxIter, Restart, 
			     Kiters);

    node0_printf("The above where eigenvalues of -Dslash^2 in MILC normalization\n");
    node0_printf("Here we also list eigenvalues of iDslash in continuum normalization\n");
    for(i=0;i<Nvecs;i++)
      { 
	if ( eigVal[i] > 0.0 ){ chirality = sqrt(eigVal[i]) / 2.0; }
	else { chirality = 0.0; }
	node0_printf("eigenval(%i): %10g\n",i,chirality) ;
      } 

    tmp = (su3_vector*)malloc(sites_on_node*sizeof(su3_vector));
    for(i=0;i<Nvecs;i++)
      { 
//	if ( eigVal[i] > 10.0*eigenval_tol )
//	  {
	    /* Construct to odd part of the vector.                 *
	     * Note that the true odd part of the eigenvector is    *
	     *  i/sqrt(eigVal) Dslash Psi. But since I only compute *
	     * the chirality the i factor is irrelevant (-i)*i=1!!  */
	    dslash_field(eigVec[i], tmp, ODD, fn[0]) ;
	    FORSOMEPARITY(si,s,ODD){ 
	      scalar_mult_su3_vector( &(tmp[si]),
				      1.0/sqrt(eigVal[i]), 
				      &(eigVec[i][si]) ) ;
	    }
	
//	    measure_chirality(eigVec[i], &chirality, EVENANDODD);
	    /* Here I divide by 2 since the EVEN vector is normalized to
	     * 1. The EVENANDODD vector is normalized to 2. I could have
	     * normalized the EVENANDODD vector to 1 and then not devide
	     * by to.  The measure_chirality routine assumes vectors
	     * normalized to 1.  */
//	    node0_printf("Chirality(%i): %g\n",i,chirality/2) ;
	    measure_chirality(eigVec[i], &chir_ev, EVEN);
	    measure_chirality(eigVec[i], &chir_od, ODD);
	    chirality = (chir_ev + chir_od) / 2.0;
	    node0_printf("Chirality(%i) -- even, odd, total: %10g, %10g, %10g\n",
			 i,chir_ev,chir_od,chirality) ;
//	  }
//	else
//	  {
	    /* This is considered a "zero mode", and treated as such */
//	    measure_chirality(eigVec[i], &chirality, EVEN);
//	    node0_printf("Chirality(%i): %g\n",i,chirality) ;
//	  }
      }
#ifdef EO
    cleanup_dslash_temps();
#endif
    free(tmp);
    /**
       for(i=0;i<Nvecs;i++)
       {
       sprintf(label,"DENSITY(%i)",i) ;
       print_densities(eigVec[i], label, ny/2,nz/2,nt/2, EVEN) ;
       }
    **/
    for(i=0;i<Nvecs;i++)
      free(eigVec[i]) ;
    free(eigVec) ;
    free(eigVal) ;
    invalidate_fermion_links(fn_links);
    fflush(stdout);
    
    node0_printf("RUNNING COMPLETED\n"); fflush(stdout);
    dtime += dclock();
    if(this_node==0){
      printf("Time = %e seconds\n",dtime);
      printf("total_iters = %d\n",total_iters);
      printf("total Rayleigh iters = %d\n",total_R_iters);
#ifdef HISQ_SVD_COUNTER
      printf("hisq_svd_counter = %d\n",hisq_svd_counter);
#endif
    }
    fflush(stdout);
  }
Ejemplo n.º 30
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;
}