Changeset 5fa1f0


Ignore:
Timestamp:
Jul 6, 2012, 10:18:44 AM (13 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
6c52d2
Parents:
0aaf84
git-author:
Frederik Heber <heber@…> (06/01/12 16:45:25)
git-committer:
Frederik Heber <heber@…> (07/06/12 10:18:44)
Message:

Outsourced DefaultOptions, ControllerOptions, ControllerOptions_SystemCommandJob, and ControllerOptions_MPQCCommandJob, into own modules.

Location:
src
Files:
8 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/Makefile.am

    r0aaf84 r5fa1f0  
    381381  Fragmentation/Automation/Pool/WorkerPool.hpp
    382382
    383 Controller_SOURCES = $(CONTROLLERSOURCE) $(CONTROLLERHEADER) controller.cpp
    384 Controller_LDFLAGS = $(AM_LDFLAGS) $(BOOST_ASIO_LDFLAGS) $(BOOST_SYSTEM_LDFLAGS) $(BOOST_THREAD_LDFLAGS) $(BOOST_SERIALIZATION_LDFLAGS)
     383Controller_SOURCES = $(CONTROLLERSOURCE) $(CONTROLLERHEADER) controller.cpp DefaultOptions.cpp DefaultOptions.hpp ControllerOptions.cpp ControllerOptions.hpp ControllerOptions_MPQCCommandJob.cpp ControllerOptions_MPQCCommandJob.hpp ControllerOptions_SystemCommandJob.cpp ControllerOptions_SystemCommandJob.hpp
     384Controller_LDFLAGS = $(AM_LDFLAGS) $(BOOST_PROGRAM__OPTIONS_LDFLAGS) $(BOOST_SYSTEM_LDFLAGS) $(BOOST_THREAD_LDFLAGS) $(BOOST_SERIALIZATION_LDFLAGS)
    385385Controller_CXXFLAGS = $(AM_CPPFLAGS)
    386386Controller_LDADD = \
  • src/controller.cpp

    r0aaf84 r5fa1f0  
    4949#include "Fragmentation/Automation/Jobs/SystemCommandJob.hpp"
    5050#include "Fragmentation/Automation/Results/FragmentResult.hpp"
     51#include "ControllerOptions_MPQCCommandJob.hpp"
    5152
    5253/** Print the status of scheduled and done jobs.
     
    287288}
    288289
    289 struct DefaultOptions
    290 {
    291   int parseHelp(boost::program_options::variables_map &vm, const boost::program_options::options_description &desc) {
    292     if (vm.count("help")) {
    293       std::cout << desc << "\n";
    294       return 1;
    295     }
    296     return 0;
    297   }
    298   int parseVerbosity(boost::program_options::variables_map &vm) {
    299     if (vm.count("verbosity")) {
    300       LOG(0, "STATUS: Verbosity level was set to " << vm["verbosity"].as<size_t>() << ".");
    301       setVerbosity(vm["verbosity"].as<size_t>());
    302     } else {
    303       LOG(0, "STATUS: Verbosity level was not set, defaulting to 5.");
    304       setVerbosity(5);
    305     }
    306     return 0;
    307   }
    308 };
    309 
    310 struct ControllerOptions : public DefaultOptions
    311 {
    312   int parseServerPort(boost::program_options::variables_map &vm) {
    313     if (vm.count("server")) {
    314       server = vm["server"].as< std::string >();
    315       serverport = server.substr(server.find_last_of(':')+1, std::string::npos);
    316       server = server.substr(0, server.find_last_of(':'));
    317       try {
    318         boost::lexical_cast<size_t>(serverport);
    319       } catch (boost::bad_lexical_cast &) {
    320         ELOG(1, "Could not interpret " << serverport << " as server:port.");
    321         return 255;
    322       }
    323       LOG(1, "INFO: Using " << server << ":" << serverport << " as server's address.");
    324     } else {
    325       ELOG(1, "Requiring server's address (host:port) to connect to.");
    326       return 255;
    327     }
    328     return 0;
    329   }
    330 
    331   int parseCommand(boost::program_options::variables_map &vm, const std::vector<std::string> &Commands) {
    332     if (!vm.count("command")) {
    333       ELOG(1, "Controller requires one of the following commands: "+toString(Commands));
    334       return 255;
    335     }
    336     command = vm["command"].as< std::string >();
    337     return 0;
    338   }
    339 
    340   std::string command;
    341   std::string server;
    342   std::string serverport;
    343 
    344 };
    345 
    346 struct ControllerOptions_SystemCommandJob : public ControllerOptions
    347 {
    348   int parseExecutable(boost::program_options::variables_map &vm) {
    349     if ((command == "createjobs") || (command == "addjobs")) {
    350       if (!vm.count("executable")) {
    351         ELOG(1, "'"+command+"' requires two options: [executable] [jobcommand].");
    352         return 255;
    353       }
    354       executable = vm["executable"].as< std::string >();
    355     }
    356     return 0;
    357   }
    358 
    359   int parseJobCommand(boost::program_options::variables_map &vm) {
    360     if (command == "createjobs") {
    361       if (!vm.count("jobcommand")) {
    362         ELOG(1, "'"+command+"' requires two options: [executable] [jobcommand].");
    363         return 255;
    364       }
    365       jobcommand = vm["jobcommand"].as< std::string >();
    366     }
    367     return 0;
    368   }
    369 
    370   std::string executable;
    371   std::string jobcommand;
    372 };
    373 
    374 struct ControllerOptions_MPQCCommandJob : public ControllerOptions_SystemCommandJob
    375 {
    376   int parseFragmentpath(boost::program_options::variables_map &vm) {
    377     if (command == "receivempqc") {
    378       if (!vm.count("fragment-path")) {
    379         ELOG(1, "'"+command+"' requires two options: [fragment-path].");
    380         return 255;
    381       }
    382       fragmentpath = vm["fragment-path"].as< std::string >();
    383     }
    384     return 0;
    385   }
    386 
    387   int parseJobfiles(boost::program_options::variables_map &vm) {
    388     if (command == "addjobs") {
    389       if (!vm.count("jobfiles")) {
    390         ELOG(1, "'"+command+"' requires two options: [executable] [jobfiles].");
    391         return 255;
    392       }
    393       jobfiles = vm["jobfiles"].as< std::vector<std::string> >();
    394     }
    395     return 0;
    396   }
    397 
    398   std::string fragmentpath;
    399   std::vector<std::string> jobfiles;
    400 };
    401 
    402290void creatingJob(FragmentController &controller, const ControllerOptions_SystemCommandJob &ControllerInfo)
    403291{
     
    517405
    518406  // set controller information
    519   ControllerInfo.parseHelp(vm, desc);
    520   ControllerInfo.parseVerbosity(vm);
    521   ControllerInfo.parseServerPort(vm);
    522   ControllerInfo.parseCommand(vm, Commands);
     407  int status = 0;
     408  status = ControllerInfo.parseHelp(vm, desc);
     409  if (status) return status;
     410  status = ControllerInfo.parseVerbosity(vm);
     411  if (status) return status;
     412  status = ControllerInfo.parseServerPort(vm);
     413  if (status) return status;
     414  status = ControllerInfo.parseCommand(vm, Commands);
     415  if (status) return status;
    523416
    524417  // all later parse functions depend on parsed command
    525   ControllerInfo.parseExecutable(vm);
    526 
    527   ControllerInfo.parseJobCommand(vm);
    528 
    529   ControllerInfo.parseFragmentpath(vm);
    530 
    531   ControllerInfo.parseJobfiles(vm);
     418  status = ControllerInfo.parseExecutable(vm);
     419  if (status) return status;
     420  status = ControllerInfo.parseJobCommand(vm);
     421  if (status) return status;
     422  status = ControllerInfo.parseFragmentpath(vm);
     423  if (status) return status;
     424  status = ControllerInfo.parseJobfiles(vm);
     425  if (status) return status;
    532426
    533427  // parse given ControllerCommand
Note: See TracChangeset for help on using the changeset viewer.