diff options
-rw-r--r-- | doc/ReferenceManual.pdf | bin | 1184068 -> 1186265 bytes | |||
-rw-r--r-- | doc/ReferenceManual/CCTKReference.tex | 63 | ||||
-rw-r--r-- | src/include/cctk_Schedule.h | 2 | ||||
-rw-r--r-- | src/main/ScheduleInterface.c | 46 |
4 files changed, 111 insertions, 0 deletions
diff --git a/doc/ReferenceManual.pdf b/doc/ReferenceManual.pdf Binary files differindex 29696f29..a90197c4 100644 --- a/doc/ReferenceManual.pdf +++ b/doc/ReferenceManual.pdf diff --git a/doc/ReferenceManual/CCTKReference.tex b/doc/ReferenceManual/CCTKReference.tex index d268dc78..1908547b 100644 --- a/doc/ReferenceManual/CCTKReference.tex +++ b/doc/ReferenceManual/CCTKReference.tex @@ -11095,6 +11095,69 @@ if (CCTK_MyProc(cctkGH)==3) +% ScheduleInterface.c +\begin{FunctionDescription}{CCTK\_ScheduleQueryCurrentFunction} + \label{CCTK-ScheduleQueryCurrentFunction} + Return the cFunctionData of the function currently executing via + \texttt{CCTK\_CallFunction}. + + \begin{SynopsisSection} + \begin{Synopsis}{C} +\begin{verbatim} +#include "cctk.h" +const cFunctionData *CCTK_ScheduleQueryCurrentFunction(const cGH *GH) +\end{verbatim} + \end{Synopsis} + \end{SynopsisSection} + + \begin{ResultSection} + \begin{ResultNote} + Data of last call to \texttt{CCTK\_CallFunction}, or + \end{ResultNote} + \begin{Result}{NULL} + if not within a scheduled function. + \end{Result} + \end{ResultSection} + + \begin{ParameterSection} + \begin{Parameter}{cctkGH} + Pointer to a Cactus grid hierarchy. + \end{Parameter} + \end{ParameterSection} + + \begin{Discussion} + Returns a data structure containing the thorn and routine name of the + currently executing function as well as the Cactus bin name. If no + function is currently executing, returns \code{NULL}. This is intended to + be used by thorns providing callable functions to identify their caller + when reporting errors. + \end{Discussion} + + \begin{SeeAlsoSection} + \begin{SeeAlso}{CCTK\_CallFunction} + Calls a function depending upon the data passed in the the fdata + structure. + \end{SeeAlso} + \end{SeeAlsoSection} + + \begin{ExampleSection} + \begin{Example}{C} + Output the name of the currently scheduled function: +\begin{verbatim} +#include <stdio.h> +#include "cctk.h" +const cFunctionData *fdata = CCTK_QueryScheduledFunction(cctkGH); +printf("scheduled function: %s::%s AT %s\n", + fdata->thorn, fdata->routine, fdata->where); +\end{verbatim} +\end{Example} + \end{ExampleSection} + +\end{FunctionDescription} + + + + % CommOverloadables.c \begin{FunctionDescription}{CCTK\_SetupGH}{Setup a new GH} \label{CCTK-SetupGH} diff --git a/src/include/cctk_Schedule.h b/src/include/cctk_Schedule.h index 5a2da202..0d3ff6b6 100644 --- a/src/include/cctk_Schedule.h +++ b/src/include/cctk_Schedule.h @@ -74,6 +74,8 @@ int CCTK_CallFunction(void *function, cFunctionData *fdata, void *data); +const cFunctionData *CCTK_ScheduleQueryCurrentFunction(const cGH *GH); + int CCTK_ScheduleTraverse(const char *where, void *GH, int (*CallFunction)(void *, cFunctionData *, void *)); 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 |