double getMP2energy(std::string fname){ std::vector<std::string> line; //read in the file, if it fails, exit if (!readFile("logs\\"+fname, line)) return -1; std::cout << line.size() << " lines read from input file" << std::endl; //extract the output block into a string, if it fails, exit std::string outputBlock; if (!getOutputBlock(line, outputBlock)) { pauser(); return -1; } std::vector<std::string> bigChunks= chunkOutputBlock(outputBlock, "\\\\"); std::vector<std::vector<std::string>> smallChunks; for (uint64_t i=0; i<bigChunks.size(); i++){ smallChunks.push_back(chunkOutputBlock(bigChunks[i], "\\")); } for (uint64_t i=0; i<bigChunks.size(); i++){ for (uint64_t j=0; j<smallChunks[i].size(); j++){ if (smallChunks[i][j].find("MP2=-")!=std::string::npos){ smallChunks[i][j].erase(0, 4); return std::stod(smallChunks[i][j]); } } } }
void Account::slotHandleErrors(QNetworkReply *reply , QList<QSslError> errors) { NetworkJobTimeoutPauser pauser(reply); QString out; QDebug(&out) << "SSL-Errors happened for url " << reply->url().toString(); foreach(const QSslError &error, errors) { QDebug(&out) << "\tError in " << error.certificate() << ":" << error.errorString() << "("<< error.error() << ")" << "\n"; }
int main( int argc, char** argv ) { if( argc > 1 ){ /* Tiempo inicial y tiempo final */ time_t start, end; /* Tiempo usado por el proceso */ double time_used; /* T�tulo en consola */ SetConsoleTitle( argv[1] ); /* Programa a ejecutar */ char * command = argv[1]; /* Inicio segundos */ start = clock(); /* Ejecuci�n del comando */ executeCommand( command ); /* Fin de ejecuci�n */ end = clock(); time_used = (( double) ( end - start)) / CLOCKS_PER_SEC; /* Pausa */ pauser( EXIT_SUCCESS, time_used ); } return 0; }
int main(){ std::cout << "GaussManip started" << std::endl; std::cout << "------------------" << std::endl; std::vector<std::string> line; //read in the file, if it fails, exit if (!readFile("test.log", line)) return -1; std::cout << line.size() << " lines read from input file" << std::endl; //extract the output block into a string, if it fails, exit std::string outputBlock; if (!getOutputBlock(line, outputBlock)) { pauser(); return -1; } std::cout << "------------------" << std::endl; std::cout<<outputBlock<<std::endl; std::cout << "------------------" << std::endl; std::vector<std::string> bigChunks= chunkOutputBlock(outputBlock, "\\\\"); for (uint64_t i=0; i<bigChunks.size(); i++){ std::cout<< bigChunks[i]<<std::endl; } std::cout << "------------------" << std::endl; std::vector<std::vector<std::string>> smallChunks; for (uint64_t i=0; i<bigChunks.size(); i++){ smallChunks.push_back(chunkOutputBlock(bigChunks[i], "\\")); } for (uint64_t i=0; i<bigChunks.size(); i++){ for (uint64_t j=0; j<smallChunks[i].size(); j++){ std::cout<< smallChunks[i][j]<<std::endl; } } std::cout << "------------------" << std::endl; std::ofstream outfile; outfile.open("chunks.log"); for (uint64_t i=0; i<bigChunks.size(); i++){ for (uint64_t j=0; j<smallChunks[i].size(); j++){ while (true){ if (smallChunks[i][j].find(",")!=std::string::npos){ smallChunks[i][j][smallChunks[i][j].find(",")]='\n'; } else break; } while (true){ if (smallChunks[i][j].find(".")!=std::string::npos){ smallChunks[i][j][smallChunks[i][j].find(".")]=','; } else break; } outfile<< smallChunks[i][j]<<std::endl; //std::cout<< smallChunks[i][j]<<std::endl; } } outfile.close(); std::vector<std::string> filenames=get_all_logfiles_names_within_folder("logs"); std::cout<< std::setprecision(8) << std::fixed; outfile<< std::setprecision(8) << std::fixed; for (uint64_t i=0; i<filenames.size(); i++){ std::vector<std::string> line; //read in the file, if it fails, exit if (!readFile(filenames[i], line)) return -1; std::cout << line.size() << " lines read from input file" << std::endl; //extract the output block into a string, if it fails, exit std::string outputBlock; if (!getOutputBlock(line, outputBlock)) { pauser(); return -1; } std::cout << "------------------" << std::endl; std::cout<<outputBlock<<std::endl; std::cout << "------------------" << std::endl; std::vector<std::string> bigChunks= chunkOutputBlock(outputBlock, "\\\\"); for (uint64_t i=0; i<bigChunks.size(); i++){ std::cout<< bigChunks[i]<<std::endl; } std::cout << "------------------" << std::endl; std::vector<std::vector<std::string>> smallChunks; for (uint64_t i=0; i<bigChunks.size(); i++){ smallChunks.push_back(chunkOutputBlock(bigChunks[i], "\\")); } for (uint64_t i=0; i<bigChunks.size(); i++){ for (uint64_t j=0; j<smallChunks[i].size(); j++){ std::cout<< smallChunks[i][j]<<std::endl; } } std::cout << "------------------" << std::endl; std::ofstream outfile; outfile.open(filenames[i]+".txt"); std::vector<std::string> envec; for (uint64_t i=0; i<bigChunks.size(); i++){ for (uint64_t j=0; j<smallChunks[i].size(); j++){ while (true){ if (smallChunks[i][j].find(",")!=std::string::npos){ smallChunks[i][j][smallChunks[i][j].find(",")]='\n'; } else break; } while (true){ if (smallChunks[i][j].find(".")!=std::string::npos){ smallChunks[i][j][smallChunks[i][j].find(".")]=','; } else break; } bool isenergy=false; if (smallChunks[i][j].find("HF=-")!=std::string::npos){ isenergy=true; } if (smallChunks[i][j].find("RMSD=")!=std::string::npos){ isenergy=false; } if (isenergy) { envec.push_back(smallChunks[i][j]); } outfile<< smallChunks[i][j]<<std::endl; } } outfile.close(); outfile.open(filenames[i]+".nrgy"); for (uint64_t k=0; k<envec.size(); k++){ outfile<<envec[k]<<std::endl; } outfile.close(); } { std::vector<pespoint> pespointVec; std::vector<std::string> linevec; if (!readFile("pespoints.dat", linevec)) return -1; std::cout<<"-------------------------------------"<<std::endl; std::cout<<linevec.size()<<" lines read from pespoints.dat"<<std::endl; for(uint64_t i=0; i<(linevec.size()/8); i++){ pespoint point; for (uint64_t j=0; j<6; j++){ point.lines[j]=linevec[i*8+2+j]; } pespointVec.push_back(point); } std::cout<<pespointVec.size()<<" PES points parsed"<<std::endl; for(uint64_t i=0; i<pespointVec.size(); i++){ std::string filename="MeCl_F_pespoint_"+std::to_string(i); outfile.open("generated\\"+filename+".gjf"); outfile<<"%chk="<<filename<<"_VAC.chk"<<std::endl; outfile<<"#P MP2=FullDirect/aug-cc-pVTZ SCF=Direct Geom=NoCrowd"<<std::endl; outfile<<std::endl; outfile<<filename<<"_VAC"<<std::endl; outfile<<std::endl; outfile<<"-1 1"<<std::endl; for (uint64_t j=0; j<6; j++){ outfile<<pespointVec[i].lines[j]<<std::endl; } outfile<<std::endl; outfile<<"--Link1--"<<std::endl; outfile<<"%chk="<<filename<<"_SMD.chk"<<std::endl; outfile<<"#P MP2=FullDirect/aug-cc-pVTZ SCF=Direct SCRF=(READ, SMD) Geom=NoCrowd"<<std::endl; outfile<<std::endl; outfile<<filename<<"_SMD"<<std::endl; outfile<<std::endl; outfile<<"-1 1"<<std::endl; for (uint64_t j=0; j<6; j++){ outfile<<pespointVec[i].lines[j]<<std::endl; } outfile<<std::endl; outfile<<"PDens=7.5"<<std::endl; outfile<<std::endl; outfile<<std::endl; outfile.close(); convertLineEndings("generated\\"+filename+".gjf"); } } /*for (uint64_t i=0; i<140; i++){ std::string outfilename; if(i<10){ outfilename=("generated\\MeCl_F_SP000"+std::to_string(i)+"_MP2TZgeom_MP2_DZ_SMDext_PD30_HPC.gjf"); } else { if(i<100){ outfilename=("generated\\MeCl_F_SP00"+std::to_string(i)+"_MP2TZgeom_MP2_DZ_SMDext_PD30_HPC.gjf"); } else { if(i<1000){ outfilename=("generated\\MeCl_F_SP0"+std::to_string(i)+"_MP2TZgeom_MP2_DZ_SMDext_PD30_HPC.gjf"); } else { outfilename=("generated\\MeCl_F_SP"+std::to_string(i)+"_MP2TZgeom_MP2_DZ_SMDext_PD30_HPC.gjf"); } } } outfile.open(outfilename); outfile.clear(); std::cout<<outfile.good(); outfile<<"#P MP2/aug-cc-pVDZ SCF=(Conver=12, XQC) SCRF=(READ, SMD, solvent=water, ExternalIteration) symmetry=none"<<'\r'; outfile<<'\r'; outfile<<"TITLE"<<'\r'; outfile<<'\r'; outfile<< "-1 1" <<'\r'; outfile<< "C" <<'\r'; outfile<< "Cl,1,B1" <<'\r'; outfile<< "H,1,B2,2,A2" <<'\r'; outfile<< "H,1,B3,2,A3,3,D3" <<'\r'; outfile<< "H,1,B4,2,A4,3,D4" <<'\r'; outfile<< "X 1 1.0 2 90.0 3 0.0" <<'\r'; outfile<< "F,1,B6,6,A6,3,D6" <<'\r'; outfile<<'\r'; outfile<< "B1=1.83973905" <<'\r'; outfile<< "B2=1.07799473" <<'\r'; outfile<< "A2=107.77911248" <<'\r'; outfile<< "B3=1.07799472" <<'\r'; outfile<< "A3=107.77911222" <<'\r'; outfile<< "D3=239.99999995" <<'\r'; outfile<< "B4=1.07799472" <<'\r'; outfile<< "A4=107.77911222" <<'\r'; outfile<< "D4=120.00000004" <<'\r'; outfile<< "B6=" <<std::to_string(6.1+(0.1*(double)i))<<'\r'; outfile<< "A6=90.00000009" <<'\r'; outfile<< "D6=0.0" <<'\r'; outfile<<'\r'; outfile<< "PDens=30.0" <<'\r'; outfile<<'\r'; outfile<<'\r'; outfile.close(); std::ifstream readback; uint64_t filesize=0; getFilesize(outfilename, filesize); unsigned char* rbuff=new unsigned char [filesize]; readback.open(outfilename, std::ios::in | std::ios::binary); readback.read(reinterpret_cast<char*>(rbuff), filesize); readback.close(); for (uint64_t k=0; k<filesize; k++){ if ((int)rbuff[k]==13) rbuff[k]=10; } std::ofstream writeback; writeback.open(outfilename, std::ios::out | std::ios::binary); writeback.write(reinterpret_cast<char*>(rbuff), filesize); writeback.close(); }*/ pauser(); return 0; }
void events(void) { int ictbeam=0, ipage=0, istract=0, line, i, j, k, l, ixhold, iyhold; double fintim = d.date + Time, datemin, xtime, repair, yank; #ifdef DEBUG if (idebug) prout("EVENTS"); #endif if (stdamtim == 1e30 && !REPORTS) { /* chart will no longer be updated because radio is dead */ stdamtim = d.date; for (i=1; i <= 8 ; i++) for (j=1; j <= 8; j++) if (starch[i][j] == 1) starch[i][j] = d.galaxy[i][j]+1000; } for (;;) { /* Select earliest extraneous event, line==0 if no events */ line = FSPY; if (alldone) return; datemin = fintim; for (l=1; l<=NEVENTS; l++) if (future[l] <= datemin) { line = l; datemin = future[l]; } xtime = datemin-d.date; #ifdef CLOAKING if (iscloaking) { energy -= xtime*500.0; if (energy <= 0.) { finish(FNRG); return; } } #endif d.date = datemin; /* Decrement Federation resources and recompute remaining time */ d.remres -= (d.remkl+4*d.remcom)*xtime; d.remtime = d.remres/(d.remkl+4*d.remcom); if (d.remtime <=0) { finish(FDEPLETE); return; } /* Is life support adequate? */ if (damage[DLIFSUP] && condit != IHDOCKED) { if (lsupres < xtime && damage[DLIFSUP] > lsupres) { finish(FLIFESUP); return; } lsupres -= xtime; if (damage[DLIFSUP] <= xtime) lsupres = inlsr; } /* Fix devices */ repair = xtime; if (condit == IHDOCKED) repair /= docfac; /* Don't fix Deathray here */ for (l=1; l<=ndevice; l++) if (damage[l] > 0.0 && l != DDRAY) damage[l] -= (damage[l]-repair > 0.0 ? repair : damage[l]); /* Fix Deathray if docked */ if (damage[DDRAY] > 0.0 && condit == IHDOCKED) damage[DDRAY] -= (damage[l] - xtime > 0.0 ? xtime : damage[DDRAY]); /* If radio repaired, update star chart and attack reports */ if (stdamtim != 1e30 && REPORTS) { stdamtim = 1e30; prout("Lt. Uhura- \"Captain, the sub-space radio is working and"); prout(" surveillance reports are coming in."); skip(1); for (i=1; i <= 8 ; i++) for (j=1; j <= 8; j++) if (starch[i][j] > 999) starch[i][j] = 1; if (iseenit==0) { attakreport(); iseenit = 1; } skip(1); prout(" The star chart is now up to date.\""); skip(1); } /* Cause extraneous event LINE to occur */ Time -= xtime; switch (line) { case FSNOVA: /* Supernova */ if (ipage==0) pauser(1); ipage=1; snova(0,0); future[FSNOVA] = d.date + expran(0.5*intime); if (d.galaxy[quadx][quady] == 1000) return; break; case FSPY: /* Check with spy to see if S.C. should tractor beam */ if (d.nscrem == 0 || #ifdef CLOAKING iscloaked || /* Cannot tractor beam if we can't be seen! */ #endif ictbeam+istract > 0 || condit==IHDOCKED || isatb==1 || iscate==1) return; if (ientesc || (energy < 2000 && torps < 4 && shield < 1250) || (damage[DPHASER]>0 && (damage[DPHOTON]>0 || torps < 4)) || (damage[DSHIELD] > 0 && (energy < 2500 || damage[DPHASER] > 0) && (torps < 5 || damage[DPHOTON] > 0))) { /* Tractor-beam her! */ istract=1; yank = square(d.isx-quadx) + square(d.isy-quady); /*********TBEAM CODE***********/ } else return; case FTBEAM: /* Tractor beam */ if (line==FTBEAM) { if (d.remcom == 0) { future[FTBEAM] = 1e30; break; } i = Rand()*d.remcom+1.0; yank = square(d.cx[i]-quadx) + square(d.cy[i]-quady); if (istract || condit == IHDOCKED || #ifdef CLOAKING iscloaked || /* cannot tractor beam if we can't be seen */ #endif yank == 0) { /* Drats! Have to reschedule */ future[FTBEAM] = d.date + Time + expran(1.5*intime/d.remcom); break; } } /* tractor beaming cases merge here */ yank = sqrt(yank); if (ipage==0) pauser(1); ipage=1; Time = (10.0/(7.5*7.5))*yank; /* 7.5 is yank rate (warp 7.5) */ ictbeam = 1; skip(1); proutn("***"); crmshp(); prout(" caught in long range tractor beam--"); /* If Kirk & Co. screwing around on planet, handle */ atover(1); /* atover(1) is Grab */ if (alldone) return; if (icraft == 1) { /* Caught in Galileo? */ finish(FSTRACTOR); return; } /* Check to see if shuttle is aboard */ if (iscraft==0) { skip(1); if (Rand() >0.5) { prout("Galileo, left on the planet surface, is captured"); prout("by aliens and made into a flying McDonald's."); damage[DSHUTTL] = -10; iscraft = -1; } else { prout("Galileo, left on the planet surface, is well hidden."); } } if (line==0) { quadx = d.isx; quady = d.isy; } else { quadx = d.cx[i]; quady = d.cy[i]; } iran10(§x, §y); crmshp(); proutn(" is pulled to"); cramlc(1, quadx, quady); proutn(", "); cramlc(2, sectx, secty); skip(1); if (resting) { prout("(Remainder of rest/repair period cancelled.)"); resting = 0; } if (shldup==0) { if (damage[DSHIELD]==0 && shield > 0) { sheild(2); /* Shldsup */ shldchg=0; } else prout("(Shields not currently useable.)"); } newqad(0); /* Adjust finish time to time of tractor beaming */ fintim = d.date+Time; if (d.remcom <= 0) future[FTBEAM] = 1e30; else future[FTBEAM] = d.date+Time+expran(1.5*intime/d.remcom); break; case FSNAP: /* Snapshot of the universe (for time warp) */ snapsht = d; d.snap = 1; future[FSNAP] = d.date + expran(0.5 * intime); break; case FBATTAK: /* Commander attacks starbase */ if (d.remcom==0 || d.rembase==0) { /* no can do */ future[FBATTAK] = future[FCDBAS] = 1e30; break; } i = 0; for (j=1; j<=d.rembase; j++) { for (k=1; k<=d.remcom; k++) if (d.baseqx[j]==d.cx[k] && d.baseqy[j]==d.cy[k] && (d.baseqx[j]!=quadx || d.baseqy[j]!=quady) && (d.baseqx[j]!=d.isx || d.baseqy[j]!=d.isy)) { i = 1; break; } if (i == 1) break; } if (j>d.rembase) { /* no match found -- try later */ future[FBATTAK] = d.date + expran(0.3*intime); future[FCDBAS] = 1e30; break; } /* commander + starbase combination found -- launch attack */ batx = d.baseqx[j]; baty = d.baseqy[j]; future[FCDBAS] = d.date+1.0+3.0*Rand(); if (isatb) /* extra time if SC already attacking */ future[FCDBAS] += future[FSCDBAS]-d.date; future[FBATTAK] = future[FCDBAS] +expran(0.3*intime); iseenit = 0; if (!REPORTS) break; /* No warning :-( */ iseenit = 1; if (ipage==0) pauser(1); ipage = 1; skip(1); proutn("Lt. Uhura- \"Captain, the starbase in"); cramlc(1, batx, baty); skip(1); prout(" reports that it is under atttack and that it can"); proutn(" hold out only until stardate "); cramf(future[FCDBAS],1,1); prout(".\""); if (resting) { skip(1); proutn("Mr. Spock- \"Captain, shall we cancel the rest period?\""); if (ja()) { resting = 0; Time = 0.0; return; } } break; case FSCDBAS: /* Supercommander destroys base */ future[FSCDBAS] = 1e30; isatb = 2; if (d.galaxy[d.isx][d.isy]%100 < 10) break; /* WAS RETURN! */ ixhold = batx; iyhold = baty; batx = d.isx; baty = d.isy; case FCDBAS: /* Commander succeeds in destroying base */ if (line==FCDBAS) { future[FCDBAS] = 1e30; /* find the lucky pair */ for (i = 1; i <= d.remcom; i++) if (d.cx[i]==batx && d.cy[i]==baty) break; if (i > d.remcom || d.rembase == 0 || d.galaxy[batx][baty] % 100 < 10) { /* No action to take after all */ batx = baty = 0; break; } } /* Code merges here for any commander destroying base */ /* Not perfect, but will have to do */ if (starch[batx][baty] == -1) starch[batx][baty] = 0; /* Handle case where base is in same quadrant as starship */ if (batx==quadx && baty==quady) { if (starch[batx][baty] > 999) starch[batx][baty] -= 10; quad[basex][basey]= IHDOT; basex=basey=0; newcnd(); skip(1); prout("Spock- \"Captain, I believe the starbase has been destroyed.\""); } else if (d.rembase != 1 && REPORTS) { /* Get word via subspace radio */ if (ipage==0) pauser(1); ipage = 1; skip(1); prout("Lt. Uhura- \"Captain, Starfleet Command reports that"); proutn(" the starbase in"); cramlc(1, batx, baty); prout(" has been destroyed by"); if (isatb==2) prout("the Klingon Super-Commander"); else prout("a Klingon Commander"); } /* Remove Starbase from galaxy */ d.galaxy[batx][baty] -= 10; for (i=1; i <= d.rembase; i++) if (d.baseqx[i]==batx && d.baseqy[i]==baty) { d.baseqx[i]=d.baseqx[d.rembase]; d.baseqy[i]=d.baseqy[d.rembase]; } d.rembase--; if (isatb == 2) { /* reinstate a commander's base attack */ batx = ixhold; baty = iyhold; isatb = 0; } else { batx = baty = 0; } break; case FSCMOVE: /* Supercommander moves */ future[FSCMOVE] = d.date+0.2777; if (ientesc+istract==0 && isatb!=1 && (iscate!=1 || justin==1)) scom(&ipage); break; case FDSPROB: /* Move deep space probe */ future[FDSPROB] = d.date + 0.01; probex += probeinx; probey += probeiny; i = (int)(probex/10 +0.05); j = (int)(probey/10 + 0.05); if (probecx != i || probecy != j) { probecx = i; probecy = j; if (i < 1 || i > 8 || j < 1 || j > 8 || d.galaxy[probecx][probecy] == 1000) { // Left galaxy or ran into supernova if (REPORTS) { if (ipage==0) pauser(1); ipage = 1; skip(1); proutn("Lt. Uhura- \"The deep space probe "); if (i < 1 ||i > 8 || j < 1 || j > 8) proutn("has left the galaxy"); else proutn("is no longer transmitting"); prout(".\""); } future[FDSPROB] = 1e30; break; } if (REPORTS) { if (ipage==0) pauser(1); ipage = 1; skip(1); proutn("Lt. Uhura- \"The deep space probe is now in "); cramlc(1, probecx, probecy); prout(".\""); } } /* Update star chart if Radio is working or have access to radio. */ if (REPORTS) starch[probecx][probecy] = damage[DRADIO] > 0.0 ? d.galaxy[probecx][probecy]+1000 : 1; proben--; // One less to travel if (proben == 0 && isarmed && d.galaxy[probecx][probecy] % 10 > 0) { /* lets blow the sucker! */ snova(1,0); future[FDSPROB] = 1e30; if (d.galaxy[quadx][quady] == 1000) return; } break; } } }