00001
00002
00003
00004
00005
00006
00007 #include "hydro.h"
00008
00009 #ifndef TOOLBOX
00010
00011
00012
00013
00014
00015 void addhydro(node * b, real R_eff)
00016 {
00017 node * bi;
00018
00019 if (b->get_oldest_daughter() != NULL)
00020 for (bi=b->get_oldest_daughter(); bi != NULL;
00021 bi=bi->get_younger_sister())
00022 addhydro(bi, R_eff);
00023 else
00024 {
00025 hydrobase * old_hydrobase = b->get_hydrobase();
00026 hydro * new_hydro = new hydro(R_eff);
00027
00028 new_hydro->set_hydro_story(old_hydrobase->get_hydro_story());
00029 b->set_hydrobase((hydrobase *) new_hydro);
00030 old_hydrobase->set_hydro_story(NULL);
00031 delete old_hydrobase;
00032 }
00033 }
00034
00035 #else
00036
00037
00038
00039
00040
00041 main(int argc, char ** argv)
00042 {
00043 int c;
00044 bool R_flag = FALSE;
00045 bool c_flag = FALSE;
00046 real R_eff = 0;
00047 char *comment;
00048 extern char *poptarg;
00049 int pgetopt(int, char **, char *);
00050
00051 while ((c = pgetopt(argc, argv, "R:c:")) != -1)
00052 switch(c)
00053 {
00054 case 'R': R_flag = TRUE;
00055 R_eff = atof(poptarg);
00056 break;
00057 case 'c': c_flag = TRUE;
00058 comment = poptarg;
00059 break;
00060 case '?': cerr <<
00061 "usage: addhydro [-R #] [-c \"..\"]\n";
00062 exit(1);
00063 }
00064
00065 node *b;
00066
00067 while (b = get_node(cin))
00068 {
00069 if (c_flag == TRUE)
00070 b->log_comment(comment);
00071 b->log_history(argc, argv);
00072
00073 addhydro(b, R_eff);
00074
00075 put_node(cout, *b);
00076 delete b;
00077 }
00078 }
00079
00080 #endif
00081
00082