Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

test2.C

Go to the documentation of this file.
00001 // test2.C:     test all the CLUI options
00002 
00003 #include "program.h"
00004 
00005 string Program::keywords[] = {
00006     "n:nbody=???\n  number of bodies",
00007     "n:nrad=10\n    number of radii",       // NOTE: bad, option is duplicated
00008     "s:seed=0\n     a seed integer either in the range [1,2147483647],\n"
00009                     "or 0 which causes a clock related seed to be used",
00010     "m:mass=1\n     Total Mass",
00011     "r:radius=1\n   Radius",
00012     "c:comment=\n   Optional comment",
00013     "v verbose=f\n  Verbose mode",
00014     "t test=f\n     Test fatal error levels",
00015     "  zero=0\n     Testing optionless keyword",
00016     NULL,
00017 };
00018 
00019 string Program::version = "1.0 6-jun-97 PJT";
00020 
00021 string Program::usage = "testing out various CLUI options";
00022 
00023 string Program::description = 
00024  "This program does not have a final name, but simply tests out all\n"
00025  "the command line user interface (CLUI) options";
00026 
00027 void starlab_main()
00028 {
00029     string comment = 0;
00030     int  n, nr, seed, argc;
00031     char **argv;
00032     real  m, r, z;
00033     bool  v_flag, t_flag;
00034     char  seedlog[128];
00035 
00036     n = getiparam("nbody");
00037     nr = getiparam("nrad");
00038     if (hasvalue("comment")) comment = getparam("comment");
00039     m = getrparam("mass");
00040     r = getrparam("radius");
00041     z = getrparam("zero");
00042 
00043     seed = getiparam("seed");
00044 
00045     v_flag = getflag("verbose");                // undocumented features
00046     t_flag = getflag("test");
00047 
00048     if (t_flag) {
00049         Warning("Hello %s","World");
00050         Error("One more go?");
00051         Error("Two more go?");
00052     }
00053     
00054     if (v_flag) {
00055        argc = get_argc();
00056        argv = get_argv();
00057        cout << "argc=" << argc << endl;
00058        for (int i=0; i<argc; i++)
00059           cout << "argv[" << i << "] = " << argv[i] << endl;
00060     }
00061 
00062     sprintf(seedlog, "       random number generator seed = %d",seed);
00063     cout << "COMMENT:" << seedlog << endl;
00064     cout << "nbody = " << n << endl;
00065     cout << "nrad = " << nr << endl;
00066     cout << "m = " << m <<endl;
00067     cout << "r = " << r <<endl;
00068     if (comment) cout << "comment: " << comment << endl;
00069 }
00070 

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