1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
/*@@
@file GroupsOnGH.c
@date Tues April 6
@author Gabrielle Allen
@desc
GH specific Routines to deal with groups.
@enddesc
@@*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "cctk_Flesh.h"
#include "cctk_Misc.h"
#include "cctk_Groups.h"
#include "cctk_WarnLevel.h"
#include "cctk_GroupsOnGH.h"
/*#define DEBUG_GROUPS*/
static char *rcsid = "$Header$";
/*@@
@routine CCTK_VarDataPtr
@date Tue 6th April 1999
@author Gabrielle Allen
@desc
Passes back a variable data pointer, given a full name and timelevel
@enddesc
@calls
@history
@endhistory
@var GH
@vdesc Pointer to Grid Hierachy
@vtype cGH *
@vio in
@vcomment
@endvar
@var fullvarname
@vdesc Full name of the grid variable
@vtype char *
@vio in
@vcomment Format <implementation>::<variable>
@endvar
@var timelevel
@vdesc Index of timelevel on which data is required
@vtype int
@vio in
@vcomment
@endvar
@returntype void *
@returndesc Pointer to the required data, should be cast to required type
@endreturndesc
@version $Header$
@@*/
void *CCTK_VarDataPtr(cGH *GH, int timelevel, char *fullvarname)
{
int index;
void *retval=NULL;
index = CCTK_VarIndex(fullvarname);
if (index >= 0)
{
retval = GH->data[index][timelevel];
}
else
CCTK_WARN(1,"Invalid index in CCTK_VarDataPtr");
#ifdef DEBUG_GROUPS
CCTK_PRINTSEPARATOR
printf("In CCTK_VarDataPtr\n----------------------------\n");
printf(" Data pointer for %s (%d) is %x\n",fullvarname,index,retval);
CCTK_PRINTSEPARATOR
#endif
return retval;
}
/*@@
@routine CCTK_VarDataPtrI
@date Tue 6th April 1999
@author Gabrielle Allen
@desc
Passes back a variable data pointer, given a variable index and timelevel
@enddesc
@calls
@history
A check for a valid index (i>=0) included by Gerd Lanfermann
@endhistory
@var GH
@vdesc Pointer to Grid Hierachy
@vtype cGH *
@vio in
@vcomment
@endvar
@var varindex
@vdesc Index of grid variable
@vtype int
@vio in
@vcomment Assumed to be in correct range
@endvar
@var timelevel
@vdesc Index of timelevel on which data is required
@vtype int
@vio in
@vcomment
@endvar
@returntype void *
@returndesc Pointer to the required data, should be cast to required type
@endreturndesc
@version $Header$
@@*/
void *CCTK_VarDataPtrI(cGH *GH, int timelevel, int varindex)
{
if (varindex < 0)
CCTK_WARN(1,"WARNING: calling CCTK_VarDataPtrI with negative index! Prob. Fatal");
return GH->data[varindex][timelevel];
}
/*@@
@routine CCTK_VarDataPtrB
@date Tue 6th April 1999
@author Gabrielle Allen
@desc
Passes back a variable data pointer, given either a variable index
or a full name and timelevel
@enddesc
@calls
@history
@endhistory
@var GH
@vdesc Pointer to Grid Hierachy
@vtype cGH *
@vio in
@vcomment
@endvar
@var varindex
@vdesc Index of grid variable
@vtype int
@vio in
@vcomment Assumed to be in correct range
@endvar
@var fullvarname
@vdesc Full name of the grid variable
@vtype char *
@vio in
@vcomment Format <implementation>::<variable>
@endvar
@var timelevel
@vdesc Index of timelevel on which data is required
@vtype int
@vio in
@vcomment
@endvar
@returntype void *
@returndesc Pointer to the required data, should be cast to required type
@endreturndesc
@version $Header$
@@*/
void *CCTK_VarDataPtrB(cGH *GH, int timelevel, int varindex, char *fullvarname)
{
if (fullvarname)
{
return CCTK_VarDataPtr(GH, timelevel, fullvarname);
}
else
{
return CCTK_VarDataPtrI(GH, timelevel, varindex);
}
}
|