/************************************************ Any number of <MergeFile> elements may be listed below a <Menu> element, giving the name of another menu file to be merged into this one. If fileName is not an absolute path then the file to be merged should be located relative to the location of this menu. If the type attribute is missing or set to "path" then the contents of the <MergeFile> element indicates the file to be merged. If the type attribute is set to "parent" and the file that contains this <MergeFile> element is located under one of the paths specified by $XDG_CONFIG_DIRS, the contents of the element should be ignored and the remaining paths specified by $XDG_CONFIG_DIRS are searched for a file with the same relative filename. The first file encountered should be merged. There should be no merging at all if no matching file is found. ( Libmenu additional scans ~/.config/menus.) ************************************************/ void XdgMenuReader::processMergeFileTag(QDomElement& element, QStringList* mergedFiles) { //qDebug() << "Process " << element;// << "in" << mFileName; if (element.attribute("type") != "parent") { mergeFile(element.text(), element, mergedFiles); } else { QString relativeName; QStringList configDirs = XdgDirs::configDirs(); foreach (QString configDir, configDirs) { if (mFileName.startsWith(configDir)) { relativeName = mFileName.mid(configDir.length()); configDirs.removeAll(configDir); break; } } if (relativeName.isEmpty()) { QString configHome = XdgDirs::configHome(); if (mFileName.startsWith(configHome)) relativeName = mFileName.mid(configHome.length()); } if (relativeName.isEmpty()) return; foreach (QString configDir, configDirs) { if (QFileInfo(configDir + relativeName).exists()) { mergeFile(configDir + relativeName, element, mergedFiles); return; } } } }
void XdgMenuReader::mergeDir(const QString& dirName, QDomElement& element, QStringList* mergedFiles) { QFileInfo dirInfo(mDirName, dirName); if (dirInfo.isDir()) { //qDebug() << "Merge dir: " << dirInfo.canonicalFilePath(); QDir dir = QDir(dirInfo.canonicalFilePath()); const QFileInfoList files = dir.entryInfoList(QStringList() << QLatin1String("*.menu"), QDir::Files | QDir::Readable); for (const QFileInfo &file : files) mergeFile(file.canonicalFilePath(), element, mergedFiles); } }
void mergeHeadFile() { FILE *file; /**< 存放头文件的文件指针 */ WIN32_FIND_DATA FindFileData; /**< 文件结信息构体 */ HANDLE hFind; /**< 文件句柄 */ file = fopen(".\\headFileSet.txt", "w+"); if (file == NULL) { perror("The following error occurred:"); exit(-1); } /**< 获取头文件句柄 */ hFind = FindFirstFile(".\\*.h", &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { /**< 如果获取句柄失败,则打印出错误编号 */ printf("Invalid File Handle. Get Last Error reports %d\n", (int)GetLastError()); } else { mergeFile(file, FindFileData.cFileName); /**< 合并搜索到的文件 */ while (FindNextFile(hFind, &FindFileData)) { mergeFile(file, FindFileData.cFileName); /**< 合并搜索到的文件 */ } FindClose(hFind); /**< 关闭文件句柄 */ } fclose(file); puts("合并完毕!!!"); }
/************************************************ The element has no content. The element should be treated as if it were a list of <MergeDir> elements containing the default merge directory locations. When expanding <DefaultMergeDirs> to a list of <MergeDir>, the default locations that are earlier in the search path go later in the <Menu> so that they have priority. Note that a system that uses either gnome-applications.menu or kde-applications.menu depending on the desktop environment in use must still use applications-merged as the default merge directory in both cases. Implementations may chose to use .menu files with names other than application.menu for tasks or menus other than the main application menu. In that case the first part of the name of the default merge directory is derived from the name of the .menu file. ************************************************/ void XdgMenuReader::processDefaultMergeDirsTag(QDomElement& element, QStringList* mergedFiles) { //qDebug() << "Process " << element;// << "in" << mFileName; QString menuBaseName = QFileInfo(mMenu->menuFileName()).baseName(); int n = menuBaseName.lastIndexOf(QLatin1Char('-')); if (n>-1) menuBaseName = menuBaseName.mid(n+1); QStringList dirs = XdgDirs::configDirs(); dirs << XdgDirs::configHome(); for (const QString &dir : qAsConst(dirs)) { mergeDir(QString::fromLatin1("%1/menus/%2-merged").arg(dir, menuBaseName), element, mergedFiles); } if (menuBaseName == QLatin1String("applications")) mergeFile(QString::fromLatin1("%1/menus/applications-kmenuedit.menu").arg(XdgDirs::configHome()), element, mergedFiles); }
int libhdfsconnector::execute () { int returnCode = EXIT_FAILURE; if (action == HCA_STREAMIN) { returnCode = streamFileOffset(); } else if (action == HCA_STREAMOUT || action == HCA_STREAMOUTPIPE) { returnCode = writeFlatOffset(); } else if (action == HCA_MERGEFILE) { returnCode = mergeFile(); } else { fprintf(stderr, "\nNo action type detected, exiting."); } return returnCode; };
int main(int argc, char *argv[]) { #ifdef step1 //1. read ply files FileIO::load_point_cloud_files( "D:\\point_data\\plystandard\\panda20150918\\",FileIO::PLY ); IndexType sampleNum = SampleSet::get_instance().size(); #endif #ifdef step2 //2. set parameter IndexType neigNum, trajLen,resolution,modelT ,smallLife; ScalarType _perC,thresHold; bool isEqual,isRigid; neigNum = 11; trajLen =2; resolution =32; _perC =0.55; // lamda thresHold = 0.7; modelT =1; smallLife =2; isEqual = true; isRigid = false; IndexType selectedSmpIdx = 2; //set the central frame //step1 TrajectoryClassifier* cluster = new TrajectoryClassifier(selectedSmpIdx); cluster->setNeigNum(neigNum); cluster->setParamter(trajLen,resolution,_perC,thresHold,modelT,smallLife,isEqual,isRigid); cluster->run(); for(IndexType frameId = selectedSmpIdx ; frameId >0 ; --frameId) { cluster->setCenterFrame(frameId-1); cluster->setParamter(trajLen,resolution,_perC,thresHold,modelT,smallLife,isEqual,isRigid); cluster->run(); } for(IndexType frameId = selectedSmpIdx ; frameId < sampleNum-1 ; ++frameId) { cluster->setCenterFrame(frameId+1); cluster->setParamter(trajLen,resolution,_perC,thresHold,modelT,smallLife,isEqual,isRigid); cluster->run(); } #endif #ifdef MERGE mergeFile( ".\\tmp\\corr\\" , ".\\tmp\\results\\hksingle_corr.txt", ".\\tmp\\label\\", ".\\tmp\\results\\cosegOOrder.txt"); //return 0; #endif #ifdef generatePly if(_access(".\\tmp",0) == -1){ CreateDirectory(_T(".\\tmp"), NULL); } if(_access(".\\tmp\\ply",0) == -1){ CreateDirectory(_T(".\\tmp\\ply"), NULL); } if(_access(".\\tmp\\ply\\init",0) == -1){ CreateDirectory(_T(".\\tmp\\ply\\init"), NULL); } generateSamplePly( ".\\tmp\\results\\cosegOOrder.txt" ,".\\tmp\\ply\\init\\",filename); // return 0; #endif #ifdef step3 //step2 GCop * graphCut = new GCop; IndexType m_nLabels,m_nExpansion,m_nSwap,m_nGraphNeig,m_nCurNeig,m_centerF; ScalarType m_nTradeOff,m_cSigma,m_dSigma,m_nDiffu; m_nLabels = 1; //read label file to determine m_nExpansion =1; m_nSwap =1 ; m_nGraphNeig = 10; m_nCurNeig = 10; m_nTradeOff = 1; m_cSigma = 1.; m_dSigma = 1.; m_nDiffu= 1.; m_centerF = 2; graphCut->setParamter(m_nLabels,m_nExpansion,m_nSwap,m_nGraphNeig,m_nCurNeig,m_nTradeOff,m_cSigma,m_dSigma,m_nDiffu,m_centerF); graphCut->run(); #endif }
// --- Main code --- // ----------------- int main(int argc, char **argv) { // ---> Set parameters // >>>> Input input_params input; int pid; string filename; // Input file // Get file and folder if(argc == 1) { filename = "params_Part.in"; } if(argc == 2) { filename = argv[1]; } if(argc > 2) { cout << "--------------------------------------------------------------------------------" << endl << endl; cout << "ERROR: more than one argument given, simulation WON'T be set up!" << endl << endl; UsageHelp(); cout << "--------------------------------------------------------------------------------" << endl; return 0; } // Read input ifstream inputF(filename.c_str()); if(inputF.good()) { pid = getpid(); input.SetParamPart(inputF); inputF.close(); } else { cout << " ERROR: input file \"" << filename << "\" not found!" << endl; inputF.close(); return 0; } // >>>> Geometry parameters string SimType = "Part"; SysConf conf(input,SimType); conf.SetNeighboursPart(); if(conf.initCondType == 0) { conf.SetInitialPartAntiFerro(); } else if(conf.initCondType == 1) { conf.SetInitialPartEmpty(); } else if(conf.initCondType == 2) { conf.SetInitialPartStar3(); } else { conf.SetInitialPart(); } // >>>> Set up order parameters OrderParam dummyOrder(input); TwoDOrderParam dummy2DOrder; // ---> Prepare the output file/folder names // >>>> Output folder string outFolder = input.outFolderName + "_" + ToString(input.nx) + "_" + ToString(input.ny) + "_" + ToString(input.p) + "_" + ToString(pid); mkdir(outFolder.c_str(),0777); // >>>> V/t folders vector<string> vtFolder(input.VtN,outFolder + "/Vt_"); for(int iii = 0; iii < input.VtN; ++iii) { vtFolder[iii] = vtFolder[iii] + ToString(input.VtValues[iii]); mkdir(vtFolder[iii].c_str(),0777); } string statusFolder = outFolder + "/status"; mkdir(statusFolder.c_str(),0777); // >>>> Filenames string dummyString; string dummyStringBis; string outBase = "./" + outFolder + "/"; string sysConfFilename = outBase + "Obj_conf.odat"; string param_out = outBase + filename; CpFile(filename.c_str(),param_out.c_str()); // ---> MC parameters MCParameters params(input,conf.L,outFolder.c_str()); // ---> Set up files // >>>> For the geometry ExportObject(conf,sysConfFilename.c_str()); dummyString = "./" + outFolder + "/Obj_InputParams.odat"; ExportObject(input,dummyString.c_str()); for(int iii = 0; iii < input.VtN; ++iii) { // >>>> For the MC parameters dummyString = "./" + vtFolder[iii] + "/Obj_MCparams.odat"; params.SetVt(input.VtValues[iii]); ExportObject(params,dummyString.c_str()); // >>>> For the order parameters dummyString = "./" + vtFolder[iii]; dummyOrder.SetVt(input.VtValues[iii]); dummyOrder.SetFolder(dummyString.c_str()); dummy2DOrder.SetVt(input.VtValues[iii]); dummy2DOrder.SetFolder(dummyString.c_str()); // Mean mag dummyOrder.SetType("Mag"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanMag.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); // Mean energy dummyOrder.SetType("Energy"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanEnergy.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetType("QEnergy"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanQEnergy.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetType("PotEnergy"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanPotEnergy.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetType("KinEnergy"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanKinEnergy.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummy2DOrder.Initialize(conf.L,1); dummy2DOrder.SetType("MeanKinEnergyDensity"); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanKinEnergyDensity.odat"; ExportObject(dummy2DOrder,dummyStringBis.c_str()); dummyOrder.SetType("QNewEnergy"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanQNewEnergy.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetType("NewKinEnergy"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanNewKinEnergy.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); // Mean N_j dummyOrder.SetType("N0"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanN0.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetType("N1"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanN1.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetType("N2"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanN2.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetType("N3"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanN3.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetType("PlaquetteIndex"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanPlaquetteIndex.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetType("Star3Index"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanStar3Index.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); // Mean mag stag if(conf.initCondType == 0) { if(input.ny==1) { dummyOrder.SetType("MeanStagMag"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanStagMag.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetType("MeanChainEnergy"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanChainEnergy.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetCorrLength(input.nx + input.p); dummyOrder.SetType("CorrMag"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_CorrMag.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetType("CorrStagMag"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_CorrStagMag.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); } else { dummyOrder.SetType("MeanCoreMag"); dummyOrder.CreateFiles(); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanCoreMag.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); } } // For the 2D order parameters dummy2DOrder.Initialize(conf.nx*conf.nx,1); dummy2DOrder.SetType("MeanPart"); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanPart.odat"; ExportObject(dummy2DOrder,dummyStringBis.c_str()); dummy2DOrder.Initialize(conf.L,1); dummy2DOrder.SetType("MeanLocalNf"); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanLocalNf.odat"; ExportObject(dummy2DOrder,dummyStringBis.c_str()); dummy2DOrder.Initialize(conf.L,conf.NbOfNeights); dummy2DOrder.SetType("MeanLocalDimer"); dummyStringBis = "./" + vtFolder[iii] + "/Obj_MeanLocalDimer.odat"; ExportObject(dummy2DOrder,dummyStringBis.c_str()); dummy2DOrder.Initialize(conf.L,1); dummy2DOrder.SetType("Star3Lattice"); dummyStringBis = "./" + vtFolder[iii] + "/Obj_Star3.odat"; ExportObject(dummy2DOrder,dummyStringBis.c_str()); dummyOrder.SetCorrLength(conf.N); dummyOrder.SetType("CorrSzSz"); dummyStringBis = "./" + vtFolder[iii] + "/Obj_CorrSzSz.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummyOrder.SetType("CorrSxSx"); dummyStringBis = "./" + vtFolder[iii] + "/Obj_CorrSxSx.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummy2DOrder.SetType("CorrMeanSz"); dummyStringBis = "./" + vtFolder[iii] + "/Obj_CorrMeanSzSz.odat"; ExportObject(dummy2DOrder,dummyStringBis.c_str()); dummyOrder.SetType("CorrDimer"); dummyStringBis = "./" + vtFolder[iii] + "/Obj_CorrDimer.odat"; ExportObject(dummyOrder,dummyStringBis.c_str()); dummy2DOrder.Initialize(conf.L,conf.NbOfNeights); dummy2DOrder.SetType("CorrMeanDimer"); dummyStringBis = "./" + vtFolder[iii] + "/Obj_CorrMeanDimer.odat"; ExportObject(dummy2DOrder,dummyStringBis.c_str()); // >>>> For the RNG engine dummyString = "./" + vtFolder[iii] + "/Obj_Engine.odat"; conf.ExportRNG(dummyString.c_str()); } string scriptFilename = "./run_Part_" + ToString(pid) + ".sh"; string commandsFilename = "comm_Part_" + ToString(pid) + ".sh"; if(input.compType==0) { ofstream commandsFile(commandsFilename.c_str(),ios::trunc); int procCounter = 0; for(int iii = 0; iii < input.VtN; ++iii) { commandsFile << "nice -19 ./" << input.execName << " " << outFolder << "/Obj_conf.odat" << " " << vtFolder[iii] << " > ${PWD}/" << vtFolder[iii] << "/out_log.txt &" << endl; ++procCounter; if(procCounter==input.numProc) { commandsFile << "wait" << endl; procCounter = 0; } } commandsFile.close(); } else if(input.compType==1||input.compType==2) { ofstream commandsFile(commandsFilename.c_str(),ios::trunc); for(int iii = 0; iii < input.VtN; ++iii) { commandsFile << "nice -19 ./" << input.execName << " " << outFolder << "/Obj_conf.odat" << " " << vtFolder[iii] << endl; } commandsFile.close(); } else if(input.compType==3) { ofstream commandsFile(commandsFilename.c_str(),ios::trunc); for(int iii = 0; iii < input.VtN; ++iii) { commandsFile << "srun --exclusive -N1 -n1 nice -19 ./" << input.execName << " " << outFolder << "/Obj_conf.odat" << " " << vtFolder[iii] << endl; } commandsFile.close(); } if(input.compType==0) { // Direct cout << "---> Output type : direct - Lab (local)" << endl; cout << " Execution script : " << scriptFilename << endl; cout << " Commands list : " << commandsFilename << endl; ofstream scriptFile(scriptFilename.c_str(),ios::trunc); scriptFile << ". " << commandsFilename << endl; scriptFile << "./Merge " << outFolder << "/Obj_InputParams.odat" << " " << outFolder << endl; scriptFile.close(); } if(input.compType==1) { // Parallel - simple cout << "---> Output type : parallel - Lab (local)" << endl; cout << " Execution script : " << scriptFilename << endl; cout << " Commands list : " << commandsFilename << endl; ofstream scriptFile(scriptFilename.c_str(),ios::trunc); scriptFile << "parallel -j " << input.numProc << " < " << commandsFilename << endl; scriptFile << "./Merge " << outFolder << "/Obj_InputParams.odat" << " " << outFolder << endl; scriptFile.close(); } if(input.compType==2) { // Torque - parallel string mergeScript = "merge_script_" + ToString(pid) + ".sh"; cout << "---> Output type : TORQUE - Totoro, MESU" << endl; cout << " Execution script : none" << endl; cout << " Commands list : " << commandsFilename << endl; cout << " Merge script : " << mergeScript << endl; ofstream mergeFile(mergeScript.c_str(),ios::trunc); mergeFile << "./Merge " << outFolder << "/Obj_InputParams.odat" << " " << outFolder << endl; mergeFile.close(); } if(input.compType==3) { // SLURM - parallel string SLURMbase = "parallel_base.sh"; string mergeScript = "merge_script_" + ToString(pid) + ".sh"; cout << "---> Output type : SLURM - Lab (cluster)" << endl; cout << " Execution script : " << scriptFilename << endl; cout << " Commands list : " << commandsFilename << endl; cout << " Base file : " << SLURMbase << endl; cout << " Merge script : " << mergeScript << endl << endl; cout << "--------------------------------------------------------------------------------" << endl << endl; cout << "---> Open '" << scriptFilename << "' to edit :" << endl; cout << " Job name : #SBATCH --job-name=[name]" << endl; cout << " Number of CPU's : #SBATCH --ntask=[number]" << endl << endl; cout << "--------------------------------------------------------------------------------" << endl << endl; cout << "---> Submit job with : 'sbatch " << scriptFilename << "'" << endl ; cout << " (from any computer, no need to use 'screen')" << endl << endl; cout << " View job queue : 'squeue'" << endl << endl; cout << " View your jobs : 'squeue -u [your username]'" << endl << endl; cout << " To kill a job : > get JOB ID no. from 'squeue -u [your username]'" << endl; cout << " > then 'scancel [job ID]'" << endl << endl; cout << " View cluster status : 'sinfo'" << endl; cout << " > 'idle' computers are 100% free" << endl; cout << " > 'mix' computers are partially free" << endl; cout << " > 'alloc' computers are 100% full" << endl; cout << " > 'drain/down' computers are offline" << endl << endl; cout << " The 'status' sub-folder contains files with the progress of the simulation" << endl << endl; cout << "--------------------------------------------------------------------------------" << endl << endl; CpFile(SLURMbase.c_str(),scriptFilename.c_str()); ofstream scriptFile(scriptFilename.c_str(),ios::app); ofstream mergeFile(mergeScript.c_str(),ios::trunc); scriptFile << "$parallel < " << commandsFilename << endl; mergeFile << "./Merge " << outFolder << "/Obj_InputParams.odat" << " " << outFolder << endl; scriptFile.close(); mergeFile.close(); } return 0; }