示例#1
0
/*!
*/
void Postprocess_method::read(vector <string> words,
                       unsigned int & pos,
                       Program_options & options)
{

  if(!readvalue(words, pos=0, configfile, "READCONFIG"))
    error("Need READCONFIG in Postprocess");
  
  if(!readvalue(words, pos=0, nskip, "NSKIP"))
    nskip=0;
  
  evaluate_energy=true;
  if(haskeyword(words,pos=0,"NOENERGY")) evaluate_energy=false;

  vector <vector < string> > dens_words;
  vector<string> tmp_dens;
  pos=0;
  while(readsection(words, pos, tmp_dens, "DENSITY")) {
    dens_words.push_back(tmp_dens);
  }


  vector <vector < string> > avg_words;
  pos=0;
  while(readsection(words, pos, tmp_dens, "AVERAGE")) {
    avg_words.push_back(tmp_dens);
  }

  
  sys=NULL;
  allocate(options.systemtext[0],  sys);
  sys->generatePseudo(options.pseudotext, pseudo);
  debug_write(cout, "wfdata allocate\n");
  wfdata=NULL;
  if(options.twftext.size() < 1) error("Need TRIALFUNC section for POSTPROCESS");
  allocate(options.twftext[0], sys, wfdata);



   
  average_var.Resize(avg_words.size());
  average_var=NULL;
  for(int i=0; i< average_var.GetDim(0); i++) { 
    allocate(avg_words[i], sys, wfdata, average_var(i));
  }

  densplt.Resize(dens_words.size());
  for(int i=0; i< densplt.GetDim(0); i++) {
    allocate(dens_words[i], sys, options.runid,densplt(i));
  }

  
}
示例#2
0
/*!
Read the "words" from the method section in the input file
via doinput() parsing, and store section information in private
variables orbs, resolution, and minmax.
Set up MO_matrix and Sample_point objects for wavefunction from input
*/
void Wannier_method::read(vector <string> words,
                          unsigned int & pos,
                          Program_options & options)
{


    sys=NULL;
    allocate(options.systemtext[0],  sys);

    if(! readvalue(words,pos=0,resolution,"RESOLUTION"))
        resolution=.1;
    if(! readvalue(words,pos=0,max_opt_steps,"MAX_OPT_STEPS"))
        max_opt_steps=80000;

    if(!readvalue(words,pos=0, out_orbs, "OUT_ORB"))
        out_orbs=options.runid+".orb";
    if(!readvalue(words,pos=0, shake,"SHAKE"))
        shake=1./10.;

    vector <vector < string> > orbgroup_txt;
    pos=0;
    vector < string> dummy;
    while( readsection(words,pos,dummy,"ORB_GROUP")) {
        orbgroup_txt.push_back(dummy);
    }
    orbital_groups.Resize(orbgroup_txt.size());
    for(int i=0; i< orbital_groups.GetDim(0); i++) {
        int norb_this=orbgroup_txt[i].size();
        orbital_groups[i].Resize(norb_this);
        for(int j=0; j< norb_this; j++) {
            orbital_groups[i][j]=atoi(orbgroup_txt[i][j].c_str())-1;
        }
    }



    vector <string> orbtext;
    if(!readsection(words, pos=0, orbtext, "ORBITALS")) {
        error("Need ORBITALS");
    }
    allocate(orbtext, sys, mymomat);

    mywalker=NULL;
    sys->generateSample(mywalker);

    origin.Resize(3);
    origin=0;
    LatticeVec.Resize(3,3);

    if(!sys->getBounds(LatticeVec,origin))
        error("need getBounds");

}
void Md_method::read(vector <string> words,
                      unsigned int & pos,
                      Program_options & options)
{
  pos=0;
  vector <string> vmcsec;
  if(!readsection(words, pos=0, vmcsec, "EMBED")) {
    error("Need EMBED section");
  }
  allocate(vmcsec,options, qmc_avg);

  if(!readvalue(words, pos=0, nstep, "NSTEP")) {
    error("Need NSTEP");
  }

  if(!readvalue(words, pos=0, tstep, "TIMESTEP")) {
    error("Need TIMESTEP in MD method");
  }

  readvalue(words, pos=0, readcheckfile, "READCHECK");
  readvalue(words, pos=0, writecheckfile, "STORECHECK");

  if(!readvalue(words, pos=0, log_label, "LABEL"))
    log_label="md";


  if(readvalue(words, pos=0, damp, "DAMP")) {
    if(damp > 1 || damp < 0) error("DAMP must be in [0,1]");
  }
  else damp=0.0;

  string resdim;
  pos=0;
  restrict_dimension.Resize(3);
  restrict_dimension=0;
  if(readvalue(words, pos, resdim, "RESTRICT")) {
    if(caseless_eq(resdim, "X")) restrict_dimension(0)=1;
    else if(caseless_eq(resdim, "Y")) restrict_dimension(1)=1;
    else if(caseless_eq(resdim, "Z")) restrict_dimension(2)=1;
    else error("Unknown argument to RESTRICT:", resdim);
  }

  vector <string> weighttxt;
  if(!readsection(words, pos=0, weighttxt, "ATOMIC_WEIGHTS") ) {
    error("Need ATOMIC_WEIGHTS in MD method");
  }
  atomic_weights.Resize(weighttxt.size());
  for(int i=0; i< atomic_weights.GetDim(0); i++) {
    atomic_weights(i)=atof(weighttxt[i].c_str());
  }

}
示例#4
0
static BOOL loadelf32(struct ElfObject *eo,struct Elf32_Shdr *shdrs)
/* parse ELF object, initialize ElfObject structure */
{
  struct Elf32_Ehdr *hdr = eo->header;
  struct ELFSection *s;
  uint16 i;

  if ((eo->secnames = readsection(eo,&shdrs[hdr->e_shstrndx])) &&
      (eo->sections = alloc32((hdr->e_shnum+1)*sizeof(void *)))) {
    memset(eo->sections,0,(hdr->e_shnum+1)*sizeof(void *));
    eo->nsects = hdr->e_shnum + 1;  /* +1 section for COMMON symbols */
    for (i=1; i<hdr->e_shnum; i++) {
      switch (shdrs[i].sh_type) {
        case SHT_PROGBITS:
        case SHT_NOBITS:
          if (!(eo->sections[i] = progsection(eo,&shdrs[i])))
            return (FALSE);
          break;
        case SHT_SYMTAB:
          if (!(eo->symnames = readsection(eo,&shdrs[shdrs[i].sh_link]))
              || !(eo->symtab = readsection(eo,&shdrs[i])))
            return (FALSE);
          eo->nsyms = shdrs[i].sh_size / sizeof(struct Elf32_Sym);
          eo->gsyms = shdrs[i].sh_info;
          break;
        default:
          break;
      }
    }
    for (i=1; i<hdr->e_shnum; i++) {
      switch (shdrs[i].sh_type) {
        case SHT_REL:
        case SHT_RELA:
          if (!getrelocs(eo,&shdrs[i]))
            return (FALSE);
          break;
        default:
          break;
      }
    }
    /* allocate space for Common symbols */
    return (common_symbols(eo));
  }
  return (FALSE);
}
/*!
Read the "words" from the method section in the input file
via doinput() parsing, and store section information in private
variables orbs, resolution, and minmax.
Set up MO_matrix and Sample_point objects for wavefunction from input
*/
void Rotate_orbs_method::read(vector <string> words,
                       unsigned int & pos,
                       Program_options & options)
{
  
  sys=NULL;
  allocate(options.systemtext[0],  sys);

  vector <vector < string> > orbgroup_txt;
  pos=0;
  vector < string> dummy;
  while( readsection(words,pos,dummy,"ORB_GROUP")) { 
    orbgroup_txt.push_back(dummy);
  }
  if(orbgroup_txt.size() != 1) { error("Need one ORB_GROUP in rotate"); } 
  orbital_groups.Resize(orbgroup_txt.size());
  for(int i=0; i< orbital_groups.GetDim(0); i++) { 
    int norb_this=orbgroup_txt[i].size();
    orbital_groups[i].Resize(norb_this);
    for(int j=0; j< norb_this; j++) { 
      orbital_groups[i][j]=atoi(orbgroup_txt[i][j].c_str())-1;
    }
  }
  vector <string> orbtext;
  if(!readsection(words, pos=0, orbtext, "ORBITALS")){
      error("Need ORBITALS");
  }
  allocate(orbtext, sys, mymomat);

  rotation_file="rotation";
  output_orb=options.runid+".orb";
  readvalue(words, pos=0, rotation_file,"ROTATION");
  readvalue(words, pos=0, output_orb,"OUTPUT");

  mywalker=NULL;
  sys->generateSample(mywalker);

}
int SHO_system::read(vector <string> & words,
                           unsigned int & pos){

  pos=0;
  vector <string> omegatxt;
  if(!readsection(words, pos=0, omegatxt, "OMEGA")) 
    omegatxt.push_back("1.0");

  int nd=omegatxt.size();
  omega.Resize(nd);
  for(int d=0; d< nd; d++) {
    omega(d)=atof(omegatxt[d].c_str());
  }
 

  vector <string> nspintxt;
  if(!readsection(words, pos=0, nspintxt, "NSPIN"))
    error("Must have NSPIN in system section");

  if(nspintxt.size()!=2) 
    error("NSPIN must have 2 elements");

  nspin.Resize(2);
  nspin(0)=atoi(nspintxt[0].c_str());
  nspin(1)=atoi(nspintxt[1].c_str());

  
  vector <string> origintxt;
  if(readsection(words, pos=0, origintxt, "ORIGIN")) {
    if(origintxt.size()!=3) error("ORIGIN must have 3 components");
    for(int d=0; d< 3; d++) 
      origin(d)=atof(origintxt[d].c_str());
  }
  
  return 1;
}
示例#7
0
//----------------------------------------------------------------------
void Average_ekt::read(vector <string> & words) { 
  unsigned int pos=0;

  readvalue(words, pos=0,nmo,"NMO");
  readvalue(words,pos=0,npoints_eval,"NPOINTS");
  if(haskeyword(words, pos=0,"OBDM")) 
    eval_obdm=true; 
  else 
    eval_obdm=false;
  if(haskeyword(words, pos=0,"CONDUCTION")) 
    eval_conduction=true; 
  else 
    eval_conduction=false;
  if(haskeyword(words,pos=0,"VALENCE")) 
    eval_valence=true;
  else 
    eval_valence=false;
  if(haskeyword(words,pos=0,"CORBITALS")) 
    complex_orbitals=true;
  else 
    complex_orbitals=false;

  eval_obdm=true; 
  eval_valence=true; 
  eval_conduction=true; 
  occupations.Resize(1);
  occupations(0).Resize(nmo);
  vector <string> orbs;
  if(!readsection(words,pos=0,orbs,"STATES")) { 
    cout << "WARNING: init section does not contain states. Numbering of the density matrix may be incorrect." << endl;
    for(int i=0; i < nmo; i++) 
      occupations[0][i]=i;
  }
  else { 
    nmo=orbs.size();
    occupations[0].Resize(nmo);
    for(int i=0; i< nmo; i++) 
      occupations[0][i]=atoi(orbs[i].c_str())-1;
  }

}
示例#8
0
//-------------------------------------------------------------------------
int Cubic_spline::readspline(vector <string> & words) {
  unsigned int pos=0;
  vector <vector <string> > splinefits;
  vector <string> onesection;
  while(readsection(words, pos, onesection, "SPLINE")) {
    splinefits.push_back(onesection);
  }
  if(splinefits.size()==0) {
    return 0;
  }

  nsplines=splinefits.size();
  splines.Resize(nsplines);
  symmetry.Resize(nsplines);
  for(int i=0; i< nsplines; i++) { 
    symmetry(i)=symmetry_lookup(splinefits[i][0]);
    //splinefits[i].erase(splinefits[i].begin());
  }
  assign_indiv_symmetries();

  //cout << "created " << nfunc() << " total functions " << endl;

  double max_support=0.0;
  for(int i=0; i< nsplines; i++) { 
    int n=splinefits[i].size();
    double supp=atof(splinefits[i][n-2].c_str());
    if(supp > max_support) max_support=supp;
  }
  //cout << "maximum support " << max_support <<endl;
  
  
  for(int s=0; s< nsplines; s++) {
    splines(s).readspline(splinefits[s], enforce_cusp, cusp/double(symmetry_lvalue(symmetry(s))+1));
    if(requested_cutoff > 0) { 
      splines(s).enforceCutoff(requested_cutoff);
    }
  }

  findCutoffs();
  return nfunc();
}
int Molecular_system::read(vector <string> & words,
                           unsigned int & pos)
{
  nspin.Resize(2);
  unsigned int startpos=pos;
  vector <string> spintxt;
  if(!readsection(words, pos, spintxt, "NSPIN")) {
    error("Need NSPIN in molecular system");
  }
  nspin(0)=atoi(spintxt[0].c_str());
  nspin(1)=atoi(spintxt[1].c_str());

  //restrcit initial walkers to a given range
  vector <string> inirangetxt;
  if(readsection(words, pos=0, inirangetxt, "INIRANGE")) {
    cout << "You are using a range of initial walkers other than default." << endl;
    if(inirangetxt.size()==0){
      error("You want to restrict the range of initial walkers, but you didn't give a range");
    }
    inirange=atof(inirangetxt[0].c_str());
  }
  else {
    inirange=3.0;
  }
  
  //use a bounding box if it's given
  vector <string> boxtxt;
  if(readsection(words, pos=0, boxtxt, "BOUNDING_BOX")) {
    const int ndim=3;
    if(boxtxt.size() != ndim*ndim) {
      error("need ", ndim*ndim," elements in BOUNDING_BOX");
    }
    Array2 <doublevar> latVec(ndim, ndim);
    for(int i=0; i< ndim; i++) {
      for(int j=0; j< ndim; j++) {
        latVec(i,j)=atof(boxtxt[i*ndim+j].c_str());
      }
    }
    Array1 <doublevar> origin(ndim);
    origin=0;
    vector <string> origintxt;
    if(readsection(words, pos=0, origintxt, "ORIGIN")) {
      for(int i=0; i < ndim; i++) origin(i)=atof(origintxt[i].c_str());
    }
    bounding_box.init(latVec);
    bounding_box.setOrigin(origin);
    use_bounding_box=1;
  }
  else {
    use_bounding_box=0;
  }
  
  
  
  ions.read(words, pos=0);
  int natoms=ions.size();
  for(int i=0; i< natoms; i++) {
    atomLabels.push_back(ions.getLabel(i));
  }


  electric_field.Resize(3);
  electric_field=0;
  vector <string> electxt;
  if(readsection(words, pos=0, electxt, "ELECTRIC_FIELD")) { 
    if(electxt.size()!=3) error("ELECTRIC_FIELD must have 3 components");
    for(int d=0; d< 3; d++) {
      electric_field(d)=atof(electxt[d].c_str());
      //cout << "efield " << electric_field(d) << endl;
    }
  }


  //---Pseudopotential
  pos=startpos;
  vector < vector <string> > pseudotext;
  vector <string> pseudotexttmp;
  if(readsection(words, pos, pseudotexttmp, "PSEUDO") != 0) {
    error("PSEUDO should go in the global space");
    pseudotext.push_back(pseudotexttmp);
  }

  //pseudo.read(pseudotext, this);
  return 1;
}
示例#10
0
void Average_ekt::read(System * sys, Wavefunction_data * wfdata, vector
    <string> & words) { 
  unsigned int pos=0;
  vector <string> orbs;
  vector <string> mosec;
  if(readsection(words,pos=0, mosec,"ORBITALS")) { 
    //error("Need ORBITALS section in ekt");
    complex_orbitals=false;
    allocate(mosec,sys,momat);
    nmo=momat->getNmo();
  }
  else if(readsection(words,pos=0,mosec,"CORBITALS")) { 
    complex_orbitals=true;
    allocate(mosec,sys,cmomat);
    nmo=cmomat->getNmo();
  }
  else { error("Need ORBITALS or CORBITALS in EKT"); } 
  occupations.Resize(1);

  if(readsection(words,pos=0,orbs,"STATES")) { 
    nmo=orbs.size();
    occupations[0].Resize(nmo);
    for(int i=0; i< nmo; i++) 
      occupations[0][i]=atoi(orbs[i].c_str())-1;
  }
  else if(readsection(words,pos=0,orbs,"EVAL_ORBS")) { 
    nmo=orbs.size();
    occupations[0].Resize(nmo);
    for(int i=0; i< nmo; i++) 
      occupations[0][i]=atoi(orbs[i].c_str());
  }
  else { 
    occupations[0].Resize(nmo);
    for(int i=0; i< nmo; i++) { 
      occupations[0][i]=i;
    }
  }

  deterministic_psp=0;
  if(haskeyword(words,pos=0,"DETERMINISTIC_PSP"))
    deterministic_psp=1;

  dump_data=false;
  if(haskeyword(words,pos=0,"DUMP_DATA"))
    dump_data=true;
  if(!readvalue(words, pos=0,ekt_cutoff,"EKT_CUTOFF"))
    ekt_cutoff=1e3;
  
  
  if(complex_orbitals) 
    cmomat->buildLists(occupations);
  else 
    momat->buildLists(occupations);



  if(!readvalue(words, pos=0,nstep_sample,"NSTEP_SAMPLE"))
    nstep_sample=10;
  if(!readvalue(words,pos=0,npoints_eval,"NPOINTS"))
    npoints_eval=4;
  string mode;
  eval_obdm=false; 
  eval_conduction=false; 
  eval_valence=false; 
  if(readvalue(words,pos=0,mode,"MODE")) {
    if(caseless_eq(mode,"ALL") or caseless_eq(mode, "CONDUCTION")) {
      eval_obdm=true;
      eval_conduction=true;
      eval_valence=true; 
    }
    else if (caseless_eq(mode, "VALENCE")) {
      eval_obdm=true; 
      eval_conduction=true;
    }
    else if (caseless_eq(mode, "OBDM")) {
      eval_obdm=true; 
    }

  }

  eval_obdm=true; 
  eval_conduction=true; 
  eval_valence=true; 
  int ndim=3;
  saved_r.Resize(npoints_eval*2); //r1 and r2;
  for(int i=0; i< npoints_eval*2; i++) saved_r(i).Resize(ndim);
  rk.Resize(npoints_eval*2);

  int warmup_steps=1000;
  Sample_point * sample=NULL;
  sys->generateSample(sample);
  sample->randomGuess();
  Array2 <dcomplex> movals(nmo,1);
  for(int i=0; i< npoints_eval*2; i++) { 
    gen_sample(warmup_steps,1.0,0,movals,sample);
    sample->getElectronPos(0,saved_r(i));
  }
  delete sample;
}
示例#11
0
//-------------------------------------------------------------------------
int Cubic_spline::read(
  vector <string> & words,
  unsigned int & pos
)
{

  Array1 <double> basisparms(4);
  atomname=words[0];
  basisparms(0)=.02;  //spacing
  basisparms(1)=2500; //number of points
  basisparms(2)=1e31;
  basisparms(3)=1e31;
  if(!readvalue(words, pos=0, norm_type, "NORMTYPE")) {
    norm_type="GAMESSNORM";
  }

  if(haskeyword(words, pos=0, "NORENORMALIZE")) {
    renormalize=false;
  }
  else {
    renormalize=true;
  }

  doublevar cutmax;
  if(readvalue(words, pos=0, cutmax, "CUTOFF")) {
    requested_cutoff=cutmax;
  }
  else {
    requested_cutoff=-1;
  }

  enforce_cusp=false;
  if(readvalue(words, pos=0, cusp, "CUSP")) enforce_cusp=true;

  match_sto=false;
  if(readvalue(words, pos=0, cusp_matching, "CUSP_MATCHING")) match_sto=true;
  
  zero_derivative=false;
  if(haskeyword(words, pos=0, "ZERO_DERIVATIVE")) zero_derivative=true;

  customspacing=basisparms(0);
  if(readvalue(words, pos=0, customspacing, "SPACING")) {
    basisparms(0)=customspacing;
    basisparms(1)=50.0/customspacing;
  }

  vector <string> basisspec;
  string read_file; //read positions from a file
  if(readsection(words,pos=0, basisspec, "GAMESS"))
  {
    unsigned int newpos=0;
    return readbasis(basisspec, newpos, basisparms);
  }
  else {
    pos=0;
    if(readspline(words)) {
      return 1;
    }
    else {
      error("couldn't find proper basis section in AOSPLINE.  "
            "Try GAMESS { .. }.");
      return 0;
    }
  }

  //We assume that all splines use the same interval,
  //which saves a few floating divisions, so check to make
  //sure the assumption is good.
  for(int i=0; i< splines.GetDim(0); i++) {
    if(!splines(0).match(splines(i))) 
      error("spline ", i, " doesn't match the first one ");
  }
}
void Dmc_method::read(vector <string> words,
                      unsigned int & pos,
                      Program_options & options)
{
  ndim=3;

  have_read_options=1;

  //vector <string> offsetwords;

  //required options
  if(!readvalue(words, pos=0, timestep, "TIMESTEP"))
    error("Need TIMESTEP in METHOD section");

  //optional options

  if(!readvalue(words, pos=0, nblock, "NBLOCK"))
    nblock=100;
 
  int target_config;
  if(!readvalue(words,pos=0,target_config,"TARGET_CONFIG"))
    target_config=2048;

  if(!readvalue(words, pos=0, nconfig, "NCONFIG"))
    nconfig=max(target_config/mpi_info.nprocs,1);

  if(!readvalue(words, pos=0, nstep, "NSTEP"))
    nstep=max(int(1.0/timestep+0.5),1);
  
  if(!readvalue(words, pos=0, readconfig, "READCONFIG"))
    readconfig=options.runid+".config";

  if(!readvalue(words, pos=0, eref, "EREF"))
    eref=0.0;

  if(!readvalue(words,pos=0, max_poss_weight, "MAX_POSS_WEIGHT")) 
    max_poss_weight=7.0;
  if(haskeyword(words, pos=0, "TMOVES")) tmoves=1;
  else tmoves=0;
  if(haskeyword(words, pos=0, "TMOVESSC")) tmoves_sizeconsistent=1;
  else tmoves_sizeconsistent=0;


  readvalue(words,pos=0,save_trace,"SAVE_TRACE");

  if(!readvalue(words, pos=0, nhist, "CORR_HIST")) 
    nhist=-1;

  if(haskeyword(words, pos=0, "PURE_DMC")) { 
    pure_dmc=1;
    if( nhist < 1 )
      error("CORR_HIST must be > 1 when PURE_DMC is on");
  }
  else pure_dmc=0;

  if(!readvalue(words, pos=0, storeconfig, "STORECONFIG"))
    storeconfig=options.runid+".config";

  if(!readvalue(words, pos=0, log_label, "LABEL"))
    log_label="dmc";

  if(!readvalue(words, pos=0, start_feedback, "START_FEEDBACK"))
    start_feedback=1;

  if(readvalue(words, pos=0, feedback_interval, "FEEDBACK_INTERVAL")) {
    if(feedback_interval < 1) 
      error("FEEDBACK_INTERVAL must be greater than or equal to 1");
  }
  else feedback_interval=5;

  if(!readvalue(words, pos=0, feedback, "FEEDBACK"))
    feedback=1.0;

  if(!readvalue(words, pos=0, branch_start_cutoff, "BRANCH_START_CUTOFF")) 
    branch_start_cutoff=10;
  
  branch_stop_cutoff=branch_start_cutoff*1.5;
  
  
  vector <string> proptxt;
  if(readsection(words, pos=0, proptxt, "PROPERTIES")) 
    mygather.read(proptxt);

  vector<string> tmp_dens;
  pos=0;
  while(readsection(words, pos, tmp_dens, "DENSITY")) {
    dens_words.push_back(tmp_dens);
  }

  pos=0;
  while(readsection(words, pos, tmp_dens, "NONLOCAL_DENSITY")) {
    nldens_words.push_back(tmp_dens);
  }

  pos=0;
  while(readsection(words, pos, tmp_dens, "AVERAGE")) {
    avg_words.push_back(tmp_dens);
  }
  
  vector <string> dynamics_words;
  if(!readsection(words, pos=0, dynamics_words, "DYNAMICS") ) 
    dynamics_words.push_back("SPLIT");

  low_io=0;
  if(haskeyword(words, pos=0,"LOW_IO")) low_io=1;
  
  allocate(dynamics_words, dyngen);
  dyngen->enforceNodes(1);

  //MB: forwark walking lengths 
  fw_length.Resize(0);
  fw_length=0;
  vector <string> fw_words;
  max_fw_length=0;
  if(readsection(words, pos=0, fw_words, "fw_length")){
    fw_length.Resize(fw_words.size());
    for(int i=0;i<fw_words.size();i++){
      fw_length(i)=atoi(fw_words[i].c_str());
      if(fw_length(i) > max_fw_length)
        max_fw_length=fw_length(i);
    }
  }
  //cout <<" Maximum forward walking history is "<<max_fw_length<<" steps"<<endl;

}
/*!
*/
int HEG_system::read(vector <string> & words,
                          unsigned int & pos)
{
  const int ndim=3;
  int startpos=pos;

  vector <string> latvectxt;

  vector <string> spintxt;
  if(!readsection(words, pos, spintxt, "NSPIN")) {
    error("Need NSPIN in HEG system");
  }
  nspin.Resize(2);
  nspin(0)=atoi(spintxt[0].c_str());
  nspin(1)=atoi(spintxt[1].c_str());
  totnelectrons=nspin(0)+nspin(1);

  vector <string> ktxt;
  if(readsection(words, pos=0, ktxt, "KPOINT")) {
    if(ktxt.size()!=3) error("KPOINT must be a section of size 3");
    kpt.Resize(3);
    for(int i=0; i< 3; i++) 
      kpt(i)=atof(ktxt[i].c_str());
  }
  else {
    kpt.Resize(3);
    kpt=0;
  }

  pos=startpos;
  if(!readsection(words, pos, latvectxt, "BOXSIZE"))
    error("BOXSIZE is required in HEG");
  if(latvectxt.size() != ndim)
    error("BOXSIZE must have exactly ",ndim, " values");

  vector< vector<string> > perturb_sec;
  vector <string> dumstring;
  pos=startpos;
  while(readsection(words, pos,dumstring, "PERTURB")) perturb_sec.push_back(dumstring);
  nperturb=perturb_sec.size();
  perturb_pos.Resize(nperturb, ndim);
  perturb_strength.Resize(nperturb);
  perturb_alpha.Resize(nperturb);
  perturb_spin.Resize(nperturb);
  for(int i=0; i< nperturb; i++) { 
    if(!readsection(perturb_sec[i], pos=0,dumstring,"POS")) error("Need POS in PERTURB");
    if(dumstring.size()!=ndim) error("wrong dimension in POS in PERTURB");
    for(int d=0; d< ndim; d++) perturb_pos(i,d)=atof(dumstring[d].c_str());
    if(!readvalue(perturb_sec[i], pos=0,perturb_strength(i),"STRENGTH")) error("Need STRENGTH in PERTURB");
    if(!readvalue(perturb_sec[i], pos=0,perturb_alpha(i),"SCALE")) error("Need SCALE in PERTURB");
    if(!readvalue(perturb_sec[i], pos=0,perturb_spin(i),"SPIN")) error("Need SPIN in PERTURB");
    
  }

  latVec.Resize(ndim, ndim);
  latVec=0.0;
  for(int i=0; i< ndim; i++)
    latVec(i,i)=atof(latvectxt[i].c_str());
  /*
  for(int i=0; i< ndim; i++) {
    for(int j=0; j< ndim; j++) {
      latVec(i,j)=atof(latvectxt[i*ndim+j].c_str());
    }
  }
  */

  origin.Resize(3);
  vector <string> origintxt;
  if(readsection(words, pos=0, origintxt, "ORIGIN")) {
    if(origintxt.size() < 3) error("ORIGIN section must have at least 3 elements.");
    for(int i=0; i< 3; i++) origin(i)=atof(origintxt[i].c_str());
  }
  else {
    origin=0;   //defaulting the origin to zero
  }

  vector <string> interactiontxt;
  // default is truncated Coulomb
  calcLocChoice=&HEG_system::calcLocTrunc;
  eeModel=2;
  same_spin_int=true;
  diff_spin_int=true;
  if(readsection(words, pos=0, interactiontxt, "INTERACTION")) {
    if( haskeyword(interactiontxt, pos=0, "EWALD") ) {
      calcLocChoice=&HEG_system::calcLocEwald;
      eeModel=1;
    }
    if( haskeyword(interactiontxt, pos=0, "TRUNCCOUL") ) {
      calcLocChoice=&HEG_system::calcLocTrunc;
      eeModel=2;
    }
    if( haskeyword(interactiontxt, pos=0, "GAUSS") ) {
      calcLocChoice=&HEG_system::calcLocGauss;
      eeModel=3;
      if(!readvalue(interactiontxt,pos=0,Gauss_a, "AMP"))
	error("Gauss interaction model requested, but no AMP given.");
      if(!readvalue(interactiontxt,pos=0,Gauss_s, "STDEV"))
	error("Gauss interaction model requested, but no STDEV given.");
      Gauss_s2=Gauss_s*Gauss_s;
    }
    if( haskeyword(interactiontxt, pos=0, "NO_SAME_SPIN") )
      same_spin_int=false;
    if( haskeyword(interactiontxt, pos=0, "NO_DIFF_SPIN") )
      diff_spin_int=false;
  }

  if ( eeModel==1 && ( !same_spin_int || !diff_spin_int ) )
    error("Spin-dependent Ewald interaction not supported.");

  

  //-------------cross products

  //cross product:  0->1x2, 1->2x0, 2->0x1
  Array2 <doublevar> crossProduct(ndim, ndim);
  crossProduct(0,0)=(latVec(1,1)*latVec(2,2)-latVec(1,2)*latVec(2,1));
  crossProduct(0,1)=(latVec(1,2)*latVec(2,0)-latVec(1,0)*latVec(2,2));
  crossProduct(0,2)=(latVec(1,0)*latVec(2,1)-latVec(1,1)*latVec(2,0));

  crossProduct(1,0)=(latVec(2,1)*latVec(0,2)-latVec(2,2)*latVec(0,1));
  crossProduct(1,1)=(latVec(2,2)*latVec(0,0)-latVec(2,0)*latVec(0,2));
  crossProduct(1,2)=(latVec(2,0)*latVec(0,1)-latVec(2,1)*latVec(0,0));

  crossProduct(2,0)=(latVec(0,1)*latVec(1,2)-latVec(0,2)*latVec(1,1));
  crossProduct(2,1)=(latVec(0,2)*latVec(1,0)-latVec(0,0)*latVec(1,2));
  crossProduct(2,2)=(latVec(0,0)*latVec(1,1)-latVec(0,1)*latVec(1,0));


  //------------ reciprocal cell  (used in setupEwald and showinfo)
  recipLatVec.Resize(ndim, ndim);
  doublevar det=Determinant(latVec, ndim);

  debug_write(cout, "cell volume ", det,"\n");
  cellVolume=det;

  for(int i=0; i< ndim; i++) {
    for(int j=0; j< ndim; j++) {
      recipLatVec(i,j)=crossProduct(i,j)/det;
    }
  }

  //------------ normal vectors (needed in enforcePbc)

  normVec.Resize(ndim, ndim);

  for(int i=0; i< ndim; i++) {
    for(int j=0; j < ndim; j++) {
      normVec(i,j)=crossProduct(i,j);
    }

    //Check to make sure the direction is facing out
    doublevar dotprod=0;
    for(int j=0; j < ndim; j++) {
      dotprod+=normVec(i,j)*latVec(i,j);
    }
    if(dotprod < 0) {
      for(int j=0; j< ndim; j++) {
        normVec(i,j)= -normVec(i,j);
      }
    }
  }

  corners.Resize(ndim, ndim);
  for(int i=0; i< ndim; i++) {
    for(int j=0; j< ndim; j++) {
      corners(i,j)=origin(j)+latVec(i,j);
    }
  }


  //------------ setup for interaction calculators (reciprocal part of Ewald sum etc.)
  if ( eeModel == 1 ) setupEwald(crossProduct);
  if ( eeModel == 2 ) setupTruncCoulomb();

  return 1;
}
示例#14
0
/* main */
int main(int argc, char* argv[])
{
    /******************* ARGS *******************/
    if(argc != 3)
    {
        printf("Error: invalid arguments\n Usage: english <destination> <vocabulary>\n");
        return WRONG_ARGUMENTS;
    }

    FILE* dest = NULL;
    FILE* voc = NULL;
    FILE* temp_file = NULL;

    /******************* OPEN *******************/
    dest = fopen(argv[1], "r+");
    if(dest == NULL)
    {
        printf("Error: couldn't open %s\n", argv[1]);
        return CANNOT_OPEN_INPUT_FILE;
    }

    voc = fopen(argv[2], "r");
    if(voc == NULL)
    {
        printf("Error: couldn't open %s\n", argv[2]);
        return CANNOT_OPEN_INPUT_FILE;
    }

    temp_file = fopen("tmp.txt", "w+");
    if(temp_file == NULL)
    {
      printf("Error: couldn't create a temporary file");
      return CANNOT_OPEN_OUTPUT_FILE;
    }

    /******************* DOING IT *******************/
    /* Largest voc line buffer ever needed - about 4.05 KB */
    char buffer_voc[LONGEST_DICTIONARY_WORD*MAX_SYNONYMS];
    /* Largest word buffer ever needed */
    char buffer_word[LONGEST_DICTIONARY_WORD];
    char temp[LONGEST_DICTIONARY_WORD];
    char k=0;

    while((k=readsection(buffer_word, dest, READ_WORD))!=EOF) { /* Read each word in the text */
        /* Add a space before and after the word */
      lower(buffer_word);
      sprintf(temp, " %s ", buffer_word);
      lower(temp);
      char* c = NULL;

      while(readsection(buffer_voc, voc, READ_LINE)!=EOF) { /* Check in each line of voc for the word */
        /* Add space */

        buffer_voc[strlen(buffer_voc)] = ' ';
        buffer_voc[strlen(buffer_voc)+1] = 0;

        if(strstr(buffer_voc, temp)!=NULL){ /* Is there a word to replace? */
            /* Find a synonym */
            c = strtok(buffer_voc, " ");
            /* Make sure it's not the word already used if possible */
            while(strcmp(c,buffer_word) == 0) {
              c = strtok(NULL, " ");
            }
            if(c != NULL) /* If there's a synonym - Write c */
              strcpy(buffer_word, c);

            break;
          }
        }

        /* Write to the tepmorary file */
        fprintf(temp_file, "%s ", buffer_word);
        if(k=='\n')
          fprintf(temp_file,"\n");

        fseek(voc, 0, SEEK_SET);
      }

      copyfile(dest, temp_file);

    /******************* CLOSE *******************/
    int rc = 0;

    if(0!=fclose(dest)) {
        rc = CANNOT_CLOSE_OUTPUT_FILE;
        printf("Error: couldn't close %s", argv[1]);
    }

    if(0!=fclose(voc)) {
        rc = CANNOT_CLOSE_INPUT_FILE;
        printf("Error: couldn't close %s", argv[2]);
    }

    if(0!=fclose(temp_file)) {
        rc = CANNOT_CLOSE_OUTPUT_FILE;
        printf("Error: couldn't close tmp.txt");
    }

    remove("tmp.txt");

    printf("Done!");

    return rc;
}
/*!
Read the "words" from the method section in the input file
via doinput() parsing, and store section information in private
variables isoses, resolution, and minmax.
Set up MO_matrix and Sample_point objects for wavefunction from input
*/
void Nodes_method::read(vector <string> words,
                       unsigned int & pos,
                       Program_options & options)
{
  pos=0;	//always start from first word
  doublevar Tres;
  vector <string> Torbs;
  vector <string> Tminmax;
  vector <string> orbtext;
  vector <string> Tdxyz;


  allocate(options.systemtext[0], sysprop);
  sysprop->generateSample(mywalker);

  allocate(options.twftext[0], sysprop, wfdata);
  wfdata->generateWavefunction(wf);

  mywalker->attachObserver(wf);
 
  pos=0;
  if(readsection(words,pos=0,Torbs,"CONTOURS")){
    //   error("Need CONTOURS in METHOD section");
  plots.Resize(Torbs.size());
  for(unsigned int i=0; i<Torbs.size(); i++){
        plots(i)=atoi(Torbs[i].c_str());
      }
  }
  else {
    cout <<"WARNING: All electrons are used for scanning!"<<endl;
    plots.Resize(mywalker->electronSize());
    for(int i=0; i<plots.GetSize(); i++){
      plots(i)=i+1;
      } 
  }
 
  pos=0;
  if(! readvalue(words,pos,Tres,"RESOLUTION"))
    error("Need RESOLUTION in METHOD section");
  resolution=Tres;


  pos=0;
  minmax.Resize(6);
  if(readsection(words,pos,Tminmax,"MINMAX")) { 
    if(Tminmax.size() != 6)
      error("MINMAX needs 6 values");
    for(unsigned int i=0; i<Tminmax.size(); i++)
    {
      minmax(i)=atof(Tminmax[i].c_str());
    }
  }
  else  { 
    minmax=0.0;
  
    int nions=sysprop->nIons();
    Array1 <doublevar> ionpos(3);
    for(int i=0; i< nions; i++) {
      sysprop->getIonPos(i,ionpos);
      for(int d=0; d< 3; d++) {
        if(ionpos(d) < minmax(2*d)) minmax(2*d) = ionpos(d);
        if(ionpos(d) > minmax(2*d+1)) minmax(2*d+1)=ionpos(d);
      }
    }

    for(int d=0; d< 3; d++) {
      minmax(2*d)-=4.0;
      minmax(2*d+1)+=4.0;
      cout << "minmax " << minmax(2*d) << " " << minmax(2*d+1) << endl;
    }
  } 
  
  
 

  // Makes the Nodes methods use the current implementation of Nodes
  if(readvalue(words, pos=0, readconfig, "READCONFIG")){
    Array1 <Config_save_point> config_pos;
    config_pos.Resize(0);
    if(readconfig!="") { 
      read_configurations(readconfig, config_pos);
    }
    if(config_pos.GetDim(0)<1)
      error("Could not read a single walker from config file");
    //take a first one
    config_pos(0).restorePos(mywalker);
  }
  else {
    mywalker->randomGuess();
    debug_write(cout, 0, " configs read ", 1,
                " configs randomly generated \n");
  }
  
  pos=0;
  doublemove=false;
  if( readsection(words,pos,Tdxyz,"DOUBLEMOVES")){
    doublemove=true;
    if(plots.GetSize()%2)
      error("Needs pairs of countours for doublemoves");
    unsigned int dummy=3*plots.GetSize()/2;
    if(Tdxyz.size()!=dummy)
      error("DOUBLEMOVES needs 3 x # of vectors values");
    dxyz.Resize(plots.GetSize()/2,3);
    for(int i=0; i<plots.GetSize()/2; i++){
      for (int j=0; j<3;j++)
        dxyz(i,j)=atof(Tdxyz[i*3+j].c_str());
    }
  }
}
void Jastrow_threebody_piece_diffspin::set_up(vector <string> & words, 
                                   System * sys) {
  //cout <<"Start Jastrow_threebody_piece_diffspin::set_up"<<endl;                                 
  vector<string> atomnames;
  sys->getAtomicLabels(atomnames);
  unique_parameters_spin.Resize(2);
  linear_parms.Resize(2);
  int tmpcounter=0;
  for(int s=0;s<unique_parameters_spin.GetSize();s++){
    get_onebody_parms_diffspin(words, atomnames, unique_parameters_spin(s),s,
			       _nparms, parm_labels,
			       linear_parms(s), tmpcounter, parm_centers);
  }

  


  if(unique_parameters_spin(0).GetDim(0)!=unique_parameters_spin(1).GetDim(0))
    error("Need same amount of LIKE_COEFFICIENTS and UNLIKE_COEFFICIENTS sections in three body");
  
  if(unique_parameters_spin(0).GetDim(1)!=unique_parameters_spin(1).GetDim(1))
    error("Need same amount of LIKE_COEFFICIENTS and UNLIKE_COEFFICIENTS parameters in three body");
  

  unsigned int pos=0;  
  int maxnparms=0;
  vector <string> klm_list;
  if(readsection(words,pos=0,klm_list,"SM_TERMS")) { 
    if(klm_list.size()%3 !=0) 
      error("SM_TERMS must contain a multiple of 3 elements");
    maxnparms=klm_list.size()/3;
    int counter=0;
    klm.Resize(maxnparms,3);
    for(int i=0; i< maxnparms; i++) { 
      for(int j=0; j< 3; j++) {
	klm(i,j)=atoi(klm_list[counter++].c_str());
      }
    }
  }
  else maxnparms=make_default_list();

  
  


  int natoms=atomnames.size();
  eebasis_max=0;
  eibasis_max.Resize(natoms);
  eibasis_max=0;
  for(int at=0; at< natoms; at++) {
    if(nparms(at) > maxnparms) 
      error("too many three-body spin parameters on ", atomnames[at]);
    for(int p=0; p < nparms(at); p++) { 
      if(eibasis_max(at) <= klm(p,0)) eibasis_max(at)=klm(p,0)+1;
      if(eibasis_max(at) <= klm(p,1)) eibasis_max(at)=klm(p,1)+1;
      if(eebasis_max <= klm(p,2)) eebasis_max=klm(p,2)+1;
    }
  }
  
  freeze=haskeyword(words, pos=0, "FREEZE");
  nspin_up=sys->nelectrons(0);
  nelectrons=sys->nelectrons(0)+sys->nelectrons(1);
  //cout <<"End Jastrow_threebody_piece_diffspin::set_up"<<endl;  

}
void get_onebody_parms_diffspin(vector<string> & words, vector<string> & atomnames,
				Array2 <doublevar> & unique_parameters,
				int s,
				Array1 <int> & nparms,
				vector <string> & parm_labels,
				Array2 <int> & linear_parms,
                                int & counter,
				Array1 <int> & parm_centers) {
  vector < vector < string> > parmtxt;
  vector <string> parmtmp;
  unsigned int pos=0;
  if(s==0){
    while(readsection(words, pos,parmtmp, "LIKE_COEFFICIENTS"))
      parmtxt.push_back(parmtmp);
    if(parmtxt.size()==0)
      error("Didn't find LIKE COEFFICIENTS in one of threebody spin Jastrow section");
  }
  else{
    while(readsection(words, pos,parmtmp, "UNLIKE_COEFFICIENTS"))
      parmtxt.push_back(parmtmp);
    if(parmtxt.size()==0)
      error("Didn't find UNLIKE COEFFICIENTS in one of threebody spin Jastrow section");
  }
    
  int nsec=parmtxt.size();
  int maxsize=0;
  nparms.Resize(nsec);
  for(int i=0; i< nsec; i++)
    nparms(i)=parmtxt[i].size()-1;

  for(int i=0; i< nsec; i++)
    if(maxsize < nparms(i)) maxsize=nparms(i);

  unique_parameters.Resize(nsec, maxsize);
  linear_parms.Resize(nsec, maxsize);
  //cout <<"spin "<<s<<" counter "<<counter<<endl;
  for(int i=0; i< nsec; i++) {
    for(int j=0; j< nparms(i); j++) {
      
      unique_parameters(i,j)=atof(parmtxt[i][j+1].c_str());
      linear_parms(i,j)=counter++;
    }
  }

  parm_labels.resize(nsec);
  for(int i=0; i< nsec; i++)
    parm_labels[i]=parmtxt[i][0];

  int natoms=atomnames.size();
  parm_centers.Resize(natoms);
  parm_centers=-1;

  for(int i=0; i< nsec; i++) {
    int found=0;
    for(int j=0; j< natoms; j++) {
      if(atomnames[j]==parm_labels[i]) {
        parm_centers(j)=i;
        found=1;
      }
    }
    if(!found)
      error("Couldn't find a matching center for ", parm_labels[i]);
  }

  doublevar scale;
  if(readvalue(words, pos=0, scale, "SCALE")) {
    for(int i=0; i< unique_parameters.GetDim(0); i++) {
      for(int j=0; j< nparms(i); j++) {
        unique_parameters(i,j)*=scale;
      }
    }
  }
}
void Reptation_method::read(vector <string> words,
                      unsigned int & pos,
                      Program_options & options)
{

  have_read_options=1;

  if(!readvalue(words, pos=0, nblock, "NBLOCK"))
    error("Need NBLOCK in RETPTATION section");

  if(!readvalue(words, pos=0, nstep, "NSTEP"))
    error("Need NSTEP in REPTATION section");

  if(!readvalue(words, pos=0, timestep, "TIMESTEP"))
    error("Need TIMESTEP in REPTATION section");

  if(!readvalue(words, pos=0, reptile_length, "LENGTH"))
    error("Need LENGTH in REPTATION");

  //------------------optional stuff

  print_pdb=haskeyword(words, pos=0,"PRINT_PDB");

  if(!readvalue(words, pos=0, readconfig, "READCONFIG"))
    readconfig=options.runid+".config";

  vector <string> proptxt;
  if(readsection(words, pos=0, proptxt, "PROPERTIES")) 
    mygather.read(proptxt);
  
  if(!readvalue(words, pos=0, log_label, "LABEL"))
    log_label="rmc";

  if(!readvalue(words, pos=0, storeconfig, "STORECONFIG"))
    storeconfig=options.runid+".config";

  if(readvalue(words, pos=0, center_trace, "CENTER_TRACE"))
    canonical_filename(center_trace);

  if(!readvalue(words, pos=0, trace_wait, "TRACE_WAIT"))
    trace_wait=int(.3/timestep)+1;

    
  vector <string> dynamics_words;
  if(!readsection(words, pos=0, dynamics_words, "DYNAMICS") ) 
    dynamics_words.push_back("SPLIT");

  allocate(dynamics_words, sampler);

  
  vector<string> tmp_dens;
  pos=0;
  while(readsection(words, pos, tmp_dens, "DENSITY")) {
    dens_words.push_back(tmp_dens);
  }
  
  pos=0;
  while(readsection(words, pos, tmp_dens, "AVERAGE")) {
    avg_words.push_back(tmp_dens);
  }
  

  sampler->enforceNodes(1);

  guidewf=new Primary;
}
int Rgaussian_function::read(
  vector <string> & words,
  unsigned int & pos)
{
  //cout << "gauss read " << endl;
  unsigned int startpos=pos;

  centername=words[0];


  rcut=1e99;
  vector < vector <doublevar> >  exptemp;
  vector < vector <doublevar> >  coefftemp;
  vector < vector <doublevar> >  radtemp;
  vector <string> oldqmctxt;

  int maxL=0, maxExpansion=0;
  if(readsection(words, pos=startpos, oldqmctxt, "OLDQMC")) {
    double zeff;
    int nlval; //number of l values that we'll read in
    if(oldqmctxt.size() < 2)
      error("badly formed OLDQMC section: size less than 2");
    int it=0; //position iterator
    zeff=atof(oldqmctxt[it++].c_str());
    nlval=atoi(oldqmctxt[it++].c_str());

    if(maxL < nlval) maxL=nlval;
    Array1 <int> nPerL(nlval); //number per l-value

    for(int l=0; l < nlval; l++) {
      nPerL(l)=atoi(oldqmctxt[it++].c_str());
      if(maxExpansion < nPerL(l))
        maxExpansion=nPerL(l);
    }
    for(int l=0; l < nlval; l++) {
      vector <doublevar> radtempl;
      vector <doublevar> exptempl;
      vector <doublevar> coefftempl;

      for(int j=0; j< nPerL(l); j++) {
        doublevar temp;
        temp=atof(oldqmctxt[it++].c_str());
        temp-=2;
        radtempl.push_back(temp);
        temp=atof(oldqmctxt[it++].c_str());
        exptempl.push_back(temp);

        temp=atof(oldqmctxt[it++].c_str());
        coefftempl.push_back(temp);
      }
      radtemp.push_back(radtempl);
      exptemp.push_back(exptempl);
      coefftemp.push_back(coefftempl);
    }
  }
  else {
    error("Try OLDQMC in RGAUSSIAN.");
  }

  gaussexp.Resize(maxL,  maxExpansion);
  gausscoeff.Resize(maxL, maxExpansion);
  radiusexp.Resize(maxL, maxExpansion);
  numExpansion.Resize(maxL);
  nmax=radtemp.size();

  //cout << "maxL " << maxL << "  maxExpansion " << maxExpansion << endl;

  assert( radtemp.size() == exptemp.size() );


  for(int l=0; l< nmax; l++)
  {

    numExpansion(l) = radtemp[l].size();

    for(int e=0; e< numExpansion(l); e++)
    {
      gaussexp(l, e) = exptemp[l][e];
      gausscoeff(l, e) = coefftemp[l][e];
      radiusexp(l, e) = radtemp[l][e];
    }
  }
  return 1;
}
void read_basis(string & basisin, Array1 <Contracted_gaussian> & basis) {
  ifstream basis_f(basisin.c_str());
  if(!basis_f)
    error("Couldn't open ", basisin);
  vector <string> words;
  parsefile(basis_f, words);
  unsigned int pos=0;
  vector <vector  <string> > sections;
  vector <string> section_temp;
  while(readsection(words, pos, section_temp, "BASIS") ) {
    sections.push_back(section_temp);
  }

  int nsections=sections.size();

  string label;
  vector <string> gamesstxt;
  vector < Contracted_gaussian > basis_tmp;


  Contracted_gaussian tempgauss;
  int totgauss=0;

  for(int sec=0; sec < nsections; sec++) {
    label=sections[sec][0];
    //cout << "label " << label << endl;
    if(!readsection(sections[sec], pos=0, gamesstxt, "GAMESS") ) {
      error("Need a GAMESS section");
    }
    unsigned int pos2=0;
    unsigned int txtsize=gamesstxt.size();
    string symm;
    int nexpand=0;

    while(pos2 < txtsize) {
      symm=gamesstxt[pos2];
      //cout << "symm " << symm << endl;
      
      nexpand=atoi(gamesstxt[++pos2].c_str());
      pos2+= 3*nexpand;
      pos2++;
      if(symm=="S") totgauss++;
      else if(symm=="P") totgauss+=3;
      else if(symm=="D" || symm=="6D") totgauss+=6;
      else error("Don't understand symmetry ", symm);
      //cout << "totgauss " << totgauss << endl;
    }
  }

  basis.Resize(totgauss);


  int gaussnum=0;
  for(int sec=0; sec < nsections; sec++) {
    label=sections[sec][0];
    //cout << "label " << label << endl;
    if(!readsection(sections[sec], pos=0, gamesstxt, "GAMESS") ) {
      error("Need a GAMESS section");
    }
    unsigned int pos2=0;
    unsigned int txtsize=gamesstxt.size();
    string symm;
    int nexpand=0;



    while(pos2 < txtsize) {
      symm=gamesstxt[pos2];
      nexpand=atoi(gamesstxt[++pos2].c_str());

      tempgauss.alpha.Resize(nexpand);
      tempgauss.coeff.Resize(nexpand);
      tempgauss.center_name=label;

      for(int i=0; i< nexpand; i++) {
        if(atoi(gamesstxt[++pos2].c_str()) != i+1) error("Some misformatting in basis section");
        tempgauss.alpha(i)=atof(gamesstxt[++pos2].c_str());
        tempgauss.coeff(i)=atof(gamesstxt[++pos2].c_str());
      }


      if(symm=="S") {
        tempgauss.lvals(0)=tempgauss.lvals(1)=tempgauss.lvals(2)=0;
        basis(gaussnum++)=tempgauss;
      }
      else if(symm=="P")  {
        for(int i=0; i< 3; i++) {
          tempgauss.lvals=0;
          tempgauss.lvals(i)=1;
          basis(gaussnum++) = tempgauss;
        }
      }
      else if(symm=="D" || symm=="6D") {

        //xx, yy, zz
        for(int i=0; i< 3; i++) {
          tempgauss.lvals=0;
          tempgauss.lvals(i)=2;
          basis(gaussnum++) = tempgauss;
        }
        //xy
        tempgauss.lvals(0)=1; tempgauss.lvals(1)=1; tempgauss.lvals(2)=0;
        basis(gaussnum++) = tempgauss;

        //xz
        tempgauss.lvals(0)=1; tempgauss.lvals(1)=0; tempgauss.lvals(2)=1;
        basis(gaussnum++) = tempgauss;

        //yz
        tempgauss.lvals(0)=0; tempgauss.lvals(1)=1; tempgauss.lvals(2)=1;
        basis(gaussnum++) = tempgauss;
      }
      else {
        error("Unsupported symmetry ", symm);
      }
      ++pos2;
    }


  }




/*
  for(int i=0; i< totgauss; i++) {
    cout << "basis " << i << "  center " << basis(i).center_name
	 << endl;
    cout << "  lvals "; for(int j=0; j< 3; j++) cout << basis(i).lvals(j) << "  ";
    cout << endl;
    for(int j=0; j< basis(i).alpha.GetDim(0); j++) {
      cout << "   " << basis(i).alpha(j) << "   " << basis(i).coeff(j) << endl;
    }

  }
*/

}