source: src/builder.cpp@ 0d1ad0

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
Last change on this file since 0d1ad0 was a356f2, checked in by Frederik Heber <heber@…>, 15 years ago

Cleaned up builder.cpp

  • ParseComandLineOptions() along with the already #ifdef 0'd functions removed from builder.cpp
  • DOCU: Rewrote introductory to Molecuilder.

Signed-off-by: Frederik Heber <heber@…>

  • Property mode set to 100755
File size: 6.6 KB
RevLine 
[14de469]1/** \file builder.cpp
[a8bcea6]2 *
[a356f2]3 * date: Jan 1, 2007
4 * author: heber
[a8bcea6]5 *
[14de469]6 */
7
[a356f2]8/*! \mainpage MoleCuilder - a molecular set builder
[a8bcea6]9 *
[a356f2]10 * This introductory shall briefly make acquainted with the program, helping in installing and a first run.
[a8bcea6]11 *
[14de469]12 * \section about About the Program
[a8bcea6]13 *
[a356f2]14 * MoleCuilder is a program, written entirely in C++, that enables the construction of a coordinate set for the
15 * atoms making up an molecule. It allows for both building of simple molecules by adding atom-wise giving bond
16 * angles and distances or absolute coordinates, but also using them as templates. Regions can be specified and
17 * ordered to be filled with a molecule in a certain manner. Greater conglomerations of molecules can be tesselated
18 * and recognized as a region themselves to be subsequently surrounded by other (surface solvated) molecules.
19 * In the end, MoleCuilder allows the construction of arbitrary nano structures, whether they be crystalline or
20 * amorphic in nature.
[a8bcea6]21 *
22 *
[14de469]23 * \section install Installation
[a8bcea6]24 *
[042f82]25 * Installation should without problems succeed as follows:
26 * -# ./configure (or: mkdir build;mkdir run;cd build; ../configure --bindir=../run)
27 * -# make
28 * -# make install
[a8bcea6]29 *
[042f82]30 * Further useful commands are
31 * -# make clean uninstall: deletes .o-files and removes executable from the given binary directory\n
32 * -# make doxygen-doc: Creates these html pages out of the documented source
[a356f2]33 * -# make check: Runs an extensive set of unit tests and a testsuite which also gives a good overview on the set of
34 * functions.
[a8bcea6]35 *
[14de469]36 * \section run Running
[a8bcea6]37 *
[042f82]38 * The program can be executed by running: ./molecuilder
[a8bcea6]39 *
[a356f2]40 * MoleCuilder has three interfaces at your disposal:
41 * -# Textmenu: A simple interactive console-based menu, where awaits your choices and inputs in order to set atoms
42 * as you like
43 * -# CommandLineUI: Every command can also be chained up as a sequence of actions on the command line to be executed
44 * with any user interaction.
45 * -# GraphicalUI: A graphical user interface that also display the molecular structure being built and lots of other
46 * informations to ease the construction of bigger geometries.
[a8bcea6]47 *
[a356f2]48 * The supported output formats right now are:
49 * -# mpqc: Configuration files of the Massively Parallel Quantum Chemistry package (Sandia labs)
50 * -# pcp: Configuration files of the Parallel Car-Parrinello program (Institute for Numerical Simulation)
51 * -# tremolo: Configuration files of TREMOLO (Institute for Numerical Simulation)
52 * -# xyz: the most basic format for the 3d arrangement of atoms consisting of a list of element and 3 coordinates.
[a8bcea6]53 *
[14de469]54 */
55
[112b09]56#include "Helpers/MemDebug.hpp"
[14de469]57
[b70721]58#include "bondgraph.hpp"
[c6efc1]59#include "CommandLineParser.hpp"
[f66195]60#include "config.hpp"
[e138de]61#include "log.hpp"
[a356f2]62#include "verbose.hpp"
63#include "World.hpp"
64
[12b845]65#include "Actions/ActionRegistry.hpp"
[d56640]66#include "Actions/ActionHistory.hpp"
[97ebf8]67#include "Actions/MapOfActions.hpp"
[042f82]68
[a356f2]69#include "Parser/ChangeTracker.hpp"
70#include "Parser/FormatParserStorage.hpp"
[1f1b23]71
[a356f2]72#include "UIElements/UIFactory.hpp"
73#include "UIElements/TextUI/TextUIFactory.hpp"
74#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
75#include "UIElements/MainWindow.hpp"
76#include "UIElements/Dialog.hpp"
[1f1b23]77
[a356f2]78#include "version.h"
[1f1b23]79
[ca2b83]80
81/********************************************** Main routine **************************************/
[14de469]82
[148d8f0]83void cleanUp(){
[35b698]84 FormatParserStorage::purgeInstance();
[a1e929]85 ChangeTracker::purgeInstance();
[23b547]86 World::purgeInstance();
[354859]87 logger::purgeInstance();
88 errorLogger::purgeInstance();
[97ebf8]89 UIFactory::purgeInstance();
90 MapOfActions::purgeInstance();
[c6efc1]91 CommandLineParser::purgeInstance();
[e73a8a2]92 ActionRegistry::purgeInstance();
[632bc3]93 ActionHistory::purgeInstance();
[cd5047]94#ifdef LOG_OBSERVER
95 cout << observerLog().getLog();
96#endif
[68f03d]97 Memory::getState();
[354859]98}
99
[ca2b83]100int main(int argc, char **argv)
101{
[a356f2]102 // while we are non interactive, we want to abort from asserts
103 //ASSERT_DO(Assert::Abort);
104 string line;
105 char **Arguments = NULL;
106 int ArgcSize = 0;
107 int ExitFlag = 0;
108 bool ArgumentsCopied = false;
109 std::string BondGraphFileName("\n");
110 FormatParserStorage::getInstance().addMpqc();
111 FormatParserStorage::getInstance().addPcp();
112 FormatParserStorage::getInstance().addXyz();
113
114 // print version check whether arguments are present at all
115 cout << ESPACKVersion << endl;
116 if (argc < 2) {
117 cout << "Obtain help with " << argv[0] << " -h." << endl;
118 cleanUp();
119 Memory::getState();
120 return(1);
121 }
122
123
124 setVerbosity(0);
125 // need to init the history before any action is created
126 ActionHistory::init();
127
128 // In the interactive mode, we can leave the user the choice in case of error
129 ASSERT_DO(Assert::Ask);
130
131 // from this moment on, we need to be sure to deeinitialize in the correct order
132 // this is handled by the cleanup function
133 atexit(cleanUp);
134
135 // Parse command line options and if present create respective UI
136 {
137 // construct bond graph
138 if (World::getInstance().getConfig()->BG == NULL) {
139 World::getInstance().getConfig()->BG = new BondGraph(World::getInstance().getConfig()->GetIsAngstroem());
140 if (World::getInstance().getConfig()->BG->LoadBondLengthTable(BondGraphFileName)) {
141 DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
[97ebf8]142 } else {
[a356f2]143 DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
[97ebf8]144 }
[c6efc1]145 }
[a356f2]146 // handle remaining arguments by CommandLineParser
147 MapOfActions::getInstance().AddOptionsToParser();
148 map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap();
149 CommandLineParser::getInstance().Run(argc,argv, ShortFormToActionMap);
150 if (!CommandLineParser::getInstance().isEmpty()) {
151 DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl);
152 UIFactory::registerFactory(new CommandLineUIFactory::description());
153 UIFactory::makeUserInterface("CommandLine");
154 } else {
155 DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl);
156 UIFactory::registerFactory(new TextUIFactory::description());
157 UIFactory::makeUserInterface("Text");
[12b845]158 }
[a356f2]159 }
160
161 {
162 MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow();
163 mainWindow->display();
164 delete mainWindow;
165 }
[6ac7ee]166
[a356f2]167 FormatParserStorage::getInstance().SaveAll();
168 ChangeTracker::getInstance().saveStatus();
[042f82]169
[97ebf8]170 // free the new argv
171 if (ArgumentsCopied) {
172 for (int i=0; i<ArgcSize;i++)
[920c70]173 delete[](Arguments[i]);
174 delete[](Arguments);
[97ebf8]175 }
[4f7f34e]176 //delete[](ConfigFileName);
[632bc3]177
[e4b5de]178 ExitFlag = World::getInstance().getExitFlag();
[99fcaf]179 return (ExitFlag == 1 ? 0 : ExitFlag);
[14de469]180}
181
182/********************************************** E N D **************************************************/
Note: See TracBrowser for help on using the repository browser.