aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2001-11-05 15:01:00 +0000
committertradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2001-11-05 15:01:00 +0000
commitaefccf7f6c7d23f01120009ea144546575cdd289 (patch)
tree0f765c9a263c807e27881c02a4920602cb97f61e
parent99faa32c501ebb610aa7d40e55b714272bb785d8 (diff)
Added const qualifier to the 'cGH *' argument of some more IO functions.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@105 b589c3ab-70e8-4b4d-a09f-cba2dd200880
-rw-r--r--src/OutputInfo.c12
-rw-r--r--src/OutputScalar.c16
-rw-r--r--src/WriteInfo.c14
-rw-r--r--src/WriteScalar.c23
-rw-r--r--src/iobasicGH.h20
5 files changed, 51 insertions, 34 deletions
diff --git a/src/OutputInfo.c b/src/OutputInfo.c
index 1d67f88..5b9fe5b 100644
--- a/src/OutputInfo.c
+++ b/src/OutputInfo.c
@@ -73,7 +73,7 @@ static void PrintHeader (iobasicGH *myGH, int num_vars);
@var GH
@vdesc Pointer to CCTK GH
- @vtype cGH *
+ @vtype const cGH *
@vio in
@endvar
@@ -82,7 +82,7 @@ static void PrintHeader (iobasicGH *myGH, int num_vars);
0 for success
@endreturndesc
@@*/
-int IOBasic_InfoOutputGH (cGH *GH)
+int IOBasic_InfoOutputGH (const cGH *GH)
{
DECLARE_CCTK_PARAMETERS
int vindex, num_vars;
@@ -173,7 +173,7 @@ int IOBasic_InfoOutputGH (cGH *GH)
@var GH
@vdesc Pointer to CCTK GH
- @vtype cGH *
+ @vtype const cGH *
@vio in
@endvar
@var vindex
@@ -187,7 +187,7 @@ int IOBasic_InfoOutputGH (cGH *GH)
true/false (1 or 0) if this variable should be output or not
@endreturndesc
@@*/
-int IOBasic_TimeForInfoOutput (cGH *GH, int vindex)
+int IOBasic_TimeForInfoOutput (const cGH *GH, int vindex)
{
DECLARE_CCTK_PARAMETERS
int retval;
@@ -236,7 +236,7 @@ int IOBasic_TimeForInfoOutput (cGH *GH, int vindex)
@var GH
@vdesc Pointer to CCTK GH
- @vtype cGH *
+ @vtype const cGH *
@vio in
@endvar
@var vindex
@@ -250,7 +250,7 @@ int IOBasic_TimeForInfoOutput (cGH *GH, int vindex)
0 for success
@endreturndesc
@@*/
-int IOBasic_TriggerInfoOutput (cGH *GH, int vindex)
+int IOBasic_TriggerInfoOutput (const cGH *GH, int vindex)
{
DECLARE_CCTK_PARAMETERS
iobasicGH *myGH;
diff --git a/src/OutputScalar.c b/src/OutputScalar.c
index 6e23774..0289625 100644
--- a/src/OutputScalar.c
+++ b/src/OutputScalar.c
@@ -40,11 +40,11 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg);
@endhistory
@var GH
@vdesc Pointer to CCTK GH
- @vtype cGH
+ @vtype const cGH *
@vio in
@endvar
@@*/
-int IOBasic_ScalarOutputGH (cGH *GH)
+int IOBasic_ScalarOutputGH (const cGH *GH)
{
int vindex;
const char *name;
@@ -111,7 +111,7 @@ int IOBasic_ScalarOutputGH (cGH *GH)
@calledby IOBasic_ScalarOutputGH, CCTK_OutputVarAsByMethod ("IOBasic")
@var GH
@vdesc Pointer to CCTK GH
- @vtype cGH
+ @vtype const cGH *
@vio in
@vcomment
@endvar
@@ -128,7 +128,7 @@ int IOBasic_ScalarOutputGH (cGH *GH)
@vcomment
@endvar
@@*/
-int IOBasic_ScalarOutputVarAs (cGH *GH, const char *fullname, const char *alias)
+int IOBasic_ScalarOutputVarAs (const cGH *GH, const char *fullname, const char *alias)
{
int vindex;
@@ -172,7 +172,7 @@ int IOBasic_ScalarOutputVarAs (cGH *GH, const char *fullname, const char *alias)
@endhistory
@var GH
@vdesc Pointer to CCTK GH
- @vtype cGH
+ @vtype const cGH *
@vio in
@vcomment
@endvar
@@ -183,7 +183,7 @@ int IOBasic_ScalarOutputVarAs (cGH *GH, const char *fullname, const char *alias)
@vcomment
@endvar
@@*/
-int IOBasic_TimeForScalarOutput (cGH *GH, int vindex)
+int IOBasic_TimeForScalarOutput (const cGH *GH, int vindex)
{
int return_type;
iobasicGH *myGH;
@@ -239,7 +239,7 @@ int IOBasic_TimeForScalarOutput (cGH *GH, int vindex)
@calledby CCTK scheduler
@var GH
@vdesc Pointer to CCTK GH
- @vtype cGH
+ @vtype const cGH *
@vio in
@vcomment
@endvar
@@ -250,7 +250,7 @@ int IOBasic_TimeForScalarOutput (cGH *GH, int vindex)
@vcomment
@endvar
@@*/
-int IOBasic_TriggerScalarOutput (cGH *GH, int vindex)
+int IOBasic_TriggerScalarOutput (const cGH *GH, int vindex)
{
const char *name;
iobasicGH *myGH;
diff --git a/src/WriteInfo.c b/src/WriteInfo.c
index 3345161..37a986d 100644
--- a/src/WriteInfo.c
+++ b/src/WriteInfo.c
@@ -32,13 +32,22 @@ CCTK_FILEVERSION(CactusBase_IOBasic_WriteInfo_c)
@calls CCTK_VarDataPtrI
CCTK_Reduce
@@*/
-void IOBasic_WriteInfo (cGH *GH, int vindex)
+void IOBasic_WriteInfo (const cGH *GH, int vindex)
{
int vtype;
char *fullname;
iobasicGH *myGH;
void *ptr;
iobasic_reduction_t *reduction;
+ /*** FIXME: can CCTK_Reduce() have a 'const cGH *' parameter ?? ***/
+ union
+ {
+ const cGH *const_ptr;
+ cGH *non_const_ptr;
+ } GH_fake_const;
+
+
+ GH_fake_const.const_ptr = GH;
myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic");
@@ -152,7 +161,8 @@ void IOBasic_WriteInfo (cGH *GH, int vindex)
/* for CCTK_GF and CCTK_ARRAY variables: loop over all reductions */
while (reduction)
{
- reduction->is_valid = CCTK_Reduce (GH, 0, reduction->handle, 1,
+ reduction->is_valid = CCTK_Reduce (GH_fake_const.non_const_ptr, 0,
+ reduction->handle, 1,
CCTK_VARIABLE_REAL,
&reduction->value, 1, vindex) == 0;
if (! reduction->is_valid)
diff --git a/src/WriteScalar.c b/src/WriteScalar.c
index 981f30e..dbd1ab3 100644
--- a/src/WriteScalar.c
+++ b/src/WriteScalar.c
@@ -24,7 +24,7 @@ static const char *rcsid = "$Header$";
CCTK_FILEVERSION(CactusBase_IOBasic_WriteScalar_c)
-static FILE *OpenScalarFile (cGH *GH,
+static FILE *OpenScalarFile (const cGH *GH,
int vindex,
const char *filename,
const char *slicename,
@@ -49,7 +49,7 @@ static FILE *OpenScalarFile (cGH *GH,
@var GH
@vdesc Pointer to CCTK grid hierarchy
- @vtype cGH *
+ @vtype const cGH *
@vio in
@endvar
@var vindex
@@ -63,7 +63,7 @@ static FILE *OpenScalarFile (cGH *GH,
@vio in
@endvar
@@*/
-void IOBasic_WriteScalarGA (cGH *GH,
+void IOBasic_WriteScalarGA (const cGH *GH,
int vindex,
const char *alias)
{
@@ -85,11 +85,18 @@ void IOBasic_WriteScalarGA (cGH *GH,
char *non_const_ptr;
const char *const_ptr;
} reductions;
+ /*** FIXME: can CCTK_Reduce() have a 'const cGH *' parameter ?? ***/
+ union
+ {
+ const cGH *const_ptr;
+ cGH *non_const_ptr;
+ } GH_fake_const;
/* this union helps us to avoid compiler warning about discarding
the const qualifier from a pointer target type */
reductions.const_ptr = outScalar_reductions;
+ GH_fake_const.const_ptr = GH;
/* first, check if variable has storage assigned */
if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (vindex)))
@@ -154,8 +161,8 @@ void IOBasic_WriteScalarGA (cGH *GH,
}
/* do the reduction (all processors) */
- ierr = CCTK_Reduce (GH, 0, reduction_handle, 1, CCTK_VARIABLE_REAL,
- &reduction_value, 1, vindex);
+ ierr = CCTK_Reduce (GH_fake_const.non_const_ptr, 0, reduction_handle, 1,
+ CCTK_VARIABLE_REAL, &reduction_value, 1, vindex);
/* dump the reduction value to file by processor 0 */
if (ierr == 0 && CCTK_MyProc (GH) == 0)
@@ -234,7 +241,7 @@ void IOBasic_WriteScalarGA (cGH *GH,
@var GH
@vdesc Pointer to CCTK grid hierarchy
- @vtype cGH *
+ @vtype const cGH *
@vio in
@endvar
@var vindex
@@ -248,7 +255,7 @@ void IOBasic_WriteScalarGA (cGH *GH,
@vio in
@endvar
@@*/
-void IOBasic_WriteScalarGS (cGH *GH, int vindex, const char *alias)
+void IOBasic_WriteScalarGS (const cGH *GH, int vindex, const char *alias)
{
DECLARE_CCTK_PARAMETERS
FILE *file;
@@ -322,7 +329,7 @@ void IOBasic_WriteScalarGS (cGH *GH, int vindex, const char *alias)
}
-static FILE *OpenScalarFile (cGH *GH,
+static FILE *OpenScalarFile (const cGH *GH,
int vindex,
const char *filename,
const char *slicename,
diff --git a/src/iobasicGH.h b/src/iobasicGH.h
index d9c6b9a..059042a 100644
--- a/src/iobasicGH.h
+++ b/src/iobasicGH.h
@@ -53,15 +53,15 @@ typedef struct IOBASIC_GH
/* prototypes of functions to be registered */
-int IOBasic_InfoOutputGH (cGH *GH);
-int IOBasic_TriggerInfoOutput (cGH *GH, int vindex);
-int IOBasic_TimeForInfoOutput (cGH *GH, int vindex);
-int IOBasic_ScalarOutputGH (cGH *GH);
-int IOBasic_TriggerScalarOutput (cGH *GH, int vindex);
-int IOBasic_TimeForScalarOutput (cGH *GH, int vindex);
-int IOBasic_ScalarOutputVarAs (cGH *GH, const char *vname, const char *alias);
+int IOBasic_InfoOutputGH (const cGH *GH);
+int IOBasic_TriggerInfoOutput (const cGH *GH, int vindex);
+int IOBasic_TimeForInfoOutput (const cGH *GH, int vindex);
+int IOBasic_ScalarOutputGH (const cGH *GH);
+int IOBasic_TriggerScalarOutput (const cGH *GH, int vindex);
+int IOBasic_TimeForScalarOutput (const cGH *GH, int vindex);
+int IOBasic_ScalarOutputVarAs (const cGH *GH, const char *vname, const char *alias);
/* other function prototypes */
-void IOBasic_WriteInfo (cGH *GH, int vindex);
-void IOBasic_WriteScalarGS (cGH *GH, int vindex, const char *alias);
-void IOBasic_WriteScalarGA (cGH *GH, int vindex, const char *alias);
+void IOBasic_WriteInfo (const cGH *GH, int vindex);
+void IOBasic_WriteScalarGS (const cGH *GH, int vindex, const char *alias);
+void IOBasic_WriteScalarGA (const cGH *GH, int vindex, const char *alias);