From 125f570312122ce3de31c699c95637d2a4eddaf2 Mon Sep 17 00:00:00 2001 From: allen Date: Wed, 4 Oct 2000 22:01:28 +0000 Subject: Made CCTK_MainLoopIndex and CCTK_SetMainLoopIndex overloadable, and added routines that were originally there as defaults git-svn-id: http://svn.cactuscode.org/flesh/trunk@1852 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/include/MainOverloadables.h | 14 +++++++++ src/main/CactusDefaultMainLoopIndex.c | 55 +++++++++++++++++++++++++++++++++++ src/main/MainUtils.c | 44 +--------------------------- src/main/OverloadMain.c | 20 +++++++++---- src/main/make.code.defn | 1 + 5 files changed, 85 insertions(+), 49 deletions(-) create mode 100644 src/main/CactusDefaultMainLoopIndex.c diff --git a/src/include/MainOverloadables.h b/src/include/MainOverloadables.h index fc20cab2..f658ab49 100644 --- a/src/include/MainOverloadables.h +++ b/src/include/MainOverloadables.h @@ -24,5 +24,19 @@ OVERLOADABLE(Initialise) OVERLOADABLE(Evolve) OVERLOADABLE(Shutdown) +#undef RETURN_TYPE +#define RETURN_TYPE int +#undef ARGUMENTS +#define ARGUMENTS void + +OVERLOADABLE(MainLoopIndex) + +#undef RETURN_TYPE +#define RETURN_TYPE int +#undef ARGUMENTS +#define ARGUMENTS int main_loop_index + +OVERLOADABLE(SetMainLoopIndex) + #undef ARGUMENTS #undef RETURN_TYPE diff --git a/src/main/CactusDefaultMainLoopIndex.c b/src/main/CactusDefaultMainLoopIndex.c new file mode 100644 index 00000000..5855d3ab --- /dev/null +++ b/src/main/CactusDefaultMainLoopIndex.c @@ -0,0 +1,55 @@ + /*@@ + @file CactusDefaultMainLoopIndex.c + @date Wed Oct 04 16:53:58 2000 + @author Gabrielle Allen + @desc + The default main loop index routines + @enddesc + @@*/ + +#include "cctk.h" + +static char *rcsid = "$Header$"; + +CCTK_FILEVERSION(main_CactusDefaultMainLoopIndex_c) + +static int iteration = 0; + + /*@@ + @routine CactusDefaultMainLoopIndex + @date Wed Oct 04 16:53:58 2000 + @author Gabrielle Allen + @desc + Default main loop index routine + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +int CactusDefaultMainLoopIndex(void) +{ + return (iteration); +} + + + /*@@ + @routine CactusDefaultSetMainLoopIndex + @date Sep 22 1999 + @author Thomas Radke + @desc + Sets the iteration counter variable of the evolution loop. + This is used for recovery. + @enddesc + @calls + @calledby + +@@*/ +int CactusDefaultSetMainLoopIndex (int main_loop_index) +{ + iteration = main_loop_index; + return iteration; +} + diff --git a/src/main/MainUtils.c b/src/main/MainUtils.c index 7fb61368..158159ec 100644 --- a/src/main/MainUtils.c +++ b/src/main/MainUtils.c @@ -17,51 +17,9 @@ static char *rcsid = "$Header$"; -static const char *startuptime = "How do I do this"; - CCTK_FILEVERSION(main_MainUtils_c) -/* the iteration counter used in the evolution loop */ -static int iteration = 0; - - - /*@@ - @routine CCTK_SetMainLoopIndex - @date Sep 22 1999 - @author Thomas Radke - @desc - Sets the iteration counter variable of the evolution loop. - This is used for recovery. - @enddesc - @calls - @calledby - -@@*/ -int CCTK_SetMainLoopIndex (int main_loop_index) -{ - iteration = main_loop_index; - return iteration; -} - - - /*@@ - @routine CCTK_MainLoopIndex - @date Sep 22 1999 - @author Thomas Radke - @desc - Returns the iteration counter variable of the evolution loop. - This is used for checkpointing. - @enddesc - @calls - @calledby - -@@*/ -int CCTK_MainLoopIndex (void) -{ - return (iteration); -} - /*@@ @routine CCTK_RunTitle @date Sun Sep 17 2000 @@ -88,7 +46,7 @@ int CCTK_RunTitle(int len, char *title) { if (CCTK_Equals(cctk_title,"")) { - strcpy(title,"Cactus Simulation"); + strncpy(title,"Cactus Simulation",len-1); } else { diff --git a/src/main/OverloadMain.c b/src/main/OverloadMain.c index e1dcd7d6..378ffa64 100644 --- a/src/main/OverloadMain.c +++ b/src/main/OverloadMain.c @@ -25,9 +25,11 @@ CCTK_FILEVERSION(main_OverloadMain_c) #define OVERLOADABLE(name) OVERLOADABLE_DUMMYPROTOTYPE(name) /* These ones actually have defaults. */ -#define CCTKi_DummyInitialise CactusDefaultInitialise -#define CCTKi_DummyEvolve CactusDefaultEvolve -#define CCTKi_DummyShutdown CactusDefaultShutdown +#define CCTKi_DummyInitialise CactusDefaultInitialise +#define CCTKi_DummyEvolve CactusDefaultEvolve +#define CCTKi_DummyShutdown CactusDefaultShutdown +#define CCTKi_DummyMainLoopIndex CactusDefaultMainLoopIndex +#define CCTKi_DummySetMainLoopIndex CactusDefaultSetMainLoopIndex #include "MainOverloadables.h" @@ -35,6 +37,8 @@ CCTK_FILEVERSION(main_OverloadMain_c) #undef CCTKi_DummyInitialise #undef CCTKi_DummyEvolve #undef CCTKi_DummyShutdown +#undef CCTKi_DummyMainLoopIndex +#undef CCTKi_DummySetMainLoopIndex #undef OVERLOADABLE @@ -68,9 +72,11 @@ int CCTKi_SetupMainFunctions(void) #define OVERLOADABLE(name) OVERLOADABLE_CHECK(name) /* These ones actually have defaults. */ -#define CCTKi_DummyInitialise CactusDefaultInitialise -#define CCTKi_DummyEvolve CactusDefaultEvolve -#define CCTKi_DummyShutdown CactusDefaultShutdown +#define CCTKi_DummyInitialise CactusDefaultInitialise +#define CCTKi_DummyEvolve CactusDefaultEvolve +#define CCTKi_DummyShutdown CactusDefaultShutdown +#define CCTKi_DummyMainLoopIndex CactusDefaultMainLoopIndex +#define CCTKi_DummySetMainLoopIndex CactusDefaultSetMainLoopIndex #include "MainOverloadables.h" @@ -78,6 +84,8 @@ int CCTKi_SetupMainFunctions(void) #undef CCTKi_DummyInitialise #undef CCTKi_DummyEvolve #undef CCTKi_DummyShutdown +#undef CCTKi_DummyMainLoopIndex +#undef CCTKi_DummySetMainLoopIndex #undef OVERLOADABLE diff --git a/src/main/make.code.defn b/src/main/make.code.defn index 0b4d7c59..24d35a3c 100644 --- a/src/main/make.code.defn +++ b/src/main/make.code.defn @@ -8,6 +8,7 @@ Banner.c\ CactusDefaultInitialise.c\ CactusDefaultEvolve.c\ CactusDefaultShutdown.c\ +CactusDefaultMainLoopIndex.c\ CallStartupFunctions.c\ CommandLine.c\ Complex.c\ -- cgit v1.2.3