summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorrhaas <rhaas@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-04-23 18:23:02 +0000
committerrhaas <rhaas@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-04-23 18:23:02 +0000
commitf21e922a0625f0299fcad549d701245ca6595b15 (patch)
tree4191343c4d79b3bd3694b10aa6b0cbb6f7f1dd32 /src/main
parent8ec8f29055a8e2da158db1ec25c2b74e5e0018c4 (diff)
add function to query name of currently scheduled function
this adds a function CCTK_ScheduleQueryCurrentFunction which returns the cFunctionData of the function currently executing via CCTK_CallScheduledFunction git-svn-id: http://svn.cactuscode.org/flesh/trunk@4805 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main')
-rw-r--r--src/main/ScheduleInterface.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main/ScheduleInterface.c b/src/main/ScheduleInterface.c
index 08309203..5f549dc1 100644
--- a/src/main/ScheduleInterface.c
+++ b/src/main/ScheduleInterface.c
@@ -233,6 +233,8 @@ static int *scheduled_storage_groups_timelevels = NULL;
static cTimerData *timerinfo = NULL;
static int total_timer = -1;
+static const cFunctionData *current_scheduled_function = NULL;
+
/********************************************************************
********************* External Routines **********************
@@ -279,6 +281,18 @@ int CCTK_CallFunction(void *function,
int (*oneargfunc)(void *);
+ if(current_scheduled_function != NULL)
+ {
+ CCTK_VWarn(CCTK_WARN_PICKY, __LINE__, __FILE__, "Cactus",
+ "CCTK_CallFunction: recursive call, calling "
+ "'%s: %s::%s' while within '%s: %s::%s'",
+ fdata->where, fdata->thorn, fdata->routine,
+ current_scheduled_function->where,
+ current_scheduled_function->thorn,
+ current_scheduled_function->routine);
+ }
+ current_scheduled_function = fdata;
+
switch(fdata->type)
{
case FunctionNoArgs:
@@ -299,6 +313,9 @@ int CCTK_CallFunction(void *function,
case LangFortran:
fdata->FortranCaller(data, function);
break;
+ case LangNone:
+ /* this should never happen */
+ /* fall through */
default :
CCTK_Warn(1,__LINE__,__FILE__,"Cactus",
"CCTK_CallFunction: Unknown language.");
@@ -309,10 +326,39 @@ int CCTK_CallFunction(void *function,
"CCTK_CallFunction: Unknown function type.");
}
+ current_scheduled_function = NULL;
+
/* Return 0, meaning didn't synchronise */
return 0;
}
+ /*@@
+ @routine CCTK_ScheduleQueryCurrentFunction
+ @date Fri Apr 20 08:57:49 PDT 2012
+ @author Roland Haas
+ @desc
+ Returns the cFunctionData of the function currenlty executing via
+ CCTK_CallFunction.
+ @enddesc
+ @calls
+
+ @var GH
+ @vdesc GH data
+ @vtype const cGH *
+ @vio in
+ @endvar
+
+ @returntype cFunctionData *
+ @returndesc
+ Data about the function. NULL if no function is currently executing via
+ CCTK_CallFunction.
+ @endreturndesc
+@@*/
+const cFunctionData *CCTK_ScheduleQueryCurrentFunction(const cGH * CCTK_ATTRIBUTE_UNUSED GH)
+{
+ return current_scheduled_function;
+}
+
/*@@
@routine CCTKi_ScheduleFunction
@date Thu Sep 16 18:19:01 1999