Changes in src/config.cpp [235bed:49e1ae]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/config.cpp
r235bed r49e1ae 6 6 7 7 #include <stdio.h> 8 #include <cstring> 8 9 9 10 #include "atom.hpp" … … 27 28 char number1[8]; 28 29 char number2[8]; 29 c har *dummy1, *dummy2;30 const char *dummy1, *dummy2; 30 31 //Log() << Verbose(0) << s1 << " " << s2 << endl; 31 32 dummy1 = strchr(s1, '_')+sizeof(char)*5; // go just after "Ion_Type" … … 140 141 void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms) 141 142 { 142 map<const char *, int, IonTypeCompare> LineList;143 map<const char *, int, IonTypeCompare> IonTypeLineMap; 143 144 if (LineMapping == NULL) { 144 145 eLog() << Verbose(0) << "map pointer is NULL: " << LineMapping << endl; … … 149 150 // put all into hashed map 150 151 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)); 152 153 } 153 154 154 155 // fill map 155 156 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) { 157 158 if (CurrentLine+nr < NoLines) 158 159 LineMapping[CurrentLine+(nr++)] = runner->second; … … 1056 1057 1057 1058 // 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 } 1063 1066 } 1064 1067 1065 1068 // 3. parse the molecule in 1066 1069 LoadMolecule(mol, FileBuffer, periode, FastParsing); 1070 mol->SetNameFromFilename(filename); 1067 1071 mol->ActiveFlag = true; 1072 MolList->insert(mol); 1068 1073 1069 1074 // 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 1073 1079 delete(FileBuffer); 1074 1080 }; … … 1771 1777 }; 1772 1778 1773 1774 /** Tries given filename or standard on saving the config file.1775 * \param *ConfigFileName name of file1776 * \param *periode pointer to periodentafel structure with all the elements1777 * \param *molecules list of molecules structure with all the atoms and coordinates1778 */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 data1791 if (ConfigFileName != NULL)1792 strcpy(filename, ConfigFileName);1793 else1794 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 else1799 Log() << Verbose(0) << "failed." << endl;1800 1801 // then save as tremolo data file1802 if (ConfigFileName != NULL)1803 strcpy(filename, ConfigFileName);1804 else1805 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 else1810 Log() << Verbose(0) << "failed." << endl;1811 1812 // translate each to its center and merge all molecules in MoleculeListClass into this molecule1813 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 back1824 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 orbitals1832 mol->CalculateOrbitals(*this);1833 InitMaxMinStopStep = MaxMinStopStep = MaxPsiDouble;1834 if (ConfigFileName != NULL) { // test the file name1835 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 else1850 Log() << Verbose(0) << "failed." << endl;1851 1852 // and save to xyz file1853 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 else1868 Log() << Verbose(0) << "failed." << endl;1869 } else {1870 if (mol->OutputTrajectoriesXYZ(&output))1871 Log() << Verbose(0) << "successful." << endl;1872 else1873 Log() << Verbose(0) << "failed." << endl;1874 }1875 output.close();1876 output.clear();1877 1878 // and save as MPQC configuration1879 if (ConfigFileName != NULL)1880 strcpy(filename, ConfigFileName);1881 else1882 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 else1887 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 1896 1779 /** Reads parameter from a parsed file. 1897 1780 * The file is either parsed for a certain keyword or if null is given for … … 2241 2124 } 2242 2125 line++; 2243 } while ( dummy1 != NULL && (dummy1[0] == '#') || (dummy1[0] == '\n'));2126 } while ((dummy1 != NULL) && ((dummy1[0] == '#') || (dummy1[0] == '\n'))); 2244 2127 dummy = dummy1; 2245 2128 } else { // simple int, strings or doubles start in the same line
Note:
See TracChangeset
for help on using the changeset viewer.