Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/builder.cpp

    r97ebf8 r50dfda  
    7777#include "Actions/ActionRegistry.hpp"
    7878#include "Actions/ActionHistory.hpp"
    79 #include "Actions/MapOfActions.hpp"
    8079#include "Actions/MethodAction.hpp"
    8180#include "Actions/MoleculeAction/ChangeNameAction.hpp"
     
    14811480
    14821481/** Parses the command line options.
    1483  * Note that this function is from now on transitional. All commands that are not passed
    1484  * here are handled by CommandLineParser and the actions of CommandLineUIFactory.
    14851482 * \param argc argument count
    14861483 * \param **argv arguments array
     
    14901487 * \param *ConfigFileName pointer to config file name in **argv
    14911488 * \param *PathToDatabases pointer to db's path in **argv
    1492  * \param &ArgcList list of arguments that we do not parse here
    14931489 * \return exit code (0 - successful, all else - something's wrong)
    14941490 */
    1495 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,
    1496                                    config& configuration, char *&ConfigFileName, list<int> &ArgcList)
     1491static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,\
     1492                                   config& configuration, char *&ConfigFileName)
    14971493{
    14981494  Vector x,y,z,n;  // coordinates for absolute point in cell volume
     
    15121508  molecule *mol = NULL;
    15131509  string BondGraphFileName("\n");
     1510  int verbosity = 0;
    15141511  strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1);
    15151512
     
    15251522          case 'H':
    15261523          case '?':
    1527             ArgcList.push_back(argptr-1);
    1528             return(1);
     1524            DoLog(0) && (Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl);
     1525            DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl);
     1526            DoLog(0) && (Log() << Verbose(0) << "or simply " << argv[0] << " without arguments for interactive session." << endl);
     1527            DoLog(0) && (Log() << Verbose(0) << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl);
     1528            DoLog(0) && (Log() << Verbose(0) << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl);
     1529            DoLog(0) && (Log() << Verbose(0) << "\t-b xx xy xz yy yz zz\tCenter atoms in domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl);
     1530            DoLog(0) && (Log() << Verbose(0) << "\t-B xx xy xz yy yz zz\tBound atoms by domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl);
     1531            DoLog(0) && (Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl);
     1532            DoLog(0) && (Log() << Verbose(0) << "\t-C <type> [params] <output> <bin output> <BinWidth> <BinStart> <BinEnd>\tPair Correlation analysis." << endl);
     1533            DoLog(0) && (Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl);
     1534            DoLog(0) && (Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl);
     1535            DoLog(0) && (Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl);
     1536            DoLog(0) && (Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl);
     1537            DoLog(0) && (Log() << Verbose(0) << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl);
     1538            DoLog(0) && (Log() << Verbose(0) << "\t-F <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl);
     1539            DoLog(0) && (Log() << Verbose(0) << "\t-FF <MaxDistance> <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl);
     1540            DoLog(0) && (Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl);
     1541            DoLog(0) && (Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl);
     1542            DoLog(0) && (Log() << Verbose(0) << "\t-I\t Dissect current system of molecules into a set of disconnected (subgraphs of) molecules." << endl);
     1543            DoLog(0) && (Log() << Verbose(0) << "\t-j\t<path> Store all bonds to file." << endl);
     1544            DoLog(0) && (Log() << Verbose(0) << "\t-J\t<path> Store adjacency per atom to file." << endl);
     1545            DoLog(0) && (Log() << Verbose(0) << "\t-L <step0> <step1> <prefix>\tStore a linear interpolation between two configurations <step0> and <step1> into single config files with prefix <prefix> and as Trajectories into the current config file." << endl);
     1546            DoLog(0) && (Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl);
     1547            DoLog(0) && (Log() << Verbose(0) << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl);
     1548            DoLog(0) && (Log() << Verbose(0) << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl);
     1549            DoLog(0) && (Log() << Verbose(0) << "\t-N <radius> <file>\tGet non-convex-envelope." << endl);
     1550            DoLog(0) && (Log() << Verbose(0) << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl);
     1551            DoLog(0) && (Log() << Verbose(0) << "\t-O\tCenter atoms in origin." << endl);
     1552            DoLog(0) && (Log() << Verbose(0) << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl);
     1553            DoLog(0) && (Log() << Verbose(0) << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl);
     1554            DoLog(0) && (Log() << Verbose(0) << "\t-r <id>\t\tRemove an atom with given id." << endl);
     1555            DoLog(0) && (Log() << Verbose(0) << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl);
     1556            DoLog(0) && (Log() << Verbose(0) << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl);
     1557            DoLog(0) && (Log() << Verbose(0) << "\t-S <file> Store temperatures from the config file in <file>." << endl);
     1558            DoLog(0) && (Log() << Verbose(0) << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl);
     1559            DoLog(0) && (Log() << Verbose(0) << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl);
     1560            DoLog(0) && (Log() << Verbose(0) << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl);
     1561            DoLog(0) && (Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl);
     1562            DoLog(0) && (Log() << Verbose(0) << "\t-V\t\tGives version information." << endl);
     1563            DoLog(0) && (Log() << Verbose(0) << "\t-X\t\tset default name of a molecule." << endl);
     1564            DoLog(0) && (Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl);
     1565            return (1);
    15291566            break;
    15301567          case 'v':
    1531             ArgcList.push_back(argptr-1);
    1532             return(1);
     1568            while (argv[argptr-1][verbosity+1] == 'v') {
     1569              verbosity++;
     1570            }
     1571            setVerbosity(verbosity);
     1572            DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
    15331573            break;
    15341574          case 'V':
    1535             ArgcList.push_back(argptr-1);
    1536             ArgcList.push_back(argptr);
    1537             argptr++;
     1575            DoLog(0) && (Log() << Verbose(0) << argv[0] << " " << VERSIONSTRING << endl);
     1576            DoLog(0) && (Log() << Verbose(0) << "Build your own molecule position set." << endl);
     1577            return (1);
    15381578            break;
    15391579          case 'B':
     
    24752515
    24762516void cleanUp(){
     2517  UIFactory::purgeInstance();
    24772518  World::purgeInstance();
    24782519  Log() << Verbose(0) <<  "Maximum of allocated memory: "
     
    24832524  logger::purgeInstance();
    24842525  errorLogger::purgeInstance();
    2485   UIFactory::purgeInstance();
    2486   MapOfActions::purgeInstance();
    24872526  CommandLineParser::purgeInstance();
    24882527  ActionRegistry::purgeInstance();
     
    24972536    ofstream output;
    24982537    string line;
    2499     char **Arguments = NULL;
    2500     int ArgcSize = 0;
    2501     bool ArgumentsCopied = false;
    25022538
    25032539    cout << ESPACKVersion << endl;
     
    25072543    ActionHistory::init();
    25082544
    2509     // Parse command line options and if present create respective UI
    25102545    {
    2511       list<int> ArgcList;
    2512       ArgcList.push_back(0); // push back program!
    2513       ArgcList.push_back(1); // push back config file name
    2514       char ConfigFileName[MAXSTRINGSIZE];
    2515       // handle arguments by ParseCommandLineOptions()
    2516       ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), (char *&)ConfigFileName, ArgcList);
    2517       // copy all remaining arguments to a new argv
    2518       Arguments = Malloc<char *>(ArgcList.size(), "main - **Arguments");
    2519       cout << "The following arguments are handled by CommandLineParser: ";
    2520       for (list<int>::iterator ArgcRunner = ArgcList.begin(); ArgcRunner != ArgcList.end(); ++ArgcRunner) {
    2521         Arguments[ArgcSize] = Malloc<char>(strlen(argv[*ArgcRunner])+2, "main - *Arguments[]");
    2522         strcpy(Arguments[ArgcSize], argv[*ArgcRunner]);
    2523         cout << " " << argv[*ArgcRunner];
    2524         ArgcSize++;
    2525       }
    2526       cout << endl;
    2527       ArgumentsCopied = true;
    2528       // handle remaining arguments by CommandLineParser
    2529       MapOfActions::getInstance().AddOptionsToParser();
    2530       CommandLineParser::getInstance().Run(ArgcSize,Arguments);
    2531       if (!CommandLineParser::getInstance().isEmpty()) {
    2532         DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl);
     2546      // Parse command line options and if present create respective UI
     2547      CommandLineParser::getInstance().generic.add_options()
     2548          ("help,h", "produce help message")
     2549          ("version,v", "show version")
     2550          ("parse-xyz,p", po::value< vector<string> >(), "parse xyz file into World")
     2551          ;
     2552      CommandLineParser::getInstance().Run(argc,argv);
     2553      if (!CommandLineParser::getInstance().isEmpty())
    25332554        UIFactory::makeUserInterface(UIFactory::CommandLine);
    2534       } else {
    2535         DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl);
     2555      else
    25362556        UIFactory::makeUserInterface(UIFactory::Text);
    2537       }
    25382557    }
    25392558
     
    25502569        Log() << Verbose(0) << "Saving of elements.db failed." << endl;
    25512570
    2552   // free the new argv
    2553   if (ArgumentsCopied) {
    2554     for (int i=0; i<ArgcSize;i++)
    2555       Free(&Arguments[i]);
    2556     Free(&Arguments);
    2557   }
    2558 
    25592571  cleanUp();
     2572
    25602573  Memory::getState();
    25612574  return (0);
Note: See TracChangeset for help on using the changeset viewer.