diff options
author | tradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350> | 2002-04-18 22:46:27 +0000 |
---|---|---|
committer | tradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350> | 2002-04-18 22:46:27 +0000 |
commit | b478b0c5fdb2f04e46a6178de5b7c8a4b9d70338 (patch) | |
tree | d9a41d2d99a856a2f3d75d672a92fb17fa1803c5 | |
parent | c80aad909253d8654578d613ea085faee45055c0 (diff) |
Just some optimizations and cosmetic changes.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@108 94b1c47f-dcfd-45ef-a468-0854c0e9e350
-rw-r--r-- | src/Output1D.c | 83 | ||||
-rw-r--r-- | src/Output2D.c | 90 | ||||
-rw-r--r-- | src/Output3D.c | 88 | ||||
-rw-r--r-- | src/Write1D.c | 34 | ||||
-rw-r--r-- | src/Write2D.c | 45 | ||||
-rw-r--r-- | src/Write3D.c | 18 | ||||
-rw-r--r-- | src/ioASCIIGH.h | 12 |
7 files changed, 94 insertions, 276 deletions
diff --git a/src/Output1D.c b/src/Output1D.c index 4610b02..47f9b4a 100644 --- a/src/Output1D.c +++ b/src/Output1D.c @@ -8,7 +8,6 @@ @version $Id$ @@*/ -#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -21,9 +20,6 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CactusBase_IOASCII_Output1D_c) -/* define this if you want debugging output */ -/* #define IO_DEBUG 1 */ - /******************************************************************** ******************** Internal Routines ************************ @@ -59,42 +55,28 @@ int IOASCII_Output1DGH (const cGH *GH) { int vindex, retval; asciiioGH *myGH; - const char *name; - /* Get the GH extensions for IOASCII */ myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - CheckSteerableParameters (myGH); - /* Loop over all variables */ + /* loop over all variables */ for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++) { - /* Check if this variable should be output */ + /* check if this variable should be output */ if (! IOASCII_TimeFor1D (GH, vindex)) { continue; } - /* Get the variable name for this index (for filename) */ - name = CCTK_VarName (vindex); - -#ifdef IO_DEBUG - printf ("\nIn IOASCII Output1DGH\n---------------------\n"); - 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[vindex]); -#endif - - /* Make the IO call */ - if (IOASCII_Write1D (GH, vindex, name) == 0) + /* do the output */ + if (IOASCII_Write1D (GH, vindex, CCTK_VarName (vindex)) == 0) { - /* Register variable as having 1D output this iteration */ + /* register variable as having 1D output this iteration */ myGH->out1D_last[vindex] = GH->cctk_iteration; retval++; } - } /* end of loop over all variables */ + } return (retval); } @@ -138,16 +120,9 @@ int IOASCII_Output1DVarAs (const cGH *GH, const char *fullname, const char *alia int vindex, retval; + retval = -1; 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", vindex); -#endif - - retval = -1; if (CheckOutputVar (vindex) == 0) { retval = IOASCII_Write1D (GH, vindex, alias); @@ -185,24 +160,22 @@ int IOASCII_Output1DVarAs (const cGH *GH, const char *fullname, const char *alia @@*/ int IOASCII_TimeFor1D (const cGH *GH, int vindex) { - int return_type; + int retval; asciiioGH *myGH; char *fullname; - /* Default is do not do output */ - return_type = 0; + /* default is not do any output */ + retval = 0; - /* Get the GH extensions for IOASCII */ myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - CheckSteerableParameters (myGH); - /* Check if this variable should be output */ + /* check if this variable should be output */ if (myGH->out1D_every[vindex] > 0 && GH->cctk_iteration % myGH->out1D_every[vindex] == 0) { - /* Check if this variable wasn't already output this iteration */ + /* check if this variable wasn't already output this iteration */ if (myGH->out1D_last[vindex] == GH->cctk_iteration) { fullname = CCTK_FullName (vindex); @@ -213,11 +186,11 @@ int IOASCII_TimeFor1D (const cGH *GH, int vindex) } else { - return_type = 1; + retval = 1; } } - return (return_type); + return (retval); } @@ -250,26 +223,14 @@ int IOASCII_TimeFor1D (const cGH *GH, int vindex) int IOASCII_TriggerOutput1D (const cGH *GH, int vindex) { int retval; - const char *var; asciiioGH *myGH; - myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - - var = CCTK_VarName (vindex); - - /* Do the 1D output */ -#ifdef IO_DEBUG - printf ("\nIn IOASCII TriggerOutput1D\n---------------------\n"); - printf (" Index = %d\n", vindex); - printf (" Variable = -%s-\n", var); -#endif - - retval = IOASCII_Write1D (GH, vindex, var); - + retval = IOASCII_Write1D (GH, vindex, CCTK_VarName (vindex)); if (retval == 0) { - /* Register variables as having 1D output this iteration */ + /* register variables as having 1D output this iteration */ + myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); myGH->out1D_last[vindex] = GH->cctk_iteration; } @@ -286,11 +247,11 @@ static void CheckSteerableParameters (asciiioGH *myGH) DECLARE_CCTK_PARAMETERS - /* How often to output */ + /* how often to output */ i = myGH->out1D_every_default; myGH->out1D_every_default = out1D_every > 0 ? out1D_every : out_every; - /* Report if frequency changed */ + /* report if frequency changed */ if (myGH->out1D_every_default != i && ! CCTK_Equals (newverbose, "none")) { if (myGH->out1D_every_default > 0) @@ -338,7 +299,7 @@ static void CheckSteerableParameters (asciiioGH *myGH) } } - /* Save the last setting of 'out1D_vars' parameter */ + /* save the last setting of 'out1D_vars' parameter */ free (myGH->out1D_vars); myGH->out1D_vars = strdup (out1D_vars); } @@ -360,8 +321,8 @@ static int CheckOutputVar (int vindex) { fullname = CCTK_FullName (vindex); CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "CheckOutputVar: No IOASCII 1D output for '%s' (not a grid " - "function or an array)", fullname); + "No IOASCII 1D output for '%s': not a grid function or an " + "array", fullname); free (fullname); } diff --git a/src/Output2D.c b/src/Output2D.c index 0ccb68d..ec806c9 100644 --- a/src/Output2D.c +++ b/src/Output2D.c @@ -8,7 +8,6 @@ @version $Id$ @@*/ -#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -21,9 +20,6 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CactusBase_IOASCII_Output2D_c) -/* define this if you want debug output */ -/*#define IOASCII_DEBUG 1*/ - /******************************************************************** ******************** Internal Routines ************************ @@ -59,42 +55,28 @@ int IOASCII_Output2DGH (const cGH *GH) { int vindex, retval; asciiioGH *myGH; - const char *name; - /* Get the GH extensions for IOASCII */ myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - CheckSteerableParameters (myGH); - /* Loop over all variables */ + /* loop over all variables */ for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++) { - /* Check if this variable should be output */ + /* check if this variable should be output */ if (! IOASCII_TimeFor2D (GH, vindex)) { continue; } - /* Get the variable name for this index (for filename) */ - name = CCTK_VarName (vindex); - -#ifdef IO_DEBUG - printf ("\nIn IOASCII Output2DGH\n---------------------\n"); - 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[vindex]); -#endif - - /* Make the IO call */ - if (IOASCII_Write2D (GH, vindex, name) == 0) + /* do the output */ + if (IOASCII_Write2D (GH, vindex, CCTK_VarName (vindex)) == 0) { - /* Register GF as having 2D output this iteration */ + /* register variable as having 2D output this iteration */ myGH->out2D_last[vindex] = GH->cctk_iteration; retval++; } - } /* end of loop over all variables */ + } return (retval); } @@ -138,16 +120,8 @@ int IOASCII_Output2DVarAs (const cGH *GH, const char *fullname, const char *alia int vindex, retval; - 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", vindex); -#endif - retval = -1; + vindex = CCTK_VarIndex (fullname); if (CheckOutputVar (vindex) == 0) { retval = IOASCII_Write2D (GH, vindex, alias); @@ -185,24 +159,22 @@ int IOASCII_Output2DVarAs (const cGH *GH, const char *fullname, const char *alia @@*/ int IOASCII_TimeFor2D (const cGH *GH, int vindex) { - int return_type; + int retval; asciiioGH *myGH; char *fullname; - /* Default is do not do output */ - return_type = 0; + /* default is not do any output */ + retval = 0; - /* Get the GH extensions for IOASCII */ myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - CheckSteerableParameters (myGH); - /* Check if this variable should be output */ + /* check if this variable should be output */ if (myGH->out2D_every[vindex] > 0 && GH->cctk_iteration % myGH->out2D_every[vindex] == 0) { - /* Check if variable wasn't already output this iteration */ + /* check if variable wasn't already output this iteration */ if (myGH->out2D_last[vindex] == GH->cctk_iteration) { fullname = CCTK_FullName (vindex); @@ -213,11 +185,11 @@ int IOASCII_TimeFor2D (const cGH *GH, int vindex) } else { - return_type = 1; + retval = 1; } } - return (return_type); + return (retval); } @@ -250,27 +222,15 @@ int IOASCII_TimeFor2D (const cGH *GH, int vindex) int IOASCII_TriggerOutput2D (const cGH *GH, int vindex) { int retval; - const char *var; asciiioGH *myGH; - /* get GH extensions for IOASCII */ - myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - - var = CCTK_VarName (vindex); - - /* Do the 2D output */ -#ifdef IO_DEBUG - printf ("\nIn IOASCII TriggerOutput2D\n---------------------\n"); - printf (" Index = %d\n", vindex); - printf (" Variable = -%s-\n", var); -#endif - - retval = IOASCII_Write2D (GH, vindex, var); - + /* do the 2D output */ + retval = IOASCII_Write2D (GH, vindex, CCTK_VarName (vindex)); if (retval == 0) { - /* Register variables as having 2D output this iteration */ + /* register variable as having 2D output this iteration */ + myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); myGH->out2D_last[vindex] = GH->cctk_iteration; } @@ -287,11 +247,11 @@ static void CheckSteerableParameters (asciiioGH *myGH) DECLARE_CCTK_PARAMETERS - /* How often to output */ + /* how often to output */ i = myGH->out2D_every_default; myGH->out2D_every_default = out2D_every > 0 ? out2D_every : out_every; - /* Report if frequency changed */ + /* report if frequency changed */ if (myGH->out2D_every_default != i && ! CCTK_Equals (newverbose, "none")) { if (myGH->out2D_every_default > 0) @@ -339,7 +299,7 @@ static void CheckSteerableParameters (asciiioGH *myGH) } } - /* Save the last setting of 'out2D_vars' parameter */ + /* save the last setting of 'out2D_vars' parameter */ free (myGH->out2D_vars); myGH->out2D_vars = strdup (out2D_vars); } @@ -359,21 +319,21 @@ static int CheckOutputVar (int vindex) groupindex = CCTK_GroupIndexFromVarI (vindex); CCTK_GroupData (groupindex, &groupinfo); - /* check if variable is grid array type with either 2 or 3 dimensions */ errormsg = NULL; if (groupinfo.dim < 2 || groupinfo.dim > 3) { - errormsg = "No IOASCII 2D output for '%s' (dim != [2,3])"; + errormsg = "dim != [2,3]"; } else if (groupinfo.grouptype != CCTK_GF && groupinfo.grouptype != CCTK_ARRAY) { - errormsg = "No IOASCII 2D output for '%s' (not a grid function or array)"; + errormsg = "not a grid function or array"; } if (errormsg) { fullname = CCTK_FullName (vindex); - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, errormsg, fullname); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "No IOASCII 2D output for '%s': %s", fullname, errormsg); free (fullname); } diff --git a/src/Output3D.c b/src/Output3D.c index 78d8354..e31f86f 100644 --- a/src/Output3D.c +++ b/src/Output3D.c @@ -8,7 +8,6 @@ @version $Id$ @@*/ -#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -21,9 +20,6 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CactusBase_IOASCII_Output3D_c) -/* define this if you want debug output */ -/*#define IOASCII_DEBUG 1*/ - /******************************************************************** ******************** Internal Routines ************************ @@ -59,42 +55,28 @@ int IOASCII_Output3DGH (const cGH *GH) { int vindex, retval; asciiioGH *myGH; - const char *name; - /* Get the GH extensions for IOASCII */ myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - CheckSteerableParameters (myGH); - /* Loop over all variables */ + /* loop over all variables */ for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++) { - /* Check if this variable should be output */ + /* check if this variable should be output */ if (! IOASCII_TimeFor3D (GH, vindex)) { continue; } - /* Get the variable name for this index (for filename) */ - name = CCTK_VarName (vindex); - -#ifdef IO_DEBUG - printf ("\nIn IOASCII Output3DGH\n---------------------\n"); - 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->out3D_last[vindex]); -#endif - - /* Make the IO call */ - if (IOASCII_Write3D (GH, vindex, name) == 0) + /* do the output */ + if (IOASCII_Write3D (GH, vindex, CCTK_VarName (vindex)) == 0) { - /* Register GF as having 3D output this iteration */ + /* register variable as having 3D output this iteration */ myGH->out3D_last[vindex] = GH->cctk_iteration; retval++; } - } /* end of loop over all variables */ + } return (retval); } @@ -138,16 +120,9 @@ int IOASCII_Output3DVarAs (const cGH *GH, const char *fullname, const char *alia int vindex, retval; + retval = -1; vindex = CCTK_VarIndex (fullname); -#ifdef IO_DEBUG - printf ("\nIn IOASCII Output3DVarAs\n-------------------\n"); - printf (" Fullname = -%s-\n", fullname); - printf (" Alias = -%s-\n", alias); - printf (" Index = %d\n", vindex); -#endif - - retval = -1; if (CheckOutputVar (vindex) == 0) { retval = IOASCII_Write3D (GH, vindex, alias); @@ -185,24 +160,22 @@ int IOASCII_Output3DVarAs (const cGH *GH, const char *fullname, const char *alia @@*/ int IOASCII_TimeFor3D (const cGH *GH, int vindex) { - int return_type; + int retval; asciiioGH *myGH; char *fullname; - /* Default is do not do output */ - return_type = 0; + /* default is not do any output */ + retval = 0; - /* Get the GH extensions for IOASCII */ myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - CheckSteerableParameters (myGH); - /* Check if this variable should be output */ + /* check if this variable should be output */ if (myGH->out3D_every[vindex] > 0 && GH->cctk_iteration % myGH->out3D_every[vindex] == 0) { - /* Check if variable wasn't already output this iteration */ + /* check if variable wasn't already output this iteration */ if (myGH->out3D_last[vindex] == GH->cctk_iteration) { fullname = CCTK_FullName (vindex); @@ -213,11 +186,11 @@ int IOASCII_TimeFor3D (const cGH *GH, int vindex) } else { - return_type = 1; + retval = 1; } } - return (return_type); + return (retval); } @@ -250,27 +223,15 @@ int IOASCII_TimeFor3D (const cGH *GH, int vindex) int IOASCII_TriggerOutput3D (const cGH *GH, int vindex) { int retval; - const char *var; asciiioGH *myGH; - /* get GH extensions for IOASCII */ - myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - - var = CCTK_VarName (vindex); - - /* Do the 3D output */ -#ifdef IO_DEBUG - printf ("\nIn IOASCII TriggerOutput3D\n---------------------\n"); - printf (" Index = %d\n", vindex); - printf (" Variable = -%s-\n", var); -#endif - - retval = IOASCII_Write3D (GH, vindex, var); - + /* do the 3D output */ + retval = IOASCII_Write3D (GH, vindex, CCTK_VarName (vindex)); if (retval == 0) { - /* Register variables as having 3D output this iteration */ + /* register variables as having 3D output this iteration */ + myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); myGH->out3D_last[vindex] = GH->cctk_iteration; } @@ -287,11 +248,11 @@ static void CheckSteerableParameters (asciiioGH *myGH) DECLARE_CCTK_PARAMETERS - /* How often to output */ + /* how often to output */ i = myGH->out3D_every_default; myGH->out3D_every_default = out3D_every > 0 ? out3D_every : out_every; - /* Report if frequency changed */ + /* report if frequency changed */ if (myGH->out3D_every_default != i && ! CCTK_Equals (newverbose, "none")) { if (myGH->out3D_every_default > 0) @@ -339,7 +300,7 @@ static void CheckSteerableParameters (asciiioGH *myGH) } } - /* Save the last setting of 'out3D_vars' parameter */ + /* save the last setting of 'out3D_vars' parameter */ free (myGH->out3D_vars); myGH->out3D_vars = strdup (out3D_vars); } @@ -363,17 +324,18 @@ static int CheckOutputVar (int vindex) errormsg = NULL; if (groupinfo.dim != 3) { - errormsg = "No IOASCII 3D output for '%s' (dim != 3)"; + errormsg = "dim != 3"; } else if (groupinfo.grouptype != CCTK_GF && groupinfo.grouptype != CCTK_ARRAY) { - errormsg = "No IOASCII 3D output for '%s' (not a grid function or array)"; + errormsg = "not a grid function or array"; } if (errormsg) { fullname = CCTK_FullName (vindex); - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, errormsg, fullname); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "No IOASCII 3D output for '%s': %s", fullname, errormsg); free (fullname); } diff --git a/src/Write1D.c b/src/Write1D.c index 7905c1c..303ea2b 100644 --- a/src/Write1D.c +++ b/src/Write1D.c @@ -35,9 +35,6 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write1D_c) /******************************************************************** ******************** Macro Definitions ************************ ********************************************************************/ -/* uncomment this to enable debugging output */ -/* #define DEBUG_IOASCII 1 */ - /* Macro to output a 1D line (with coordinates if available) as typed data For readability, the macro definition implicitely uses the following variables (which are defined in the calling routine): @@ -151,13 +148,6 @@ int IOASCII_Write1D (const cGH *GH, int vindex, const char *alias) DECLARE_CCTK_PARAMETERS -#ifdef DEBUG_IOASCII - printf ("\nIn IOASCII Write1D\n------------------\n"); - printf (" Variable index is %d\n", vindex); - printf (" Alias is -%s-\n", alias); - fflush (stdout); -#endif - /* get the variable's group index and its full name */ groupindex = CCTK_GroupIndexFromVarI (vindex); fullname = CCTK_FullName (vindex); @@ -582,29 +572,13 @@ static void OpenFile (const cGH *GH, sprintf (slicename, "%s%dD_diagonal", type_extension, gdata->dim); } - /* skip the pathname if output goes into current directory */ - if (strcmp (myGH->outdir1D, ".")) - { - sprintf (filename, "%s/%s_%s%s", myGH->outdir1D, alias, - slicename, file_extension); - } - else - { - sprintf (filename, "%s_%s%s", alias, slicename, file_extension); - } + sprintf (filename, "%s%s_%s%s", myGH->outdir1D, alias, slicename, + file_extension); } else { - /* skip the pathname if output goes into current directory */ - if (strcmp (myGH->outdir1D, ".")) - { - sprintf (filename, "%s/%s%s.%s", myGH->outdir1D, alias, - type_extension, extensions[dir]); - } - else - { - sprintf (filename, "%s%s.%s", alias, type_extension, extensions[dir]); - } + sprintf (filename, "%s%s%s.%s", myGH->outdir1D, alias, type_extension, + extensions[dir]); } /* create the output file the first time through diff --git a/src/Write2D.c b/src/Write2D.c index 6442060..32c8642 100644 --- a/src/Write2D.c +++ b/src/Write2D.c @@ -27,10 +27,6 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write2D_c) /******************************************************************** ******************** Macro Definitions ************************ ********************************************************************/ -/* uncomment this to enable debugging output */ -/* #define DEBUG_IOASCII 1 */ - -/* macro to output a time slice as typed data */ /* Macro to output a 2D slice (with coordinates if available) as typed data For readability, the macro definition implicitely uses the following variables (which are defined in the calling routine): @@ -140,8 +136,7 @@ int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias) int extent_int[3]; CCTK_INT mapping; CCTK_REAL offset[2]; - CCTK_INT vindices[3]; - CCTK_INT origin[3], extent[3], direction[6], hsize[2]; + CCTK_INT vindices[3], origin[3], extent[3], direction[6], hsize[2]; void *hdata[3]; FILE **fileset; DECLARE_CCTK_PARAMETERS @@ -161,7 +156,7 @@ int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias) return (-1); } - /* Get the handle for IOASCII extensions */ + /* get the handle for IOASCII extensions */ myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); /* get the number of slices to output */ @@ -226,6 +221,7 @@ int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias) fileset = NULL; } + /* get the extents of the variable */ CCTK_GroupgshVI (GH, 3, extent_int, vindex); /* now do the actual I/O looping over all directions */ @@ -307,7 +303,7 @@ int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias) /* release the mapping structure */ Hyperslab_FreeMapping (mapping); - /* And dump the data to file */ + /* and dump the data to file */ if (myproc == 0 && fileset) { if (num_returned_hslabs == num_requested_hslabs) @@ -421,41 +417,18 @@ static FILE **OpenFile (const cGH *GH, myGH->sp2xyz[dim - 1][dir]); } - /* skip pathname if output goes into current directory */ - if (strcmp (myGH->outdir2D, ".")) - { - sprintf (filename, "%s/%s_%s.asc", myGH->outdir2D, alias, slicename); - } - else - { - sprintf (filename, "%s_%s.asc", alias, slicename); - } + sprintf (filename, "%s/%s_%s.asc", myGH->outdir2D, alias, slicename); } else { - /* skip pathname if output goes into current directory */ - if (strcmp (myGH->outdir2D, ".")) + if (dim == 2) { - if (dim == 2) - { - sprintf (filename, "%s/%s_2D.gnuplot", myGH->outdir2D, alias); - } - else - { - sprintf (filename, "%s/%s_2d_%s.gnuplot", myGH->outdir2D, alias, - extensions[dir]); - } + sprintf (filename, "%s%s_2D.gnuplot", myGH->outdir2D, alias); } else { - if (dim == 2) - { - sprintf (filename, "%s_2D.gnuplot", alias); - } - else - { - sprintf (filename, "%s_2d_%s.gnuplot", alias, extensions[dir]); - } + sprintf (filename, "%s%s_2d_%s.gnuplot", myGH->outdir2D, alias, + extensions[dir]); } } diff --git a/src/Write3D.c b/src/Write3D.c index 0aee309..cc3bf6b 100644 --- a/src/Write3D.c +++ b/src/Write3D.c @@ -27,9 +27,6 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write3D_c) /******************************************************************** ******************** Macro Definitions ************************ ********************************************************************/ -/* uncomment this to enable debugging output */ -/* #define DEBUG_IOASCII 1 */ - /* Macro to output a 3D array (with coordinates if available) as typed data For readability, the macro definition implicitely uses the following variables (which are defined in the calling routine): @@ -138,8 +135,7 @@ int IOASCII_Write3D (const cGH *GH, int vindex, const char *alias) int extent_int[3]; CCTK_REAL offset[3]; CCTK_INT mapping; - CCTK_INT vindices[4]; - CCTK_INT extent[3], hsize[3]; + CCTK_INT vindices[4], extent[3], hsize[3]; const CCTK_INT origin[] = {0, 0, 0}, direction[] = {1, 0, 0, 0, 1, 0, 0, 0, 1}; DECLARE_CCTK_PARAMETERS @@ -347,16 +343,8 @@ static FILE *OpenFile (const cGH *GH, const char *fullname, const char *alias) file = (FILE **) malloc (sizeof (FILE *)); filename = (char *) malloc (strlen (myGH->outdir3D) + strlen (alias) + 9); - /* Open/Create the file */ - /* skip pathname if output goes into current directory */ - if (strcmp (myGH->outdir3D, ".")) - { - sprintf (filename, "%s/%s_3D.asc", myGH->outdir3D, alias); - } - else - { - sprintf (filename, "%s_3D.asc", alias); - } + /* open/create the file */ + sprintf (filename, "%s%s_3D.asc", myGH->outdir3D, alias); /* if restart from recovery, try to open an existing file ... */ *file = fopen (filename, ioUtilGH->recovered ? "a" : "w"); diff --git a/src/ioASCIIGH.h b/src/ioASCIIGH.h index 19d5316..6a60458 100644 --- a/src/ioASCIIGH.h +++ b/src/ioASCIIGH.h @@ -3,12 +3,12 @@ @date Tue 9th Jan 1999 @author Gabrielle Allen @desc - The extensions to the GH structure from IO. + The extensions to the GH structure from IOASCII. @version $Header$ @@*/ -#ifndef _IOASCII_IOASCII_H_ -#define _IOASCII_IOASCII_H_ +#ifndef _IOASCII_IOASCIIGH_H_ +#define _IOASCII_IOASCIIGH_H_ 1 #include "StoreNamedData.h" @@ -22,10 +22,10 @@ typedef struct IOASCIIGH /* default number of times to output */ int out1D_every_default, out2D_every_default, out3D_every_default; - /* flags indicating output for var[i] */ + /* number of times to output every variable */ int *out1D_every, *out2D_every, *out3D_every; - /* variables to output */ + /* lists of variables to output */ char *out1D_vars, *out2D_vars, *out3D_vars; /* directories in which to output */ @@ -71,4 +71,4 @@ int IOASCII_Write3D (const cGH *GH, int vindex, const char *alias); } // extern "C" #endif -#endif /* _IOASCII_IOASCII_H_ */ +#endif /* _IOASCII_IOASCIIGH_H_ */ |