From 8817019f6d31f718986aed295b2af6ca97e404e7 Mon Sep 17 00:00:00 2001 From: tradke Date: Thu, 23 Nov 2000 21:39:04 +0000 Subject: Fixed gcc verbose warnings about missing prototypes and use of variables named 'index' which hides a global function index(3). Also polished grdocs, added missing version and rcs IDs. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@32 94b1c47f-dcfd-45ef-a468-0854c0e9e350 --- src/ChooseOutput.c | 87 ++++++++++++---------- src/Output1D.c | 192 +++++++++++++++++++++++++------------------------ src/Output2D.c | 193 +++++++++++++++++++++++++------------------------ src/Startup.c | 208 ++++++++++++++++++++++++++++++++++++++++++++--------- src/Write1D.c | 44 ++++++------ src/Write2D.c | 20 +++--- src/ioASCIIGH.h | 4 +- src/make.code.defn | 1 - 8 files changed, 453 insertions(+), 296 deletions(-) diff --git a/src/ChooseOutput.c b/src/ChooseOutput.c index 5997fc7..76153a6 100644 --- a/src/ChooseOutput.c +++ b/src/ChooseOutput.c @@ -1,15 +1,12 @@ /*@@ - @file ChooseOutput.c - @author Gabrielle Allen - @date July 6 2000 + @file ChooseOutput.c + @author Gabrielle Allen + @date July 6 2000 @desc - Choose what data to write for different IO methods in IOASCII - @enddesc + Choose what data to write for different IO methods in IOASCII + @enddesc - @history - @hauthor - @hdesc - @version $Header$ + @version $Id$ @@*/ #include @@ -20,24 +17,34 @@ #include "CactusBase/IOUtil/src/ioutil_Utils.h" #include "ioASCIIGH.h" +/* the rcs ID and its dummy function to use it */ static char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusBase_IOASCII_ChooseOutput_c) -/*@@ - @routine IOASCII_Choose1D - @author Gabrielle Allen - @date July 6 2000 - @desc - Use parameters to choose the 1D slices through the output data. - @enddesc - @history - @hauthor - @hdesc - @version $Header$ -@@*/ +/* prototypes of routines defined in this source file */ +void IOASCII_Choose1D (cGH *GH); +void IOASCII_Choose2D (cGH *GH); + + + /*@@ + @routine IOASCII_Choose1D + @author Gabrielle Allen + @date July 6 2000 + @desc + Use parameters to choose the 1D slices through the output data. + @enddesc -void IOASCII_Choose1D(CCTK_ARGUMENTS) + @calls CCTK_ParameterQueryTimesSet + IOUtil_1DLines + + @var GH + @vdesc Pointer to CCTK grid hierarchy + @vtype cGH * + @vio in + @endvar +@@*/ +void IOASCII_Choose1D (cGH *GH) { DECLARE_CCTK_PARAMETERS int i; @@ -46,7 +53,7 @@ void IOASCII_Choose1D(CCTK_ARGUMENTS) CCTK_REAL *origin_phys[3]; /* Specify output lines with coordinates */ - myGH = (asciiioGH *) cctkGH->extensions[CCTK_GHExtensionHandle ("IOASCII")]; + myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); /* Set up lines to be output */ origin_phys[0] = (CCTK_REAL *) malloc (3*3 * sizeof (CCTK_REAL)); @@ -195,7 +202,7 @@ void IOASCII_Choose1D(CCTK_ARGUMENTS) for (i = 1; i <= CCTK_MaxDim(); i++) { - IOUtil_1DLines (cctkGH, i, origin_index, origin_phys, myGH->spxyz[i-1]); + IOUtil_1DLines (GH, i, origin_index, origin_phys, myGH->spxyz[i-1]); } free (origin_phys[0]); @@ -203,22 +210,24 @@ void IOASCII_Choose1D(CCTK_ARGUMENTS) } + /*@@ + @routine IOASCII_Choose2D + @author Gabrielle Allen + @date July 6 2000 + @desc + Use parameters to choose the 2D slices through the output data. + @enddesc -/*@@ - @routine IOASCII_Choose2D - @author Gabrielle Allen - @date July 6 2000 - @desc - Use parameters to choose the 2D planes through the output data. - @enddesc + @calls CCTK_ParameterQueryTimesSet + IOUtil_2DPlanes - @history - @hauthor - @hdesc - @version $Header$ + @var GH + @vdesc Pointer to CCTK grid hierarchy + @vtype cGH * + @vio in + @endvar @@*/ - -void IOASCII_Choose2D(CCTK_ARGUMENTS) +void IOASCII_Choose2D (cGH *GH) { DECLARE_CCTK_PARAMETERS int i; @@ -227,7 +236,7 @@ void IOASCII_Choose2D(CCTK_ARGUMENTS) CCTK_REAL origin_phys[3]; /* Specify output planes by coordinates */ - myGH = (asciiioGH *) cctkGH->extensions[CCTK_GHExtensionHandle ("IOASCII")]; + myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); /* Set parameters using 1. Indices from IOASCII @@ -300,6 +309,6 @@ void IOASCII_Choose2D(CCTK_ARGUMENTS) for (i = 1; i <= CCTK_MaxDim(); i++) { - IOUtil_2DPlanes (cctkGH, i, origin_index, origin_phys, myGH->sp2xyz[i-1]); + IOUtil_2DPlanes (GH, i, origin_index, origin_phys, myGH->sp2xyz[i-1]); } } diff --git a/src/Output1D.c b/src/Output1D.c index ace1a38..4bcdcf7 100644 --- a/src/Output1D.c +++ b/src/Output1D.c @@ -3,12 +3,11 @@ @date Tue Jan 9 1999 @author Gabrielle Allen @desc - Functions to deal with 1D output of GFs + Functions to deal with 1D ASCII output of variables @enddesc + @version $Id$ @@*/ -/*#define IO_DEBUG*/ - #include #include #include @@ -17,11 +16,22 @@ #include "cctk_Parameters.h" #include "ioASCIIGH.h" -/* function prototypes */ -int IOASCII_TimeFor1D (cGH *GH, int index); -static int CheckOutputVar (int index); +/* the rcs ID and its dummy function to use it */ +static char *rcsid = "$Id$"; +CCTK_FILEVERSION(CactusBase_IOASCII_Output1D_c) + +/* define this if you want debugging output */ +/*#define IO_DEBUG 1*/ + + +/* prototypes of routines defined in this source file */ +int IOASCII_Output1DGH (cGH *GH); +int IOASCII_Output1DVarAs (cGH *GH, const char *fullname, const char *alias); +int IOASCII_TimeFor1D (cGH *GH, int vindex); +int IOASCII_TriggerOutput1D (cGH *GH, int vindex); +static int CheckOutputVar (int vindex); static void CheckSteerableParameters (asciiioGH *myGH); -static void SetOutputFlag (int index, const char *optstring, void *arg); +static void SetOutputFlag (int vindex, const char *optstring, void *arg); /*@@ @@ -29,27 +39,26 @@ static void SetOutputFlag (int index, const char *optstring, void *arg); @date Sat March 6 1999 @author Gabrielle Allen @desc - Loops over all variables and outputs them if necessary + Loops over all variables and outputs them if necessary @enddesc - @calledby CCTK_OutputGH ("IOASCII") - @history - - @endhistory - @var GH - @vdesc Pointer to CCTK GH - @vtype cGH - @vio in + @calls IOASCII_TimeFor1D + IOASCII_Write1D + + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH * + @vio in @endvar @@*/ int IOASCII_Output1DGH (cGH *GH) { - int index; + int vindex; asciiioGH *myGH; const char *name; /* Get the GH extensions for IOASCII */ - myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); CheckSteerableParameters (myGH); @@ -60,31 +69,31 @@ int IOASCII_Output1DGH (cGH *GH) } /* Loop over all variables */ - for (index = 0; index < CCTK_NumVars (); index++) + for (vindex = 0; vindex < CCTK_NumVars (); vindex++) { /* Check if this variable should be output */ - if (! IOASCII_TimeFor1D (GH, index)) + if (! IOASCII_TimeFor1D (GH, vindex)) { continue; } /* Get the variable name for this index (for filename) */ - name = CCTK_VarName (index); + name = CCTK_VarName (vindex); #ifdef IO_DEBUG printf ("\nIn IOASCII Output1DGH\n---------------------\n"); - printf (" Index = %d\n", index); + printf (" Index = %d\n", vindex); printf (" Variable = -%s-\n", name); printf (" On iteration %d\n", GH->cctk_iteration); - printf (" Last output iteration was = %d\n", myGH->out1D_last [index]); + printf (" Last output iteration was = %d\n", myGH->out1D_last[vindex]); #endif /* Make the IO call */ - IOASCII_Write1D (GH, index, name); + IOASCII_Write1D (GH, vindex, name); /* Register variable as having 1D output this iteration */ - myGH->out1D_last [index] = GH->cctk_iteration; + myGH->out1D_last[vindex] = GH->cctk_iteration; } /* end of loop over all variables */ @@ -97,45 +106,45 @@ int IOASCII_Output1DGH (cGH *GH) @date Sat March 6 1999 @author Gabrielle Allen @desc - unconditional output of a variable using the IOASCII output method + Unconditional output of a variable + using the IOASCII output method @enddesc - @calledby IOASCII_Output1DGH, CCTK_OutputVarAsByMethod ("IOASCII") - @var GH - @vdesc Pointer to CCTK GH - @vtype cGH - @vio in - @vcomment + @calls IOASCII_Write1D + + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH * + @vio in @endvar - @var fullname - @vdesc complete name of variable to output - @vtype const char * - @vio in - @vcomment + @var fullname + @vdesc complete name of variable to output + @vtype const char * + @vio in @endvar - @var alias - @vdesc alias name of variable to output (used to generate output filename) - @vtype const char * - @vio in - @vcomment + @var alias + @vdesc alias name of variable to output + (used to generate output filename) + @vtype const char * + @vio in @endvar @@*/ int IOASCII_Output1DVarAs (cGH *GH, const char *fullname, const char *alias) { - int index; + int vindex; - index = CCTK_VarIndex (fullname); + vindex = CCTK_VarIndex (fullname); #ifdef IO_DEBUG printf ("\nIn IOASCII Output1DVarAs\n-------------------\n"); printf (" Fullname = -%s-\n", fullname); printf (" Alias = -%s-\n", alias); - printf (" Index = %d\n", index); + printf (" Index = %d\n", vindex); #endif - if (CheckOutputVar (index) == 0) + if (CheckOutputVar (vindex) == 0) { - IOASCII_Write1D (GH, index, alias); + IOASCII_Write1D (GH, vindex, alias); } return (0); @@ -147,27 +156,22 @@ int IOASCII_Output1DVarAs (cGH *GH, const char *fullname, const char *alias) @date Sat March 6 1999 @author Gabrielle Allen @desc - Decides if it is time to output a variable using the IO 1D output - method + Decides if it is time to output a variable + using the IO 1D output method @enddesc - @calledby IOASCII_Output1DGH - @history - @endhistory - @var GH - @vdesc Pointer to CCTK GH - @vtype cGH - @vio in - @vcomment - @endvar - @var index - @vdesc index of variable - @vtype int - @vio in - @vcomment - @endvar + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH * + @vio in + @endvar + @var vindex + @vdesc index of variable + @vtype int + @vio in + @endvar @@*/ -int IOASCII_TimeFor1D (cGH *GH, int index) +int IOASCII_TimeFor1D (cGH *GH, int vindex) { int return_type; asciiioGH *myGH; @@ -178,7 +182,7 @@ int IOASCII_TimeFor1D (cGH *GH, int index) return_type = 0; /* Get the GH extensions for IOASCII */ - myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); CheckSteerableParameters (myGH); @@ -189,13 +193,13 @@ int IOASCII_TimeFor1D (cGH *GH, int index) } /* Check if this variable should be output */ - if (myGH->do_out1D [index] && + if (myGH->do_out1D[vindex] && GH->cctk_iteration % myGH->out1D_every == 0) { /* Check if this variable wasn't already output this iteration */ - if (myGH->out1D_last[index] == GH->cctk_iteration) + if (myGH->out1D_last[vindex] == GH->cctk_iteration) { - fullname = CCTK_FullName (index); + fullname = CCTK_FullName (vindex); CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, "Already done IOASCII 1D output for '%s' in current " "iteration (probably via triggers)", fullname); @@ -216,43 +220,43 @@ int IOASCII_TimeFor1D (cGH *GH, int index) @date Sat March 6 1999 @author Gabrielle Allen @desc - Triggers the output a variable using the IOASCII output method - method + Triggers the output a variable + using the IOASCII output method method @enddesc - @calledby CCTK scheduler - @var GH - @vdesc Pointer to CCTK GH - @vtype cGH - @vio in - @vcomment + @calls IOASCII_Write1D + + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH * + @vio in @endvar - @var index - @vdesc index of variable to output - @vtype int - @vio in - @vcomment + @var vindex + @vdesc index of variable to output + @vtype int + @vio in @endvar @@*/ -int IOASCII_TriggerOutput1D (cGH *GH, int index) +int IOASCII_TriggerOutput1D (cGH *GH, int vindex) { const char *var; asciiioGH *myGH; - myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - var = CCTK_VarName (index); + var = CCTK_VarName (vindex); /* Do the 1D output */ #ifdef IO_DEBUG printf ("\nIn IOASCII TriggerOutput1D\n---------------------\n"); - printf (" Index = %d\n", index); + printf (" Index = %d\n", vindex); printf (" Variable = -%s-\n", var); #endif - IOASCII_Write1D (GH, index, var); + IOASCII_Write1D (GH, vindex, var); /* Register variables as having 1D output this iteration */ - myGH->out1D_last [index] = GH->cctk_iteration; + myGH->out1D_last[vindex] = GH->cctk_iteration; return (0); } @@ -290,7 +294,7 @@ static void CheckSteerableParameters (asciiioGH *myGH) /* check if this variable can be output (static conditions) */ -static int CheckOutputVar (int index) +static int CheckOutputVar (int vindex) { int retval; int grouptype; @@ -298,11 +302,11 @@ static int CheckOutputVar (int index) /* check the variable type */ - grouptype = CCTK_GroupTypeFromVarI (index); + grouptype = CCTK_GroupTypeFromVarI (vindex); retval = grouptype != CCTK_GF && grouptype != CCTK_ARRAY; if (retval) { - fullname = CCTK_FullName (index); + fullname = CCTK_FullName (vindex); CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "No IOASCII 1D output for '%s' (not a grid function " "or an array)", fullname); @@ -315,14 +319,14 @@ static int CheckOutputVar (int index) /* callback for CCTK_TraverseString() to set the output flag for the given variable */ -static void SetOutputFlag (int index, const char *optstring, void *arg) +static void SetOutputFlag (int vindex, const char *optstring, void *arg) { char *flags = (char *) arg; - if (CheckOutputVar (index) == 0) + if (CheckOutputVar (vindex) == 0) { - flags[index] = 1; + flags[vindex] = 1; } if (optstring) diff --git a/src/Output2D.c b/src/Output2D.c index 3fa477e..2306a5a 100644 --- a/src/Output2D.c +++ b/src/Output2D.c @@ -3,8 +3,9 @@ @date Thu May 11 2000 @author Thomas Radke @desc - Functions to deal with 2D ASCII output of variables + Functions to deal with 2D ASCII output of variables @enddesc + @version $Id$ @@*/ #include @@ -15,13 +16,22 @@ #include "cctk_Parameters.h" #include "ioASCIIGH.h" -/*#define IOASCII_DEBUG*/ +/* the rcs ID and its dummy function to use it */ +static char *rcsid = "$Id$"; +CCTK_FILEVERSION(CactusBase_IOASCII_Output2D_c) -/* function prototypes */ -int IOASCII_TimeFor2D (cGH *GH, int index); -static int CheckOutputVar (int index); +/* define this if you want debug output */ +/*#define IOASCII_DEBUG 1*/ + + +/* prototypes of routines defined in this source file */ +int IOASCII_TriggerOutput2D (cGH *GH, int vindex); +int IOASCII_Output2DVarAs (cGH *GH, const char *fullname, const char *alias); +int IOASCII_TimeFor2D (cGH *GH, int vindex); +int IOASCII_Output2DGH (cGH *GH); +static int CheckOutputVar (int vindex); static void CheckSteerableParameters (asciiioGH *myGH); -static void SetOutputFlag (int index, const char *optstring, void *arg); +static void SetOutputFlag (int vindex, const char *optstring, void *arg); /*@@ @@ -29,27 +39,26 @@ static void SetOutputFlag (int index, const char *optstring, void *arg); @date Sat March 6 1999 @author Gabrielle Allen @desc - Loops over all variables and outputs them if necessary + Loops over all variables and outputs them if necessary @enddesc - @calledby CCTK_OutputGH ("IOASCII") - @history - - @endhistory - @var GH - @vdesc Pointer to CCTK GH - @vtype cGH - @vio in + @calls IOASCII_TimeFor2D + IOASCII_Write2D + + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH * + @vio in @endvar @@*/ int IOASCII_Output2DGH (cGH *GH) { - int index; + int vindex; asciiioGH *myGH; const char *name; /* Get the GH extensions for IOASCII */ - myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); CheckSteerableParameters (myGH); @@ -60,31 +69,31 @@ int IOASCII_Output2DGH (cGH *GH) } /* Loop over all variables */ - for (index = 0; index < CCTK_NumVars (); index++) + for (vindex = 0; vindex < CCTK_NumVars (); vindex++) { /* Check if this variable should be output */ - if (! IOASCII_TimeFor2D (GH, index)) + if (! IOASCII_TimeFor2D (GH, vindex)) { continue; } /* Get the variable name for this index (for filename) */ - name = CCTK_VarName (index); + name = CCTK_VarName (vindex); #ifdef IO_DEBUG printf ("\nIn IOASCII Output2DGH\n---------------------\n"); - printf (" Index = %d\n", index); + printf (" Index = %d\n", vindex); printf (" Variable = -%s-\n", name); printf (" On iteration %d\n", GH->cctk_iteration); - printf (" Last output iteration was = %d\n", myGH->out2D_last [index]); + printf (" Last output iteration was = %d\n", myGH->out2D_last[vindex]); #endif /* Make the IO call */ - IOASCII_Write2D (GH, index, name); + IOASCII_Write2D (GH, vindex, name); /* Register GF as having 2D output this iteration */ - myGH->out2D_last [index] = GH->cctk_iteration; + myGH->out2D_last[vindex] = GH->cctk_iteration; } /* end of loop over all variables */ @@ -97,45 +106,45 @@ int IOASCII_Output2DGH (cGH *GH) @date Sat March 6 1999 @author Gabrielle Allen @desc - unconditional output of a variable using the IOASCII output method + Unconditional output of a variable + using the IOASCII 2D output method @enddesc - @calledby IOASCII_Output2DGH, CCTK_OutputVarAsByMethod ("IOASCII") - @var GH - @vdesc Pointer to CCTK GH - @vtype cGH - @vio in - @vcomment + @calls IOASCII_Write2D + + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH * + @vio in @endvar - @var fullname - @vdesc complete name of variable to output - @vtype const char * - @vio in - @vcomment + @var fullname + @vdesc complete name of variable to output + @vtype const char * + @vio in @endvar - @var alias - @vdesc alias name of variable to output (used to generate output filename) - @vtype const char * - @vio in - @vcomment + @var alias + @vdesc alias name of variable to output + (used to generate output filename) + @vtype const char * + @vio in @endvar @@*/ int IOASCII_Output2DVarAs (cGH *GH, const char *fullname, const char *alias) { - int index; + int vindex; - index = CCTK_VarIndex (fullname); + vindex = CCTK_VarIndex (fullname); #ifdef IO_DEBUG printf ("\nIn IOASCII Output2DVarAs\n-------------------\n"); printf (" Fullname = -%s-\n", fullname); printf (" Alias = -%s-\n", alias); - printf (" Index = %d\n", index); + printf (" Index = %d\n", vindex); #endif - if (CheckOutputVar (index) == 0) + if (CheckOutputVar (vindex) == 0) { - IOASCII_Write2D (GH, index, alias); + IOASCII_Write2D (GH, vindex, alias); } return (0); @@ -147,27 +156,22 @@ int IOASCII_Output2DVarAs (cGH *GH, const char *fullname, const char *alias) @date Sat March 6 1999 @author Gabrielle Allen @desc - Decides if it is time to output a variable using the IO 2D output - method + Decides if it is time to output a variable + using the IOASCII 2D output method @enddesc - @calledby IOASCII_Output2DGH - @history - - @endhistory - @var GH - @vdesc Pointer to CCTK GH - @vtype cGH - @vio in - @vcomment - @endvar - @var index - @vdesc index of variable - @vtype int - @vio in - @vcomment - @endvar + + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH * + @vio in + @endvar + @var vindex + @vdesc index of variable + @vtype int + @vio in + @endvar @@*/ -int IOASCII_TimeFor2D (cGH *GH, int index) +int IOASCII_TimeFor2D (cGH *GH, int vindex) { int return_type; asciiioGH *myGH; @@ -178,7 +182,7 @@ int IOASCII_TimeFor2D (cGH *GH, int index) return_type = 0; /* Get the GH extensions for IOASCII */ - myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); CheckSteerableParameters (myGH); @@ -189,12 +193,12 @@ int IOASCII_TimeFor2D (cGH *GH, int index) } /* Check if this variable should be output */ - if (myGH->do_out2D [index] && (GH->cctk_iteration % myGH->out2D_every == 0)) + if (myGH->do_out2D[vindex] && (GH->cctk_iteration % myGH->out2D_every == 0)) { /* Check if variable wasn't already output this iteration */ - if (myGH->out2D_last[index] == GH->cctk_iteration) + if (myGH->out2D_last[vindex] == GH->cctk_iteration) { - fullname = CCTK_FullName (index); + fullname = CCTK_FullName (vindex); CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, "Already done IOASCII 2D output for '%s' in current " "iteration (probably via triggers)", fullname); @@ -215,43 +219,44 @@ int IOASCII_TimeFor2D (cGH *GH, int index) @date Sat March 6 1999 @author Gabrielle Allen @desc - Triggers the output a variable using the IOASCII output method - method + Triggers the output of a variable + using the IOASCII 2D output method @enddesc - @calledby CCTK scheduler - @var GH - @vdesc Pointer to CCTK GH - @vtype cGH - @vio in - @vcomment + @calls IOASCII_Write2D + + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH * + @vio in @endvar - @var index - @vdesc index of variable to output - @vtype int - @vio in - @vcomment + @var vindex + @vdesc index of variable to output + @vtype int + @vio in @endvar @@*/ -int IOASCII_TriggerOutput2D (cGH *GH, int index) +int IOASCII_TriggerOutput2D (cGH *GH, int vindex) { const char *var; asciiioGH *myGH; - myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + /* get GH extensions for IOASCII */ + myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - var = CCTK_VarName (index); + var = CCTK_VarName (vindex); /* Do the 2D output */ #ifdef IO_DEBUG printf ("\nIn IOASCII TriggerOutput2D\n---------------------\n"); - printf (" Index = %d\n", index); + printf (" Index = %d\n", vindex); printf (" Variable = -%s-\n", var); #endif - IOASCII_Write2D (GH, index, var); + IOASCII_Write2D (GH, vindex, var); /* Register variables as having 2D output this iteration */ - myGH->out2D_last [index] = GH->cctk_iteration; + myGH->out2D_last[vindex] = GH->cctk_iteration; return (0); } @@ -289,7 +294,7 @@ static void CheckSteerableParameters (asciiioGH *myGH) /* check if this variable can be output (static conditions) */ -static int CheckOutputVar (int index) +static int CheckOutputVar (int vindex) { int groupindex; cGroup groupinfo; @@ -298,7 +303,7 @@ static int CheckOutputVar (int index) /* get the variable group indormation */ - groupindex = CCTK_GroupIndexFromVarI (index); + groupindex = CCTK_GroupIndexFromVarI (vindex); CCTK_GroupData (groupindex, &groupinfo); /* check if variable is of dimension 3 and is a GF or array type */ @@ -314,7 +319,7 @@ static int CheckOutputVar (int index) if (errormsg) { - fullname = CCTK_FullName (index); + fullname = CCTK_FullName (vindex); CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, errormsg, fullname); free (fullname); } @@ -325,15 +330,15 @@ static int CheckOutputVar (int index) /* callback for CCTK_TraverseString() to set the output flag for the given variable */ -static void SetOutputFlag (int index, const char *optstring, void *arg) +static void SetOutputFlag (int vindex, const char *optstring, void *arg) { char *flags = (char *) arg; /* Check the variable type */ - if (CheckOutputVar (index) == 0) + if (CheckOutputVar (vindex) == 0) { - flags[index] = 1; + flags[vindex] = 1; } if (optstring) diff --git a/src/Startup.c b/src/Startup.c index ad7fc69..4fa5eab 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -3,8 +3,9 @@ @date Sat Feb 6 1999 @author Gabrielle Allen @desc - Startup routines for IO. + Startup routines for IOASCII. @enddesc + @version $Id$ @@*/ @@ -14,6 +15,18 @@ #include "cctk.h" #include "cctk_IOMethods.h" #include "cctk_Parameters.h" +#include "ioASCIIGH.h" + +/* the rcs ID and its dummy function to use it */ +static char *rcsid = "$Id$"; +CCTK_FILEVERSION(CactusBase_IOASCII_Startup_c) + + +/* prototypes of routines defined in this source file */ +void IOASCII_Startup (void); +static void *IOASCII_SetupGH (tFleshConfig *config, + int convergence_level, + cGH *GH); /* prototypes of functions to be registered */ int IOASCII_Output1DGH (cGH *GH); @@ -24,32 +37,22 @@ int IOASCII_Output2DGH (cGH *GH); int IOASCII_TriggerOutput2D (cGH *GH, int); int IOASCII_TimeFor2D (cGH *GH, int); int IOASCII_Output2DVarAs (cGH *GH, const char *var, const char *alias); -void *IOASCII_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH); -int IOASCII_InitGH (cGH *GH); + /*@@ - @routine IOASCII_Startup - @date Sat Feb 6 1999 - @author Gabrielle Allen + @routine IOASCII_Startup + @date Sat Feb 6 1999 + @author Gabrielle Allen @desc - The startup registration routine for IO. - Registers the GH extensions needed for IO and - the registerable routines used for each method of IO. - IO does not overload any functions. + The startup registration routine for IOASCII. + Registers the GH extensions needed for IOASCII + along with its setup routine. @enddesc - @calls - @calledby - @history - - @endhistory - + @calls CCTK_RegisterGHExtensionSetupGH @@*/ void IOASCII_Startup (void) { - int IOMethod; - int IO_GHExtension; - - + /* check that thorn IOUtil was activated */ if (CCTK_GHExtensionHandle ("IO") < 0) { CCTK_WARN (1, "Thorn IOUtil was not activated. " @@ -57,21 +60,158 @@ void IOASCII_Startup (void) return; } - IO_GHExtension = CCTK_RegisterGHExtension ("IOASCII"); - CCTK_RegisterGHExtensionSetupGH (IO_GHExtension, IOASCII_SetupGH); - CCTK_RegisterGHExtensionInitGH (IO_GHExtension, IOASCII_InitGH); + CCTK_RegisterGHExtensionSetupGH (CCTK_RegisterGHExtension ("IOASCII"), + IOASCII_SetupGH); + +} + + +/****************************************************************************/ +/* local routines */ +/****************************************************************************/ + /*@@ + @routine IOASCII_SetupGH + @date Sat Feb 6 1999 + @author Gabrielle Allen + @desc + Allocates and sets up IOASCII's GH extension structure + @enddesc + + @calls CCTK_RegisterIOMethod + CCTK_RegisterIOMethodOutputGH + CCTK_RegisterIOMethodOutputVarAs + CCTK_RegisterIOMethodTimeToOutput + CCTK_RegisterIOMethodTriggerOutput + + @var config + @vdesc the CCTK configuration as provided by the flesh + @vtype tFleshConfig * + @vio unused + @endvar + @var convergence_level + @vdesc the convergence level + @vtype int + @vio unused + @endvar + @var GH + @vdesc Pointer to CCTK grid hierarchy + @vtype cGH * + @vio in + @endvar + + @returntype void * + @returndesc + pointer to the allocated GH extension structure + @endreturndesc +@@*/ +static void *IOASCII_SetupGH (tFleshConfig *config, + int convergence_level, + cGH *GH) +{ + DECLARE_CCTK_PARAMETERS + int i; + asciiioGH *newGH; + + + /* suppress compiler warnings about unused variables */ + config = config; + convergence_level = convergence_level; + GH = GH; /* Register the IOASCII routines as output methods */ - IOMethod = CCTK_RegisterIOMethod ("IOASCII_1D"); - CCTK_RegisterIOMethodOutputGH (IOMethod, IOASCII_Output1DGH); - CCTK_RegisterIOMethodOutputVarAs (IOMethod, IOASCII_Output1DVarAs); - CCTK_RegisterIOMethodTimeToOutput (IOMethod, IOASCII_TimeFor1D); - CCTK_RegisterIOMethodTriggerOutput (IOMethod, IOASCII_TriggerOutput1D); - - IOMethod = CCTK_RegisterIOMethod ("IOASCII_2D"); - CCTK_RegisterIOMethodOutputGH (IOMethod, IOASCII_Output2DGH); - CCTK_RegisterIOMethodOutputVarAs (IOMethod, IOASCII_Output2DVarAs); - CCTK_RegisterIOMethodTimeToOutput (IOMethod, IOASCII_TimeFor2D); - CCTK_RegisterIOMethodTriggerOutput (IOMethod, IOASCII_TriggerOutput2D); + i = CCTK_RegisterIOMethod ("IOASCII_1D"); + CCTK_RegisterIOMethodOutputGH (i, IOASCII_Output1DGH); + CCTK_RegisterIOMethodOutputVarAs (i, IOASCII_Output1DVarAs); + CCTK_RegisterIOMethodTimeToOutput (i, IOASCII_TimeFor1D); + CCTK_RegisterIOMethodTriggerOutput (i, IOASCII_TriggerOutput1D); + + i = CCTK_RegisterIOMethod ("IOASCII_2D"); + CCTK_RegisterIOMethodOutputGH (i, IOASCII_Output2DGH); + CCTK_RegisterIOMethodOutputVarAs (i, IOASCII_Output2DVarAs); + CCTK_RegisterIOMethodTimeToOutput (i, IOASCII_TimeFor2D); + CCTK_RegisterIOMethodTriggerOutput (i, IOASCII_TriggerOutput2D); + + /* allocate the GH extension and its components */ + newGH = (asciiioGH *) malloc (sizeof (asciiioGH)); + + i = CCTK_NumVars (); + newGH->do_out1D = (char *) malloc (i * sizeof (char)); + newGH->do_out2D = (char *) malloc (i * sizeof (char)); + newGH->out1D_last = (int *) malloc (i * sizeof (int)); + newGH->out2D_last = (int *) malloc (i * sizeof (int)); + newGH->spxyz = (int ***) malloc (CCTK_MaxDim() * sizeof (int **)); + newGH->sp2xyz = (int **) malloc (3 * sizeof (int *)); + + for (i = CCTK_MaxDim () - 1; i >= 0; i--) + { + newGH->spxyz[i] = (int **) malloc (3 * sizeof (int *)); + newGH->spxyz[i][0] = (int *) malloc (3 * sizeof (int )); + newGH->spxyz[i][1] = (int *) malloc (3 * sizeof (int )); + newGH->spxyz[i][2] = (int *) malloc (3 * sizeof (int )); + + newGH->sp2xyz[i] = (int *) malloc (3 * sizeof (int )); + } + /* How often to output */ + newGH->out1D_every = out_every > 0 ? out_every : -1; + if (out1D_every > 0) + { + newGH->out1D_every = out1D_every; + } + newGH->out2D_every = out_every > 0 ? out_every : -1; + if (out2D_every > 0) + { + newGH->out2D_every = out2D_every; + } + + /* Deal with the output directories */ + /* Check whether "outdirXD" was set. + If so take this dir otherwise default to "IO::outdir" */ + newGH->outdir1D = CCTK_ParameterQueryTimesSet("outdir1D",CCTK_THORNSTRING)>0 ? + strdup (outdir1D) : strdup (outdir); + newGH->outdir2D = CCTK_ParameterQueryTimesSet("outdir2D",CCTK_THORNSTRING)>0 ? + strdup (outdir2D) : strdup (outdir); + + /* create the output dir */ + if (CCTK_MyProc (GH) == 0) + { + i = CCTK_CreateDirectory (0755, newGH->outdir1D); + if (i < 0) + { + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "IOASCII_InitGH: Problem creating 1D output directory '%s'", + newGH->outdir1D); + } + if (i > 0) + { + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "IOASCII_InitGH: 1D output directory '%s' already exists", + newGH->outdir1D); + } + i = CCTK_CreateDirectory (0755, newGH->outdir2D); + if (i < 0) + { + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "IOASCII_InitGH: Problem creating 2D output directory '%s'", + newGH->outdir2D); + } + if (i > 0) + { + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "IOASCII_InitGH: 2D output directory '%s' already exists", + newGH->outdir2D); + } + } + + for (i = 0; i < CCTK_NumVars (); i++) + { + newGH->out1D_last[i] = -1; + newGH->out2D_last[i] = -1; + } + + newGH->filenameList1D = NULL; + newGH->fileList_2D = NULL; + + return (newGH); } + diff --git a/src/Write1D.c b/src/Write1D.c index 6213b96..ecc5fd5 100644 --- a/src/Write1D.c +++ b/src/Write1D.c @@ -40,26 +40,26 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write1D_c) cctk_type, cctk_extract_fn, c_type, data, \ format, file) \ { \ - int i; \ + int h; \ cctk_type *typed_data = (cctk_type *) data; \ \ \ if (grouptype == CCTK_GF) \ { \ - for (i = 0; i < hsize; i++) \ + for (h = 0; h < hsize; h++) \ { \ fprintf (file, format, \ - (double) (coord_data[i] + stagger_offset), \ - (c_type) cctk_extract_fn (typed_data[i])); \ + (double) (coord_data[h] + stagger_offset), \ + (c_type) cctk_extract_fn (typed_data[h])); \ } \ } \ else \ { \ - for (i = 0; i < hsize; i++) \ + for (h = 0; h < hsize; h++) \ { \ fprintf (file, format, \ - (double) i, \ - (c_type) cctk_extract_fn (typed_data[i])); \ + (double) h, \ + (c_type) cctk_extract_fn (typed_data[h])); \ } \ } \ } @@ -90,7 +90,7 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write1D_c) @vtype cGH * @vio in @endvar - @var index + @var vindex @vdesc global index of variable to output @vtype int @vio in @@ -102,7 +102,7 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write1D_c) @endvar @@*/ -void IOASCII_Write1D (cGH *GH, int index, const char *alias) +void IOASCII_Write1D (cGH *GH, int vindex, const char *alias) { DECLARE_CCTK_PARAMETERS asciiioGH *myGH; /* IOASCII extension handle */ @@ -128,18 +128,18 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) int upper, lower; struct stat fileinfo; const char *openmode; - const char *extensions[] = {"xl", "yl", "zl", "dl"}; + static char *extensions[] = {"xl", "yl", "zl", "dl"}; char *filename, *type_extension; ioAdvertisedFileDesc advertisedFile; /* get the variable's group index */ - groupindex = CCTK_GroupIndexFromVarI (index); + groupindex = CCTK_GroupIndexFromVarI (vindex); /* check if variable has storage assigned */ if (! CCTK_QueryGroupStorageI (GH, groupindex)) { - fullname = CCTK_FullName (index); + fullname = CCTK_FullName (vindex); CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "IOASCII_Write1D: No IOASCII_1D output for '%s' (no storage)", fullname); @@ -193,7 +193,7 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) #ifdef DEBUG_IOASCII printf ("\nIn IOASCII Write1D\n------------------\n"); - printf (" Variable index is %d\n",index); + printf (" Variable index is %d\n",vindex); printf (" Alias is -%s-\n",alias); fflush (stdout); #endif @@ -307,9 +307,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) { /* FIXME: this can go after the old filename scheme has gone */ advertisedFile.slice = new_filename_scheme ? - slicename : (char *) extensions[i % 4]; + slicename : extensions[i % 4]; advertisedFile.thorn = CCTK_THORNSTRING; - advertisedFile.varname = CCTK_FullName (index); + advertisedFile.varname = CCTK_FullName (vindex); advertisedFile.description = "One-dimensional line plots"; advertisedFile.mimetype = CCTK_Equals (out_style, "gnuplot") ? "application/gnuplot" : "application/x-graph"; @@ -338,7 +338,7 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) { CCTK_VWarn (8, __LINE__, __FILE__, CCTK_THORNSTRING, "IOASCII_Write1D: No coordinate system '%s' found for '%s'", - coord_system, CCTK_VarName (index)); + coord_system, CCTK_VarName (vindex)); } } else @@ -348,7 +348,7 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) } /* get the current time level */ - timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1; + timelevel = CCTK_NumTimeLevelsFromVarI (vindex) - 1; if (timelevel > 0) { timelevel--; @@ -446,11 +446,11 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) } /* get the variable's 1D data */ - if (Hyperslab_GetHyperslab (GH, 0, index, timelevel, 1, origin, + if (Hyperslab_GetHyperslab (GH, 0, vindex, timelevel, 1, origin, directions, &length, &downsample, &data, &hsize) < 0) { - fullname = CCTK_FullName (index); + fullname = CCTK_FullName (vindex); CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "IOASCII_Write1D: Failed to extract hyperslab for " "variable '%s'", fullname); @@ -465,7 +465,7 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) /* And write it out on processor 0 */ if (myproc == 0 && file[dir] != NULL) { - CCTK_REAL lower, offset; + CCTK_REAL coord_lower, offset; if (group_static_data.grouptype == CCTK_GF) @@ -496,8 +496,8 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) } if (have_coords) { - CCTK_CoordRange (GH, &lower, &offset, 1, NULL, "cart3d"); - offset = lower * sqrt (3); + CCTK_CoordRange (GH, &coord_lower, &offset, 1, NULL, "cart3d"); + offset = coord_lower * sqrt (3); } else { diff --git a/src/Write2D.c b/src/Write2D.c index fe2e304..8c1a563 100644 --- a/src/Write2D.c +++ b/src/Write2D.c @@ -89,7 +89,7 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write2D_c) @vtype cGH * @vio in @endvar - @var index + @var vindex @vdesc index of variable to output @vtype int @vio in @@ -100,7 +100,7 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write2D_c) @vio in @endvar @@*/ -void IOASCII_Write2D (cGH *GH, int index, const char *alias) +void IOASCII_Write2D (cGH *GH, int vindex, const char *alias) { DECLARE_CCTK_PARAMETERS int myproc; @@ -120,20 +120,20 @@ void IOASCII_Write2D (cGH *GH, int index, const char *alias) char *fullname; char slicename[20]; ioAdvertisedFileDesc advertised_file; - const char *extensions[3] = {"yz", "xz", "xy"}; + static char *extensions[3] = {"yz", "xz", "xy"}; /* to make the compiler happy */ fdset_2D = NULL; /* get the variable group indormation */ - groupindex = CCTK_GroupIndexFromVarI (index); + groupindex = CCTK_GroupIndexFromVarI (vindex); CCTK_GroupData (groupindex, &groupinfo); /* check if variable has storage assigned */ if (! CCTK_QueryGroupStorageI (GH, groupindex)) { - fullname = CCTK_FullName (index); + fullname = CCTK_FullName (vindex); CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "No IOASCII 2D output for '%s' (no storage)", fullname); free (fullname); @@ -226,9 +226,9 @@ FIXME: get rid of PUGH here /* FIXME: this can go when we permanently switch the the new filename scheme */ advertised_file.slice = new_filename_scheme ? - slicename : (char *) extensions[dir]; + slicename : extensions[dir]; advertised_file.thorn = CCTK_THORNSTRING; - advertised_file.varname = CCTK_FullName (index); + advertised_file.varname = CCTK_FullName (vindex); advertised_file.description = "Two-dimensional slice plots"; advertised_file.mimetype = "application/gnuplot"; @@ -277,7 +277,7 @@ FIXME: get rid of PUGH here } /* get the timelevel for the variable to output */ - timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1; + timelevel = CCTK_NumTimeLevelsFromVarI (vindex) - 1; if (timelevel > 0) { timelevel--; @@ -356,10 +356,10 @@ FIXME: get rid of PUGH here } /* get the variable slice */ - if (Hyperslab_GetHyperslab (GH, 0, index, timelevel, 2, origin, directions, + if (Hyperslab_GetHyperslab (GH, 0, vindex, timelevel, 2, origin, directions, lengths, downsamples, &data, data_hsizes) < 0) { - fullname = CCTK_FullName (index); + fullname = CCTK_FullName (vindex); CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Failed to extract 2D hyperslab for variable '%s'", fullname); free (fullname); diff --git a/src/ioASCIIGH.h b/src/ioASCIIGH.h index e2235f7..7027ebb 100644 --- a/src/ioASCIIGH.h +++ b/src/ioASCIIGH.h @@ -53,5 +53,5 @@ typedef struct IOASCIIGH { /* function prototypes */ -void IOASCII_Write1D (cGH *GH, int index, const char *alias); -void IOASCII_Write2D (cGH *GH, int index, const char *alias); +void IOASCII_Write1D (cGH *GH, int vindex, const char *alias); +void IOASCII_Write2D (cGH *GH, int vindex, const char *alias); diff --git a/src/make.code.defn b/src/make.code.defn index a8cd01d..b250174 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -4,7 +4,6 @@ # Source files in this directory SRCS = Startup.c\ ChooseOutput.c\ - GHExtension.c\ Output1D.c\ Write1D.c\ Output2D.c\ -- cgit v1.2.3