Changeset 73f80e for src


Ignore:
Timestamp:
Apr 27, 2008, 12:59:18 PM (17 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:
206887
Parents:
cf959d
Message:

new elementsdb-switch and command line options parsing parts moved around to accomodate.

New switch (just sets a variable) made some moving around necessary. Elements db cannot be parsed right at the start anymore, neither the config file before the command line switches. Hence, the following is now in operation:

  1. first parse through all options for stuff just setting variables, giving help et al
  2. parse elements db
  3. parse config file if present
  4. parse again through options for those that actually operate on a given configuration or add atoms (parsing xyz) ...

This was necessary, as 'make check' could not be made workable otherwise and its "bad behaviour" if the code assumes the elements.db to be in the same dir as the exe.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/builder.cpp

    rcf959d r73f80e  
    694694  ofstream output;
    695695
     696  cout << Verbose(0) << "Storing configuration ... " << endl;
    696697  // get correct valence orbitals
    697698  mol->CalculateOrbitals(*configuration);
     
    746747  char filename[255];
    747748  char *ConfigFileName = NULL;
     749  char *ElementsFileName = NULL;
    748750  int flag = 1;
    749751  int Z;
     
    757759  element **Elements;
    758760  vector **Vectors;
    759 
    760   // load element list
    761   periode->LoadPeriodentafel();
    762   cout << Verbose(1) << "Element list loaded." << endl; 
    763  
    764   // parse config file if given
     761  int argptr;
     762
     763  // =========================== PARSE COMMAND LINE OPTIONS ====================================
    765764  if (argc >= 1) { // config file specified as option
    766         if (argv[argc-1][0] != '-') {
     765    // 1. : Parse options that just set variables or print help
     766        argptr = 1;
     767        do {
     768          if (argv[argptr][0] == '-') {
     769        cout << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n";
     770        argptr++;
     771        switch(argv[argptr-1][1]) {
     772          case 'h':
     773          case 'H':
     774          case '?':
     775            cout << "MoleCuilder suite" << endl << "==================" << endl << endl;
     776            cout << "Usage: " << argv[0] << "[-{acepsthH?vfrp}] [further arguments] [config file]" << endl;
     777            cout << "or simply " << argv[0] << " without arguments for interactive session." << endl;
     778            cout << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl;
     779            cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
     780            cout << "\t-e <file>\tSets the element database to be parsed from this file (default: elements.db in same dir as " << argv[0] << ")." << endl;
     781            cout << "\t-h/-H/-?\tGive this help screen." << endl;
     782            cout << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl;
     783            cout << "\t-r\t\tConvert file from an old pcp syntax." << endl;
     784            cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl;
     785            cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
     786            cout << "\t-v/-V\t\tGives version information." << endl;
     787            return 0;
     788            break;
     789          case 'v':
     790          case 'V':
     791            cout << argv[0] << " " << VERSIONSTRING << endl;
     792            cout << "Build your own molecule position set." << endl;
     793            return 0;
     794            break;
     795          case 'e':
     796            cout << "Using " << argv[argptr] << " as elements database." << endl;
     797            ElementsFileName = argv[argptr];
     798            argptr+=1;
     799            break;
     800          default:   // no match? Step on
     801            argptr++;
     802            break;
     803        }
     804          } else
     805            argptr++;
     806    } while (argptr < (argc-1));
     807        // 2. Parse the element database
     808    if (periode->LoadPeriodentafel(ElementsFileName))
     809      cout << Verbose(0) << "Element list loaded successfully." << endl;
     810    else
     811      cout << Verbose(0) << "Element list loading failed." << endl;
     812        // 3. Find config file name and parse if possible
     813    if (argv[argc-1][0] != '-') {
    767814      cout << Verbose(0) << "Config file given." << endl;
    768815      test.open(argv[argc-1], ios::in);
     
    799846        test.close();
    800847      }
    801         } else
    802           config_present = absent;
    803         int argptr = 1;
    804         do {
    805           if (argv[argptr][0] == '-') {
    806         cout << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n";
     848    } else
     849      config_present = absent;
     850    // 4. parse again through options, now for those depending on elements db and config presence
     851    argptr = 1;
     852    do {
     853      if (argv[argptr][0] == '-') {
    807854        argptr++;
    808         switch(argv[argptr-1][1]) {
    809           case 'h':
    810           case 'H':
    811           case '?':
    812             cout << "MoleCuilder suite" << endl << "==================" << endl << endl;
    813             cout << "Usage: " << argv[0] << "[-{acsthH?vfrp}] [further arguments] [config file]" << endl;
    814             cout << "or simply " << argv[0] << " without arguments for interactive session." << endl;
    815             cout << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl;
    816             cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
    817             cout << "\t-h/-H/-?\tGive this help screen." << endl;
    818             cout << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl;
    819             cout << "\t-r\t\tConvert file from an old pcp syntax." << endl;
    820             cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl;
    821             cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
    822             cout << "\t-v/-V\t\tGives version information." << endl;
    823             return 0;
    824             break;
    825           case 'v':
    826           case 'V':
    827             cout << argv[0] << " " << VERSIONSTRING << endl;
    828             cout << "Build your own molecule position set." << endl;
    829             return 0;
    830             break;
    831           default:   
    832             break;
    833         }
    834855        if ((config_present == present) || (config_present == empty)) {
    835856          switch(argv[argptr-1][1]) {
     
    840861              else
    841862                cout << Verbose(2) << "File found and parsed." << endl;
     863                config_present = present;
    842864              break;
    843             default:
     865            default:   // no match? Don't step on (this is done in next switch's default)
    844866              break;
    845867          }
     
    965987                }
    966988                break;
    967               default:
     989              default:   // no match? Step on
     990                argptr++;
    968991                break;
    969992            }
     
    9911014    }
    9921015  }
     1016
     1017  // =========================== START INTERACTIVE SESSION ====================================
    9931018
    9941019  // now the main construction loop
     
    11971222 
    11981223  // save element data base
    1199   if (periode->StorePeriodentafel())
     1224  if (periode->StorePeriodentafel()) //ElementsFileName
    12001225    cout << Verbose(0) << "Saving of elements.db successful." << endl;
    12011226  else
Note: See TracChangeset for help on using the changeset viewer.