summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2005-09-26 00:21:00 +0000
committerschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2005-09-26 00:21:00 +0000
commita1492b067055e73d5b61dfe45c3cd4200bee64a2 (patch)
treef0677049f29bd0d18f50337523989fc8a1c563ac /src/main
parent06d94fb1dae1bedc506b432ccb1157d6aaa874d8 (diff)
Introduce macros CCTK_DECLARE and CCTK_DECLARE_INIT which declare or
declare and initialise local variables. They also add the necessary magic to prevent compiler warnings about unused variables. If the compiler supports __attribute__((unused)), then use this. Otherwise, use the existing fallback of taking the variable's address. In Fortran, use the variable's kind as fallback. Use these macros in autogenerated code and in "cctk.h". git-svn-id: http://svn.cactuscode.org/flesh/trunk@4146 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main')
-rw-r--r--src/main/Groups.c151
1 files changed, 146 insertions, 5 deletions
diff --git a/src/main/Groups.c b/src/main/Groups.c
index 605215fb..45970659 100644
--- a/src/main/Groups.c
+++ b/src/main/Groups.c
@@ -2733,12 +2733,108 @@ static CCTK_INT **CCTKi_ExtractSize (int dimension,
}
/*@@
+ @routine CCTKi_GroupLength
+ @date Sat Jan 22 2005
+ @author Erik Schnetter
+ @desc
+ Get the number of vector elements in a group
+ @enddesc
+
+ @var fullgroupname
+ @vdesc The full name of a GV group
+ @vtype const char *
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ the number of vector elements in the group
+ -1
+ @endreturndesc
+@@*/
+int CCTKi_GroupLength(const char *fullgroupname)
+{
+ int group;
+ int retval;
+ char *impname, *groupname;
+
+
+ retval = -1;
+ impname = groupname = NULL;
+
+ if (! CCTK_DecomposeName (fullgroupname, &impname, &groupname))
+ {
+ for (group = 0; group < n_groups; group++)
+ {
+ if (CCTK_Equals (impname, groups[group].implementation) &&
+ CCTK_Equals (groupname, groups[group].name))
+ {
+ retval = groups[group].vectorlength;
+ break;
+ }
+ }
+ }
+
+ if (retval == -1)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, "Cactus",
+ "CCTKi_GroupLength: No group named '%s' found",
+ fullgroupname);
+ }
+
+ /* Free memory from CCTK_DecomposeName */
+ free (impname);
+ free (groupname);
+
+ return retval;
+}
+
+ /*@@
+ @routine CCTKi_GroupLengthI
+ @date Thu Mar 24 2005
+ @author Erik Schnetter
+ @desc
+ Get the number of vector elements in a group
+ @enddesc
+
+ @var group
+ @vdesc The group index of a GV group
+ @vtype int
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ the number of vector elements in the group
+ -1
+ @endreturndesc
+@@*/
+int CCTKi_GroupLengthI(int group)
+{
+ int retval;
+
+ retval = -1;
+
+ if (group < 0 || group >= n_groups)
+ {
+ CCTK_VWarn (6, __LINE__, __FILE__, "Cactus",
+ "CCTKi_GroupLengthI: Illegal group index %d",
+ group);
+ }
+ else
+ {
+ retval = groups[group].vectorlength;
+ }
+
+ return retval;
+}
+
+ /*@@
@routine CCTKi_GroupLengthAsPointer
@date Sun Oct 7 03:58:44 2001
@author Tom Goodale
@desc
- Get the number of variables in a group,
- or the number of elements in a vector group
+ Get the number of vector elements in a group
@enddesc
@var fullgroupname
@@ -2749,7 +2845,7 @@ static CCTK_INT **CCTKi_ExtractSize (int dimension,
@returntype const int *
@returndesc
- pointer to an integer containing the number of variables in the group
+ pointer to an integer containing the number of vector elements in the group
NULL if group doesn't exist
@endreturndesc
@@*/
@@ -2770,8 +2866,7 @@ const int *CCTKi_GroupLengthAsPointer(const char *fullgroupname)
if (CCTK_Equals (impname, groups[group].implementation) &&
CCTK_Equals (groupname, groups[group].name))
{
- retval = groups[group].vectorlength ?
- &groups[group].vectorlength : &groups[group].n_variables;
+ retval = &groups[group].vectorlength;
break;
}
}
@@ -2792,6 +2887,52 @@ const int *CCTKi_GroupLengthAsPointer(const char *fullgroupname)
}
/*@@
+ @routine CCTKi_GroupLengthAsPointerI
+ @date Sun Jan 27 19:13 2002
+ @author Erik Schnetter
+ @desc
+ Get the number of vector elements in a group
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+ @var group
+ @vdesc The index of a GV group
+ @vtype int
+ @vio in
+ @vcomment
+
+ @endvar
+
+ @returntype const int *
+ @returndesc
+ pointer to an integer containing the number of vector elements in the group
+ NULL if group doesn't exist
+ @endreturndesc
+@@*/
+const int *CCTKi_GroupLengthAsPointerI(int group)
+{
+ const int *retval;
+
+ retval = NULL;
+
+ if (group < 0 || group >= n_groups)
+ {
+ CCTK_VWarn (6, __LINE__, __FILE__, "Cactus",
+ "CCTKi_GroupLengthAsPointerI: Group index %d does not exist",
+ group);
+ }
+ else
+ {
+ retval = &groups[group].vectorlength;
+ }
+
+ return retval;
+}
+
+ /*@@
@routine IntParameterEvaluator
@date Fri Oct 12 10:01:32 2001
@author Tom Goodale