summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-10-26 14:23:31 +0000
committereschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-10-26 14:23:31 +0000
commite91cde0953119fa01d92174413643e889adbb98e (patch)
tree484912fa90f1a1e3262e03d154a9ffb938f3f14f
parent80f043ecb43335a3c1862b8a6ffde4332703f069 (diff)
Use CCTKi_VarDataPtrI in CCTK_DECLARE_ARGUMENTS
Introduce new function CCTKi_VarDataPtrI which does not emit warnings. Use it when defining CCTK_DECLARE_ARGUMENTS. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4898 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r--lib/make/force-rebuild1
-rw-r--r--lib/sbin/GridFuncStuff.pl15
-rw-r--r--src/include/cctki_GroupsOnGH.h26
-rw-r--r--src/main/GroupsOnGH.c45
4 files changed, 75 insertions, 12 deletions
diff --git a/lib/make/force-rebuild b/lib/make/force-rebuild
index b4aece37..7a6a9201 100644
--- a/lib/make/force-rebuild
+++ b/lib/make/force-rebuild
@@ -39,3 +39,4 @@
27 Oct 2011: Optimize CCTK_ARGUMENTS for grid functions in Fortran
17 Jun 2012: Correct error in handling optional dependencies
18 Jun 2012: Ticket 768, switch from per thorn define to per thorn include
+26 Oct 2012: Use CCTKi_VarDataPtrI instead of CCTK_VarDataPtrI
diff --git a/lib/sbin/GridFuncStuff.pl b/lib/sbin/GridFuncStuff.pl
index ec25def7..56b1a4ef 100644
--- a/lib/sbin/GridFuncStuff.pl
+++ b/lib/sbin/GridFuncStuff.pl
@@ -64,15 +64,8 @@ sub CreateVariableBindings
push(@data, '#include "cctk_Types.h"');
push(@data, '');
push(@data, '#ifdef CCODE');
- push(@data, '/* prototype for CCTKi_VarDataPtr() goes here');
- push(@data, ' because we don\'t want to include another CCTK header file */');
push(@data, '#include "cGH.h"');
- push(@data, '#ifdef __cplusplus');
- push(@data, 'extern "C"');
- push(@data, '#endif');
- push(@data, 'void *CCTKi_VarDataPtr(const cGH *GH, int timelevel,');
- push(@data, ' const char *implementation, const char *varname);');
- push(@data, '');
+ push(@data, '#include "cctki_GroupsOnGH.h"');
push(@data, '#define PASS_GROUPSIZE(group, dir) CCTKGROUPNUM_##group >= 0 ? \\');
push(@data, ' CCTK_ArrayGroupSizeI(GH, dir, CCTKGROUPNUM_##group) : &_cctk_zero');
@@ -534,12 +527,12 @@ sub CreateCArgumentDeclarations
}
my $varname0 = $varname;
- push(@declarations, "static int cctki_vi_$varname0 = -1;");
- push(@declarations, "if (cctki_vi_$varname0 < 0) cctki_vi_$varname0 = CCTK_VarIndex($fullvar);");
+ push(@declarations, "static int cctki_vi_$varname0 = -100;");
+ push(@declarations, "if (cctki_vi_$varname0 == -100) cctki_vi_$varname0 = CCTK_VarIndex($fullvar);");
for(my $level = 0; $level < $ntimelevels; $level++)
{
- push(@declarations, "CCTK_DECLARE_INIT (CCTK_$type * restrict const, $varname, (CCTK_$type *) CCTK_VarDataPtrI(cctkGH, $level, cctki_vi_$varname0));");
+ push(@declarations, "CCTK_DECLARE_INIT (CCTK_$type * restrict const, $varname, (CCTK_$type *) CCTKi_VarDataPtrI(cctkGH, $level, cctki_vi_$varname0));");
# Modify the name for the time level
$varname .= '_p';
diff --git a/src/include/cctki_GroupsOnGH.h b/src/include/cctki_GroupsOnGH.h
new file mode 100644
index 00000000..f2fc72b2
--- /dev/null
+++ b/src/include/cctki_GroupsOnGH.h
@@ -0,0 +1,26 @@
+ /*@@
+ @header cctki_GroupsOnGH.h
+ @date 2012-10-26
+ @author Erik Schnetter
+ @desc
+ Prototypes and constants for internal group functions which use GH structure.
+ @enddesc
+ @version $Header$
+ @@*/
+
+#ifndef _CCTKI_GROUPSONGH_H_
+#define _CCTKI_GROUPSONGH_H_
+
+/* Prototypes */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void *CCTKi_VarDataPtrI(const cGH *GH, int timelevel, int varindex);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/main/GroupsOnGH.c b/src/main/GroupsOnGH.c
index 55a4f5da..d3b02935 100644
--- a/src/main/GroupsOnGH.c
+++ b/src/main/GroupsOnGH.c
@@ -21,6 +21,8 @@
#include "cctk_Misc.h"
#include "cctk_WarnLevel.h"
+#include "cctki_GroupsOnGH.h"
+
static const char *rcsid = "$Header$";
CCTK_FILEVERSION(main_GroupsOnGH_c);
@@ -369,11 +371,52 @@ void CCTK_FCALL CCTK_FNAME(CCTK_VarDataPtrI)
}
/*@@
+ @routine CCTKi_VarDataPtrI
+ @date 2012-10-26
+ @author Erik Schnetter
+ @desc
+ Passes back a variable data pointer, given a variable index and timelevel.
+ This function does not output any warnings.
+ @enddesc
+
+ @var GH
+ @vdesc Pointer to Grid Hierachy
+ @vtype const cGH *
+ @vio in
+ @endvar
+
+ @var vindex
+ @vdesc Index of grid variable
+ @vtype int
+ @vio in
+ @endvar
+
+ @var timelevel
+ @vdesc Index of timelevel on which data is required
+ @vtype int
+ @vio in
+ @endvar
+
+ @returntype void *
+ @returndesc Pointer to the required data, should be cast to required type
+ @endreturndesc
+@@*/
+void *CCTKi_VarDataPtrI(const cGH *GH, int timelevel, int vindex)
+{
+ int numtimelevels = CCTK_MaxTimeLevelsVI (vindex);
+ if (timelevel < 0 || timelevel >= numtimelevels)
+ {
+ return NULL;
+ }
+ return GH->data[vindex][timelevel];
+}
+
+ /*@@
@routine CCTK_VarDataPtrB
@date Tue 6th April 1999
@author Gabrielle Allen
@desc
- Passes back a variable data pointer, given either a variable index
+ Passes back a variable data pointer, given either a variable index
or a full name and timelevel
@enddesc