diff options
-rw-r--r-- | src/include/CommandLine.h | 3 | ||||
-rw-r--r-- | src/include/OverloadMacros.h | 8 | ||||
-rw-r--r-- | src/main/CallStartupFunctions.c | 22 | ||||
-rw-r--r-- | src/main/CommandLine.c | 105 | ||||
-rw-r--r-- | src/main/InitialiseCactus.c | 2 | ||||
-rw-r--r-- | src/main/ProcessCommandLine.c | 5 | ||||
-rw-r--r-- | src/main/Subsystems.c | 35 | ||||
-rw-r--r-- | src/main/make.code.defn | 6 |
8 files changed, 163 insertions, 23 deletions
diff --git a/src/include/CommandLine.h b/src/include/CommandLine.h index 74ff045d..72286863 100644 --- a/src/include/CommandLine.h +++ b/src/include/CommandLine.h @@ -20,11 +20,12 @@ void CCTK_CommandLineDescribeParameter(const char *optarg); void CCTK_CommandLineTestParameters(const char *optarg); void CCTK_CommandLineWarningLevel(const char *optarg); void CCTK_CommandLineErrorLevel(const char *optarg); -void CCTK_CommandLineRedirectStderr(void); +void CCTK_CommandLineRedirectStdout(void); void CCTK_CommandLineListThorns(void); void CCTK_CommandLineVersion(void); void CCTK_CommandLineHelp(void); void CCTK_CommandLineUsage(void); +void CCTK_CommandLineFinished(void); #ifdef __cplusplus } diff --git a/src/include/OverloadMacros.h b/src/include/OverloadMacros.h index dd09bd2c..72c22583 100644 --- a/src/include/OverloadMacros.h +++ b/src/include/OverloadMacros.h @@ -24,16 +24,20 @@ /* This macro defines a global variable with the name of the function * and a function which allows people to set its value. + * + * The function can only be called twice - to set the default, and to overload it. */ #define OVERLOADABLE_FUNCTION(name) \ RETURN_TYPE (*CCTK_##name)(ARGUMENTS) = NULL; \ int CCTK_Overload##name(RETURN_TYPE (*func)(ARGUMENTS)) \ { \ int return_code; \ - if(! CCTK_##name) \ + static int overloaded = 0; \ + if(overloaded < 2) \ { \ CCTK_##name = func; \ - return_code = 1; \ + overloaded++; \ + return_code = overloaded; \ } \ else \ { \ diff --git a/src/main/CallStartupFunctions.c b/src/main/CallStartupFunctions.c index 4de330c8..9e70e39f 100644 --- a/src/main/CallStartupFunctions.c +++ b/src/main/CallStartupFunctions.c @@ -34,25 +34,15 @@ int dummy(tFleshConfig *); int CallStartupFunctions(tFleshConfig *ConfigData) { - CCTK_BindingsScheduleRegister("STARTUP", NULL); - /* - RegisterMainFunction(0, dummy); - RegisterMainFunction(1, dummy); - RegisterMainFunction(2, dummy); + CCTK_BindingsScheduleRegister("STARTUP", NULL); - */ - SetupMainFunctions(); - SetupCommFunctions(); - SetupIOFunctions(); + /* These used to be here to set the defaults afterwards. Now set the default before. + * SetupMainFunctions(); + * SetupCommFunctions(); + * SetupIOFunctions(); + */ return 0; } - -int dummy(tFleshConfig *foo) -{ - printf("I'm in dummy\n"); - - return 0; -} diff --git a/src/main/CommandLine.c b/src/main/CommandLine.c index f3b27cfa..b400f5d6 100644 --- a/src/main/CommandLine.c +++ b/src/main/CommandLine.c @@ -12,6 +12,9 @@ #include <string.h> #include "CommandLine.h" +#include "flesh.h" +#include "cGH.h" +#include "Comm.h" #include "WarnLevel.h" #include "CCTK_Bindings.h" @@ -26,6 +29,8 @@ char *compileTime(void); char *compileDate(void); int CCTK_GetCommandLine(char ***outargv); +static int redirectsubs; + /* FIXME. This shouldn't be in this file */ int CCTK_IsThornCompiled(const char *thorn) ; @@ -137,10 +142,28 @@ void CCTK_CommandLineErrorLevel(const char *optarg) } -void CCTK_CommandLineRedirectStderr(void) + /*@@ + @routine CCTK_CommandLineRedirectStdout + @date Fri Jul 23 11:32:46 1999 + @author Tom Goodale + @desc + + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +void CCTK_CommandLineRedirectStdout(void) { + /* Set the flag to say we need to redirect the stdout. */ + + redirectsubs = 1; } + void CCTK_CommandLineListThorns(void) { int i; @@ -153,6 +176,20 @@ void CCTK_CommandLineListThorns(void) exit(1); } + /*@@ + @routine CCTK_CommandLineVersion + @date Fri Jul 23 12:57:45 1999 + @author Tom Goodale + @desc + Prints version info + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ void CCTK_CommandLineVersion(void) { int argc; @@ -165,6 +202,20 @@ void CCTK_CommandLineVersion(void) exit(1); } + /*@@ + @routine CCTK_CommandLineHelp + @date Fri Jul 23 12:57:23 1999 + @author Tom Goodale + @desc + Prints a help message + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ void CCTK_CommandLineHelp(void) { int argc; @@ -193,6 +244,20 @@ void CCTK_CommandLineHelp(void) exit(1); } + /*@@ + @routine CCTK_CommandLineUsage + @date Fri Jul 23 12:57:04 1999 + @author Tom Goodale + @desc + Prints a usage message. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ void CCTK_CommandLineUsage(void) { int argc; @@ -204,6 +269,42 @@ void CCTK_CommandLineUsage(void) exit(1); } + /*@@ + @routine CCTK_CommandLineFinished + @date Fri Jul 23 12:55:39 1999 + @author Tom Goodale + @desc + Subroutine to do anything which has to be done based upon the + commandline, but needs to be have a default. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +void CCTK_CommandLineFinished(void) +{ + int myproc; + + /* Redirect output from sub-processors ... */ + + if ((myproc = CCTK_MyProc(NULL)) != 0) + { + char fname[256]; + if (redirectsubs) + { + sprintf(fname,"CCTK_Proc%d.out",myproc); + } + else + { + sprintf(fname,"/dev/null"); + } + + freopen(fname,"w",stdout); + } +} @@ -238,3 +339,5 @@ int CCTK_IsThornCompiled(const char *thorn) return 0; } + + diff --git a/src/main/InitialiseCactus.c b/src/main/InitialiseCactus.c index df75f9fb..864b5c43 100644 --- a/src/main/InitialiseCactus.c +++ b/src/main/InitialiseCactus.c @@ -55,6 +55,8 @@ static char *rcsid = "$Header$"; int InitialiseCactus(int *argc, char ***argv, tFleshConfig *ConfigData) { + InitialiseSubsystemDefaults(); + ProcessEnvironment(argc, argv, ConfigData); ProcessCommandLine(argc, argv, ConfigData); diff --git a/src/main/ProcessCommandLine.c b/src/main/ProcessCommandLine.c index 4ae2f3ad..989044d5 100644 --- a/src/main/ProcessCommandLine.c +++ b/src/main/ProcessCommandLine.c @@ -18,7 +18,6 @@ static int argc; static char **argv; - /*@@ @routine ProcessCommandLine @date Thu Sep 24 10:33:31 1998 @@ -79,7 +78,7 @@ int ProcessCommandLine(int *inargc, char ***inargv, tFleshConfig *ConfigData) case 'x': CCTK_CommandLineTestParameters(optarg); break; case 'W': CCTK_CommandLineWarningLevel(optarg); break; case 'E': CCTK_CommandLineErrorLevel(optarg); break; - case 'r': CCTK_CommandLineRedirectStderr(); break; + case 'r': CCTK_CommandLineRedirectStdout(); break; case 'T': CCTK_CommandLineListThorns(); break; case 'v': CCTK_CommandLineVersion(); break; case 'h': @@ -104,6 +103,8 @@ int ProcessCommandLine(int *inargc, char ***inargv, tFleshConfig *ConfigData) CCTK_CommandLineUsage(); } + CCTK_CommandLineFinished(); + return 0; } diff --git a/src/main/Subsystems.c b/src/main/Subsystems.c new file mode 100644 index 00000000..f2ad3cc7 --- /dev/null +++ b/src/main/Subsystems.c @@ -0,0 +1,35 @@ + /*@@ + @file Subsystems.c + @date Fri Jul 23 14:38:25 1999 + @author Tom Goodale + @desc + Misc stuff for the subsystems. + @enddesc + @@*/ + + + + + /*@@ + @routine InitialiseSubsystemDefaults + @date Fri Jul 23 14:39:53 1999 + @author Tom Goodale + @desc + Sets up the defaults for the overloadable functions in the subsystems. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +int InitialiseSubsystemDefaults(void) +{ + SetupMainFunctions(); + SetupCommFunctions(); + SetupIOFunctions(); + + return 0; +} + diff --git a/src/main/make.code.defn b/src/main/make.code.defn index 60c68690..8d60eed9 100644 --- a/src/main/make.code.defn +++ b/src/main/make.code.defn @@ -28,4 +28,8 @@ OverloadMain.c\ CommandLine.c\ GHExtensions.c\ WarnLevel.c\ -ActiveThorns.c +ActiveThorns.c\ +Parameters.c\ +Subsystems.c + + |