Changeset 2e06c4 for molecuilder/src/builder.cpp
- Timestamp:
- May 15, 2010, 5:56:57 PM (16 years ago)
- Children:
- 356180, 494bf6
- Parents:
- dbec4e
- git-author:
- Frederik Heber <heber@…> (05/14/10 20:14:27)
- git-committer:
- Frederik Heber <heber@…> (05/15/10 17:56:57)
- File:
-
- 1 edited
-
molecuilder/src/builder.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/builder.cpp
rdbec4e r2e06c4 77 77 #include "Actions/ActionRegistry.hpp" 78 78 #include "Actions/ActionHistory.hpp" 79 #include "Actions/MapOfActions.hpp" 79 80 #include "Actions/MethodAction.hpp" 80 81 #include "Actions/MoleculeAction/ChangeNameAction.hpp" … … 1480 1481 1481 1482 /** 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. 1482 1485 * \param argc argument count 1483 1486 * \param **argv arguments array … … 1487 1490 * \param *ConfigFileName pointer to config file name in **argv 1488 1491 * \param *PathToDatabases pointer to db's path in **argv 1492 * \param &ArgcList list of arguments that we do not parse here 1489 1493 * \return exit code (0 - successful, all else - something's wrong) 1490 1494 */ 1491 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, \1492 config& configuration, char *&ConfigFileName )1495 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, 1496 config& configuration, char *&ConfigFileName, list<int> &ArgcList) 1493 1497 { 1494 1498 Vector x,y,z,n; // coordinates for absolute point in cell volume … … 1508 1512 molecule *mol = NULL; 1509 1513 string BondGraphFileName("\n"); 1510 int verbosity = 0;1511 1514 strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1); 1512 1515 … … 1522 1525 case 'H': 1523 1526 case '?': 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); 1527 ArgcList.push_back(argptr-1); 1528 return(1); 1566 1529 break; 1567 1530 case 'v': 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); 1531 ArgcList.push_back(argptr-1); 1532 return(1); 1573 1533 break; 1574 1534 case 'V': 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);1535 ArgcList.push_back(argptr-1); 1536 ArgcList.push_back(argptr); 1537 argptr++; 1578 1538 break; 1579 1539 case 'B': … … 2515 2475 2516 2476 void cleanUp(){ 2517 UIFactory::purgeInstance();2518 2477 World::purgeInstance(); 2519 2478 Log() << Verbose(0) << "Maximum of allocated memory: " … … 2524 2483 logger::purgeInstance(); 2525 2484 errorLogger::purgeInstance(); 2485 UIFactory::purgeInstance(); 2486 MapOfActions::purgeInstance(); 2526 2487 CommandLineParser::purgeInstance(); 2527 2488 ActionRegistry::purgeInstance(); … … 2536 2497 ofstream output; 2537 2498 string line; 2499 char **Arguments = NULL; 2500 int ArgcSize = 0; 2501 bool ArgumentsCopied = false; 2538 2502 2539 2503 cout << ESPACKVersion << endl; … … 2543 2507 ActionHistory::init(); 2544 2508 2509 // Parse command line options and if present create respective UI 2545 2510 { 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()) 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); 2554 2533 UIFactory::makeUserInterface(UIFactory::CommandLine); 2555 else 2534 } else { 2535 DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl); 2556 2536 UIFactory::makeUserInterface(UIFactory::Text); 2537 } 2557 2538 } 2558 2539 … … 2569 2550 Log() << Verbose(0) << "Saving of elements.db failed." << endl; 2570 2551 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 2571 2559 cleanUp(); 2572 2573 2560 Memory::getState(); 2574 2561 return (0);
Note:
See TracChangeset
for help on using the changeset viewer.
