bool D2Container::parseDir(wchar_t const* path, D2Data* d2data) { if (!path) return false; items.clear(); WIN32_FIND_DATA data; HANDLE hFind = FindFirstFile(WideString::buildFullName(path, L"*"), &data); if (hFind == INVALID_HANDLE_VALUE) return false; Array<D2Container*> newSub; bool changes = false; do { if (!wcscmp(data.cFileName, L".") || !wcscmp(data.cFileName, L"..")) continue; if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { D2Container* cur = find(data.cFileName); if (!cur) { cur = new D2Container(data.cFileName, this); newSub.push(cur); } if (cur->parseDir(WideString::buildFullName(path, data.cFileName), d2data)) changes = true; } else if (!WideString::getExtension(data.cFileName).icompare(L".txt")) { WideString curName(WideString::getFileTitle(data.cFileName)); D2Container* cur = find(curName); if (!cur) { cur = new D2Container(curName, this); newSub.push(cur); } if (cur->parseFile(WideString::buildFullName(path, data.cFileName), d2data)) changes = true; } } while (FindNextFile(hFind, &data)); FindClose(hFind); sub.append(newSub); sub.sort(compare); return changes; }
bool QMCDriverFactory::setQMCDriver(int curSeries, xmlNodePtr cur) { string curName((const char*)cur->name); string update_mode("pbyp"); string qmc_mode("invalid"); string multi_tag("no"); string warp_tag("no"); string append_tag("no"); #if defined(QMC_CUDA) string gpu_tag("yes"); #else string gpu_tag("no"); #endif OhmmsAttributeSet aAttrib; aAttrib.add(qmc_mode,"method"); aAttrib.add(update_mode,"move"); aAttrib.add(multi_tag,"multiple"); aAttrib.add(warp_tag,"warp"); aAttrib.add(append_tag,"append"); aAttrib.add(gpu_tag,"gpu"); aAttrib.put(cur); bitset<QMC_MODE_MAX> WhatToDo; bool append_run =(append_tag == "yes"); WhatToDo[SPACEWARP_MODE]= (warp_tag == "yes"); WhatToDo[MULTIPLE_MODE]= (multi_tag == "yes"); WhatToDo[UPDATE_MODE]= (update_mode == "pbyp"); #if defined(QMC_CUDA) WhatToDo[GPU_MODE ] = (gpu_tag == "yes"); #endif OhmmsInfo::flush(); QMCRunType newRunType = DUMMY_RUN; if(curName != "qmc") qmc_mode=curName; int nchars=qmc_mode.size(); if(qmc_mode.find("linear") < nchars) { if (qmc_mode.find("cslinear") < nchars) newRunType=CS_LINEAR_OPTIMIZE_RUN; else newRunType=LINEAR_OPTIMIZE_RUN; } else if(qmc_mode.find("opt") < nchars) { newRunType=OPTIMIZE_RUN; } else { if(qmc_mode.find("ptcl")<nchars) WhatToDo[UPDATE_MODE]=1; if(qmc_mode.find("mul")<nchars) WhatToDo[MULTIPLE_MODE]=1; if(qmc_mode.find("warp")<nchars) WhatToDo[SPACEWARP_MODE]=1; // if (qmc_mode.find("rmcPbyP")<nchars) // { // newRunType=RMC_PBYP_RUN; // } // else else if(qmc_mode.find("vmc")<nchars) { newRunType=VMC_RUN; } else if(qmc_mode.find("dmc")<nchars) { newRunType=DMC_RUN; } } unsigned long newQmcMode=WhatToDo.to_ulong(); //initialize to 0 QMCDriver::BranchEngineType* branchEngine=0; if(qmcDriver) { if( newRunType != curRunType || newQmcMode != curQmcMode) { if(curRunType == DUMMY_RUN) { APP_ABORT("QMCDriverFactory::setQMCDriver\n Other qmc sections cannot come after <qmc method=\"test\">.\n"); } //pass to the new driver branchEngine=qmcDriver->getBranchEngine(); delete qmcDriver; //set to 0 so that a new driver is created qmcDriver = 0; //if the current qmc method is different from the previous one, append_run is set to false append_run = false; } else { app_log() << " Reusing " << qmcDriver->getEngineName() << endl; // if(curRunType == DMC_RUN) qmcDriver->resetComponents(cur); } } if(curSeries == 0) append_run = false; //continue with the existing qmcDriver if(qmcDriver) return append_run; //need to create a qmcDriver curRunType = newRunType; curQmcMode = newQmcMode; curQmcModeBits = WhatToDo; //create a driver createQMCDriver(cur); //initialize QMCDriver::myComm qmcDriver->initCommunicator(myComm); //branchEngine has to be transferred to a new QMCDriver if(branchEngine) qmcDriver->setBranchEngine(branchEngine); OhmmsInfo::flush(); return append_run; }
bool QMCDriverFactory::setQMCDriver(int curSeries, xmlNodePtr cur) { string curName((const char*)cur->name); string update_mode("walker"); string qmc_mode("invalid"); string multi_tag("no"); string warp_tag("no"); string append_tag("no"); OhmmsAttributeSet aAttrib; aAttrib.add(qmc_mode,"method"); aAttrib.add(update_mode,"move"); aAttrib.add(multi_tag,"multiple"); aAttrib.add(warp_tag,"warp"); aAttrib.add(append_tag,"append"); aAttrib.put(cur); bool append_run =(append_tag == "yes"); bitset<3> WhatToDo; WhatToDo[SPACEWARP_MODE]= (warp_tag == "yes"); WhatToDo[MULTIPLE_MODE]= (multi_tag == "yes"); WhatToDo[UPDATE_MODE]= (update_mode == "pbyp"); QMCRunType newRunType = DUMMY_RUN; if(curName != "qmc") qmc_mode=curName; int nchars=qmc_mode.size(); if(qmc_mode.find("opt") < nchars) { newRunType=OPTIMIZE_RUN; } else { if(qmc_mode.find("vmc")<nchars) { newRunType=VMC_RUN; } else if(qmc_mode.find("dmc")<nchars) { newRunType=DMC_RUN; } else if(qmc_mode.find("rmc")<nchars) { newRunType=RMC_RUN; } if(qmc_mode.find("ptcl")<nchars) WhatToDo[UPDATE_MODE]=1; if(qmc_mode.find("mul")<nchars) WhatToDo[MULTIPLE_MODE]=1; if(qmc_mode.find("warp")<nchars) WhatToDo[SPACEWARP_MODE]=1; } unsigned long newQmcMode=WhatToDo.to_ulong(); //initialize to 0 QMCDriver::BranchEngineType* branchEngine=0; if(qmcDriver) { if(newRunType != curRunType || newQmcMode != curQmcMode) { //copy the pointer of the BranchEngine branchEngine=qmcDriver->getBranchEngine(); //remove the qmcDriver delete qmcDriver; //set to 0 so that a new driver is created qmcDriver = 0; //if the current qmc method is different from the previous one, append_run is set to false append_run = false; } else { app_log() << " Reusing " << qmcDriver->getEngineName() << endl; } } if(curSeries == 0) append_run = false; //carryon with the existing qmcDriver if(qmcDriver) return append_run; //need to create a qmcDriver curRunType = newRunType; curQmcMode = newQmcMode; curQmcModeBits = WhatToDo; createQMCDriver(cur); if(qmcComm) qmcDriver->setCommunicator(qmcComm); else qmcDriver->setCommunicator(OHMMS::Controller); //branchEngine has to be transferred to a new QMCDriver if(branchEngine) qmcDriver->setBranchEngine(branchEngine); return append_run; }