713{
714 std::string extTasksFile = _tasksFile;
715 std::string extMechanicsFile = _mechanicsFile;
716 std::string extDefaultsFile = _defaultsFile;
717 std::string extSwitchersFile = _switchersFile;
718
719 if (
723 )
724 {
725 std::stringstream tasksFile(
Preprocessor(extTasksFile).resultString);
726 std::stringstream defaultsFile(
Preprocessor(extDefaultsFile).resultString);
727 std::stringstream switchersFile(
Preprocessor(extSwitchersFile).resultString);
728 std::vector<std::string> taskFolder;
729
730 std::unique_ptr<StreamParser> parserTaskList;
731 parserTaskList.reset(
new StreamParser(
info,
"parser", tasksFile,
'(',
')'));
732
733 std::vector<std::string> alltasks;
734 parserTaskList->get("problems", alltasks);
735
736 std::ptrdiff_t nTasks = std::count_if(alltasks.begin(), alltasks.end(), [](const std::string& a) {return (a.length() > 0);});
738 info(
'i') <<
"Number of problems to be solved: " << nTasks << std::endl;
739
740 for (size_t i = 0; i < alltasks.size(); ++i)
741 {
742 if (alltasks[i].length() > 0)
743 {
744
746
747 std::string dir = taskLine.first;
748
750 info(
'i') <<
"-------- Loading problem #" << i <<
" (" << dir <<
") --------" << std::endl;
751
752
754
755
757 std::unique_ptr<StreamParser> parserTask;
758
759 parserTask.reset(
new StreamParser(
info,
"problem parameters", tskStream, defaultsFile, {
"pspfile",
"np",
"copyPath"}));
760
761 std::string pspFile;
762 int np;
763
764
767
768 if (np > 1)
769 {
771 info(
'e') <<
"Internal MPI-parallelization is not supported longer!" << std::endl;
772 exit(-1);
773 }
774
775 std::string copyPath;
777 if (copyPath.length() > 0)
778 {
779
781 {
782 std::string initDir(copyPath.begin(), copyPath.end());
783 std::string command;
784
785#if defined(_WIN32)
786 std::replace(dir.begin(), dir.end(), '/', '\\');
787 std::replace(initDir.begin(), initDir.end(), '/', '\\');
788#endif
789
791
792#if defined(_WIN32)
793 command = "copy \"" + initDir + "\\*.*\" "+ dir + "\\";
794#else
795 command = "cp ./" + initDir + "/* " + dir + "/";
796#endif
797
798 std::cout << "Copying files from folder \"" << initDir << "\" to \"" << dir << "\"" << std::endl;
799
800 int systemRet = system(command.c_str());
801 if(systemRet == -1)
802 {
803
804 info(
'e') <<
"problem #" << i <<
" (" << dir << \
805 ") copying passport system method failed" << std::endl;
806 exit(-1);
807 }
808 std::cout << "Copying OK " << std::endl << std::endl;
809
810
811 }
812 }
813
814#ifdef USE_MPI
815 MPI_Barrier(MPI_COMM_WORLD);
816#endif
817
818 std::unique_ptr<PassportGen> ptrPsp;
819
820#ifdef CODE2D
821 ptrPsp.reset(
new VM2D::Passport(
info, dir, i, pspFile, extMechanicsFile, extDefaultsFile, extSwitchersFile, vecTaskLineSecond));
822#endif
823
824#ifdef CODE3D
825 ptrPsp.reset(
new VM3D::Passport(
info, dir, i, pspFile, extMechanicsFile, extDefaultsFile, extSwitchersFile, vecTaskLineSecond));
826#endif
827
828 AddTask(np, std::move(ptrPsp));
829
830 info(
'i') <<
"-------- Problem #" << i <<
" (" << dir <<
") is loaded --------" << std::endl << std::endl;
831 }
832 }
833
834
835 tasksFile.clear();
836
837
838 defaultsFile.clear();
839
840
841 switchersFile.clear();
842
843 }
844 else
845 {
846 exit(1);
847 }
848
849}
void endl()
Вывод в поток логов пустой строки
Класс, позволяющий выполнять предварительную обработку файлов
void AddTask(int _nProc, std::unique_ptr< PassportGen > _passport)
Добавление задачи в список
Класс, позволяющий выполнять разбор файлов и строк с настройками и параметрами
static std::vector< std::string > StringToVector(std::string line, char openBracket='(', char closeBracket=')')
Pазбор строки, содержащей запятые, на отдельные строки
static std::pair< std::string, std::string > SplitString(LogStream &info, std::string line, bool upcase=true)
Разбор строки на пару ключ-значение
static std::string VectorStringToString(const std::vector< std::string > &_vecString)
Объединение вектора (списка) из строк в одну строку
bool fileExistTest(std::string &fileName, LogStream &info, bool exitKey=false, const std::list< std::string > &extList={})
Проверка существования файла
void CreateDirectory(const std::string &dir, const std::string &name)
Создание каталога
const int defaultNp
Необходимое число процессоров для решения задачи
const std::string defaultCopyPath
Путь к каталогу с задачей для копирования в новые каталоги
const std::string defaultPspFile
Имя файла с паспортом задачи