/* Read in configuration specific parameters */ int readin(int prompt) { int status; /* On node zero, read parameters and send to all other nodes */ if(this_node==0) { printf("\n\n"); status=0; /* Identify the starting configuration */ IF_OK status += ask_starting_lattice(stdin, prompt, &(par_buf.startflag), par_buf.startfile); /* Get flow parameters */ IF_OK { /* Get flow description */ if (prompt==1) printf("enter 'wilson' or 'symanzik'\n"); scanf("%s", par_buf.flow_description); printf("%s\n", par_buf.flow_description); /* Check flow description and set staple flag */ if( strcmp("wilson", par_buf.flow_description) == 0 ) { par_buf.stapleflag = WILSON; printf("set staple to wilson\n"); } else if( strcmp("symanzik", par_buf.flow_description) == 0 ) { par_buf.stapleflag = SYMANZIK; printf("set staple to symanzik\n"); } else { printf("Error: flow_description %s is invalid\n", par_buf.flow_description); status++; } } /*end: flow_description IF_OK */ IF_OK status += get_i(stdin, prompt, "exp_order", &par_buf.exp_order); IF_OK status += get_f(stdin, prompt, "stepsize", &par_buf.stepsize); IF_OK status += get_f(stdin, prompt, "stoptime", &par_buf.stoptime); /* Determine what to do with the final configuration */ IF_OK status += ask_ending_lattice(stdin, prompt, &(par_buf.saveflag), par_buf.savefile ); IF_OK status += ask_ildg_LFN(stdin, prompt, par_buf.saveflag, par_buf.stringLFN ); if( status > 0) par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(this_node==0) */
virtual void initialize() { if(get_x()!=Teuchos::null) get_x()->putScalar(0.0); if(get_dxdt()!=Teuchos::null) get_dxdt()->putScalar(0.0); if(get_f()!=Teuchos::null) get_f()->putScalar(0.0); if(get_A()!=Teuchos::null) { Teuchos::RCP<CrsMatrixType> mat = get_A(); mat->resumeFill(); mat->setAllToScalar(0.0); mat->fillComplete(); } }
bool Number::is_zero() const { switch (type()) { case Number::INTEGER: return get_i().is_zero(); case Number::FLOATING: return get_f().is_zero(); case Number::RATIONAL: return get_r().is_zero(); #ifndef PMP_DISABLE_VECTOR case Number::VECTOR: for (size_t i = 0; i < size(); ++i) { if (!get_v()[i].is_zero()) return false; } return true; #endif default: assert(0); return false; } }
floating_type Number::to_f() const { switch (type()) { case Number::INTEGER: return i_to_f(); case Number::FLOATING: return get_f(); case Number::RATIONAL: return r_to_f(); #ifndef PMP_DISABLE_VECTOR case Number::VECTOR: if (empty()) return 0; else return get_v()[0].to_f(); #endif default: assert(0); return 0; } }
std::string Number::str(unsigned precision) const { switch (type()) { case Number::INTEGER: return get_i().str(precision); case Number::FLOATING: return get_f().str(precision); case Number::RATIONAL: return get_r().str(); #ifndef PMP_DISABLE_VECTOR case Number::VECTOR: { std::string s; if (!empty()) { s += get_v()[0].str(precision); for (size_t i = 1; i < size(); ++i) { s += ", "; s += get_v()[i].str(precision); } } return s; } #endif default: assert(0); return ""; } }
int maxProfit(vector<int>& p) { f = new int* [p.size()]; for (int i=0;i<p.size();++i) f[i] = new int [2]; for (int i=0;i<p.size();++i) { f[i][1] = max(get_f(i-1,0), get_f(i-1,1)); f[i][0] = 0; for (int j=0;j<i;++j) f[i][0] = max(f[i][0], get_f(j-1,1) + p[i]-p[j]); } //for (int i=0;i<p.size();++i) cout << f[i][0] << " "; //cout << endl; //for (int i=0;i<p.size();++i) cout << f[i][1] << " "; //cout << endl; int ans = 0; for (int i=0;i<p.size();++i) ans = max(ans, f[i][0]); return ans; }
int Number::sign() const { switch (type()) { case Number::INTEGER: return get_i().sign(); case Number::FLOATING: return get_f().sign();; case Number::RATIONAL: return get_r().sign(); default: assert(0); return 0; } }
/* read in parameters and coupling constants */ int readin(int prompt) { /* read in parameters for su3 monte carlo */ /* argument "prompt" is 1 if prompts are to be given for input */ int status, jflav; /* On node zero, read parameters and send to all other nodes */ if(this_node==0){ printf("\n\n"); status=0; IF_OK status += get_i(stdin, prompt, "number_of_random_sources", ¶m.nrand); if(param.nrand < 2){ fprintf(stderr, "ERROR: need more than 1 random source to compute correlations\n"); status++; } IF_OK status += get_i(stdin, prompt, "number_of_flavors", ¶m.nflav); for(jflav = 0; jflav < param.nflav; jflav++){ IF_OK status += get_f(stdin, prompt, "charge", ¶m.charges[jflav]); IF_OK status += get_s(stdin, prompt, "file", param.fname[jflav]); } IF_OK status += get_s(stdin, prompt, "save_corr", param.corrfile); /* End of input fields */ if( status > 0)param.stopflag=1; else param.stopflag=0; } /* end if(this_node==0) */ broadcast_bytes((char *)¶m,sizeof(param)); if( param.stopflag != 0 )return param.stopflag; if(prompt==2)return 0; } /* setup.c */
void Number::trim(unsigned precision/* = s_default_precision*/) { switch (type()) { case Number::INTEGER: break; case Number::FLOATING: { assign(str(precision, std::ios_base::fixed)); integer_type i = to_i(); floating_type f = static_cast<floating_type>(i); if (f == get_f()) assign(i); } break; case Number::RATIONAL: { rational_type r = get_r(); if (b_mp::denominator(r) == 1) assign(b_mp::numerator(r)); } break; #ifndef PMP_DISABLE_VECTOR case Number::VECTOR: for (size_t i = 0; i < get_v().size(); ++i) get_v()[i].trim(precision); if (size() == 1) assign(get_v()[0]); break; #endif default: assert(0); break; } }
char* DTrack::get_block(char* str, char* fmt, unsigned long* uldat, float* fdat) { char* strend; int index_ul, index_f; if(!(str = strchr(str, '['))){ // search begin of block return NULL; } if(!(strend = strchr(str, ']'))){ // search end of block return NULL; } str++; *strend = '\0'; index_ul = index_f = 0; while(*fmt){ switch(*fmt++){ case 'u': if(!(str = get_ul(str, &uldat[index_ul++]))){ return NULL; } break; case 'f': if(!(str = get_f(str, &fdat[index_f++]))){ return NULL; } break; default: // ignore unknown format character break; } } return strend + 1; }
int temp_div0() { return 1 / get_f(X(0)); }
int var_div1() { X x(1); return 1 / get_f(x); }
int var_div0() { X x(0); return 1 / get_f(x); }
/* read in parameters and coupling constants */ int readin(int prompt) { /* read in parameters for su3 monte carlo */ /* argument "prompt" is 1 if prompts are to be given for input */ int status,status2; char savebuf[128]; char save_w[128]; int i; char descrp[30]; /* On node zero, read parameters and send to all other nodes */ if(this_node==0) { printf("\n\n"); status=0; /* Number of heavy kappas */ IF_OK status += get_i(stdin, prompt,"number_of_heavy_kappas", &par_buf.num_kap_heavy ); IF_OK if( par_buf.num_kap_heavy>MAX_KAP ) { printf("num_kap_heavy = %d must be in [1,%d]!\n", num_kap_heavy, MAX_KAP); status++; } /* Values of heavy kappas */ for(i=0; i<par_buf.num_kap_heavy; i++) { IF_OK status += get_f(stdin, prompt,"kappa_heavy", &par_buf.kap[i] ); } /* Number of light kappas */ IF_OK status += get_i(stdin, prompt,"number_of_light_kappas", &par_buf.num_kap_light ); par_buf.num_kap = par_buf.num_kap_heavy + par_buf.num_kap_light; IF_OK if(par_buf.num_kap_light>MAX_KAP-num_kap_heavy || par_buf.num_kap_light < 1) { printf("num_kap_light = %d must be in [1,%d]!\n", par_buf.num_kap_light, MAX_KAP - num_kap_heavy); status++; } /* Values of light kappas */ for(i=par_buf.num_kap_heavy; i<par_buf.num_kap; i++) { IF_OK status += get_f(stdin, prompt,"kappa_light", &par_buf.kap[i] ); } /* Clover coefficient, u0 */ IF_OK status += get_f(stdin, prompt,"clov_c", &par_buf.clov_c ); IF_OK status += get_f(stdin, prompt,"u0", &par_buf.u0 ); IF_OK { if (prompt!=0) printf("enter 'nr_forward, nr_backward, nr_forward_backward'\n"); status2=scanf("%s",savebuf); if(status2!=1) { printf("ERROR IN INPUT: nr type command\n"); status++; } else if(strcmp("nr_forward",savebuf) == 0 ) par_buf.nr_forw_back = 1; else if(strcmp("nr_backward",savebuf) == 0 ) par_buf.nr_forw_back = 2; else if(strcmp("nr_forward_backward",savebuf) == 0 ) par_buf.nr_forw_back = 3; else{ printf("ERROR IN INPUT: nr command is invalid\n"); status++; } } /** starting timeslice for the inversion ***/ IF_OK status += get_i(stdin, prompt,"q_source_time", &par_buf.source_time ); /* maximum no. of conjugate gradient iterations */ IF_OK status += get_i(stdin, prompt,"max_cg_iterations", &par_buf.niter ); /* maximum no. of conjugate gradient restarts */ IF_OK status += get_i(stdin, prompt,"max_cg_restarts", &par_buf.nrestart ); /* error for propagator conjugate gradient */ for(i=0; i<par_buf.num_kap; i++) { IF_OK status += get_f(stdin, prompt,"error_for_propagator", &par_buf.resid[i] ); } /* Get source type */ IF_OK status += ask_w_quark_source( stdin, prompt, &wallflag, descrp); /* width: psi=exp(-(r/r0)^2) */ IF_OK if (prompt!=0) printf("enter width(s) r0 as in: source=exp(-(r/r0)^2)\n"); for(i=0; i<par_buf.num_kap; i++) { IF_OK status += get_f(stdin, prompt,"r0", &par_buf.wqs[i].r0 ); /* (Same source type for each spectator) */ IF_OK par_buf.wqs[i].type = wallflag; IF_OK strcpy(par_buf.wqs[i].descrp,descrp); /* (Hardwired source location for each spectator) */ IF_OK { par_buf.wqs[i].x0 = source_loc[0]; par_buf.wqs[i].y0 = source_loc[1]; par_buf.wqs[i].z0 = source_loc[2]; par_buf.wqs[i].t0 = par_buf.source_time ; } } /* find out what kind of starting lattice to use */ IF_OK status += ask_starting_lattice(stdin, prompt, &par_buf.startflag, par_buf.startfile ); IF_OK if (prompt!=0) printf("enter 'no_gauge_fix', or 'coulomb_gauge_fix'\n"); IF_OK scanf("%s",savebuf); IF_OK printf("%s\n",savebuf); IF_OK { if(strcmp("coulomb_gauge_fix",savebuf) == 0 ) { par_buf.fixflag = COULOMB_GAUGE_FIX; } else if(strcmp("no_gauge_fix",savebuf) == 0 ) { par_buf.fixflag = NO_GAUGE_FIX; } else{ printf("error in input: fixing_command is invalid\n"); status++; } } /* find out what to do with lattice at end */ IF_OK status += ask_ending_lattice(stdin, prompt, &(par_buf.saveflag), par_buf.savefile ); IF_OK status += ask_ildg_LFN(stdin, prompt, par_buf.saveflag, par_buf.stringLFN ); /* find out starting propagator */ IF_OK for(i=0; i<par_buf.num_kap; i++) status += ask_starting_wprop(stdin, prompt,&par_buf.startflag_w[i], par_buf.startfile_w[i]); /* what to do with computed propagator */ IF_OK for(i=0; i<par_buf.num_kap; i++) status += ask_ending_wprop(stdin, prompt,&par_buf.saveflag_w[i], par_buf.savefile_w[i]); IF_OK if(prompt!=0) printf("propagator scratch file:\n enter 'serial_scratch_wprop' or 'parallel_scratch_wprop'\n"); IF_OK status2=scanf("%s",save_w); IF_OK printf("%s ",save_w); IF_OK { if(strcmp("serial_scratch_wprop",save_w) == 0 ) par_buf.scratchflag = SAVE_SERIAL; else if(strcmp("parallel_scratch_wprop",save_w) == 0 ) par_buf.scratchflag = SAVE_CHECKPOINT; else { printf("error in input: %s is not a scratch file command\n",save_w); status++; } IF_OK { /*read name of file and load it */ if(prompt!=0)printf("enter name of scratch file stem for props\n"); status2=scanf("%s",par_buf.scratchstem_w); if(status2 !=1) { printf("error in input: scratch file stem name\n"); status++; } printf("%s\n",par_buf.scratchstem_w); } } if( status > 0)par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(this_node==0) */
/* read in parameters and coupling constants */ int readin(int prompt) { /* read in parameters for su3 monte carlo */ /* argument "prompt" is 1 if prompts are to be given for input */ int status; char savebuf[128]; int i,k,nprop; int ipair, itriplet; #ifdef PRTIME double dtime; #endif STARTTIME; /* On node zero, read parameters and send to all other nodes */ if(this_node==0){ printf("\n\n"); status=0; /*------------------------------------------------------------*/ /* Gauge configuration section */ /*------------------------------------------------------------*/ IF_OK status += ask_starting_lattice(stdin, prompt, ¶m.startflag, param.startfile ); IF_OK status += get_f(stdin, prompt,"u0", ¶m.u0 ); IF_OK if (prompt==1) printf("enter 'no_gauge_fix', or 'coulomb_gauge_fix'\n"); IF_OK scanf("%s",savebuf); IF_OK printf("%s\n",savebuf); IF_OK { if(strcmp("coulomb_gauge_fix",savebuf) == 0 ){ param.fixflag = COULOMB_GAUGE_FIX; } else if(strcmp("no_gauge_fix",savebuf) == 0 ) { param.fixflag = NO_GAUGE_FIX; } else{ printf("error in input: fixing_command %s is invalid\n",savebuf); status++; } } /* find out what to do with lattice at end */ IF_OK status += ask_ending_lattice(stdin, prompt, &(param.saveflag), param.savefile ); IF_OK status += ask_ildg_LFN(stdin, prompt, param.saveflag, param.stringLFN ); #ifdef U1_FIELD /* what kind of starting U(1) lattice to use, read filename */ IF_OK status+=ask_starting_u1_lattice(stdin,prompt, ¶m.start_u1flag, param.start_u1file ); IF_OK status+=ask_ending_u1_lattice(stdin,prompt, ¶m.save_u1flag, param.save_u1file ); #endif /* Provision is made to build covariant sources from smeared links */ /* APE smearing parameters (if needed) */ /* Zero suppresses APE smearing */ IF_OK status += get_f(stdin, prompt, "staple_weight", ¶m.staple_weight); IF_OK status += get_i(stdin, prompt, "ape_iter", ¶m.ape_iter); /* Coordinate origin for KS phases and antiperiodic boundary condition */ IF_OK status += get_vi(stdin, prompt, "coordinate_origin", param.coord_origin, 4); /*------------------------------------------------------------*/ /* Chiral condensate and related quantities */ /*------------------------------------------------------------*/ IF_OK status += get_i(stdin, prompt, "number_of_pbp_masses", ¶m.num_pbp_masses); if(param.num_pbp_masses > MAX_MASS_PBP){ printf("Number of masses exceeds dimension %d\n",MAX_MASS_PBP); status++; } IF_OK if(param.num_pbp_masses > 0){ IF_OK status += get_i(stdin, prompt, "max_cg_iterations", ¶m.qic_pbp[0].max); IF_OK status += get_i(stdin, prompt, "max_cg_restarts", ¶m.qic_pbp[0].nrestart); IF_OK status += get_i(stdin, prompt, "npbp_reps", ¶m.npbp_reps ); IF_OK status += get_i(stdin, prompt, "prec_pbp", ¶m.qic_pbp[0].prec); IF_OK for(i = 0; i < param.num_pbp_masses; i++){ IF_OK status += get_f(stdin, prompt, "mass", ¶m.ksp_pbp[i].mass); #if ( FERM_ACTION == HISQ || FERM_ACTION == HYPISQ ) IF_OK status += get_f(stdin, prompt, "naik_term_epsilon", ¶m.ksp_pbp[i].naik_term_epsilon); #else param.ksp_pbp[i].naik_term_epsilon = 0.0; #endif #ifdef U1_FIELD IF_OK status += get_f(stdin, prompt, "charge", ¶m.charge_pbp[i]); #endif param.qic_pbp[i].min = 0; param.qic_pbp[i].start_flag = 0; param.qic_pbp[i].nsrc = 1; param.qic_pbp[i].max = param.qic_pbp[0].max; param.qic_pbp[i].nrestart = param.qic_pbp[0].nrestart; param.qic_pbp[i].prec = param.qic_pbp[0].prec; IF_OK status += get_f(stdin, prompt, "error_for_propagator", ¶m.qic_pbp[i].resid); IF_OK status += get_f(stdin, prompt, "rel_error_for_propagator", ¶m.qic_pbp[i].relresid ); } }
/* read in parameters and coupling constants */ int readin(int prompt) { /* read in parameters for su3 monte carlo */ /* argument "prompt" is 1 if prompts are to be given for input */ int status; int i; /* On node zero, read parameters and send to all other nodes */ if(this_node==0){ printf("\n\n"); status=0; /* Number of kappas */ IF_OK status += get_i(stdin, prompt,"number_of_kappas", &par_buf.num_kap ); if( par_buf.num_kap>MAX_KAP ){ printf("num_kap = %d must be <= %d!\n", par_buf.num_kap, MAX_KAP); status++; } /* boundary condition flag */ IF_OK status += get_i(stdin, prompt, "bc_flag", &par_buf.bc_flag); /* Number of APE smearings */ IF_OK status += get_i(stdin, prompt, "num_smear", &par_buf.num_smear); /* APE smearing parameter (Boulder convention) */ IF_OK status += get_f(stdin, prompt, "alpha", &par_buf.alpha); /* To be save initialize the following to zero */ for(i=0;i<MAX_KAP;i++){ kap[i] = 0.0; resid[i] = 0.0; } for(i=0;i<par_buf.num_kap;i++){ IF_OK status += get_f(stdin, prompt,"kappa", &par_buf.kap[i] ); } /* Clover coefficient */ IF_OK status += get_f(stdin, prompt,"clov_c", &par_buf.clov_c ); /* fermion phase factors */ IF_OK status += get_f(stdin, prompt,"ferm_phases[0]", &par_buf.ferm_phas[0] ); IF_OK status += get_f(stdin, prompt,"ferm_phases[1]", &par_buf.ferm_phas[1] ); IF_OK status += get_f(stdin, prompt,"ferm_phases[2]", &par_buf.ferm_phas[2] ); /* maximum no. of conjugate gradient iterations */ IF_OK status += get_i(stdin, prompt,"max_cg_iterations", &par_buf.niter ); /* maximum no. of conjugate gradient restarts */ IF_OK status += get_i(stdin, prompt,"max_cg_restarts", &par_buf.nrestart ); /* error for propagator conjugate gradient */ for(i=0;i<par_buf.num_kap;i++){ IF_OK status += get_f(stdin, prompt,"error_for_propagator", &par_buf.resid[i] ); } /* find out what kind of starting lattice to use */ IF_OK status += ask_starting_lattice(stdin, prompt, &par_buf.startflag, par_buf.startfile ); /* send parameter structure */ if( status > 0)par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(this_node==0) */ /* Node 0 broadcasts parameter buffer to all other nodes */ broadcast_bytes((char *)&par_buf,sizeof(par_buf)); if( par_buf.stopflag != 0 ) normal_exit(0); startflag = par_buf.startflag; bc_flag = par_buf.bc_flag; num_kap = par_buf.num_kap; clov_c = par_buf.clov_c; niter = par_buf.niter; nrestart = par_buf.nrestart; num_smear = par_buf.num_smear; alpha = par_buf.alpha; for(i=0;i<par_buf.num_kap;i++){ kap[i] = par_buf.kap[i]; resid[i] = par_buf.resid[i]; } for(i=0;i<3;i++){ ferm_phases[i] = par_buf.ferm_phas[i]; } strcpy(startfile,par_buf.startfile); for(i=0;i<par_buf.num_kap;i++){ wqs[i].c_src = NULL; wqs[i].wv_src = NULL; wqs[i].type = 0; wqs[i].x0 = 0; wqs[i].y0 = 0; wqs[i].z0 = 0; wqs[i].t0 = 0; strcpy(wqs[i].descrp,"Schroedinger wall source"); } beta = 1e20; /* Only needed in io_helpers for setting boundary fields */ c_t11 = 0; /* Only needed in io_helpers for setting boundary fields */ /* These boundary fields are actually never used here */ /* Do whatever is needed to get lattice */ if( startflag != CONTINUE ){ startlat_p = reload_lattice( startflag, startfile ); invalidate_this_clov(gen_clov); } /* put in fermion phases */ if( startflag != CONTINUE) do_phases(); return(0); }
/* read in parameters and coupling constants */ int readin(int prompt) { /* read in parameters for su3 monte carlo */ /* argument "prompt" is 1 if prompts are to be given for input */ int i, status, current_index; #ifdef CHECK_INVERT char invert_string[16]; #endif /* On node zero, read parameters and send to all other nodes */ if(this_node==0) { printf("\n\n"); status=0; /* find out what kind of starting lattice to use */ IF_OK status += ask_starting_lattice(stdin, prompt, &(par_buf.startflag), par_buf.startfile ); IF_OK status += get_f(stdin, prompt,"u0", &par_buf.u0 ); /* find out what to do with lattice at end */ IF_OK status += ask_ending_lattice(stdin, prompt, &(par_buf.saveflag), par_buf.savefile ); IF_OK status += ask_ildg_LFN(stdin, prompt, par_buf.saveflag, par_buf.stringLFN ); /* find out what to do with longlinks at end */ IF_OK status += ask_ending_lattice(stdin, prompt, &(par_buf.savelongflag), par_buf.savelongfile ); /* find out what to do with fatlinks at end */ IF_OK status += ask_ending_lattice(stdin, prompt, &(par_buf.savefatflag), par_buf.savefatfile ); /* Inversion parameters */ IF_OK status += get_i(stdin, prompt,"number_of_masses", &par_buf.nmass ); /* maximum no. of conjugate gradient iterations */ IF_OK status += get_i(stdin, prompt,"max_cg_iterations", &par_buf.qic[0].max ); /* maximum no. of conjugate gradient restarts */ IF_OK status += get_i(stdin, prompt,"max_cg_restarts", &par_buf.qic[0].nrestart ); /* find out what kind of color vector source to use */ #ifdef CHECK_INVERT IF_OK status += ask_color_vector( prompt, &(par_buf.srcflag[0]), par_buf.srcfile[0] ); #endif IF_OK for(i = 0; i < par_buf.nmass; i++){ #ifndef CHECK_INVERT IF_OK status += ask_color_vector( prompt, &(par_buf.srcflag[i]), par_buf.srcfile[i] ); IF_OK if(par_buf.srcflag[i] != par_buf.srcflag[0]){ node0_printf("Must reload all or save all alike."); status++; } #endif IF_OK status += get_f(stdin, prompt,"mass", &par_buf.ksp[i].mass ); #if FERM_ACTION == HISQ || FERM_ACTION == HYPISQ IF_OK status += get_f(stdin, prompt, "naik_term_epsilon", &par_buf.ksp[i].naik_term_epsilon); IF_OK { if(i == 0){ if(par_buf.ksp[i].naik_term_epsilon != 0.0){ node0_printf("First Naik term epsilon must be zero."); status++; } } else { if(par_buf.ksp[i].naik_term_epsilon > par_buf.ksp[i-1].naik_term_epsilon){ node0_printf("Naik term epsilons must be in descending order."); status++; } } } #else par_buf.ksp[i].naik_term_epsilon = 0.0; #endif par_buf.qic[i].min = 0; par_buf.qic[i].start_flag = 0; par_buf.qic[i].nsrc = 1; par_buf.qic[i].max = par_buf.qic[0].max; par_buf.qic[i].nrestart = par_buf.qic[0].nrestart; par_buf.qic[i].prec = PRECISION; par_buf.qic[i].parity = EVENANDODD; /* error for propagator conjugate gradient */ IF_OK status += get_f(stdin, prompt, "error_for_propagator", &par_buf.qic[i].resid); IF_OK status += get_f(stdin, prompt, "rel_error_for_propagator", &par_buf.qic[i].relresid ); #ifdef CHECK_INVERT /* find out what kind of color vector result to use */ IF_OK status += ask_color_vector( prompt, &(par_buf.ansflag[i]), par_buf.ansfile[i] ); IF_OK if(par_buf.ansflag[i] != par_buf.ansflag[0]){ node0_printf("Must reload all or save all alike."); status++; } #endif } #ifndef CHECK_INVERT /* find out what kind of color matrix momentum to use */ IF_OK status += ask_color_matrix( prompt, &(par_buf.ansflag[0]), par_buf.ansfile[0] ); #endif #ifdef CHECK_INVERT /* find out which inversion to check */ IF_OK status += get_s(stdin, prompt, "invert", invert_string); if(status == 0){ if(strcmp(invert_string,"M")==0) par_buf.inverttype = INVERT_M; else if(strcmp(invert_string,"MdaggerM")==0) par_buf.inverttype = INVERT_MdaggerM; else{ printf("Unrecognized invert string %s\n",invert_string); status++; } } #endif if( status > 0)par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(this_node==0) */
/* SETUP ROUTINES */ int initial_set() { int prompt,status,i,tmporder; Real current_naik_mass; /* On node zero, read lattice size, seed, and send to others */ if(mynode()==0){ /* print banner */ printf("SU3 with improved KS action\n"); printf("Microcanonical simulation with refreshing\n"); printf("MIMD version 7 $Name: $\n"); printf("Machine = %s, with %d nodes\n",machine_type(),numnodes()); printf("Rational function hybrid Monte Carlo algorithm\n"); /* Print list of options selected */ node0_printf("Options selected...\n"); show_generic_opts(); show_generic_ks_opts(); #ifdef INT_ALG node0_printf("INT_ALG=%s\n",ks_int_alg_opt_chr()); #endif //#ifdef HISQ_NAIK_ADJUSTABLE // node0_printf("HISQ_NAIK_ADJUSTABLE (means Naik correction is full epsilon and not just mass)\n"); //#endif #ifdef HISQ_FORCE_FILTER node0_printf("HISQ_FORCE_FILTER=%f\n",HISQ_FORCE_FILTER); #endif #ifdef HISQ_REUNIT_ALLOW_SVD node0_printf("HISQ_REUNIT_ALLOW_SVD\n"); #endif #ifdef HISQ_REUNIT_SVD_ONLY node0_printf("HISQ_REUNIT_SVD_ONLY (used together with HISQ_REUNIT_ALLOW_SVD)\n"); #endif #ifdef MILC_GLOBAL_DEBUG node0_printf("MILC_GLOBAL_DEBUG ***********************\n"); #endif #ifdef HISQ_REUNITARIZATION_DEBUG node0_printf("HISQ_REUNITARIZATION_DEBUG is ON\n"); #endif #ifdef HISQ_FF_MULTI_WRAPPER node0_printf("HISQ_FF_MULTI_WRAPPER is ON\n"); #endif #ifdef HISQ_FF_DEBUG node0_printf("HISQ_FF_DEBUG is ON\n"); #endif status=get_prompt(stdin, &prompt); IF_OK status += get_i(stdin, prompt,"nx", &par_buf.nx ); IF_OK status += get_i(stdin, prompt,"ny", &par_buf.ny ); IF_OK status += get_i(stdin, prompt,"nz", &par_buf.nz ); IF_OK status += get_i(stdin, prompt,"nt", &par_buf.nt ); #ifdef FIX_NODE_GEOM IF_OK status += get_vi(stdin, prompt, "node_geometry", par_buf.node_geometry, 4); #ifdef FIX_IONODE_GEOM IF_OK status += get_vi(stdin, prompt, "ionode_geometry", par_buf.ionode_geometry, 4); #endif #endif IF_OK status += get_i(stdin, prompt,"iseed", &par_buf.iseed ); /* Number of pseudofermions */ IF_OK status += get_i(stdin, prompt,"n_pseudo", &par_buf.n_pseudo ); if(par_buf.n_pseudo > MAX_N_PSEUDO){ printf("Error: Too many pseudofermion fields. Recompile. Current max is %d\n" ,MAX_N_PSEUDO); terminate(1); } /* get name of file containing rational function parameters */ IF_OK status += get_s(stdin, prompt, "load_rhmc_params", par_buf.rparamfile); /* beta, quark masses */ IF_OK status += get_f(stdin, prompt,"beta", &par_buf.beta ); IF_OK status += get_i(stdin, prompt,"n_dyn_masses", &par_buf.n_dyn_masses ); IF_OK status += get_vf(stdin, prompt, "dyn_mass", par_buf.dyn_mass, par_buf.n_dyn_masses); IF_OK status += get_vi(stdin, prompt, "dyn_flavors", par_buf.dyn_flavors, par_buf.n_dyn_masses); IF_OK status += get_f(stdin, prompt,"u0", &par_buf.u0 ); if(status>0) par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(mynode()==0) */ /* Node 0 broadcasts parameter buffer to all other nodes */ broadcast_bytes((char *)&par_buf,sizeof(par_buf)); if( par_buf.stopflag != 0 ) normal_exit(0); nx = par_buf.nx; ny = par_buf.ny; nz = par_buf.nz; nt = par_buf.nt; #ifdef FIX_NODE_GEOM for(i = 0; i < 4; i++) node_geometry[i] = par_buf.node_geometry[i]; #ifdef FIX_IONODE_GEOM for(i = 0; i < 4; i++) ionode_geometry[i] = par_buf.ionode_geometry[i]; #endif #endif iseed = par_buf.iseed; n_pseudo = par_buf.n_pseudo; strcpy(rparamfile,par_buf.rparamfile); this_node = mynode(); number_of_nodes = numnodes(); volume=nx*ny*nz*nt; total_iters=0; /* Load rational function parameters */ rparam = load_rhmc_params(rparamfile, n_pseudo); if(rparam == NULL)terminate(1); /* Determine the maximum rational fcn order */ max_rat_order = 0; for(i = 0; i < n_pseudo; i++){ if(rparam[i].MD.order > max_rat_order)max_rat_order = rparam[i].MD.order; if(rparam[i].GR.order > max_rat_order)max_rat_order = rparam[i].GR.order; if(rparam[i].FA.order > max_rat_order)max_rat_order = rparam[i].FA.order; } node0_printf("Maximum rational func order is %d\n",max_rat_order); /* Determine the number of different Naik masses */ current_naik_mass = rparam[0].naik_term_epsilon; tmporder = 0; n_naiks = 0; n_order_naik_total = 0; for( i=0; i<n_pseudo; i++ ) { if( rparam[i].naik_term_epsilon != current_naik_mass ) { if( tmporder > 0 ) { n_orders_naik[n_naiks] = tmporder; masses_naik[n_naiks] = current_naik_mass; current_naik_mass = rparam[i].naik_term_epsilon; n_naiks++; n_order_naik_total += tmporder; tmporder = 0; } } tmporder += rparam[i].MD.order; n_pseudo_naik[n_naiks]++; } if( tmporder > 0 ) { n_orders_naik[n_naiks] = tmporder; masses_naik[n_naiks] = current_naik_mass; n_order_naik_total += tmporder; n_naiks++; } // calculate epsilon corrections for different Naik terms if( 0!=masses_naik[0] ) { node0_printf("IN HISQ ACTION FIRST SET OF PSEUDO FERMION FIELDS SHOULD HAVE EPSILON CORRECTION TO NAIK TERM ZERO.\n"); terminate(1); } eps_naik[0] = 0.0; // first set of X links always has 0 correction for( i=1; i<n_naiks; i++ ) { #ifdef HISQ //#ifdef HISQ_NAIK_ADJUSTABLE // value read from rational function file is considered full epsilon correction eps_naik[i] = masses_naik[i]; //#else // value read from rational function file is considered quark mass // and epsilon correction is calculated with the second order perturbation theory, // HISQ_NAIK_2ND_ORDER is set in the hisq_action.h // eps_naik[i] = HISQ_NAIK_2ND_ORDER*masses_naik[i]*masses_naik[i]; //#endif #else /* HISQ */ // IT IS ASSUMED THAT ACTIONS OTHER THAN HISQ DO NOT HAVE // ANY EPSILON CORRECTION TERMS eps_naik[i] = 0; #endif /* HISQ */ } node0_printf("Naik term correction structure of multi_x:\n"); node0_printf("n_naiks %d\n",n_naiks); for( i=0; i<n_naiks; i++ ) { node0_printf("n_pseudo_naik[%d]=%d\n",i,n_pseudo_naik[i]); node0_printf("n_orders_naik[%d]=%d\n",i,n_orders_naik[i]); node0_printf("masses_naik[%d]=%f\n",i,masses_naik[i]); node0_printf("eps_naik[%d]=%f\n",i,eps_naik[i]); } node0_printf("n_order_naik_total %d\n",n_order_naik_total); #ifdef HISQ if( n_naiks+1 > MAX_NAIK ) { node0_printf("MAX_NAIK=%d < n_naiks+1=%d\n", MAX_NAIK, n_naiks+1 ); node0_printf("Increase MAX_NAIK\n"); terminate(1); } #else /* HISQ */ if( n_naiks>1 ) { node0_printf("FOR ACTIONS OTHER THAN HISQ EPSILON CORRECTION IS NOT USED.\n"); node0_printf("ONLY ONE SET OF X LINKS IS USED.\n"); node0_printf("SET ALL naik_mass TO 0 IN RATIONAL FUNCTION FILE.\n"); terminate(1); } #endif /* HISQ */ beta = par_buf.beta; n_dyn_masses = par_buf.n_dyn_masses; for(i = 0; i < n_dyn_masses; i++){ dyn_mass[i] = par_buf.dyn_mass[i]; dyn_flavors[i] = par_buf.dyn_flavors[i]; } u0 = par_buf.u0; return(prompt); }
/* read in parameters and coupling constants */ int readin(int prompt) { /* read in parameters for su3 monte carlo */ /* argument "prompt" is 1 if prompts are to be given for input */ int status; /* On node zero, read parameters and send to all other nodes */ if(this_node==0) { printf("\n\n"); status=0; /* find out what kind of starting lattice to use */ IF_OK status += ask_starting_lattice(stdin, prompt, &(param.startflag), param.startfile ); /* Gauge fixing parameters */ IF_OK if (prompt==1) printf("enter 'no_gauge_fix', 'landau_gauge_fix', or 'coulomb_gauge_fix'\n"); IF_OK scanf("%s",param.gauge_fix_description); IF_OK printf("%s\n",param.gauge_fix_description); IF_OK { if(strcmp("coulomb_gauge_fix",param.gauge_fix_description) == 0 ){ param.fixflag = COULOMB_GAUGE_FIX; if(this_node==0)printf("fixing to coulomb gauge\n"); } else if(strcmp("landau_gauge_fix",param.gauge_fix_description) == 0 ) { param.fixflag = LANDAU_GAUGE_FIX; if(this_node==0)printf("fixing to landau gauge\n"); } else if(strcmp("no_gauge_fix",param.gauge_fix_description) == 0 ) { param.fixflag = NO_GAUGE_FIX; if(this_node==0)printf("NOT fixing the gauge\n"); } else{ printf("error in input: fixing_command %s is invalid\n", param.gauge_fix_description); status++; } } /* Gauge fixing parameters */ if(param.fixflag != NO_GAUGE_FIX){ IF_OK status += get_f(stdin, prompt, "gauge_fix_tol", ¶m.gauge_fix_tol); } /* Get translation vector */ IF_OK status += get_vi(stdin, prompt, "rshift", param.rshift, 4); /* Get boundary twist */ IF_OK status += get_vf(stdin, prompt, "momentum_twist", param.bdry_phase, 4); /* find out what to do with lattice at end */ IF_OK status += ask_ending_lattice(stdin, prompt, &(param.saveflag), param.savefile ); IF_OK status += ask_ildg_LFN(stdin, prompt, param.saveflag, param.stringLFN ); if( status > 0)param.stopflag=1; else param.stopflag=0; } /* end if(this_node==0) */
/* read in parameters and coupling constants */ int readin(int prompt) { /* read in parameters for su3 monte carlo */ /* argument "prompt" is 1 if prompts are to be given for input */ int status; char savebuf[128]; int i; int ipair; int max_cg_iterations, max_cg_restarts; Real bdry_phase[4]; #ifdef PRTIME double dtime; #endif STARTTIME; /* On node zero, read parameters and send to all other nodes */ if(this_node==0){ printf("\n\n"); status=0; /*------------------------------------------------------------*/ /* Gauge configuration section */ /*------------------------------------------------------------*/ IF_OK status += ask_starting_lattice(stdin, prompt, ¶m.startflag, param.startfile ); IF_OK status += get_f(stdin, prompt,"u0", ¶m.u0 ); IF_OK if (prompt==1) printf("enter 'no_gauge_fix', or 'coulomb_gauge_fix'\n"); IF_OK scanf("%s",savebuf); IF_OK printf("%s\n",savebuf); IF_OK { if(strcmp("coulomb_gauge_fix",savebuf) == 0 ){ param.fixflag = COULOMB_GAUGE_FIX; } else if(strcmp("no_gauge_fix",savebuf) == 0 ) { param.fixflag = NO_GAUGE_FIX; } else{ printf("error in input: fixing_command %s is invalid\n",savebuf); status++; } } /* find out what to do with lattice at end */ IF_OK status += ask_ending_lattice(stdin, prompt, &(param.saveflag), param.savefile ); IF_OK status += ask_ildg_LFN(stdin, prompt, param.saveflag, param.stringLFN ); /* APE smearing parameters (if needed) */ /* Zero suppresses APE smearing */ IF_OK status += get_f(stdin, prompt, "staple_weight", ¶m.staple_weight); IF_OK status += get_i(stdin, prompt, "ape_iter", ¶m.ape_iter); /* Coordinate origin for KS phases and antiperiodic boundary condition */ IF_OK status += get_vi(stdin, prompt, "coordinate_origin", param.coord_origin, 4); /*------------------------------------------------------------*/ /* Propagator inversion control */ /*------------------------------------------------------------*/ /* maximum no. of conjugate gradient iterations */ IF_OK status += get_i(stdin,prompt,"max_cg_iterations", &max_cg_iterations ); /* maximum no. of conjugate gradient restarts */ IF_OK status += get_i(stdin,prompt,"max_cg_restarts", &max_cg_restarts ); /*------------------------------------------------------------*/ /* Base sources */ /*------------------------------------------------------------*/ IF_OK status += get_i(stdin,prompt,"number_of_base_sources", ¶m.num_base_source); IF_OK { if(param.num_base_source > MAX_SOURCE){ printf("Exceeded dimension %d\n",MAX_SOURCE); status++; } } for(i = 0; i < param.num_base_source; i++){ IF_OK init_qs(¶m.base_src_qs[i]); IF_OK status += get_wv_quark_source( stdin, prompt, ¶m.base_src_qs[i]); /* Base sources have no parents or ops */ IF_OK param.parent_source[i] = BASE_SOURCE_PARENT; IF_OK init_qss_op(¶m.src_qs_op[i]); IF_OK set_qss_op_offset(¶m.src_qs_op[i], param.coord_origin); /* Get optional file for saving the base source */ IF_OK { int source_type, saveflag_s; char descrp[MAXDESCRP]; char savefile_s[MAXFILENAME]; status += ask_output_quark_source_file( stdin, prompt, &saveflag_s, &source_type, NULL, descrp, savefile_s ); IF_OK { param.base_src_qs[i].savetype = source_type; param.base_src_qs[i].saveflag = saveflag_s; strcpy(param.base_src_qs[i].save_file, savefile_s); if(saveflag_s != FORGET && source_type != DIRAC_FIELD_FILE && source_type != VECTOR_FIELD_FILE){ printf("Unsupported output source type\n"); status++; } } /* OK */ } /* OK */ } /*------------------------------------------------------------*/ /* Modified sources */ /*------------------------------------------------------------*/ IF_OK status += get_i(stdin,prompt,"number_of_modified_sources", ¶m.num_modified_source); IF_OK { if(param.num_base_source + param.num_modified_source > MAX_SOURCE){ printf("Total including base sources exceeds dimension %d\n", MAX_SOURCE); status++; } } for(i = 0; i < param.num_modified_source; i++){ /* We append the modified sources to the list of base sources */ int is = param.num_base_source + i; IF_OK status += get_i(stdin,prompt,"source", ¶m.parent_source[is]); IF_OK { if( param.parent_source[is] >= is){ printf("Source index must be less than %d here\n",is); status++; } } IF_OK init_qss_op(¶m.src_qs_op[is]); set_qss_op_offset(¶m.src_qs_op[is], param.coord_origin); /* Get source operator attributes */ IF_OK status += get_wv_field_op( stdin, prompt, ¶m.src_qs_op[is]); /* Copy parent source attributes to the derived source structure */ IF_OK { int p = param.parent_source[is]; param.base_src_qs[is] = param.base_src_qs[p]; param.base_src_qs[is].op = copy_qss_op_list(param.base_src_qs[p].op); /* Add the new operator to the linked list */ insert_qss_op(¶m.base_src_qs[is], ¶m.src_qs_op[is]); /* Append the operator info to the description if the operator is nontrivial, but simply copy the label */ if(param.src_qs_op[is].type != IDENTITY){ char *descrp = param.base_src_qs[is].descrp; char *op_descrp = param.src_qs_op[is].descrp; char *label = param.base_src_qs[is].label; char *op_label = param.src_qs_op[is].label; strncat(descrp, "/", MAXDESCRP-strlen(descrp)-1); strncat(descrp, op_descrp, MAXDESCRP-strlen(descrp)-1); strncpy(label, op_label, MAXSRCLABEL-strlen(label)-1); } } /* Get optional file for saving the modified source */ IF_OK { int source_type, saveflag_s; char descrp[MAXDESCRP]; char savefile_s[MAXFILENAME]; status += ask_output_quark_source_file( stdin, prompt, &saveflag_s, &source_type, NULL, descrp, savefile_s ); IF_OK { param.base_src_qs[is].savetype = source_type; param.base_src_qs[is].saveflag = saveflag_s; strcpy(param.base_src_qs[is].save_file, savefile_s); if(saveflag_s != FORGET && source_type != DIRAC_FIELD_FILE && source_type != VECTOR_FIELD_FILE){ printf("Unsupported output source type\n"); status++; } } /* OK */ } /* OK */ } /*------------------------------------------------------------*/ /* Propagators and their sources */ /*------------------------------------------------------------*/ /* Number of propagators */ IF_OK status += get_i(stdin,prompt,"number_of_propagators", ¶m.num_prop ); if( param.num_prop>MAX_PROP ){ printf("num_prop = %d must be <= %d!\n", param.num_prop, MAX_PROP); status++; } /* Get propagator parameters */ IF_OK for(i = 0; i < param.num_prop; i++){ /* Initialize dependency */ param.prop_dep_qkno[i] = 0; /* Type of propagator */ IF_OK status += get_s(stdin, prompt,"propagator_type", savebuf ); IF_OK { /* Standard clover */ if(strcmp(savebuf,"clover") == 0)param.prop_type[i] = CLOVER_TYPE; /* Standard staggered (asqtad or HISQ) to be converted to naive */ else if(strcmp(savebuf,"KS") == 0)param.prop_type[i] = KS_TYPE; /* Same as standard staggered, but conversion to naive is based on hypercube offset 0 */ else if(strcmp(savebuf,"KS0") == 0)param.prop_type[i] = KS0_TYPE; /* Staggered propagator originating from an extended Dirac source */ else if(strcmp(savebuf,"KS4") == 0)param.prop_type[i] = KS4_TYPE; /* Improved fermion lattice action (OK action) */ else if(strcmp(savebuf,"ifla") == 0 )param.prop_type[i] = IFLA_TYPE; else { printf("Unknown quark type %s\n",savebuf); status++; } } /* Mass parameters, etc */ if(param.prop_type[i] == CLOVER_TYPE){ IF_OK status += get_s(stdin, prompt,"kappa", param.kappa_label[i]); IF_OK param.dcp[i].Kappa = atof(param.kappa_label[i]); IF_OK status += get_f(stdin, prompt,"clov_c", ¶m.dcp[i].Clov_c ); param.dcp[i].U0 = param.u0; } else if(param.prop_type[i] == IFLA_TYPE) { printf("Ifla Type Fermion\n"); #ifndef HAVE_QOP printf("Compilation with the QOP package is required for this fermion type\n"); terminate(1); #endif IF_OK status += get_s(stdin,prompt,"kapifla",param.kappa_label[i]); IF_OK param.nap[i].kapifla = atof(param.kappa_label[i]); IF_OK status += get_f(stdin, prompt, "kappa_s", ¶m.nap[i].kappa_s); IF_OK status += get_f(stdin, prompt, "kappa_t", ¶m.nap[i].kappa_t); IF_OK status += get_f(stdin, prompt, "r_s", ¶m.nap[i].r_s); IF_OK status += get_f(stdin, prompt, "r_t", ¶m.nap[i].r_t); IF_OK status += get_f(stdin, prompt, "zeta", ¶m.nap[i].zeta); IF_OK status += get_f(stdin, prompt, "c_E", ¶m.nap[i].c_E); IF_OK status += get_f(stdin, prompt, "c_B", ¶m.nap[i].c_B); IF_OK status += get_f(stdin, prompt, "c_1", ¶m.nap[i].c_1); IF_OK status += get_f(stdin, prompt, "c_2", ¶m.nap[i].c_2); IF_OK status += get_f(stdin, prompt, "c_3", ¶m.nap[i].c_3); IF_OK status += get_f(stdin, prompt, "c_4", ¶m.nap[i].c_4); IF_OK status += get_f(stdin, prompt, "c_5", ¶m.nap[i].c_5); IF_OK status += get_f(stdin, prompt, "c_EE", ¶m.nap[i].c_EE); param.nap[i].u0 = param.u0; } else { /* KS_TYPE || KS0_TYPE || KS4_TYPE */ IF_OK status += get_s(stdin, prompt,"mass", param.mass_label[i] ); IF_OK param.ksp[i].mass = atof(param.mass_label[i]); #if FERM_ACTION == HISQ IF_OK status += get_f(stdin, prompt, "naik_term_epsilon", ¶m.ksp[i].naik_term_epsilon); #else IF_OK param.ksp[i].naik_term_epsilon = 0.0; #endif } /* Should we solve for the propagator? */ IF_OK status += get_s(stdin, prompt,"check", savebuf); IF_OK { /* Should we be checking the propagator by running the solver? */ if(strcmp(savebuf,"no") == 0)param.check[i] = CHECK_NO; else if(strcmp(savebuf,"yes") == 0) param.check[i] = CHECK_YES; else if(strcmp(savebuf,"sourceonly") == 0) param.check[i] = CHECK_SOURCE_ONLY; else{ printf("Unrecognized 'check' option. Wanted 'no', 'yes', or 'sourceonly'\n"); status++; } } /* Error for propagator conjugate gradient or bicg */ IF_OK status += get_f(stdin, prompt,"error_for_propagator", ¶m.qic[i].resid ); IF_OK status += get_f(stdin, prompt,"rel_error_for_propagator", ¶m.qic[i].relresid ); IF_OK status += get_i(stdin, prompt,"precision", ¶m.qic[i].prec ); #if ! defined(HAVE_QOP) && ! defined(USE_CG_GPU) if(param.qic[i].prec != PRECISION){ node0_printf("WARNING: Compiled precision %d overrides request\n",PRECISION); node0_printf("QOP or CG_GPU compilation is required for mixed precision\n"); param.qic[i].prec = PRECISION; } #endif param.qic[i].max = max_cg_iterations; param.qic[i].nrestart = max_cg_restarts; param.qic[i].parity = EVENANDODD; param.qic[i].min = 0; param.qic[i].start_flag = 0; param.qic[i].nsrc = 1; /* Momentum twist and time boundary condition */ IF_OK status += get_vf(stdin, prompt, "momentum_twist", bdry_phase, 3); IF_OK status += get_s(stdin, prompt,"time_bc", savebuf); if(param.prop_type[i] == CLOVER_TYPE || param.prop_type[i] == IFLA_TYPE){ /* NOTE: The Dirac built-in bc is periodic. */ IF_OK { if(strcmp(savebuf,"antiperiodic") == 0)bdry_phase[3] = 1; else if(strcmp(savebuf,"periodic") == 0)bdry_phase[3] = 0; else{ node0_printf("Expecting 'periodic' or 'antiperiodic' but found %s\n", savebuf); status++; } } } else { /* KS_TYPE || KS0_TYPE || KS4_TYPE */
/* read in parameters and coupling constants */ int readin(int prompt) { /* read in parameters for su3 monte carlo */ /* argument "prompt" is 1 if prompts are to be given for input */ int status; Real x; /* On node zero, read parameters and send to all other nodes */ if(this_node==0){ printf("\n\n"); status=0; /* get couplings and broadcast to nodes */ /* beta, mass */ IF_OK status += get_f(stdin, prompt,"mass", &par_buf.mass ); IF_OK status += get_f(stdin, prompt,"u0", &par_buf.u0 ); /* maximum no. of conjugate gradient iterations */ IF_OK status += get_i(stdin, prompt,"max_cg_iterations", &par_buf.niter ); /* maximum no. of conjugate gradient restarts */ IF_OK status += get_i(stdin, prompt,"max_cg_restarts", &par_buf.nrestart ); /* error per site for conjugate gradient */ IF_OK status += get_f(stdin, prompt,"error_per_site", &x ); IF_OK par_buf.rsqmin = x*x; /* rsqmin is r**2 in conjugate gradient */ /* New conjugate gradient normalizes rsqmin by norm of source */ /* error for propagator conjugate gradient */ IF_OK status += get_f(stdin, prompt,"error_for_propagator", &x ); IF_OK par_buf.rsqprop = x*x; IF_OK status += get_i(stdin, prompt,"Number_of_eigenvals", &par_buf.Nvecs ); IF_OK status += get_i(stdin, prompt,"Max_Rayleigh_iters", &par_buf.MaxIter ); IF_OK status += get_i(stdin, prompt,"Restart_Rayleigh", &par_buf.Restart ); IF_OK status += get_i(stdin, prompt,"Kalkreuter_iters", &par_buf.Kiters ); IF_OK status += get_f(stdin, prompt,"eigenval_tolerance", &par_buf.eigenval_tol ); IF_OK status += get_f(stdin, prompt,"error_decrease", &par_buf.error_decr); /* find out what kind of starting lattice to use */ IF_OK status += ask_starting_lattice(stdin, prompt, &(par_buf.startflag), par_buf.startfile ); if( status > 0)par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(this_node==0) */ /* Node 0 broadcasts parameter buffer to all other nodes */ broadcast_bytes((char *)&par_buf,sizeof(par_buf)); if( par_buf.stopflag != 0 )return par_buf.stopflag; niter = par_buf.niter; nrestart = par_buf.nrestart; rsqmin = par_buf.rsqmin; rsqprop = par_buf.rsqprop; mass = par_buf.mass; u0 = par_buf.u0; Nvecs = par_buf.Nvecs ; MaxIter = par_buf.MaxIter ; Restart = par_buf.Restart ; Kiters = par_buf.Kiters ; eigenval_tol = par_buf.eigenval_tol ; error_decr = par_buf.error_decr ; startflag = par_buf.startflag; strcpy(startfile,par_buf.startfile); #if ( FERM_ACTION == HISQ || FERM_ACTION == HYPISQ ) n_naiks = 1; eps_naik[0] = 0.0; #endif /* Do whatever is needed to get lattice */ if( startflag == CONTINUE ){ rephase( OFF ); } if( startflag != CONTINUE ) startlat_p = reload_lattice( startflag, startfile ); /* if a lattice was read in, put in KS phases and AP boundary condition */ phases_in = OFF; rephase( ON ); /* Set uptions for fermion links */ #ifdef DBLSTORE_FN /* We want to double-store the links for optimization */ fermion_links_want_back(1); #endif #if ( FERM_ACTION == HISQ || FERM_ACTION == HYPISQ ) fn_links = create_fermion_links_from_site(PRECISION, n_naiks, eps_naik); #else fn_links = create_fermion_links_from_site(PRECISION, 0, NULL); #endif // node0_printf("Calling for path table\n");fflush(stdout); // /* make table of coefficients and permutations of paths in quark action */ // init_path_table(fn_links.ap); // make_path_table(fn_links.ap, NULL); // node0_printf("Done with path table\n");fflush(stdout); return(0); }
/* read in parameters and coupling constants */ int readin(int prompt) { /* read in parameters for su3 monte carlo */ /* argument "prompt" is 1 if prompts are to be given for input */ int status; /* On node zero, read parameters and send to all other nodes */ if(this_node==0){ printf("\n\n"); status=0; /* warms, trajecs */ IF_OK status += get_i(stdin, prompt,"warms", &par_buf.warms ); IF_OK status += get_i(stdin, prompt,"trajecs", &par_buf.trajecs ); /* trajectories between propagator measurements */ IF_OK status += get_i(stdin, prompt,"traj_between_meas", &par_buf.propinterval ); /* get couplings and broadcast to nodes */ /* beta */ IF_OK status += get_f(stdin, prompt,"beta", &par_buf.beta ); /* boundary condition flag */ IF_OK status += get_i(stdin, prompt,"bc_flag", &par_buf.bc_flag ); #if ( defined HMC_ALGORITHM || defined RMD_ALGORITHM ) /* microcanonical time step */ IF_OK status += get_f(stdin, prompt,"microcanonical_time_step", &par_buf.epsilon ); #endif /*microcanonical steps per trajectory */ IF_OK status += get_i(stdin, prompt,"steps_per_trajectory", &par_buf.steps ); #ifdef ORA_ALGORITHM /*qhb steps per trajectory */ IF_OK status += get_i(stdin, prompt,"qhb_steps", &par_buf.stepsQ ); #endif /* find out what kind of starting lattice to use */ IF_OK status += ask_starting_lattice(stdin, prompt, &(par_buf.startflag), par_buf.startfile ); /* find out what to do with lattice at end */ IF_OK status += ask_ending_lattice(stdin, prompt, &(par_buf.saveflag), par_buf.savefile ); IF_OK status += ask_ildg_LFN(stdin, prompt, par_buf.saveflag, par_buf.stringLFN ); /* send parameter structure */ if( status > 0)par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(this_node==0) */ /* Node 0 broadcasts parameter buffer to all other nodes */ broadcast_bytes((char *)&par_buf,sizeof(par_buf)); if( par_buf.stopflag != 0 ) normal_exit(0); warms = par_buf.warms; trajecs = par_buf.trajecs; steps = par_buf.steps; stepsQ = par_buf.stepsQ; propinterval = par_buf.propinterval; startflag = par_buf.startflag; saveflag = par_buf.saveflag; epsilon = par_buf.epsilon; beta = par_buf.beta; bc_flag = par_buf.bc_flag; strcpy(startfile,par_buf.startfile); strcpy(savefile,par_buf.savefile); strcpy(stringLFN, par_buf.stringLFN); c_t11 = 0; /* Do whatever is needed to get lattice */ if( startflag != CONTINUE ) startlat_p = reload_lattice( startflag, startfile ); return(0); } /*readin()*/
int temp_div1() { return 1 / get_f(X(1)); }
int readin(int prompt) { /* argument "prompt" is 1 if prompts are to be given for input */ int status,i; /* On node zero, read parameters and send to all other nodes */ if(this_node==0){ status=0; /* find out what kind of starting lattice to use */ IF_OK status += ask_starting_lattice(stdin, prompt, &(par_buf.startflag), par_buf.startfile ); /* find out what to do with lattice at end */ IF_OK status += ask_ending_lattice(stdin, prompt, &(par_buf.saveflag), par_buf.savefile ); IF_OK status += ask_ildg_LFN(stdin, prompt, par_buf.saveflag, par_buf.stringLFN ); /* Get ensemble values for NERSC archive */ IF_OK if (par_buf.saveflag == SAVE_SERIAL_ARCHIVE) status += get_s(stdin, prompt,"ensemble_id", par_buf.ensemble_id ); IF_OK if (par_buf.saveflag == SAVE_SERIAL_ARCHIVE) status += get_i(stdin, prompt,"sequence_number", &par_buf.sequence_number ); /* Number of kappas */ IF_OK status += get_i(stdin, prompt,"number_of_kappas", &par_buf.num_kap ); if( par_buf.num_kap>MAX_KAP ){ printf("num_kap = %d must be <= %d!\n", par_buf.num_kap, MAX_KAP); status++; } /* To be safe initialize the following to zero */ for(i=0;i<MAX_KAP;i++){ kap[i] = 0.0; } for(i=0;i<par_buf.num_kap;i++){ IF_OK status += ask_starting_wprop(stdin, prompt, &par_buf.startflag_w[i], par_buf.startfile_w[i]); /* Save the string to create the FNAL file name */ IF_OK status += get_s(stdin, prompt,"kappa", par_buf.kap_label[i] ); IF_OK par_buf.kap[i] = atof(par_buf.kap_label[i]); IF_OK status += get_s(stdin, prompt,"source_label", par_buf.src_label_w[i] ); IF_OK status += get_f(stdin, prompt,"d1", &par_buf.d1[i] ); } IF_OK status += get_i(stdin, prompt,"number_of_smearings", &par_buf.num_smear ); /* We always have a point sink */ par_buf.num_smear++; strcpy(par_buf.sink_label[0],"d"); par_buf.smearfile[0][0] = '\0'; for(i=1;i<par_buf.num_smear;i++){ IF_OK status += get_s(stdin, prompt,"sink_label", par_buf.sink_label[i] ); IF_OK status += get_s(stdin, prompt,"smear_func_file", par_buf.smearfile[i]); } IF_OK status += ask_starting_ksprop (stdin, prompt, &par_buf.ks_prop_startflag, par_buf.start_ks_prop_file); IF_OK status += get_s(stdin, prompt,"mass", par_buf.mass_label ); IF_OK par_buf.mass = atof(par_buf.mass_label); /* What file for the resulting correlators? */ IF_OK status += ask_corr_file( stdin, prompt, &par_buf.saveflag_c, par_buf.savefile_c); IF_OK status += get_i(stdin, prompt, "log_correlators", &par_buf.log_correlators); if( status > 0)par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(this_node==0) */
int field_div0() { X x(0); Y y(x); return 1 / get_f(y.x); }
/* read in parameters and coupling constants */ int readin(int prompt) { /* read in parameters for su3 monte carlo */ /* argument "prompt" is 1 if prompts are to be given for input */ int status; int i, k, npbp_masses; #ifdef PRTIME double dtime; #endif STARTTIME; /* On node zero, read parameters and send to all other nodes */ if(this_node==0){ printf("\n\n"); status=0; /*------------------------------------------------------------*/ /* Gauge configuration section */ /*------------------------------------------------------------*/ IF_OK status += ask_starting_lattice(stdin, prompt, ¶m.startflag, param.startfile ); IF_OK status += get_f(stdin, prompt,"u0", ¶m.u0 ); /* find out what to do with lattice at end */ IF_OK status += ask_ending_lattice(stdin, prompt, &(param.saveflag), param.savefile ); IF_OK status += ask_ildg_LFN(stdin, prompt, param.saveflag, param.stringLFN ); /* Provision is made to build covariant sources from smeared links */ /* APE smearing parameters (if needed) */ /* Zero suppresses APE smearing */ IF_OK status += get_f(stdin, prompt, "staple_weight", ¶m.staple_weight); IF_OK status += get_i(stdin, prompt, "ape_iter", ¶m.ape_iter); #if EIGMODE == EIGCG /* for eigcg */ /* restart for Lanczos */ IF_OK status += get_i(stdin, prompt,"restart_lanczos", ¶m.eigcgp.m); /* number of eigenvectors per inversion */ IF_OK status += get_i(stdin, prompt,"Number_of_eigenvals", ¶m.eigcgp.Nvecs); if(param.eigcgp.m <= 2*param.eigcgp.Nvecs){ printf("restart_lanczos should be larger than 2*Number_of_eigenvals!\n"); status++; } /* maximum number of eigenvectors */ IF_OK status += get_i(stdin, prompt,"Max_Number_of_eigenvals", ¶m.eigcgp.Nvecs_max); /* eigenvector input */ IF_OK status += ask_starting_ks_eigen(stdin, prompt, ¶m.ks_eigen_startflag, param.ks_eigen_startfile); /* eigenvector output */ IF_OK status += ask_ending_ks_eigen(stdin, prompt, ¶m.ks_eigen_saveflag, param.ks_eigen_savefile); param.eigcgp.Nvecs_curr = 0; param.eigcgp.H = NULL; #endif #if EIGMODE == DEFLATION /*------------------------------------------------------------*/ /* Dirac eigenpair calculation */ /*------------------------------------------------------------*/ /* number of eigenvectors */ IF_OK status += get_i(stdin, prompt,"Number_of_eigenvals", ¶m.Nvecs); /* max Rayleigh iterations */ IF_OK status += get_i(stdin, prompt,"Max_Rayleigh_iters", ¶m.MaxIter); /* Restart Rayleigh every so many iterations */ IF_OK status += get_i(stdin, prompt,"Restart_Rayleigh", ¶m.Restart); /* Kalkreuter iterations */ IF_OK status += get_i(stdin, prompt,"Kalkreuter_iters", ¶m.Kiters); /* Tolerance for the eigenvalue computation */ IF_OK status += get_f(stdin, prompt,"eigenval_tolerance", ¶m.eigenval_tol); /* error decrease per Rayleigh minimization */ IF_OK status += get_f(stdin, prompt,"error_decrease", ¶m.error_decr); /* eigenvector input */ IF_OK status += ask_starting_ks_eigen(stdin, prompt, ¶m.ks_eigen_startflag, param.ks_eigen_startfile); /* eigenvector output */ IF_OK status += ask_ending_ks_eigen(stdin, prompt, ¶m.ks_eigen_saveflag, param.ks_eigen_savefile); #endif /*------------------------------------------------------------*/ /* Chiral condensate and related quantities */ /*------------------------------------------------------------*/ IF_OK status += get_i(stdin,prompt,"number_of_sets", ¶m.num_set); if( param.num_set>MAX_SET ){ printf("num_set = %d must be <= %d!\n", param.num_set, MAX_SET); status++; } npbp_masses = 0; IF_OK for(k = 0; k < param.num_set; k++){ int max_cg_iterations, max_cg_restarts, prec_pbp; Real error_for_propagator, rel_error_for_propagator; #ifdef CURRENT_DISC int max_cg_iterations_sloppy, max_cg_restarts_sloppy, prec_pbp_sloppy; Real error_for_propagator_sloppy, rel_error_for_propagator_sloppy; #endif /* Number of stochastic sources */ IF_OK status += get_i(stdin, prompt, "npbp_reps", ¶m.npbp_reps[k] ); #ifdef CURRENT_DISC /* For some applications. Random source count between writes */ IF_OK status += get_i(stdin, prompt, "nwrite", ¶m.nwrite[k] ); IF_OK status += get_i(stdin, prompt, "source_spacing", ¶m.thinning[k] ); /* For truncated solver Take difference of sloppy and precise?*/ char savebuf[128]; IF_OK status += get_s(stdin, prompt, "take_truncate_diff", savebuf); IF_OK { if(strcmp(savebuf,"no") == 0)param.truncate_diff[k] = 0; else if(strcmp(savebuf,"yes") == 0)param.truncate_diff[k] = 1; else { printf("Unrecognized response %s\n",savebuf); printf("Choices are 'yes' and 'no'\n"); status++; } } #endif /* The following parameters are common to the set and will be copied to each member */ /* maximum no. of conjugate gradient iterations */ IF_OK status += get_i(stdin,prompt,"max_cg_iterations", &max_cg_iterations ); /* maximum no. of conjugate gradient restarts */ IF_OK status += get_i(stdin,prompt,"max_cg_restarts", &max_cg_restarts ); IF_OK status += get_i(stdin, prompt, "prec_pbp", &prec_pbp ); #ifdef CURRENT_DISC /* If we are taking the difference between a sloppy and a precise solve, get the sloppy solve parameters */ if(param.truncate_diff[k]){ Real error_for_propagator_sloppy, rel_error_for_propagator_sloppy; /* The following parameters are common to the set and will be copied to each member */ /* maximum no. of conjugate gradient iterations */ IF_OK status += get_i(stdin,prompt,"max_cg_iterations_sloppy", &max_cg_iterations_sloppy ); /* maximum no. of conjugate gradient restarts */ IF_OK status += get_i(stdin,prompt,"max_cg_restarts_sloppy", &max_cg_restarts_sloppy ); IF_OK status += get_i(stdin, prompt, "prec_pbp_sloppy", &prec_pbp_sloppy ); } #endif /* Number of pbp masses in this set */ IF_OK status += get_i(stdin, prompt, "number_of_pbp_masses", ¶m.num_pbp_masses[k]); if(param.num_pbp_masses[k] > MAX_MASS_PBP){ printf("Number of masses exceeds dimension %d\n",MAX_MASS_PBP); status++; } /* Indexing range for set */ param.begin_pbp_masses[k] = npbp_masses; param.end_pbp_masses[k] = npbp_masses + param.num_pbp_masses[k] - 1; if(param.end_pbp_masses[k] > MAX_PBP_MASSES){ printf("Total number of masses must be <= %d!\n", MAX_PBP_MASSES); status++; } IF_OK for(i = 0; i < param.num_pbp_masses[k]; i++){ /* PBP mass parameters */ IF_OK status += get_s(stdin, prompt,"mass", param.mass_label[npbp_masses] ); IF_OK param.ksp_pbp[npbp_masses].mass = atof(param.mass_label[npbp_masses]); #if ( FERM_ACTION == HISQ || FERM_ACTION == HYPISQ ) IF_OK status += get_f(stdin, prompt,"naik_term_epsilon", ¶m.ksp_pbp[npbp_masses].naik_term_epsilon ); #else IF_OK param.ksp_pbp[npbp_masses].naik_term_epsilon = 0.0; #endif /* error for staggered propagator conjugate gradient */ IF_OK status += get_f(stdin, prompt,"error_for_propagator", &error_for_propagator ); IF_OK status += get_f(stdin, prompt,"rel_error_for_propagator", &rel_error_for_propagator ); #ifdef CURRENT_DISC if(param.truncate_diff[k]){ /* error for staggered propagator conjugate gradient */ IF_OK status += get_f(stdin, prompt,"error_for_propagator_sloppy", &error_for_propagator_sloppy ); IF_OK status += get_f(stdin, prompt,"rel_error_for_propagator_sloppy", &rel_error_for_propagator_sloppy ); } IF_OK status += get_s(stdin, prompt, "save_file", param.pbp_filenames[npbp_masses] ); #endif /* The set to which this pbp_mass belongs */ IF_OK param.set[npbp_masses] = k; /* maximum no. of conjugate gradient iterations */ param.qic_pbp[npbp_masses].max = max_cg_iterations; /* maximum no. of conjugate gradient restarts */ param.qic_pbp[npbp_masses].nrestart = max_cg_restarts; /* precision */ param.qic_pbp[npbp_masses].prec = prec_pbp; /* errors */ param.qic_pbp[npbp_masses].resid = error_for_propagator; param.qic_pbp[npbp_masses].relresid = rel_error_for_propagator; param.qic_pbp[npbp_masses].parity = EVENANDODD; param.qic_pbp[npbp_masses].min = 0; param.qic_pbp[npbp_masses].start_flag = 0; param.qic_pbp[npbp_masses].nsrc = 1; #ifdef CURRENT_DISC /* If we are taking the difference between a sloppy and a precise solve, get the sloppy solve parameters */ if(param.truncate_diff[k]){ /* maximum no. of conjugate gradient iterations */ param.qic_pbp_sloppy[npbp_masses].max = max_cg_iterations_sloppy; /* maximum no. of conjugate gradient restarts */ param.qic_pbp_sloppy[npbp_masses].nrestart = max_cg_restarts_sloppy; /* precision */ param.qic_pbp_sloppy[npbp_masses].prec = prec_pbp_sloppy; /* errors */ param.qic_pbp_sloppy[npbp_masses].resid = error_for_propagator_sloppy; param.qic_pbp_sloppy[npbp_masses].relresid = rel_error_for_propagator_sloppy; param.qic_pbp_sloppy[npbp_masses].parity = EVENANDODD; param.qic_pbp_sloppy[npbp_masses].min = 0; param.qic_pbp_sloppy[npbp_masses].start_flag = 0; param.qic_pbp_sloppy[npbp_masses].nsrc = 1; } #endif npbp_masses++; } } /* End of input fields */ if( status > 0)param.stopflag=1; else param.stopflag=0; } /* end if(this_node==0) */
/* read in parameters and coupling constants */ int readin(int prompt) { /* read in parameters for su3 monte carlo */ /* argument "prompt" is 1 if prompts are to be given for input */ int status; Real x; int i; #ifdef SPECTRUM char request_buf[MAX_SPECTRUM_REQUEST]; #endif /* On node zero, read parameters and send to all other nodes */ if(this_node==0) { printf("\n\n"); status=0; /* warms, trajecs */ IF_OK status += get_i(stdin, prompt,"warms", &par_buf.warms ); IF_OK status += get_i(stdin, prompt,"trajecs", &par_buf.trajecs ); /* trajectories between propagator measurements */ IF_OK status += get_i(stdin, prompt,"traj_between_meas", &par_buf.propinterval ); /* microcanonical time step */ IF_OK status += get_f(stdin, prompt,"microcanonical_time_step", &par_buf.epsilon ); /*microcanonical steps per trajectory */ IF_OK status += get_i(stdin, prompt,"steps_per_trajectory", &par_buf.steps ); /* Data for each pseudofermion */ for(i = 0; i < par_buf.n_pseudo; i++){ Real tmp[3]; int itmp[3]; /* Residuals for multicg solves */ IF_OK status += get_vf(stdin, prompt,"cgresid_md_fa_gr", tmp, 3 ); /* rsqmin is r**2 in conjugate gradient */ IF_OK { par_buf.rsqmin_md[i] = tmp[0]*tmp[0]; par_buf.rsqmin_fa[i] = tmp[1]*tmp[1]; par_buf.rsqmin_gr[i] = tmp[2]*tmp[2]; } /* Max CG iterations for multicg solves */ IF_OK status += get_vi(stdin, prompt, "max_multicg_md_fa_gr", itmp, 3); IF_OK { par_buf.niter_md[i] = itmp[0]; par_buf.niter_fa[i] = itmp[1]; par_buf.niter_gr[i] = itmp[2]; } /* Precision for multicg solves */ IF_OK status += get_vi(stdin, prompt, "cgprec_md_fa_gr", itmp, 3); IF_OK { par_buf.prec_md[i] = itmp[0]; par_buf.prec_fa[i] = itmp[1]; par_buf.prec_gr[i] = itmp[2]; } } /* Precision for fermion force calculation */ IF_OK status = get_i(stdin, prompt, "prec_ff", &par_buf.prec_ff); /* error for propagator conjugate gradient */ IF_OK status += get_f(stdin, prompt,"error_for_propagator", &x ); IF_OK par_buf.rsqprop = x*x; /* maximum no. of conjugate gradient iterations for propagator etc. and maximum no. of restarts */ IF_OK status += get_i(stdin, prompt,"max_cg_prop", &par_buf.niter ); IF_OK status += get_i(stdin, prompt,"max_cg_prop_restarts", &par_buf.nrestart ); #ifdef NPBP_REPS /* number of random sources npbp_reps and precision for inversions */ IF_OK status += get_i(stdin, prompt,"npbp_reps", &par_buf.npbp_reps_in ); IF_OK status += get_i(stdin, prompt,"prec_pbp", &par_buf.prec_pbp ); #endif #ifdef SPECTRUM /* request list for spectral measurments */ /* prepend and append a comma for ease in parsing */ IF_OK status += get_s(stdin, prompt,"spectrum_request", request_buf ); IF_OK strcpy(par_buf.spectrum_request,","); IF_OK strcat(par_buf.spectrum_request,request_buf); IF_OK strcat(par_buf.spectrum_request,","); /* source time slice and increment */ IF_OK status += get_i(stdin, prompt,"source_start", &par_buf.source_start ); IF_OK status += get_i(stdin, prompt,"source_inc", &par_buf.source_inc ); IF_OK status += get_i(stdin, prompt,"n_sources", &par_buf.n_sources ); /* Additional parameters for spectrum_multimom */ if(strstr(par_buf.spectrum_request,",spectrum_multimom,") != NULL){ IF_OK status += get_i(stdin, prompt,"spectrum_multimom_nmasses", &par_buf.spectrum_multimom_nmasses ); IF_OK status += get_f(stdin, prompt,"spectrum_multimom_low_mass", &par_buf.spectrum_multimom_low_mass ); IF_OK status += get_f(stdin, prompt,"spectrum_multimom_mass_step", &par_buf.spectrum_multimom_mass_step ); } /* Additional parameters for fpi */ par_buf.fpi_nmasses = 0; if(strstr(par_buf.spectrum_request,",fpi,") != NULL){ IF_OK status += get_i(stdin, prompt,"fpi_nmasses", &par_buf.fpi_nmasses ); if(par_buf.fpi_nmasses > MAX_FPI_NMASSES){ printf("Maximum of %d exceeded.\n",MAX_FPI_NMASSES); terminate(1); } for(i = 0; i < par_buf.fpi_nmasses; i++){ IF_OK status += get_f(stdin, prompt,"fpi_mass", &par_buf.fpi_mass[i]); } } #endif /*SPECTRUM*/ /* find out what kind of starting lattice to use */ IF_OK status += ask_starting_lattice(stdin, prompt, &(par_buf.startflag), par_buf.startfile ); /* find out what to do with lattice at end */ IF_OK status += ask_ending_lattice(stdin, prompt, &(par_buf.saveflag), par_buf.savefile ); IF_OK status += ask_ildg_LFN(stdin, prompt, par_buf.saveflag, par_buf.stringLFN ); if( status > 0)par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(this_node==0) */
/* read in parameters and coupling constants */ int readin(int prompt) { /* read in parameters for U1 monte carlo */ /* argument "prompt" is 1 if prompts are to be given for input */ complex *temp_field; complex *temp_link; register int dir, j; register site *s; int status; Real x; /* On node zero, read parameters and send to all other nodes */ if(this_node==0){ printf("\n\n"); status=0; /* get couplings and broadcast to nodes */ /* beta, mass */ IF_OK status += get_f(stdin, prompt,"mass", &par_buf.mass ); IF_OK status += get_f(stdin, prompt,"u0_s", &par_buf.u0_s ); IF_OK status += get_f(stdin, prompt,"u0_t", &par_buf.u0_t ); IF_OK status += get_f(stdin, prompt,"v_Fermi", &par_buf.v_Fermi); printf("par_buf.v_Fermi = %f\n", par_buf.v_Fermi); /* maximum no. of conjugate gradient iterations */ IF_OK status += get_i(stdin, prompt,"max_cg_iterations", &par_buf.niter ); /* maximum no. of conjugate gradient restarts */ IF_OK status += get_i(stdin, prompt,"max_cg_restarts", &par_buf.nrestart ); /* error per site for conjugate gradient */ IF_OK status += get_f(stdin, prompt,"error_per_site", &x ); IF_OK par_buf.rsqmin = x*x; /* rsqmin is r**2 in conjugate gradient */ /* New conjugate gradient normalizes rsqmin by norm of source */ /* error for propagator conjugate gradient */ IF_OK status += get_f(stdin, prompt,"error_for_propagator", &x ); IF_OK par_buf.rsqprop = x*x; IF_OK status += get_i(stdin, prompt,"Number_of_eigenvals", &par_buf.Nvecs ); IF_OK status += get_i(stdin, prompt,"Max_Rayleigh_iters", &par_buf.MaxIter ); IF_OK status += get_i(stdin, prompt,"Restart_Rayleigh", &par_buf.Restart ); IF_OK status += get_i(stdin, prompt,"Kalkreuter_iters", &par_buf.Kiters ); IF_OK status += get_f(stdin, prompt,"eigenval_tolerance", &par_buf.eigenval_tol ); IF_OK status += get_f(stdin, prompt,"error_decrease", &par_buf.error_decr); /* find out what kind of starting lattice to use */ IF_OK status += ask_starting_lattice(stdin, prompt, &(par_buf.startflag), par_buf.startfile ); if( status > 0)par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(this_node==0) */ /* Node 0 broadcasts parameter buffer to all other nodes */ broadcast_bytes((char *)&par_buf,sizeof(par_buf)); if( par_buf.stopflag != 0 )return par_buf.stopflag; niter = par_buf.niter; nrestart = par_buf.nrestart; rsqmin = par_buf.rsqmin; rsqprop = par_buf.rsqprop; mass = par_buf.mass; u0_s = par_buf.u0_s; u0_t = par_buf.u0_t; v_Fermi = par_buf.v_Fermi; Nvecs = par_buf.Nvecs ; MaxIter = par_buf.MaxIter ; Restart = par_buf.Restart ; Kiters = par_buf.Kiters ; eigenval_tol = par_buf.eigenval_tol ; error_decr = par_buf.error_decr ; startflag = par_buf.startflag; strcpy(startfile,par_buf.startfile); /* Do whatever is needed to get lattice */ if( startflag == CONTINUE ){ rephase( OFF ); } if( startflag != CONTINUE ) { if(startflag == FRESH ) { coldlat_u1(); //funnylat_u1(); /*testing SciDAC routines and eigenvalues*/ } else { temp_field = (complex *)malloc(sites_on_node*4*sizeof(complex)); if(temp_field == NULL) { printf("Malloc failed to create temp_field in setup\n"); exit(1); } restore_complex_scidac_to_field( startfile, QIO_SERIAL, temp_field, 4); //put back into site structure FORALLSITES(j,s) { for(dir=XUP;dir<=TUP;dir++){ temp_link = temp_field + 4*j + dir; s->link[dir].real = temp_link->real; s->link[dir].imag = temp_link->imag; } } free(temp_field); }//else } //if /* if a lattice was read in, put in KS phases and AP boundary condition */ phases_in = OFF; rephase( ON ); node0_printf("Calling for path table\n");fflush(stdout); /* make table of coefficients and permutations of paths in quark action */ init_path_table(&ks_act_paths); make_path_table(&ks_act_paths, NULL); node0_printf("Done with path table\n");fflush(stdout); return(0); }
/* SETUP ROUTINES */ int initial_set() { int prompt,status; int i; /* On node zero, read lattice size, seed, nflavors1, nflavors2, nflavors, and send to others */ if(mynode()==0){ /* print banner */ printf("SU3 gauge utility program\n"); printf("MIMD version 7\n"); printf("Machine = %s, with %d nodes\n",machine_type(),numnodes()); status=get_prompt(stdin, &prompt); IF_OK status += get_i(stdin, prompt,"nx", ¶m.nx ); IF_OK status += get_i(stdin, prompt,"ny", ¶m.ny ); IF_OK status += get_i(stdin, prompt,"nz", ¶m.nz ); IF_OK status += get_i(stdin, prompt,"nt", ¶m.nt ); #ifdef FIX_NODE_GEOM IF_OK status += get_vi(stdin, prompt, "node_geometry", param.node_geometry, 4); #ifdef FIX_IONODE_GEOM IF_OK status += get_vi(stdin, prompt, "ionode_geometry", param.ionode_geometry, 4); #endif #endif IF_OK status += get_i(stdin, prompt,"iseed", ¶m.iseed ); /* beta, quark masses */ IF_OK status += get_f(stdin, prompt,"beta", ¶m.beta ); IF_OK status += get_i(stdin, prompt,"n_dyn_masses", ¶m.n_dyn_masses ); IF_OK status += get_vf(stdin, prompt, "dyn_mass", param.dyn_mass, param.n_dyn_masses); IF_OK status += get_vi(stdin, prompt, "dyn_flavors", param.dyn_flavors, param.n_dyn_masses); /* Get tadpole factor */ IF_OK status += get_f(stdin, prompt, "u0", ¶m.u0); /* Get translation vector */ if(status>0) param.stopflag=1; else param.stopflag=0; } /* end if(mynode()==0) */ /* Node 0 broadcasts parameter buffer to all other nodes */ broadcast_bytes((char *)¶m,sizeof(param)); if( param.stopflag != 0 ) normal_exit(0); nx=param.nx; ny=param.ny; nz=param.nz; nt=param.nt; #ifdef FIX_NODE_GEOM for(i = 0; i < 4; i++) node_geometry[i] = param.node_geometry[i]; #ifdef FIX_IONODE_GEOM for(i = 0; i < 4; i++) ionode_geometry[i] = param.ionode_geometry[i]; #endif #endif iseed=param.iseed; this_node = mynode(); number_of_nodes = numnodes(); volume=nx*ny*nz*nt; beta = param.beta; n_dyn_masses = param.n_dyn_masses; for(i = 0; i < n_dyn_masses; i++){ dyn_mass[i] = param.dyn_mass[i]; dyn_flavors[i] = param.dyn_flavors[i]; } u0 = param.u0; return prompt; }
int main() { int n,looplim = 10000; while(cin >> n) { vMat all_Mat; Mat sec_Mat; cout << "=======" << endl; cout << n << endl; Mat L; double start_t = clock(); double ans = INF; double t3 = 0,t4 = 0; clock_t c1,c2; //step 0 vd ans_v; for(int i = 0 ; i < n ; i++) { vd tmpl,x; for(int j = 0 ; j < n ; j++) { if(i == j) {x.push_back(1);} else {x.push_back(0);} } if(get_f(x) <= ans) { ans = get_f(x); ans_v = x; } for(int j = 0 ; j < n ; j++) { if(x[j] == 1) { tmpl.push_back(get_f(x)); } else { tmpl.push_back(INF); } } L.push_back(tmpl); } int cnt = 0; vMat used_Mat;//,all_Mat; all_Mat.push_back(L); sec_Mat.push_back(get_sec(L)); multimap<double,Mat> dMatmp; set<pvdi> st; set<pdi> stf; vector<set<pdi> > vst(n); set<int> used_idx; st.insert(make_pair(get_diag(L),all_Mat.size()-1)); stf.insert(make_pair(L[0][0],all_Mat.size()-1)); priority_queue<pair<double,int> , vector<pair<double,int> > , greater<pair<double,int> > > pq; //priority_queue<pair<double,int> > pq; pq.push(make_pair(get_d(L),all_Mat.size()-1)); //O(min(loop,local min)) int max_set_size = 1000000; int cut_cnt = 0; while(cnt++ < looplim && !pq.empty()) { if(pq.size() > 1000000) break; if(cnt % 1000 == 0) { cout << "cnt:" << cnt << endl; cout << "lb:" << pq.top().first << endl; cout << "f:" << ans << endl; cout << "size:" << pq.size() << endl; cout << "cut:" << cut_cnt << endl; cout << "time:" << (clock() - start_t)/CLOCKS_PER_SEC << endl; cout << "---" << endl; } //step 1 //select l in Lk with the smallest d double d = pq.top().first; int idx = pq.top().second; pq.pop(); L = all_Mat[idx]; //print_Mat(L); //print_Mat(L); //cout << endl; if(used_idx.find(idx) != used_idx.end()){ continue; } if(ans - d < eps) { break; } vd xs; for(int i = 0 ; i < L.size() ; i++) { //caution : division by zero xs.push_back(d/L[i][i]); } //step 2 double tmpf = get_f(xs); //print_v(xs); //cout << get_f(xs) << endl; if(tmpf <= ans) { ans = tmpf; ans_v = xs; } vd lk; for(int i = 0 ; i < xs.size() ; i++) { if(xs[i] > zero_boundary) lk.push_back(tmpf/xs[i]); else lk.push_back(INF); } vMat Lm; vi idxs = get_lower_idx_s(st,lk); //vi idxs = get_lower_idx(st,lk,vst); //vi idxs = get_lower_idx_s(st,lk); Mat Sec; for(int i = 0 ; i < idxs.size() ; i++) { if(used_idx.find(idxs[i]) == used_idx.end()){ used_idx.insert(idxs[i]); Lm.push_back(all_Mat[idxs[i]]); Sec.push_back(sec_Mat[idxs[i]]); } } used_idx.insert(idx); //step 4 //O(L- size * n * n^2) vd dlk = lk; for(int j = 0 ; j < Lm.size() ; j++) { Mat tmpL = Lm[j]; vd tmplk = lk; //print_Mat(tmpL); //cout << endl; vi idx = get_swap_idx(tmplk,Sec[j]); /* cout << "s:" << endl; for(int i = 0 ; i < idx.size() ; i++) { cout << idx[i] << " "; } cout << endl; */ for(int i = 0 ; i < idx.size() ; i++) { L = tmpL; lk = tmplk; //print_Mat(L); swap(L[idx[i]],lk); //cout << "--" << endl; //print_v(Sec[j]); //cout << "v:" << is_valid_combination(L,Sec[j]) << " " << is_valid_combination(L) << endl; //if(get_d(L) > d) { all_Mat.push_back(L); sec_Mat.push_back(get_sec(L)); st.insert(make_pair(get_diag(L),all_Mat.size()-1)); stf.insert(make_pair(L[0][0],all_Mat.size()-1)); pq.push(make_pair(get_d(L),all_Mat.size()-1)); //} swap(L[idx[i]],lk); } } priority_queue<pair<double,int> , vector<pair<double,int> > , greater<pair<double,int> > > tmp_pq = pq; priority_queue<pair<double,int> , vector<pair<double,int> > , greater<pair<double,int> > > nxt_pq; int set_size = 0; while(!tmp_pq.empty()) { set_size++; int idx = tmp_pq.top().second; if(set_size < max_set_size) nxt_pq.push(tmp_pq.top()); else { st.erase(make_pair(get_diag(all_Mat[idx]),idx)); } tmp_pq.pop(); } pq = nxt_pq; } cout << "cnt:" << cnt << endl; cout << "ans:" << ans << endl; cout << "ans_v:"; print_v(ans_v); } return 0; }