Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

setmass.C

Go to the documentation of this file.
00001 
00009 
00010 // Steve McMillan, July 1998
00011 
00012 #include "node.h"
00013 
00014 #ifdef TOOLBOX
00015 
00016 // leaf_with_label: Return a pointer to the leaf with the specified name.
00017 
00018 local node* leaf_with_label(node* b, char* label)
00019 {
00020     for_all_leaves(node, b, bi) {
00021         if (bi->get_name() != NULL) {
00022             if (strcmp(bi->get_name(), label) == 0)
00023                 return bi;
00024         } else if (bi->get_index() >= 0) {
00025             char id[64];
00026             sprintf(id, "%d", bi->get_index());
00027             if (strcmp(id, label) == 0)
00028                 return bi;
00029         }
00030     }
00031     return NULL;
00032 }
00033 
00034 local void set_mass_by_label(node* b, char* label, real mass)
00035 {
00036     // Locate the particle to be split.
00037 
00038     node* bi = leaf_with_label(b, label);
00039 
00040     if (bi == NULL)
00041         cerr << "Warning: particle \"" << label << "\" not found.\n";
00042     else
00043         bi->set_mass(mass);
00044 
00045 }
00046 
00047 void main(int argc, char ** argv)
00048 {
00049     char label[64];
00050     label[0] = '\0';
00051 
00052     check_help();
00053 
00054     node* b;
00055     b = get_node(cin);
00056 
00057     b->log_history(argc, argv);
00058 
00059     // Parse the command line by hand, modifying the system as we go.
00060 
00061     int i = 0;
00062     while (++i < argc)
00063         if (argv[i][0] == '-')
00064             switch (argv[i][1]) {
00065 
00066                 case 'l': strcpy(label, argv[++i]);
00067                           break;
00068 
00069                 case 'm': set_mass_by_label(b, label, (real)atof(argv[++i]));
00070                           break;
00071 
00072                 default:  get_help();
00073             }
00074 
00075     put_node(cout, *b);
00076 }
00077 
00078 #endif

Generated at Sun Feb 24 09:57:15 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001