Changeset 5b15ab
- Timestamp:
- Apr 29, 2008, 6:30:38 AM (17 years ago)
- 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:
- 2910e0
- Parents:
- 555063
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/builder.cpp
r555063 r5b15ab 748 748 char *ConfigFileName = NULL; 749 749 char *ElementsFileName = NULL; 750 int flag = 1;750 int flag = 0; 751 751 int Z; 752 752 int j, axis, count, faktor; … … 773 773 case 'H': 774 774 case '?': 775 flag=2; 775 776 cout << "MoleCuilder suite" << endl << "==================" << endl << endl; 776 777 cout << "Usage: " << argv[0] << "[-{acepsthH?vfrp}] [further arguments] [config file]" << endl; … … 785 786 cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl; 786 787 cout << "\t-v/-V\t\tGives version information." << endl; 787 return 0;788 cout << "Note: config files must not begin with '-' !" << endl; 788 789 break; 789 790 case 'v': 790 791 case 'V': 792 flag=2; 791 793 cout << argv[0] << " " << VERSIONSTRING << endl; 792 794 cout << "Build your own molecule position set." << endl; 793 return 0;794 795 break; 795 796 case 'e': … … 827 828 } 828 829 } else { 830 test.close(); 829 831 ConfigFileName = argv[argc-1]; 830 832 cout << Verbose(1) << "Specified config file found, parsing ..."; 831 switch (configuration.TestSyntax( &test, periode, mol)) {833 switch (configuration.TestSyntax(ConfigFileName, periode, mol)) { 832 834 case 1: 833 835 cout << "new syntax." << endl; 834 configuration.Load( &test, periode, mol);836 configuration.Load(ConfigFileName, periode, mol); 835 837 config_present = present; 836 838 break; 837 839 case 0: 838 840 cout << "old syntax." << endl; 839 configuration.LoadOld( &test, periode, mol);841 configuration.LoadOld(ConfigFileName, periode, mol); 840 842 config_present = present; 841 843 break; … … 844 846 config_present = empty; 845 847 } 846 test.close();847 848 } 848 849 } else … … 856 857 switch(argv[argptr-1][1]) { 857 858 case 'p': 859 flag = 1; 858 860 cout << Verbose(1) << "Parsing xyz file for new atoms." << endl; 859 861 if (!mol->AddXYZFile(argv[argptr++])) … … 871 873 switch(argv[argptr-1][1]) { 872 874 case 't': 875 flag = 1; 873 876 cout << Verbose(1) << "Translating all ions to new origin." << endl; 874 877 for (int i=0;i<3;i++) … … 878 881 break; 879 882 case 'a': 883 flag = 1; 880 884 cout << Verbose(1) << "Adding new atom." << endl; 881 885 first = new atom; … … 894 898 break; 895 899 case 's': 900 flag = 1; 896 901 j = -1; 897 902 cout << Verbose(1) << "Scaling all ion positions by factor." << endl; … … 914 919 break; 915 920 case 'c': 921 flag = 1; 916 922 j = -1; 917 923 cout << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl; … … 930 936 break; 931 937 case 'r': 938 flag = 1; 932 939 cout << Verbose(1) << "Converting config file from supposed old to new syntax." << endl; 933 940 break; 934 941 case 'f': 935 942 int i,j; 936 flag = 0;943 flag = 1; 937 944 if (argc > argptr+3) { 938 945 cout << Verbose(0) << "Creating connection matrix..." << endl; … … 998 1005 } else argptr++; 999 1006 } while (argptr < (argc-1)); 1000 if (flag )1007 if (flag == 1) // 1 means save and exit 1001 1008 SaveConfig(ConfigFileName, &configuration, periode, mol); 1002 delete(mol); 1003 delete(periode); 1004 return (0); 1009 if (flag > 1) { // 2 means just exit 1010 delete(mol); 1011 delete(periode); 1012 return (0); 1013 } 1005 1014 } 1006 1015 -
src/config.cpp
r555063 r5b15ab 16 16 defaultpath = (char *) MallocString(sizeof(char)*255,"config constructor: mainname"); 17 17 pseudopotpath = (char *) MallocString(sizeof(char)*255,"config constructor: mainname"); 18 configpath = (char *) MallocString(sizeof(char)*255,"config constructor: mainname"); 18 19 strcpy(mainname,"pcp"); 19 strcpy(defaultpath,"not specified 20 strcpy(pseudopotpath,"not specified 20 strcpy(defaultpath,"not specified"); 21 strcpy(pseudopotpath,"not specified"); 21 22 22 23 ProcPEGamma=8; … … 86 87 Free((void **)&defaultpath, "config::~config: *defaultpath"); 87 88 Free((void **)&pseudopotpath, "config::~config: *pseudopotpath"); 89 Free((void **)&configpath, "config::~config: *configpath"); 88 90 }; 89 91 … … 352 354 353 355 /** Tests whether a given configuration file adhears to old or new syntax. 354 * \param *file input file stream being the opened config file356 * \param *filename filename of config file to be tested 355 357 * \param *periode pointer to a periodentafel class with all elements 356 358 * \param *mol pointer to molecule containing all atoms of the molecule 357 359 * \return 0 - old syntax, 1 - new syntax, -1 - unknown syntax 358 360 */ 359 int config::TestSyntax( ifstream *file, periodentafel *periode, molecule *mol)361 int config::TestSyntax(char *filename, periodentafel *periode, molecule *mol) 360 362 { 361 363 int test; 364 ifstream file(filename); 365 362 366 // search file for keyword: ProcPEGamma (new syntax) 363 if (ParseForParameter(1,file,"ProcPEGamma", 0, 1, 1, int_type, &test, 1, optional)) 367 if (ParseForParameter(1,&file,"ProcPEGamma", 0, 1, 1, int_type, &test, 1, optional)) { 368 file.close(); 364 369 return 1; 370 } 365 371 // search file for keyword: ProcsGammaPsi (old syntax) 366 if (ParseForParameter(1,file,"ProcsGammaPsi", 0, 1, 1, int_type, &test, 1, optional)) 372 if (ParseForParameter(1,&file,"ProcsGammaPsi", 0, 1, 1, int_type, &test, 1, optional)) { 373 file.close(); 367 374 return 0; 375 } 376 file.close(); 368 377 return -1; 369 378 } … … 394 403 }; 395 404 405 /** Retrieves the path in the given config file name. 406 * \param *filename config file string 407 */ 408 void config::RetrieveConfigPath(char *filename) 409 { 410 int last = -1; 411 for(int i=0;i<255;i++) { 412 if (filename[i] == '/') 413 last = i; 414 if (filename[i] == '\0') 415 break; 416 } 417 if (last == -1) { // no path in front, set to local directory. 418 strcpy(configpath, "./"); 419 } else { 420 strncpy(configpath, filename, last+1); 421 if (last < 254) 422 configpath[last+1]='\0'; 423 } 424 cout << "Found configpath: " << configpath << ", dir slash was found at " << last << "." << endl; 425 }; 426 427 396 428 /** Initializes config file structure by loading elements from a give file. 397 429 * \param *file input file stream being the opened config file … … 399 431 * \param *mol pointer to molecule containing all atoms of the molecule 400 432 */ 401 void config::Load( ifstream *file, periodentafel *periode, molecule *mol)433 void config::Load(char *filename, periodentafel *periode, molecule *mol) 402 434 { 435 ifstream *file = new ifstream(filename); 436 if (file == NULL) { 437 cerr << "ERROR: config file " << filename << " missing!" << endl; 438 return; 439 } 440 RetrieveConfigPath(filename); 403 441 // ParseParameters 404 442 … … 615 653 } 616 654 } 655 file->close(); 656 delete(file); 617 657 }; 618 658 … … 622 662 * \param *mol pointer to molecule containing all atoms of the molecule 623 663 */ 624 void config::LoadOld( ifstream *file, periodentafel *periode, molecule *mol)664 void config::LoadOld(char *filename, periodentafel *periode, molecule *mol) 625 665 { 666 ifstream *file = new ifstream(filename); 667 if (file == NULL) { 668 cerr << "ERROR: config file " << filename << " missing!" << endl; 669 return; 670 } 671 RetrieveConfigPath(filename); 626 672 // ParseParameters 627 673 … … 810 856 } 811 857 } 858 file->close(); 859 delete(file); 812 860 }; 813 861 -
src/molecules.hpp
r555063 r5b15ab 612 612 int ProcPEGamma; 613 613 int ProcPEPsi; 614 char *configpath; 614 615 615 616 private: … … 674 675 ~config(); 675 676 676 int TestSyntax(ifstream *file, periodentafel *periode, molecule *mol); 677 void Load(ifstream *file, periodentafel *periode, molecule *mol); 678 void LoadOld(ifstream *file, periodentafel *periode, molecule *mol); 677 int TestSyntax(char *filename, periodentafel *periode, molecule *mol); 678 void Load(char *filename, periodentafel *periode, molecule *mol); 679 void LoadOld(char *filename, periodentafel *periode, molecule *mol); 680 void RetrieveConfigPath(char *filename); 679 681 bool Save(ofstream *file, periodentafel *periode, molecule *mol) const; 680 682 void Edit(molecule *mol);
Note:
See TracChangeset
for help on using the changeset viewer.