//BASIS file creation functions void LICHEM2BASIS(int& argc,char**& argv) { //Writes a BASIS file based on a LICHEM regions file fstream regfile,ofile; //File streams string dummy; //Generic string regfilename = "NOFILE"; //Global regions filename //Read arguments Nqm = 0; //For safety Npseudo = 0; //For safety bool DoQuit = 0; //Exit with an error cout << "Reading LICHEM input: "; for (int i=0;i<argc;i++) { dummy = string(argv[i]); //Check regions file if (dummy == "-b") { stringstream file; file << argv[i+1]; if (!CheckFile(file.str())) { cout << "Error: Could not open regions file!!!"; cout << '\n'; DoQuit = 1; } regfilename = file.str(); regfile.open(argv[i+1],ios_base::in); cout << argv[i+1]; } } cout << '\n' << '\n'; //Terminate output //Error check if (!CheckFile(regfilename)) { cout << "Error: Missing region file!!!"; cout << '\n' << '\n'; DoQuit = 1; } //Parse input if (!DoQuit) { //Parse region file bool FoundWrapper = 0; bool FoundBasis = 0; bool FoundQM = 0; bool FoundPB = 0; vector<int> QMatoms; vector<int> PBatoms; string BasisSetName = "???"; string WrapperName = "N/A"; ofile.open("BASIS",ios_base::out); if (regfile.good()) { //Loop over the lines while (!regfile.eof()) { //Look for key words stringstream line; //Generic stream getline(regfile,dummy); //Read the line line << dummy; //Copy to a better container line >> dummy; //Read first item in the string LICHEMLowerText(dummy); if (dummy == "qm_type:") { //Read basis set information line >> WrapperName; LICHEMLowerText(WrapperName); FoundWrapper = 1; } if (dummy == "qm_basis:") { //Read basis set information line >> BasisSetName; FoundBasis = 1; } if (dummy == "qm_atoms:") { //Read the list QM atoms line >> Nqm; for (int i=0;i<Nqm;i++) { //Save ID to the array int AtNum = 0; regfile >> AtNum; QMatoms.push_back(AtNum); } FoundQM = 1; }
//Parsers void TINK2LICHEM(int& argc, char**& argv) { //Local variables fstream TINKxyz,TINKkey,paramfile; //Input fstream posfile,confile,regfile; //Output stringstream line; string dummy; //Generic string int Ninact = 0; bool SomeFroz = 0; bool SomeAct = 0; int ct; //Generic counter //Open files posfile.open("xyzfile.xyz",ios_base::out); confile.open("connect.inp",ios_base::out); regfile.open("regions.inp",ios_base::out); //Read arguments PBCon = 0; cout << '\n'; cout << "Reading files: "; for (int i=0;i<argc;i++) { dummy = string(argv[i]); if (dummy == "-t") { //TINKER XYZ file TINKxyz.open(argv[i+1],ios_base::in); cout << argv[i+1]; cout << " "; } if (dummy == "-k") { //TINKER key file TINKkey.open(argv[i+1],ios_base::in); cout << argv[i+1]; cout << " "; } if (dummy == "-p") { //Flag for PBC dummy = string(argv[i+1]); LICHEMLowerText(dummy); if ((dummy == "yes") or (dummy == "true")) { PBCon = 1; } } } //Start writing the files if (PBCon) { //Remind forgetful users that they said the system was periodic cout << '\n'; cout << " with PBC"; } cout << "..."; cout << '\n'; getline(TINKxyz,dummy); line.str(dummy); line >> Natoms; line >> Nqm; if (!line.eof()) { //Read QMMM information //NB: This only works if the atoms are in the correct order: // QM->PB->BA->MM line >> Npseudo; line >> Nbound; }