Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/config.cpp

    r235bed r49e1ae  
    66
    77#include <stdio.h>
     8#include <cstring>
    89
    910#include "atom.hpp"
     
    2728    char number1[8];
    2829    char number2[8];
    29     char *dummy1, *dummy2;
     30    const char *dummy1, *dummy2;
    3031    //Log() << Verbose(0) << s1 << "  " << s2 << endl;
    3132    dummy1 = strchr(s1, '_')+sizeof(char)*5;  // go just after "Ion_Type"
     
    140141void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms)
    141142{
    142   map<const char *, int, IonTypeCompare> LineList;
     143  map<const char *, int, IonTypeCompare> IonTypeLineMap;
    143144  if (LineMapping == NULL) {
    144145    eLog() << Verbose(0) << "map pointer is NULL: " << LineMapping << endl;
     
    149150  // put all into hashed map
    150151  for (int i=0; i<NoAtoms; ++i) {
    151     LineList.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));
     152    IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));
    152153  }
    153154
    154155  // fill map
    155156  int nr=0;
    156   for (map<const char *, int, IonTypeCompare>::iterator runner = LineList.begin(); runner != LineList.end(); ++runner) {
     157  for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) {
    157158    if (CurrentLine+nr < NoLines)
    158159      LineMapping[CurrentLine+(nr++)] = runner->second;
     
    10561057
    10571058  // 2. parse the bond graph file if given
    1058   BG = new BondGraph(IsAngstroem);
    1059   if (BG->LoadBondLengthTable(BondGraphFileName)) {
    1060     Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
    1061   } else {
    1062     eLog() << Verbose(1) << "Bond length table loading failed." << endl;
     1059  if (BG == NULL) {
     1060    BG = new BondGraph(IsAngstroem);
     1061    if (BG->LoadBondLengthTable(BondGraphFileName)) {
     1062      Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
     1063    } else {
     1064      eLog() << Verbose(1) << "Bond length table loading failed." << endl;
     1065    }
    10631066  }
    10641067
    10651068  // 3. parse the molecule in
    10661069  LoadMolecule(mol, FileBuffer, periode, FastParsing);
     1070  mol->SetNameFromFilename(filename);
    10671071  mol->ActiveFlag = true;
     1072  MolList->insert(mol);
    10681073
    10691074  // 4. dissect the molecule into connected subgraphs
    1070   MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
    1071 
    1072   delete(mol);
     1075  // don't do this here ...
     1076  //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
     1077  //delete(mol);
     1078
    10731079  delete(FileBuffer);
    10741080};
     
    17711777};
    17721778
    1773 
    1774 /** Tries given filename or standard on saving the config file.
    1775  * \param *ConfigFileName name of file
    1776  * \param *periode pointer to periodentafel structure with all the elements
    1777  * \param *molecules list of molecules structure with all the atoms and coordinates
    1778  */
    1779 void config::SaveAll(char *ConfigFileName, periodentafel *periode, MoleculeListClass *molecules)
    1780 {
    1781   char filename[MAXSTRINGSIZE];
    1782   ofstream output;
    1783   molecule *mol = new molecule(periode);
    1784 
    1785   if (!strcmp(configpath, GetDefaultPath())) {
    1786     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
    1787   }
    1788 
    1789 
    1790   // first save as PDB data
    1791   if (ConfigFileName != NULL)
    1792     strcpy(filename, ConfigFileName);
    1793   else
    1794     strcpy(filename,"main_pcp_linux");
    1795   Log() << Verbose(0) << "Saving as pdb input ";
    1796   if (SavePDB(filename, molecules))
    1797     Log() << Verbose(0) << "done." << endl;
    1798   else
    1799     Log() << Verbose(0) << "failed." << endl;
    1800 
    1801   // then save as tremolo data file
    1802   if (ConfigFileName != NULL)
    1803     strcpy(filename, ConfigFileName);
    1804   else
    1805     strcpy(filename,"main_pcp_linux");
    1806   Log() << Verbose(0) << "Saving as tremolo data input ";
    1807   if (SaveTREMOLO(filename, molecules))
    1808     Log() << Verbose(0) << "done." << endl;
    1809   else
    1810     Log() << Verbose(0) << "failed." << endl;
    1811 
    1812   // translate each to its center and merge all molecules in MoleculeListClass into this molecule
    1813   int N = molecules->ListOfMolecules.size();
    1814   int *src = new int[N];
    1815   N=0;
    1816   for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
    1817     src[N++] = (*ListRunner)->IndexNr;
    1818     (*ListRunner)->Translate(&(*ListRunner)->Center);
    1819   }
    1820   molecules->SimpleMultiAdd(mol, src, N);
    1821   delete[](src);
    1822 
    1823   // ... and translate back
    1824   for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
    1825     (*ListRunner)->Center.Scale(-1.);
    1826     (*ListRunner)->Translate(&(*ListRunner)->Center);
    1827     (*ListRunner)->Center.Scale(-1.);
    1828   }
    1829 
    1830   Log() << Verbose(0) << "Storing configuration ... " << endl;
    1831   // get correct valence orbitals
    1832   mol->CalculateOrbitals(*this);
    1833   InitMaxMinStopStep = MaxMinStopStep = MaxPsiDouble;
    1834   if (ConfigFileName != NULL) { // test the file name
    1835     strcpy(filename, ConfigFileName);
    1836     output.open(filename, ios::trunc);
    1837   } else if (strlen(configname) != 0) {
    1838     strcpy(filename, configname);
    1839     output.open(configname, ios::trunc);
    1840     } else {
    1841       strcpy(filename, DEFAULTCONFIG);
    1842       output.open(DEFAULTCONFIG, ios::trunc);
    1843     }
    1844   output.close();
    1845   output.clear();
    1846   Log() << Verbose(0) << "Saving of config file ";
    1847   if (Save(filename, periode, mol))
    1848     Log() << Verbose(0) << "successful." << endl;
    1849   else
    1850     Log() << Verbose(0) << "failed." << endl;
    1851 
    1852   // and save to xyz file
    1853   if (ConfigFileName != NULL) {
    1854     strcpy(filename, ConfigFileName);
    1855     strcat(filename, ".xyz");
    1856     output.open(filename, ios::trunc);
    1857   }
    1858   else {
    1859     strcpy(filename,"main_pcp_linux");
    1860     strcat(filename, ".xyz");
    1861     output.open(filename, ios::trunc);
    1862   }
    1863   Log() << Verbose(0) << "Saving of XYZ file ";
    1864   if (mol->MDSteps <= 1) {
    1865     if (mol->OutputXYZ(&output))
    1866       Log() << Verbose(0) << "successful." << endl;
    1867     else
    1868       Log() << Verbose(0) << "failed." << endl;
    1869   } else {
    1870     if (mol->OutputTrajectoriesXYZ(&output))
    1871       Log() << Verbose(0) << "successful." << endl;
    1872     else
    1873       Log() << Verbose(0) << "failed." << endl;
    1874   }
    1875   output.close();
    1876   output.clear();
    1877 
    1878   // and save as MPQC configuration
    1879   if (ConfigFileName != NULL)
    1880     strcpy(filename, ConfigFileName);
    1881   else
    1882     strcpy(filename,"main_pcp_linux");
    1883   Log() << Verbose(0) << "Saving as mpqc input ";
    1884   if (SaveMPQC(filename, mol))
    1885     Log() << Verbose(0) << "done." << endl;
    1886   else
    1887     Log() << Verbose(0) << "failed." << endl;
    1888 
    1889   if (!strcmp(configpath, GetDefaultPath())) {
    1890     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
    1891   }
    1892 
    1893   delete(mol);
    1894 };
    1895 
    18961779/** Reads parameter from a parsed file.
    18971780 * The file is either parsed for a certain keyword or if null is given for
     
    22412124              }
    22422125              line++;
    2243             } while (dummy1 != NULL && (dummy1[0] == '#') || (dummy1[0] == '\n'));
     2126            } while ((dummy1 != NULL) && ((dummy1[0] == '#') || (dummy1[0] == '\n')));
    22442127            dummy = dummy1;
    22452128          } else { // simple int, strings or doubles start in the same line
Note: See TracChangeset for help on using the changeset viewer.