summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrideout <rideout@17b73243-c579-4c4c-a9d2-2d5706c11dac>2003-05-15 12:12:44 +0000
committerrideout <rideout@17b73243-c579-4c4c-a9d2-2d5706c11dac>2003-05-15 12:12:44 +0000
commit699e3cf99998b2dbcac048031da70919e19a4f35 (patch)
treee86a22d624594a7c242ed77b5b998e9225f62f51
parent29963a62a970bfdd613c42b2addfb881a4094fe3 (diff)
Add support for redirection of standard error.
Use -r[o|e|oe|eo] or -redirect=[o|e|oe|eo]. Document verbose option on -describe-all-parameters. git-svn-id: http://svn.cactuscode.org/flesh/trunk@3218 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r--src/include/CommandLine.h2
-rw-r--r--src/main/CommandLine.c40
-rw-r--r--src/main/ProcessCommandLine.c8
3 files changed, 33 insertions, 17 deletions
diff --git a/src/include/CommandLine.h b/src/include/CommandLine.h
index 4d22f049..c11d7fb5 100644
--- a/src/include/CommandLine.h
+++ b/src/include/CommandLine.h
@@ -21,7 +21,7 @@ void CCTKi_CommandLineTestParameters(const char *argument);
void CCTKi_CommandLineWarningLevel(const char *argument);
void CCTKi_CommandLineErrorLevel(const char *argument);
void CCTKi_CommandLineParameterLevel(const char *argument);
-void CCTKi_CommandLineRedirectStdout(void);
+void CCTKi_CommandLineRedirect(const char *argument);
void CCTKi_CommandLineListThorns(void);
void CCTKi_CommandLineVersion(void);
void CCTKi_CommandLineHelp(void);
diff --git a/src/main/CommandLine.c b/src/main/CommandLine.c
index 3f59d388..ab3591b5 100644
--- a/src/main/CommandLine.c
+++ b/src/main/CommandLine.c
@@ -46,7 +46,7 @@ static void CommandLinePrintParameter (const cParamData *properties);
/********************************************************************
********************* Local Data *****************************
********************************************************************/
-static int already_redirected = 0;
+static int already_redirected_stdout = 0;
static int paramchecking = 0;
@@ -60,8 +60,8 @@ int cctki_paramcheck_nprocs;
/********************************************************************
********************* Defines **********************
********************************************************************/
-#define CACTUS_COMMANDLINE_OPTIONS \
- "[-h] [-O] [-o paramname] [-W n] [-E n] [-r] [-T] " \
+#define CACTUS_COMMANDLINE_OPTIONS \
+ "[-h] [-O] [-o paramname] [-W n] [-E n] [-r[o|e|oe|eo]] [-T] " \
"[-t name] [-parameter-level <level>] [-v] <parameter_file_name>"
@@ -391,21 +391,34 @@ void CCTKi_CommandLineParameterLevel (const char *argument)
@desc
Redirect standard output on non-root processors into a file
@enddesc
+
+ @var argument
+ @vdesc option argument
+ @vtype const char *
+ @vio in
+ @endvar
@@*/
-void CCTKi_CommandLineRedirectStdout (void)
+void CCTKi_CommandLineRedirect (const char *argument)
{
int myproc;
- char fname[32];
+ char fname[24];
myproc = CCTK_MyProc (NULL);
if (myproc)
{
- sprintf (fname, "CCTK_Proc%d.out", myproc);
- freopen (fname, "w", stdout);
+ if (!argument || strchr(argument,'o')) /* redirect stdout */
+ {
+ sprintf (fname, "CCTK_Proc%d.out", myproc);
+ freopen (fname, "w", stdout);
+ already_redirected_stdout = 1;
+ }
+ if (argument && strchr(argument,'e')) /* redirect stderr */
+ {
+ sprintf (fname, "CCTK_Proc%d.err", myproc);
+ freopen (fname, "w", stderr);
+ }
}
-
- already_redirected = 1;
}
@@ -477,13 +490,16 @@ void CCTKi_CommandLineHelp (void)
char **argv;
const char *commandline_options_description =
"-h, -help : gets this help.\n"
- "-O, -describe-all-parameters : describes all the parameters.\n"
+ "-O[v], -describe-all-parameters : describes all the parameters.\n"
+ " v makes this verbose, i.e. it\n"
+ " gives a verbose description of"
+ " all parameters"
"-o, -describe-parameter <paramname> : describe the given parameter.\n"
" pretending to be on nprocs processors, \n"
" or 1 if not given.\n"
"-W, -warning-level <n> : Sets the warning level to n.\n"
"-E, -error-level <n> : Sets the error level to n.\n"
- "-r, -redirect-stdout : Redirects standard output to files.\n"
+ "-r, -redirect [o|e|oe|eo] : Redirects standard output and/or standard error to files.\n"
"-T, -list-thorns : Lists the compiled-in thorns.\n"
"-t, -test-thorn-compiled <name> : Tests for the presence of thorn <name>.\n"
" -parameter-level <level> : Sets the amount of parameter checking, \n"
@@ -553,7 +569,7 @@ void CCTKi_CommandLineFinished (void)
/* if no redirect was requested on the command line
send stdout messages on non-root processors to /dev/null */
- if (! already_redirected && CCTK_MyProc (NULL) != 0)
+ if (! already_redirected_stdout && CCTK_MyProc (NULL) != 0)
{
freopen (NULL_DEVICE, "w", stdout);
}
diff --git a/src/main/ProcessCommandLine.c b/src/main/ProcessCommandLine.c
index 3c0211ad..e297dee1 100644
--- a/src/main/ProcessCommandLine.c
+++ b/src/main/ProcessCommandLine.c
@@ -113,14 +113,14 @@ int CCTKi_ProcessCommandLine(int *inargc, char ***inargv, tFleshConfig *ConfigDa
{
struct option long_options[] =
{
- {"help", no_argument, NULL, 'h'},
+ {"help", no_argument, NULL, 'h'},
{"describe-all-parameters", optional_argument, NULL, 'O'},
{"describe-parameter", required_argument, NULL, 'o'},
/*{"test-parameters", optional_argument, NULL, 'x'},*/
{"warning-level", required_argument, NULL, 'W'},
{"error-level", required_argument, NULL, 'E'},
{"parameter-level", required_argument, NULL, 256},
- {"redirect-stdout", no_argument, NULL, 'r'},
+ {"redirect", optional_argument, NULL, 'r'},
{"list-thorns", no_argument, NULL, 'T'},
{"test-thorn-compiled", required_argument, NULL, 't'},
{"version", no_argument, NULL, 'v'},
@@ -128,7 +128,7 @@ int CCTKi_ProcessCommandLine(int *inargc, char ***inargv, tFleshConfig *ConfigDa
{0, 0, 0, 0}
};
- c = getopt_long_only (argc, argv, "hO::o:x::W:E:rTt:vi",
+ c = getopt_long_only (argc, argv, "hO::o:x::W:E:r::Tt:vi",
long_options, &option_index);
if (c == -1)
break;
@@ -144,7 +144,7 @@ int CCTKi_ProcessCommandLine(int *inargc, char ***inargv, tFleshConfig *ConfigDa
case 'W': CCTKi_CommandLineWarningLevel(optarg); break;
case 'E': CCTKi_CommandLineErrorLevel(optarg); break;
case 256: CCTKi_CommandLineParameterLevel(optarg); break;
- case 'r': CCTKi_CommandLineRedirectStdout(); break;
+ case 'r': CCTKi_CommandLineRedirect(optarg); break;
case 'T': CCTKi_CommandLineListThorns(); break;
case 'v': CCTKi_CommandLineVersion(); break;
case 'i': ignore = 1; break;