summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-07-03 14:54:27 +0000
committerallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-07-03 14:54:27 +0000
commit7b721aeb46e4774c478b12844c85f2f85c7e371f (patch)
treefe155b7e286be172ea83596f457c6788972e757e /src
parent393215a1f63d91cf68f9d5e70b7f16b9d90f5780 (diff)
Changed CCTK_Warns t CCTK_WARN so that I can try and pass thorught the
line number and file name to the Warn message. This hass problems: 1) I really need to include cctk.h then (for some reason) in WarnLevel.h, but then I guess the Fortran name for CCTK_Warn is CCTK_WARN so it doesn't much care for me having a macro for CCTK_WARN. 2) Now I need three fortran strings to be passed into C. This works at the moment on Linux, but not on other machines, so you may need to run with warnings off for a little while. 3) Fortran doesn't get the file name, because (?) it is actually something from a pipe which gets preprocessed and not the file. I have no idea how to fix this. I may just scrap all this, but I want to persevere a bit Oh, there is a new parameter cctk_full_warnings (default yes for now) which gives the old style warnings with no. git-svn-id: http://svn.cactuscode.org/flesh/trunk@618 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src')
-rw-r--r--src/comm/Reduction.c49
-rw-r--r--src/include/FortranString.h22
-rw-r--r--src/include/Reduction.h22
-rw-r--r--src/include/WarnLevel.h2
-rw-r--r--src/include/cctk.h11
-rw-r--r--src/main/Coord.c4
-rw-r--r--src/main/Groups.c16
-rw-r--r--src/main/GroupsOnGH.c2
-rw-r--r--src/main/WarnLevel.c44
-rw-r--r--src/param.ccl4
-rw-r--r--src/util/Misc.c8
11 files changed, 128 insertions, 56 deletions
diff --git a/src/comm/Reduction.c b/src/comm/Reduction.c
index a54ef998..20646eb6 100644
--- a/src/comm/Reduction.c
+++ b/src/comm/Reduction.c
@@ -69,7 +69,7 @@ int CCTK_RegisterReductionOperator(void (*function)(REGISTER_ARGLIST),
else
{
/* Reduction operator with this name already exists. */
- CCTK_Warn(1,"CCTK","Reduction operator with this name already exists");
+ CCTK_WARN(1,"Reduction operator with this name already exists");
handle = -1;
}
@@ -104,7 +104,7 @@ int CCTK_GetReductionHandle(const char *reduction)
#endif
if (handle < 0)
- CCTK_Warn(1,"CCTK","No handle found for this reduction operator");
+ CCTK_WARN(1,"No handle found for this reduction operator");
return handle;
@@ -124,29 +124,40 @@ int CCTK_Reduce( cGH *GH,
va_list indices;
int i;
int *in_fields = malloc(num_in_fields*sizeof(int));
- void (*function)(REGISTER_ARGLIST);
+ void (*function)(REGISTER_ARGLIST)=NULL;
/* Get the pointer to the reduction operator */
- function = (void (*)(REGISTER_ARGLIST))
- CCTK_GetHandledData(ReductionOperators,operation_handle);
- if (function)
- {
- /* Fill in the array of variable indices from the variable argument list */
- va_start(indices, num_in_fields);
- for (i=0; i<num_in_fields; i++)
- in_fields[i] = va_arg(indices,int);
- va_end(indices);
-
- function(GH,proc,num_out_vals,type_out_vals,out_vals,num_in_fields,in_fields);
+ if (operation_handle < 0)
- if (in_fields) free(in_fields);
+ CCTK_WARN(3,"Invalid handle passed to CCTK_Reduce");
- }
else
- CCTK_Warn(3,"CCTK","Reduction operation is not registered and cannot be called");
-
+ {
+ function = (void (*)(REGISTER_ARGLIST))
+ CCTK_GetHandledData(ReductionOperators,operation_handle);
+
+ if (function)
+ {
+
+ /* Fill in the array of variable indices from the variable argument list */
+ va_start(indices, num_in_fields);
+ for (i=0; i<num_in_fields; i++)
+ in_fields[i] = va_arg(indices,int);
+ va_end(indices);
+
+ function(GH,proc,num_out_vals,type_out_vals,out_vals,num_in_fields,in_fields);
+
+ if (in_fields) free(in_fields);
+
+ }
+ else
+ CCTK_WARN(3,"Reduction operation is not registered and cannot be called");
+ }
+
+ return 1;
+
}
@@ -156,3 +167,5 @@ int CCTK_Reduce( cGH *GH,
+
+
diff --git a/src/include/FortranString.h b/src/include/FortranString.h
index a9081234..8a0a2e79 100644
--- a/src/include/FortranString.h
+++ b/src/include/FortranString.h
@@ -24,6 +24,13 @@
_fcd fcdarg
#define TWO_FORTSTRINGS_ARGS\
_fcd fcd_n, _fcd fcd_w
+#define THREE_FORTSTRINGS_ARGS\
+ const char *CCTK_str1,\
+ const char *CCTK_str2,\
+ const char *CCTK_str3,\
+ unsigned int CCTK_len1,\
+ unsigned int CCTK_len2,\
+ unsigned int CCTK_len3
#define ONE_FORTSTRING_CREATE(argn)\
int len = _fcdlen(fcdarg); \
char *argn = CCTK_NullTerminateString(_fcdtocp(fcdarg),len);;
@@ -32,6 +39,10 @@
int wl = _fcdlen(fcd_w);\
char *argn = CCTK_NullTerminateString(_fcdtocp(fcd_n),nl);\
char *argw = CCTK_NullTerminateString(_fcdtocp(fcd_w),wl);
+#define THREE_FORTSTRINGS_CREATE(arg1,arg2,arg3)\
+ char *arg1 = CCTK_NullTerminateString(CCTK_str1,CCTK_len1);\
+ char *arg2 = CCTK_NullTerminateString(CCTK_str2,CCTK_len2);\
+ char *arg3 = CCTK_NullTerminateString(CCTK_str3,CCTK_len3);
#elif defined WIN32
@@ -39,11 +50,22 @@
char *n, unsigned int nl
#define TWO_FORTSTRINGS_ARGS\
char *n, int nl, char *w, int wl
+#define THREE_FORTSTRINGS_ARGS\
+ const char *CCTK_str1,\
+ const char *CCTK_str2,\
+ const char *CCTK_str3,\
+ unsigned int CCTK_len1,\
+ unsigned int CCTK_len2,\
+ unsigned int CCTK_len3
#define ONE_FORTSTRING_CREATE(argn)\
char *argn = CCTK_NullTerminateString(n,nl);
#define TWO_FORTSTRINGS_CREATE(argn,argw)\
char *argn = CCTK_NullTerminateString(n,nl);\
char *argw = CCTK_NullTerminateString(w,wl);
+#define THREE_FORTSTRINGS_CREATE(arg1,arg2,arg3)\
+ char *arg1 = CCTK_NullTerminateString(CCTK_str1,CCTK_len1);\
+ char *arg2 = CCTK_NullTerminateString(CCTK_str2,CCTK_len2);\
+ char *arg3 = CCTK_NullTerminateString(CCTK_str3,CCTK_len3);
#else
diff --git a/src/include/Reduction.h b/src/include/Reduction.h
index 9c42c550..fc1c7af9 100644
--- a/src/include/Reduction.h
+++ b/src/include/Reduction.h
@@ -17,15 +17,29 @@
extern "C" {
#endif
+#define REGISTER_ARGLIST \
+ cGH *, \
+ int, \
+ int, \
+ int, \
+ void *, \
+ int, \
+ int *
+
int CCTK_Reduce(cGH *GH,
- int retvaltype,
- int retvalnum,
- void *retval,
+ int proc,
int operation_handle,
- int index, ...);
+ int num_out_vals,
+ int type_out_vals,
+ void *out_vals,
+ int num_in_fields, ...);
int CCTK_GetReductionHandle(const char *reduction);
+int CCTK_RegisterReductionOperator(void (*function)(REGISTER_ARGLIST),
+ const char *name);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/include/WarnLevel.h b/src/include/WarnLevel.h
index c14cab95..12108aa1 100644
--- a/src/include/WarnLevel.h
+++ b/src/include/WarnLevel.h
@@ -15,7 +15,7 @@ extern "C" {
#endif
int CCTK_SetWarnLevel(int level);
-int CCTK_Warn(int level, const char *thorn, const char *message);
+int CCTK_Warn(int level, int line, const char *file, const char *thorn, const char *message);
void CCTK_ParamWarn(const char *thorn, const char *message);
void CCTKi_FinaliseParamWarn(void);
int CCTK_SetErrorLevel(int level);
diff --git a/src/include/cctk.h b/src/include/cctk.h
index ea19ce8c..a9687a22 100644
--- a/src/include/cctk.h
+++ b/src/include/cctk.h
@@ -47,6 +47,9 @@
INTEGER cctk_iteration&&\
CCTK_POINTER cctkGH&&\
+#define CCTK_WARN(a,b) CCTK_Warn(a,__LINE__,"unknown file",CCTK_THORNSTRING,b)
+
+
#endif /*FCODE*/
#ifdef CCODE
@@ -107,18 +110,20 @@
extern int _cctk_one;
+#define CCTK_WARN(a,b) CCTK_Warn(a,__LINE__,__FILE__,CCTK_THORNSTRING,b)
+
+
#endif /*CCODE*/
#define CCTK_VARIABLE_CHAR 1
-#define CCTK_VARIABLE_INTEGER 2
+#define CCTK_VARIABLE_INT 2
#define CCTK_VARIABLE_REAL 3
#define CCTK_VARIABLE_COMPLEX 4
/*#define CCTK_MAKESTRING(x) CCTK_REALSTRING(x)
#define CCTK_REALSTRING(x) #x
-#define CCTK_WARN(a,b) CCTK_Warn(a,CCTK_MAKESTRING(CCTK_THORN),b)
+#define CCTK_WARN(a,b) CCTK_Warn(a,CCTK_MAKESTRING(CCTK_THORN),b,__LINE__,__FILE__)
*/
-#define CCTK_WARN(a,b) CCTK_Warn(a,CCTK_THORNSTRING,b)
#define CCTK_INFO(a) CCTK_Info(CCTK_THORNSTRING,a)
#define CCTK_PARAMWARN(a) CCTK_ParamWarn(CCTK_THORNSTRING,a)
diff --git a/src/main/Coord.c b/src/main/Coord.c
index b9ac9516..d332d096 100644
--- a/src/main/Coord.c
+++ b/src/main/Coord.c
@@ -111,7 +111,7 @@ int CCTK_RegisterCoord_ByIndex(const char *name, int index, int dir)
char *msg;
msg = (char *)malloc(200*sizeof(char)+sizeof(name));
sprintf(msg,"Coordinate with name -%s- already registered",name);
- CCTK_Warn(1,"CCTK",msg);
+ CCTK_WARN(1,msg);
if (msg) free(msg);
handle = -1;
}
@@ -204,7 +204,7 @@ int CCTK_GetCoordIndex(const char *name)
char *msg;
msg = (char *)malloc( 100*sizeof(char)+sizeof(name) );
sprintf(msg,"Could not find registered coordinate %s",name);
- CCTK_Warn(2,"CCTK",msg);
+ CCTK_WARN(2,msg);
if (msg) free(msg);
return ERROR_COORDNOTFOUND;
}
diff --git a/src/main/Groups.c b/src/main/Groups.c
index 1cf7e604..cc5974fc 100644
--- a/src/main/Groups.c
+++ b/src/main/Groups.c
@@ -72,13 +72,13 @@ int CCTK_GetGroupIndex(const char *fullgroupname)
{
case 1:
- CCTK_Warn(2,"CCTK","Group name not in correct format implementation::group");
+ CCTK_WARN(2,"Group name not in correct format implementation::group");
retval = -3;
break;
case 2:
- CCTK_Warn(2,"CCTK","Memory allocation failed");
+ CCTK_WARN(2,"Memory allocation failed");
retval = -4;
break;
@@ -102,7 +102,7 @@ int CCTK_GetGroupIndex(const char *fullgroupname)
char *message;
message = (char *)malloc( (100+strlen(fullgroupname))*sizeof(char) );
sprintf(message,"No group found with the name %s",fullgroupname);
- CCTK_Warn(2,"CCTK",message);
+ CCTK_WARN(2,message);
if (message) free(message);
retval = -1;
}
@@ -165,7 +165,7 @@ int CCTK_CreateGroup(const char *gname, const char *thorn, const char *imp,
}
else
{
- CCTK_Warn(1,"CCTK","Unrecognised group scope in CCTK_CreateGroup");
+ CCTK_WARN(1,"Unrecognised group scope in CCTK_CreateGroup");
}
/* Allocate storage for the group and setup some stuff. */
@@ -402,18 +402,18 @@ int CCTK_GetVarIndex(const char *variable_name)
message = (char *)malloc( (100+strlen(variable_name))*sizeof(char) );
sprintf(message,"Full name %s in wrong format in CCTK_GetVarNum",
variable_name);
- CCTK_Warn(2,"CCTK",message);
+ CCTK_WARN(2,message);
if (message) free(message);
retval = -3;
}
else if (ierr == 2)
{
- CCTK_Warn(2,"CCTK","Memory allocation failed");
+ CCTK_WARN(2,"Memory allocation failed");
retval = -4;
}
else
{
- CCTK_Warn(1,"CCTK","Error failed to be caught");
+ CCTK_WARN(1,"Error failed to be caught");
}
#ifdef DEBUG_GROUPS
@@ -677,7 +677,7 @@ int CCTK_VTypeNumber(const char *type)
if(!strcmp(type, "INT"))
{
- retval = CCTK_VARIABLE_INTEGER;
+ retval = CCTK_VARIABLE_INT;
}
if(!strcmp(type, "REAL"))
diff --git a/src/main/GroupsOnGH.c b/src/main/GroupsOnGH.c
index fc23bec5..d3b1d597 100644
--- a/src/main/GroupsOnGH.c
+++ b/src/main/GroupsOnGH.c
@@ -75,7 +75,7 @@ void *CCTK_GetVarDataPtr_ByName(cGH *GH, int timelevel, char *fullvarname)
retval = GH->data[index][timelevel];
}
else
- CCTK_Warn(1,"CCTK","Invalid index in CCTK_GetVarDataPtr_ByName");
+ CCTK_WARN(1,"Invalid index in CCTK_GetVarDataPtr_ByName");
#ifdef DEBUG_GROUPS
CCTK_PRINTSEPARATOR
diff --git a/src/main/WarnLevel.c b/src/main/WarnLevel.c
index dc4236d5..6ae17e62 100644
--- a/src/main/WarnLevel.c
+++ b/src/main/WarnLevel.c
@@ -64,19 +64,19 @@ int CCTK_SetWarnLevel(int level)
if(level > old_level)
{
sprintf(warning_message, "Increasing warning level from %d to %d\n", old_level, level);
- CCTK_Warn(1,"CCTK", warning_message);
+ CCTK_Warn(1, __LINE__,__FILE__,"Cactus",warning_message);
retval = 1;
}
else if(level == old_level)
{
sprintf(warning_message, "Warning level is already %d\n", level);
- CCTK_Warn(1,"CCTK", warning_message);
+ CCTK_Warn(1, __LINE__,__FILE__,"Cactus",warning_message);
retval = 0;
}
else
{
sprintf(warning_message, "Decreasing warning level from %d to %d\n", old_level, level);
- CCTK_Warn(1,"CCTK", warning_message);
+ CCTK_Warn(1,__LINE__,__FILE__,"Cactus", warning_message);
retval = -1;
}
@@ -85,7 +85,7 @@ int CCTK_SetWarnLevel(int level)
{
error_level = warning_level;
sprintf(warning_message, "Decreasing error level to warning_level\n");
- CCTK_Warn(2, "CCTK", warning_message);
+ CCTK_Warn(2, __LINE__,__FILE__,"Cactus",warning_message);
}
return retval;
}
@@ -104,15 +104,28 @@ int CCTK_SetWarnLevel(int level)
@endhistory
@@*/
-int CCTK_Warn(int level, const char *thorn, const char *message)
+int CCTK_Warn(int level, int line, const char *file, const char *thorn, const char *message)
{
+
+ DECLARE_CCTK_PARAMETERS
+
int retval;
if(level <= warning_level)
{
- fprintf(stderr, "WARNING (%s): %s\n", thorn, message);
- fflush(stderr);
- retval = 1;
+ if (cctk_full_warnings)
+ {
+ fprintf(stderr, "WARNING level %d in thorn %s (line %d of %s): \n", level, thorn, line, file);
+ fprintf(stderr, " -> %s\n",message);
+ fflush(stderr);
+ retval = 1;
+ }
+ else
+ {
+ fprintf(stderr, "WARNING (%s): %s\n", thorn, message);
+ fflush(stderr);
+ retval = 1;
+ }
}
else
{
@@ -127,13 +140,14 @@ int CCTK_Warn(int level, const char *thorn, const char *message)
return retval;
}
-int FMODIFIER FORTRAN_NAME(CCTK_Warn)(int *level, TWO_FORTSTRINGS_ARGS)
+int FMODIFIER FORTRAN_NAME(CCTK_Warn)(int *level, int *line, THREE_FORTSTRINGS_ARGS)
{
- TWO_FORTSTRINGS_CREATE(thorn,message)
+ THREE_FORTSTRINGS_CREATE(file,thorn,message)
int retval;
- retval = CCTK_Warn(*level,thorn,message);
+ retval = CCTK_Warn(*level,*line,file,thorn,message);
free(thorn);
free(message);
+ free(file);
return(retval);
}
@@ -238,26 +252,26 @@ int CCTK_SetErrorLevel(int level)
if(level > old_level)
{
sprintf(warning_message, "Increasing error level from %d to %d\n", old_level, level);
- CCTK_Warn(1,"CCTK", warning_message);
+ CCTK_Warn(1, __LINE__,__FILE__,"Cactus",warning_message);
retval = 1;
}
else if(level == old_level)
{
sprintf(warning_message, "Error level is already %d\n", level);
- CCTK_Warn(3, "CCTK", warning_message);
+ CCTK_Warn(3, __LINE__,__FILE__,"Cactus",warning_message);
retval = 0;
}
else
{
sprintf(warning_message, "Decreasing error level from %d to %d\n", old_level, level);
- CCTK_Warn(1, "CCTK", warning_message);
+ CCTK_Warn(1,__LINE__,__FILE__,"Cactus", warning_message);
retval = -1;
}
}
else
{
sprintf(warning_message, "Error level cannot be higher than warning level\n");
- CCTK_Warn(1, "CCTK", warning_message);
+ CCTK_Warn(1,__LINE__,__FILE__,"Cactus", warning_message);
retval = 0;
}
diff --git a/src/param.ccl b/src/param.ccl
index 99ec215d..c275a005 100644
--- a/src/param.ccl
+++ b/src/param.ccl
@@ -4,6 +4,10 @@
private:
+LOGICAL cctk_full_warnings "Give detailed information for each warning statement"
+{
+} "yes"
+
LOGICAL cctk_strong_param_check "Die on parameter errors in CCTK_PARAMCHECK"
{
: ::
diff --git a/src/util/Misc.c b/src/util/Misc.c
index 2c6b5874..6af6cf1d 100644
--- a/src/util/Misc.c
+++ b/src/util/Misc.c
@@ -117,17 +117,17 @@ int CCTK_Equals(const char *string1, const char *string2)
{
message = (char *)malloc((100+sizeof(string2))*sizeof(char));
sprintf(message,"First string null in CCTK_Equals (2nd is %s)",string2);
- CCTK_Warn(0,"CCTK",message);
+ CCTK_WARN(0,message);
}
else if (string1 && !string2)
{
message = (char *)malloc((100+sizeof(string1))*sizeof(char));
sprintf(message,"Second string null in CCTK_Equals (1st is %s)",string1);
- CCTK_Warn(0,"CCTK",message);
+ CCTK_WARN(0,message);
}
else
{
- CCTK_Warn(0,"CCTK","Both strings null in CCTK_Equals");
+ CCTK_WARN(0,"Both strings null in CCTK_Equals");
}
}
@@ -682,7 +682,7 @@ int CCTK_SetLogical(int *data, const char *value)
}
else
{
- CCTK_Warn(1,"CCTK","Logical not set in CCTK_SetLogical");
+ CCTK_WARN(1,"Logical not set in CCTK_SetLogical");
retval = -1;
}