| { |
| "thorn_name": "CactusBase/IOASCII", |
| "url": "https://bitbucket.org/cactuscode/cactusbase.git", |
| "configuration": "# Configuration definition for thorn IOASCII\n# $Header$\n\nREQUIRES IOUtil\n\nREQUIRES THORNS: IOUtil\n", |
| "interface": "# Interface definition for thorn IOASCII\n# $Header$\n\nimplements: IOASCII\n### FIXME: need private inheritance in order to be implementation-compatible\n### with CarpetIOASCII\n#inherits: IO\n\nCCTK_INT FUNCTION \\\n Hyperslab_GetList (CCTK_POINTER_TO_CONST IN cctkGH, \\\n CCTK_INT IN mapping_handle, \\\n CCTK_INT IN num_arrays, \\\n CCTK_INT ARRAY IN procs, \\\n CCTK_INT ARRAY IN vindices, \\\n CCTK_INT ARRAY IN timelevels, \\\n CCTK_INT ARRAY IN hdatatypes, \\\n CCTK_POINTER ARRAY IN hdata, \\\n CCTK_INT ARRAY OUT retvals)\n\nCCTK_INT FUNCTION \\\n Hyperslab_GlobalMappingByIndex (CCTK_POINTER_TO_CONST IN cctkGH, \\\n CCTK_INT IN vindex, \\\n CCTK_INT IN hdim, \\\n CCTK_INT ARRAY IN direction, \\\n CCTK_INT ARRAY IN origin, \\\n CCTK_INT ARRAY IN extent, \\\n CCTK_INT ARRAY IN downsample, \\\n CCTK_INT IN table_handle, \\\n CCTK_INT CCTK_FPOINTER IN \\\n conversion_fn (CCTK_INT IN nelems, \\\n CCTK_INT IN src_stride, \\\n CCTK_INT IN dst_stride, \\\n CCTK_INT IN src_type, \\\n CCTK_INT IN dst_type, \\\n CCTK_POINTER_TO_CONST IN from, \\\n CCTK_POINTER IN to), \\\n CCTK_INT ARRAY OUT hsize)\n\nCCTK_INT FUNCTION Hyperslab_FreeMapping (CCTK_INT IN mapping_handle)\n\n\nREQUIRES FUNCTION Hyperslab_GetList\nREQUIRES FUNCTION Hyperslab_GlobalMappingByIndex\nREQUIRES FUNCTION Hyperslab_FreeMapping\n\nCCTK_INT FUNCTION IO_TruncateOutputFiles \\\n (CCTK_POINTER_TO_CONST IN GH)\n\nREQUIRES FUNCTION IO_TruncateOutputFiles\n\nCCTK_INT FUNCTION Coord_GroupSystem \\\n (CCTK_POINTER_TO_CONST IN GH, \\\n CCTK_STRING IN groupname)\n\nUSES FUNCTION Coord_GroupSystem\n", |
| "param": "# Parameter definitions for thorn IOASCII\n# $Header$\n\n\n#############################################################################\n### declare IOASCII parameters\n#############################################################################\nprivate:\n\n##########################\n# Directories to output to\n##########################\nSTRING out1D_dir \"Output directory for 1D IOASCII files, overrides IO::out_dir\" STEERABLE = RECOVER\n{\n \".+\" :: \"A valid directory name\"\n \"^$\" :: \"An empty string to choose the default from IO::out_dir\"\n} \"\"\nSTRING out2D_dir \"Output directory for 2D IOASCII files, overrides out_dir\" STEERABLE = RECOVER\n{\n \".+\" :: \"A valid directory name\"\n \"^$\" :: \"An empty string to choose the default from IO::out_dir\"\n} \"\"\nSTRING out3D_dir \"Output directory for 3D IOASCII files, overrides IO::out_dir\" STEERABLE = RECOVER\n{\n \".+\" :: \"A valid directory name\"\n \"^$\" :: \"An empty string to choose the default from IO::out_dir\"\n} \"\"\n\n\n##########################\n# What variables to output\n##########################\nSTRING out1D_vars \"Variables to output in 1D IOASCII file format\" STEERABLE = ALWAYS\n{\n \".+\" :: \"Space-separated list of fully qualified variable/group names\"\n \"^$\" :: \"An empty string to output nothing\"\n} \"\"\nSTRING out2D_vars \"Variables to output in 2D IOASCII file format\" STEERABLE = ALWAYS\n{\n \".+\" :: \"Space-separated list of fully qualified variable/group names\"\n \"^$\" :: \"An empty string to output nothing\"\n} \"\"\nSTRING out3D_vars \"Variables to output in 3D IOASCII file format\" STEERABLE = ALWAYS\n{\n \".+\" :: \"Space-separated list of fully qualified variable/group names\"\n \"^$\" :: \"An empty string to output nothing\"\n} \"\"\n\n\n########################\n# How often to do output\n########################\nINT out1D_every \"How often to do 1D IOASCII output, overrides IO::out_every\" STEERABLE = ALWAYS\n{\n 1:* :: \"Every so many iterations\"\n 0: :: \"Disable 1D IOASCII output\"\n -1: :: \"Default to IO::out_every\"\n} -1\nINT out2D_every \"How often to do 2D IOASCII output, overrides IO::out_every\" STEERABLE = ALWAYS\n{\n 1:* :: \"Every so many iterations\"\n 0: :: \"Disable 2D IOASCII output\"\n -1: :: \"Default to IO::out_every\"\n} -1\nINT out3D_every \"How often to do 3D IOASCII output, overrides IO::out_every\" STEERABLE = ALWAYS\n{\n 1:* :: \"Every so many iterations\"\n 0: :: \"Disable 3D IOASCII output\"\n -1: :: \"Default to IO::out_every\"\n} -1\n\n\n#################\n# output style\n#################\nKEYWORD out1D_style \"Which style for 1D lines IOASCII output\"\n{\n \"xgraph\" :: \"f over x plots suitable for xgraph\"\n \"gnuplot f(x)\" :: \"f over x plots suitable for gnuplot\"\n \"gnuplot f(t,x)\" :: \"f over t,x plots suitable for gnuplot\"\n} \"xgraph\"\n\nKEYWORD out2D_style \"Which style for 2D slices IOASCII output\"\n{\n \"gnuplot f(x,y)\" :: \"f over x,y plots suitable for gnuplot\"\n \"gnuplot f(t,x,y)\" :: \"f over t,x,y plots suitable for gnuplot\"\n} \"gnuplot f(x,y)\"\n\nKEYWORD out3D_style \"Which style for 3D volume IOASCII output\"\n{\n \"gnuplot f(x,y,z)\" :: \"f over x,y,z plots suitable for gnuplot\"\n \"gnuplot f(t,x,y,z)\" :: \"f over t,x,y,z plots suitable for gnuplot\"\n} \"gnuplot f(x,y,z)\"\n\nSTRING out_format \"Which format for IOASCII floating-point number output\" STEERABLE = ALWAYS\n{\n \"^(\\.[1]?[0-9])?[EGefg]$\" :: \"output with given precision in exponential / floating point notation\"\n} \".13f\"\n\n\n############################\n# Specific to 1D output\n# Choosing what output to do\n############################\nBOOLEAN out1D_x \"Do 1D IOASCII output in the x-direction\" STEERABLE = ALWAYS\n{\n} \"yes\"\nBOOLEAN out1D_y \"Do 1D IOASCII output in the y-direction\" STEERABLE = ALWAYS\n{\n} \"yes\"\nBOOLEAN out1D_z \"Do 1D IOASCII output in the z-direction\" STEERABLE = ALWAYS\n{\n} \"yes\"\nBOOLEAN out1D_d \"Do 1D IOASCII output in the diagonal-direction\" STEERABLE = ALWAYS\n{\n} \"yes\"\n\n################################\n# Choosing what slices to output\n################################\nREAL out1D_xline_y \"y-coord for 1D lines in x-direction\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [ymin, ymax]\"\n -424242: :: \"Default to IO::out_xline_y\"\n} -424242\nREAL out1D_xline_z \"z-coord for 1D lines in x-direction\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [zmin, zmax]\"\n -424242: :: \"Default to IO::out_xline_z\"\n} -424242\nREAL out1D_yline_x \"x-coord for 1D lines in y-direction\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [xmin, xmax]\"\n -424242: :: \"Default to IO::out_yline_x\"\n} -424242\nREAL out1D_yline_z \"z-coord for 1D lines in y-direction\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [zmin, zmax]\"\n -424242: :: \"Default to IO::out_yline_z\"\n} -424242\nREAL out1D_zline_x \"x-coord for 1D lines in z-direction\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [xmin, xmax]\"\n -424242: :: \"Default to IO::out_zline_x\"\n} -424242\nREAL out1D_zline_y \"y-coord for 1D lines in z-direction\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [ymin, ymax]\"\n -424242: :: \"Default to IO::out_zline_y\"\n} -424242\n\nINT out1D_xline_yi \"y-index (from 0) for 1D lines in x-direction\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, ny)\"\n -1: :: \"Choose the default from IO::out_xline_yi\"\n} -1\nINT out1D_xline_zi \"z-index (from 0) for 1D lines in x-direction\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, nz)\"\n -1: :: \"Choose the default from IO::out_xline_zi\"\n} -1\n\nINT out1D_yline_xi \"x-index (from 0) for 1D lines in y-direction\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, nx)\"\n -1: :: \"Choose the default from IO::out_yline_xi\"\n} -1\nINT out1D_yline_zi \"z-index (from 0) for 1D lines in y-direction\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, nz)\"\n -1: :: \"Choose the default from IO::out_yline_zi\"\n} -1\n\nINT out1D_zline_xi \"x-index (from 0) for 1D lines in z-direction\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, nx)\"\n -1: :: \"Choose the default from IO::out_zline_xi\"\n} -1\nINT out1D_zline_yi \"y-index (from 0) for 1D lines in z-direction\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, ny)\"\n -1: :: \"Choose the default from IO::out_zline_yi\"\n} -1\n\n\n################################\n# Specific to 2D output\n# Choosing what planes to output\n################################\nREAL out2D_yzplane_x \"x-coord for 2D planes in yz\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [xmin, xmax]\"\n -424242: :: \"Default to IO::out_yzplane_x\"\n} -424242\nREAL out2D_xzplane_y \"y-coord for 2D planes in xz\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [ymin, ymax]\"\n -424242: :: \"Default to IO::out_xzplane_y\"\n} -424242\nREAL out2D_xyplane_z \"z-coord for 2D planes in xy\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [zmin, zmax]\"\n -424242: :: \"Default to IO::out_xyplane_z\"\n} -424242\n\nINT out2D_yzplane_xi \"x-index (from 0) for 2D planes in yz\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, nx)\"\n -1: :: \"Choose the default from IO::out_yzplane_xi\"\n} -1\nINT out2D_xzplane_yi \"y-index (from 0) for 2D planes in xz\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, ny)\"\n -1: :: \"Choose the default from IO::out_xzplane_yi\"\n} -1\nINT out2D_xyplane_zi \"z-index (from 0) for 2D planes in xy\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, nz)\"\n -1: :: \"Choose the default from IO::out_xyplane_zi\"\n} -1\n\n\n#############################################################################\n### import IOUtil parameters\n#############################################################################\nshares: IO\n\nUSES STRING out_dir\nUSES INT out_every\nUSES REAL out_xline_y\nUSES REAL out_xline_z\nUSES REAL out_yline_x\nUSES REAL out_yline_z\nUSES REAL out_zline_x\nUSES REAL out_zline_y\nUSES INT out_xline_yi\nUSES INT out_xline_zi\nUSES INT out_yline_xi\nUSES INT out_yline_zi\nUSES INT out_zline_xi\nUSES INT out_zline_yi\nUSES REAL out_yzplane_x\nUSES REAL out_xzplane_y\nUSES REAL out_xyplane_z\nUSES INT out_yzplane_xi\nUSES INT out_xzplane_yi\nUSES INT out_xyplane_zi\nUSES INT out_downsample_x\nUSES INT out_downsample_y\nUSES INT out_downsample_z\nUSES KEYWORD verbose\nUSES KEYWORD out_fileinfo\nUSES BOOLEAN new_filename_scheme\nUSES BOOLEAN strict_io_parameter_check\n", |
| "schedule": "# Schedule definitions for thorn IOASCII\n# $Header$\n\n########################################################################\n### register IOASCII routines\n########################################################################\nschedule IOASCII_Startup at STARTUP after IOUtil_Startup\n{\n LANG:C\n} \"Startup routine\"\n\nschedule IOASCII_Choose1D at BASEGRID after SpatialCoordinates\n{\n LANG:C\n} \"Choose 1D output lines\"\n\nschedule IOASCII_Choose2D at BASEGRID after SpatialCoordinates\n{\n LANG:C\n} \"Choose 2D output planes\"\n", |
| "src": { |
| "make.code.defn": "# Main make.code.defn file for thorn IOASCII\n# $Header$\n\n# Source files in this directory\nSRCS = Startup.c ChooseOutput.c Output1D.c Write1D.c Output2D.c Write2D.c \\\n Output3D.c Write3D.c\n", |
| "Write1D.c": "/*@@\n @file Write1D.c\n @date March 1997\n @author Paul Walker\n @desc\n Output one-dimensional lines in ASCII xgraph/gnuplot format.\n @enddesc\n\n @history\n @hauthor Thomas Radke\n @hdate 30 May 2000\n @hdesc\n Get rid of all the PUGH stuff by using thorn Hyperslab.\n @endhdesc\n @hendhistory\n @version $Id$\n@@*/\n\n#include <math.h> /* sqrt(3) */\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Parameters.h\"\n#include \"util_Table.h\"\n#include \"CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h\"\n#include \"ioASCIIGH.h\"\n\n/* the rcs ID and its dummy function to use it */\nstatic const char *rcsid = \"$Header$\";\nCCTK_FILEVERSION(CactusBase_IOASCII_Write1D_c)\n\n/********************************************************************\n ******************** Macro Definitions ************************\n ********************************************************************/\n/* Macro to output a 1D line (with coordinates if available) as typed data\n For readability, the macro definition implicitely uses the following\n variables (which are defined in the calling routine):\n hdata, hstride, hsize, format[2] */\n#define WRITE_DATA(hstart, cctk_type, c_type, is_complex, fmt, file) \\\n { \\\n int _h; \\\n int _offset = is_complex ? 2 : 1; \\\n const cctk_type *_hdata = hdata[0]; \\\n const CCTK_REAL *_coord = hdata[1]; \\\n \\\n _hdata += hstart; \\\n for (_h = 0; _h < hsize; _h++) { \\\n if (_coord) { \\\n fprintf(file, fmt, (double)_coord[_h], (c_type)_hdata[_h * _offset]); \\\n } else { \\\n fprintf(file, fmt, _h, (c_type)_hdata[_h * _offset]); \\\n } \\\n \\\n if (is_complex && hstride == 1) { \\\n fprintf(file, format[2], (c_type)_hdata[_h * _offset + 1]); \\\n } \\\n fputc('\\n', file); \\\n } \\\n }\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\nstatic void OpenFile(const cGH *GH, const char *fullname, const char *alias,\n const cGroup *gdata, const int *do_dir,\n const CCTK_REAL *coord_lower, int num_files, FILE *file[]);\nstatic void WriteData(int vtype, const char *header, char format[3][64],\n int hsize, int hstride, void *const *const hdata,\n FILE *const file[]);\n\n/*@@\n @routine IOASCII_Write1D\n @date March 1999\n @author Gabrielle Allen\n @desc\n This routine does 1D line output along the orthogonals\n and the diagonal (in case of a cubed grid).\n <p>\n It writes to ASCII files suitable for gnuplot and xgraph.\n A header telling the physical time prefixes the output data.\n @enddesc\n @calls Hyperslab_GlobalMappingByIndex\n Hyperslab_FreeMapping\n Hyperslab_GetList\n OpenFile\n WriteData\n\n @var GH\n @vdesc Pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var vindex\n @vdesc global index of variable to output\n @vtype int\n @vio in\n @endvar\n @var alias\n @vdesc alias name (used for creating the output filename)\n @vtype const char *\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n 0 for success, or<BR>\n -1 if variable has no storage assigned\n @endreturndesc\n@@*/\nint IOASCII_Write1D(const cGH *GH, int vindex, const char *alias) {\n asciiioGH *myGH;\n int do_dir[4];\n CCTK_INT coord_index[4];\n int i, dir, myproc, gindex, have_coords, mapping;\n int hstride, num_files, num_requested_hslabs, num_returned_hslabs;\n int *extent_int;\n cGroup gdata;\n char *fullname, *groupname;\n char header[40], buffer[30];\n CCTK_INT coord_system_handle, coord_handles[3];\n char format[3][64];\n FILE *file[8];\n CCTK_REAL offset;\n CCTK_REAL coord_lower[3];\n CCTK_INT downsample[4];\n CCTK_INT *origin, *direction;\n CCTK_INT hsize, extent;\n CCTK_INT vindices[2];\n void *hdata[2];\n DECLARE_CCTK_PARAMETERS\n\n /* get the variable's group index and its full name */\n gindex = CCTK_GroupIndexFromVarI(vindex);\n fullname = CCTK_FullName(vindex);\n\n /* check if variable has storage assigned */\n if (!CCTK_QueryGroupStorageI(GH, gindex)) {\n CCTK_VWarn(2, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOASCII_Write1D: No IOASCII_1D output for '%s' (no storage)\",\n fullname);\n free(fullname);\n return (-1);\n }\n\n /* get the handle for IOASCII extension */\n myGH = CCTK_GHExtension(GH, \"IOASCII\");\n\n /* get the variable's group information */\n CCTK_GroupData(gindex, &gdata);\n\n /* see what slices should be output */\n do_dir[0] = out1D_x && gdata.dim >= 1;\n do_dir[1] = out1D_y && gdata.dim >= 2;\n do_dir[2] = out1D_z && gdata.dim >= 3;\n /* diagonal slice is done only if variable is 3D */\n do_dir[3] = out1D_d && gdata.dim == 3;\n if (out1D_d && !do_dir[3] && myGH->out1D_last[vindex] < 0) {\n CCTK_VWarn(3, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOASCII_Write1D: No IOASCII_1D diagonal output for '%s' \"\n \"(only implemented for non-staggered 3D variables)\",\n fullname);\n }\n\n /* return if nothing to do */\n if (!(do_dir[0] || do_dir[1] || do_dir[2] || do_dir[3])) {\n free(fullname);\n return (0);\n }\n\n dir = gdata.dim < 3 ? gdata.dim : 3;\n\n have_coords = CCTK_IsFunctionAliased(\"Coord_GroupSystem\");\n if (have_coords) {\n /* get the coordinate system associated with this grid variable */\n groupname = CCTK_GroupName(gindex);\n coord_system_handle = Coord_GroupSystem(GH, groupname);\n free(groupname);\n\n have_coords = coord_system_handle >= 0 &&\n Util_TableGetIntArray(coord_system_handle, dir, coord_handles,\n \"COORDINATES\") >= 0;\n }\n if (have_coords) {\n /* get the coordinate functions and coordinate physical minimum */\n for (i = 0; i < dir; i++) {\n coord_index[i] = -1;\n coord_lower[i] = 0;\n Util_TableGetInt(coord_handles[i], &coord_index[i], \"GAINDEX\");\n Util_TableGetReal(coord_handles[i], &coord_lower[i], \"COMPMIN\");\n have_coords &= coord_index[i] >= 0;\n }\n }\n\n /* set header format string */\n if (CCTK_Equals(out1D_style, \"xgraph\")) {\n sprintf(buffer, \"\\n\\n\\\"Time = %%%s\\n\", out_format);\n } else {\n sprintf(buffer, \"\\n#Time = %%%s\\n\", out_format);\n }\n sprintf(header, buffer, (double)GH->cctk_time);\n\n /* check whether to include physical time as separate column in the output */\n i = 0;\n if (CCTK_Equals(out1D_style, \"gnuplot f(t,x)\")) {\n sprintf(buffer, \"%%%s\\t\\t\", out_format);\n sprintf(format[0], buffer, (double)GH->cctk_time);\n sprintf(format[1], buffer, (double)GH->cctk_time);\n i = strlen(format[0]);\n }\n if (have_coords) {\n sprintf(format[0] + i, \"%%%s\\t\\t%%d\", out_format);\n sprintf(format[1] + i, \"%%%s\\t\\t%%%s\", out_format, out_format);\n } else {\n sprintf(format[0] + i, \"%%d\\t\\t%%d\");\n sprintf(format[1] + i, \"%%d\\t\\t%%%s\", out_format);\n }\n sprintf(format[2], \"\\t\\t%%%s\", out_format);\n\n /* get the stride into the data and the (maximum) number of files to write */\n hstride = gdata.vartype == CCTK_VARIABLE_COMPLEX &&\n CCTK_Equals(out1D_style, \"xgraph\")\n ? 2\n : 1;\n num_files = hstride * 4;\n\n /* processor 0 opens the files with the appropriate name */\n myproc = CCTK_MyProc(GH);\n memset(file, 0, sizeof(file));\n if (myproc == 0) {\n OpenFile(GH, fullname, alias, &gdata, do_dir,\n have_coords ? coord_lower : NULL, num_files, file);\n }\n\n origin = calloc(2 * gdata.dim, sizeof(CCTK_INT));\n direction = origin + gdata.dim;\n extent_int = malloc((gdata.dim + 1) * sizeof(int));\n\n /* set downsampling vector from I/O parameters */\n downsample[0] = out_downsample_x;\n downsample[1] = out_downsample_y;\n downsample[2] = out_downsample_z;\n downsample[3] = 1;\n\n /* get the variable's extents, compute the extent for 3D-diagonals as the\n minimum of grid points in each direction */\n if (gdata.grouptype == CCTK_GF || gdata.disttype != CCTK_DISTRIB_CONSTANT)\n CCTK_GroupgshVI(GH, gdata.dim, extent_int, vindex);\n else\n CCTK_GrouplshVI(GH, gdata.dim, extent_int, vindex);\n if (gdata.dim == 3) {\n extent_int[3] =\n extent_int[0] < extent_int[1] ? extent_int[0] : extent_int[1];\n if (extent_int[2] < extent_int[3]) {\n extent_int[3] = extent_int[2];\n }\n }\n /* get the total number of grid points to check for zero-sized variables */\n for (dir = 0, hsize = 1; dir < gdata.dim; dir++) {\n hsize *= extent_int[dir];\n }\n\n /* now do the actual I/O looping over all directions */\n for (dir = 0; dir < 4; dir++) {\n if (hsize <= 0) {\n continue;\n }\n\n /* skip empty slices */\n if (!do_dir[dir]) {\n continue;\n }\n\n /* get the number of hyperslabs to extract\n (ie. whether to get a coordinate hyperslab too or not) */\n num_requested_hslabs = have_coords && dir < 3 ? 2 : 1;\n\n /* set the direction vector */\n for (i = 0; i < gdata.dim; i++) {\n direction[i] = (dir == i || dir == 3) ? 1 : 0;\n }\n\n /* set the extent */\n extent = extent_int[dir];\n\n /* set the origin of the line */\n if (gdata.grouptype == CCTK_GF && dir < 3) {\n for (i = 0; i < gdata.dim; i++) {\n origin[i] = myGH->spxyz[gdata.dim - 1][dir][i];\n }\n extent -= origin[dir];\n } else /* origin for CCTK_ARRAYS is always (0, 0, 0) */\n {\n memset(origin, 0, gdata.dim * sizeof(CCTK_INT));\n }\n\n mapping = Hyperslab_GlobalMappingByIndex(GH, vindex, 1, direction, origin,\n &extent, &downsample[dir],\n -1, /* table handle */\n NULL /* conversion fn */, &hsize);\n if (mapping < 0) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOASCII_Write1D: Failed to define hyperslab mapping for \"\n \"variable '%s'\",\n fullname);\n continue;\n }\n if (hsize <= 0) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOASCII_Write1D: selected hyperslab has zero size for \"\n \"variable '%s' direction %d\",\n fullname, dir);\n Hyperslab_FreeMapping(mapping);\n continue;\n }\n\n /* allocate hyperslab buffers on I/O processor */\n hdata[0] = hdata[1] = NULL;\n if (myproc == 0) {\n hdata[0] = malloc(hsize * CCTK_VarTypeSize(gdata.vartype));\n hdata[1] = have_coords ? malloc(hsize * sizeof(CCTK_REAL)) : NULL;\n }\n\n /* get the hyperslabs */\n vindices[0] = vindex;\n vindices[1] = coord_index[dir];\n num_returned_hslabs =\n Hyperslab_GetList(GH, mapping, num_requested_hslabs, NULL, vindices,\n NULL, NULL, hdata, NULL);\n\n /* release the mapping structure */\n Hyperslab_FreeMapping(mapping);\n\n /* And dump the data to file */\n if (file[dir] != NULL) {\n if (num_returned_hslabs != num_requested_hslabs) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOASCII_Write1D: Failed to extract hyperslab for \"\n \"variable '%s'\",\n fullname);\n } else {\n if (have_coords) {\n if (dir < 3) {\n /* do nothing */\n } else {\n /* calculate the diagonal coordinates */\n offset = GH->cctk_delta_space[0] * sqrt(3);\n for (i = 0; i < hsize; i++) {\n ((CCTK_REAL *)hdata[1])[i] =\n coord_lower[0] * sqrt(3) + i * offset;\n }\n }\n }\n\n WriteData(gdata.vartype, header, format, hsize, hstride, hdata,\n file + dir);\n }\n }\n\n /* clean up */\n free(hdata[0]);\n free(hdata[1]);\n } /* end of loop through all directions */\n\n /* close the output file(s) */\n for (dir = 0; dir < 8; dir++) {\n if (file[dir]) {\n fclose(file[dir]);\n }\n }\n\n /* free allocated resources */\n free(origin);\n free(fullname);\n free(extent_int);\n\n return (0);\n}\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\n/*@@\n @routine OpenFile\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Opens a set of ASCII files for a given alias name.\n If this is the first time through, it will create the files,\n write some header information, and advertise them to IOUtil.\n @enddesc\n @@*/\nstatic void OpenFile(const cGH *GH, const char *fullname, const char *alias,\n const cGroup *gdata, const int *do_dir,\n const CCTK_REAL *coord_lower, int num_files,\n FILE *file[]) {\n int i, dir, upper, lower, first_time_through;\n asciiioGH *myGH;\n char comment_char;\n char *filename, *type_extension;\n const char *file_extension;\n char slicename[20], buffer[128];\n char ylabel1_fmt_string[13], ylabel2_fmt_string[13];\n ioAdvertisedFileDesc advertised_file;\n const char *extensions[] = {\"xl\", \"yl\", \"zl\", \"dl\"};\n DECLARE_CCTK_PARAMETERS\n\n /* get handle for IOASCII extension */\n myGH = CCTK_GHExtension(GH, \"IOASCII\");\n\n /* set comment character and file extension */\n if (CCTK_Equals(out1D_style, \"xgraph\")) {\n comment_char = '\"';\n file_extension = \".xg\";\n } else {\n comment_char = '#';\n file_extension = \".asc\";\n }\n\n sprintf(ylabel1_fmt_string, \" (%%c = %%%s\", out_format);\n sprintf(ylabel2_fmt_string, \", %%c = %%%s\", out_format);\n\n /* 20 extra characters should be enough for '/',\n the type extension, the file extension, and the trailing '\\0' */\n filename =\n malloc(strlen(myGH->out1D_dir) + strlen(alias) + sizeof(slicename) + 20);\n\n for (i = 0; i < num_files; i++) {\n dir = i % 4;\n\n /* skip empty slices */\n if (!do_dir[dir]) {\n continue;\n }\n\n /* add suffix for complex type variables in xgraph output */\n if (gdata->vartype == CCTK_VARIABLE_COMPLEX && num_files == 8) {\n if (new_filename_scheme) {\n type_extension = i < 4 ? \"re_\" : \"im_\";\n } else {\n type_extension = i < 4 ? \"_re\" : \"_im\";\n }\n } else {\n type_extension = \"\";\n }\n\n /* get the indices into spxyz[] */\n lower = (dir + 1) % 3;\n upper = (dir + 2) % 3;\n if (upper < lower) {\n upper = lower;\n lower = 0;\n }\n\n /* FIXME: this can go after the old filename scheme has gone */\n if (new_filename_scheme) {\n if ((i + 1) % 4) {\n if (gdata->dim == 1) {\n sprintf(slicename, \"%s1D\", type_extension);\n } else if (gdata->dim == 2) {\n /* give the slice origin as range [1 .. n] */\n sprintf(slicename, \"%s%c_[%d]\", type_extension, 'x' + dir,\n gdata->grouptype == CCTK_GF\n ? myGH->spxyz[gdata->dim - 1][dir][lower]\n : 0);\n } else {\n /* give the slice origin as range [1 .. n] */\n sprintf(slicename, \"%s%c_[%d][%d]\", type_extension, 'x' + dir,\n gdata->grouptype == CCTK_GF\n ? myGH->spxyz[gdata->dim - 1][dir][lower]\n : 0,\n gdata->grouptype == CCTK_GF\n ? myGH->spxyz[gdata->dim - 1][dir][upper]\n : 0);\n }\n } else {\n sprintf(slicename, \"%s%dD_diagonal\", type_extension, gdata->dim);\n }\n\n sprintf(filename, \"%s%s_%s%s\", myGH->out1D_dir, alias, slicename,\n file_extension);\n } else {\n sprintf(filename, \"%s%s%s.%s\", myGH->out1D_dir, alias, type_extension,\n extensions[dir]);\n }\n\n /* create the output file the first time through\n If restart from recovery, existing files are opened in append mode. */\n first_time_through = GetNamedData(myGH->filenameList1D, filename) == NULL;\n file[i] = fopen(\n filename, IO_TruncateOutputFiles(GH) && first_time_through ? \"w\" : \"a\");\n if (!file[i]) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOASCII_Write1D: Cannot open 1D output file '%s'\", filename);\n } else if (first_time_through) {\n /* advertise new files for downloading and add file info */\n /* FIXME: this can go after the old filename scheme has gone */\n advertised_file.slice = new_filename_scheme ? slicename : extensions[dir];\n advertised_file.thorn = CCTK_THORNSTRING;\n advertised_file.varname = fullname;\n advertised_file.description = \"One-dimensional line plots\";\n advertised_file.mimetype =\n comment_char == '#' ? \"application/gnuplot\" : \"application/x-graph\";\n\n IOUtil_AdvertiseFile(GH, filename, &advertised_file);\n\n /* mark a restart point with an empty line in the output file,\n so that gnuplot/xgraph don't try to connect the last output\n before the abort and the first output after the restart */\n if (!IO_TruncateOutputFiles(GH)) {\n fputc('\\n', file[i]);\n }\n\n /* add some file information to the output file */\n if (CCTK_Equals(out_fileinfo, \"parameter filename\") ||\n CCTK_Equals(out_fileinfo, \"all\")) {\n buffer[0] = 0;\n CCTK_ParameterFilename(sizeof(buffer), buffer);\n fprintf(file[i], \"%cParameter file %s\\n\", comment_char, buffer);\n }\n if (CCTK_Equals(out_fileinfo, \"creation date\") ||\n CCTK_Equals(out_fileinfo, \"all\")) {\n buffer[0] = 0;\n Util_CurrentDate(sizeof(buffer), buffer);\n fprintf(file[i], \"%cCreated %s \", comment_char, buffer);\n Util_CurrentTime(sizeof(buffer), buffer);\n fprintf(file[i], \"%s\\n\", buffer);\n }\n if (CCTK_Equals(out_fileinfo, \"axis labels\") ||\n CCTK_Equals(out_fileinfo, \"all\")) {\n if (dir < 3) {\n fprintf(file[i], \"%cx-label %c\\n\", comment_char, 'x' + dir);\n } else {\n fprintf(file[i], \"%cx-label diagonal\\n\", comment_char);\n }\n fprintf(file[i], \"%cy-label %s\", comment_char, fullname);\n if (dir < 3 && gdata->dim > 1) {\n /* output the physical coordinates of the 1D line */\n if (coord_lower) {\n fprintf(file[i], ylabel1_fmt_string, 'x' + lower,\n coord_lower[lower] +\n GH->cctk_delta_space[lower] *\n myGH->spxyz[gdata->dim - 1][dir][lower]);\n if (gdata->dim > 2) {\n fprintf(file[i], ylabel2_fmt_string, 'x' + upper,\n coord_lower[upper] +\n GH->cctk_delta_space[upper] *\n myGH->spxyz[gdata->dim - 1][dir][upper]);\n }\n fputs(\"),\", file[i]);\n }\n /* output the index coordinates of the 1D line */\n fprintf(file[i], \" (%ci = %d\", 'x' + lower,\n gdata->grouptype == CCTK_GF\n ? myGH->spxyz[gdata->dim - 1][dir][lower]\n : 0);\n if (gdata->dim > 2) {\n fprintf(file[i], \", %ci = %d\", 'x' + upper,\n gdata->grouptype == CCTK_GF\n ? myGH->spxyz[gdata->dim - 1][dir][upper]\n : 0);\n }\n fputs(\")\", file[i]);\n }\n fputc('\\n', file[i]);\n }\n\n StoreNamedData(&myGH->filenameList1D, filename, file[i]);\n }\n }\n\n free(filename);\n}\n\n/*@@\n @routine WriteData\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Writes the given hyperslabs into the appropriate output files.\n @enddesc\n @@*/\nstatic void WriteData(int vtype, const char *header, char format[3][64],\n int hsize, int hstride, void *const *const hdata,\n FILE *const file[]) {\n /* print out header */\n fputs(header, file[0]);\n\n if (vtype == CCTK_VARIABLE_BYTE) {\n WRITE_DATA(0, CCTK_BYTE, int, 0, format[0], file[0]);\n } else if (vtype == CCTK_VARIABLE_INT) {\n WRITE_DATA(0, CCTK_INT, int, 0, format[0], file[0]);\n } else if (vtype == CCTK_VARIABLE_REAL) {\n WRITE_DATA(0, CCTK_REAL, double, 0, format[1], file[0]);\n } else if (vtype == CCTK_VARIABLE_COMPLEX) {\n WRITE_DATA(0, CCTK_REAL, double, 1, format[1], file[0]);\n if (hstride == 2) {\n /* print out header */\n fputs(header, file[0 + 4]);\n WRITE_DATA(1, CCTK_REAL, double, 1, format[1], file[4]);\n }\n }\n#ifdef HAVE_CCTK_INT1\n else if (vtype == CCTK_VARIABLE_INT1) {\n WRITE_DATA(0, CCTK_INT1, int, 0, format[0], file[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_INT2\n else if (vtype == CCTK_VARIABLE_INT2) {\n WRITE_DATA(0, CCTK_INT2, int, 0, format[0], file[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_INT4\n else if (vtype == CCTK_VARIABLE_INT4) {\n WRITE_DATA(0, CCTK_INT4, int, 0, format[0], file[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_INT8\n else if (vtype == CCTK_VARIABLE_INT8) {\n WRITE_DATA(0, CCTK_INT8, int, 0, format[0], file[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_INT16\n else if (vtype == CCTK_VARIABLE_INT16) {\n WRITE_DATA(0, CCTK_INT16, int, 0, format[0], file[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_REAL4\n else if (vtype == CCTK_VARIABLE_REAL4) {\n WRITE_DATA(0, CCTK_REAL4, double, 0, format[1], file[0]);\n } else if (vtype == CCTK_VARIABLE_COMPLEX8) {\n WRITE_DATA(0, CCTK_REAL4, double, 1, format[1], file[0]);\n if (hstride == 2) {\n /* print out header */\n fputs(header, file[0 + 4]);\n WRITE_DATA(1, CCTK_REAL4, double, 1, format[1], file[0 + 4]);\n }\n }\n#endif\n\n#ifdef HAVE_CCTK_REAL8\n else if (vtype == CCTK_VARIABLE_REAL8) {\n WRITE_DATA(0, CCTK_REAL8, double, 0, format[1], file[0]);\n } else if (vtype == CCTK_VARIABLE_COMPLEX16) {\n WRITE_DATA(0, CCTK_REAL8, double, 1, format[1], file[0]);\n if (hstride == 2) {\n /* print out header */\n fputs(header, file[0 + 4]);\n WRITE_DATA(1, CCTK_REAL8, double, 1, format[1], file[0 + 4]);\n }\n }\n#endif\n\n#ifdef HAVE_CCTK_REAL16\n else if (vtype == CCTK_VARIABLE_REAL16) {\n WRITE_DATA(0, CCTK_REAL16, double, 0, format[1], file[0]);\n } else if (vtype == CCTK_VARIABLE_COMPLEX32) {\n WRITE_DATA(0, CCTK_REAL16, double, 1, format[1], file[0]);\n if (hstride == 2) {\n /* print out header */\n fputs(header, file[0 + 4]);\n WRITE_DATA(1, CCTK_REAL16, double, 1, format[1], file[0 + 4]);\n }\n }\n#endif\n\n else {\n CCTK_WARN(1, \"Unsupported variable type\");\n }\n}\n", |
| "Write2D.c": "/*@@\n @file Write2D.c\n @date Thu May 11 2000\n @author Thomas Radke\n @desc\n Output two-dimensional slices in ASCII gnuplot format.\n @enddesc\n @version $Id$\n @@*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Parameters.h\"\n#include \"util_Table.h\"\n#include \"CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h\"\n#include \"ioASCIIGH.h\"\n\n/* the rcs ID and its dummy function to use it */\nstatic const char *rcsid = \"$Id$\";\nCCTK_FILEVERSION(CactusBase_IOASCII_Write2D_c)\n\n/********************************************************************\n ******************** Macro Definitions ************************\n ********************************************************************/\n/* Macro to output a 2D slice (with coordinates if available) as typed data\n For readability, the macro definition implicitely uses the following\n variables (which are defined in the calling routine):\n hdata, hsize, is_complex, format[2], file */\n#define WRITE_DATA(cctk_type, c_type, fmt) \\\n { \\\n int _i, _j; \\\n const cctk_type *_hdata = hdata[0]; \\\n const CCTK_REAL *_coord[2]; \\\n const int _di = is_complex ? 2 : 1; \\\n \\\n _coord[0] = (const CCTK_REAL *)hdata[1]; \\\n _coord[1] = (const CCTK_REAL *)hdata[2]; \\\n for (_i = 0; _i < hsize[0]; _i++) { \\\n for (_j = 0; _j < hsize[1]; _j++) { \\\n if (_coord[0]) { \\\n fprintf(file, fmt, (double)_coord[0][_i + hsize[0] * _j], \\\n (double)_coord[1][_i + hsize[0] * _j], \\\n (c_type)_hdata[_di * (_i + hsize[0] * _j)]); \\\n } else { \\\n fprintf(file, fmt, _i, _j, \\\n (c_type)_hdata[_di * (_i + hsize[0] * _j)]); \\\n } \\\n \\\n if (is_complex) { \\\n fprintf(file, format[2], \\\n (c_type)_hdata[_di * (_i + hsize[0] * _j) + 1]); \\\n } \\\n fputc('\\n', file); \\\n } \\\n fputc('\\n', file); \\\n } \\\n _coord[0] += hsize[0] * _j; \\\n _coord[1] += hsize[0] * _j; \\\n _hdata += _di * hsize[0] * _j; \\\n }\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\nstatic FILE **OpenFile(const cGH *GH, const char *fullname, const char *alias,\n int dim, const CCTK_REAL *coord_lower, int maxdir);\nstatic void WriteData(int vtype, const char *header, char format[3][64],\n const CCTK_INT hsize[2], void *const *const hdata,\n FILE *file);\n\n/*@@\n @routine IOASCII_Write2D\n @date Thu May 11 2000\n @author Thomas Radke\n @desc\n Writes the 2D slices of a variable into separate ASCII files.\n @enddesc\n @calls Hyperslab_GlobalMappingByIndex\n Hyperslab_FreeMapping\n Hyperslab_GetList\n OpenFile\n WriteData\n\n @var GH\n @vdesc Pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var vindex\n @vdesc index of variable to output\n @vtype int\n @vio in\n @endvar\n @var alias\n @vdesc alias name of variable to output\n @vtype const char *\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n 0 for success, or<BR>\n -1 if variable has no storage assigned<BR>\n -2 if output file couldn't be opened<BR>\n -3 if hyperslab for coordinates and/or variable couldn't be\n extracted\n @endreturndesc\n@@*/\nint IOASCII_Write2D(const cGH *GH, int vindex, const char *alias) {\n asciiioGH *myGH;\n int i, total_hsize, num_requested_hslabs, num_returned_hslabs;\n int dir, dir_i, dir_j, maxdir, myproc, gindex, have_coords;\n int mapping;\n cGroup gdata;\n CCTK_INT coord_index[3];\n CCTK_INT coord_system_handle, coord_handles[3];\n CCTK_REAL coord_lower[3];\n char format[3][64];\n char header[40], buffer[30];\n char *fullname, *groupname;\n int extent_int[3];\n CCTK_INT vindices[3], origin[3], extent[2], direction[6], downsample[2],\n hsize[2];\n void *hdata[3];\n FILE **fileset;\n DECLARE_CCTK_PARAMETERS\n\n /* get the variable name and group information */\n fullname = CCTK_FullName(vindex);\n gindex = CCTK_GroupIndexFromVarI(vindex);\n CCTK_GroupData(gindex, &gdata);\n\n /* check if variable has storage assigned */\n if (!CCTK_QueryGroupStorageI(GH, gindex)) {\n CCTK_VWarn(2, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"No IOASCII 2D output for '%s' (no storage)\", fullname);\n free(fullname);\n return (-1);\n }\n\n /* get the handle for IOASCII extension */\n myGH = CCTK_GHExtension(GH, \"IOASCII\");\n\n /* get the number of slices to output */\n /* in general: maxdir = gdata.dim * (gdata.dim - 1) / 2; */\n maxdir = gdata.dim == 2 ? 1 : 3;\n\n dir = gdata.dim < 3 ? gdata.dim : 3;\n\n have_coords = CCTK_IsFunctionAliased(\"Coord_GroupSystem\");\n if (have_coords) {\n /* get the coordinate system associated with this grid variable */\n groupname = CCTK_GroupName(gindex);\n coord_system_handle = Coord_GroupSystem(GH, groupname);\n free(groupname);\n\n have_coords = coord_system_handle >= 0 &&\n Util_TableGetIntArray(coord_system_handle, dir, coord_handles,\n \"COORDINATES\") >= 0;\n }\n if (have_coords) {\n /* get the coordinate functions and coordinate physical minimum */\n for (i = 0; i < dir; i++) {\n coord_index[i] = -1;\n coord_lower[i] = 0;\n Util_TableGetInt(coord_handles[i], &coord_index[i], \"GAINDEX\");\n Util_TableGetReal(coord_handles[i], &coord_lower[i], \"COMPMIN\");\n have_coords &= coord_index[i] >= 0;\n }\n }\n num_requested_hslabs = have_coords ? 3 : 1;\n\n /* set header and data format strings */\n sprintf(buffer, \"\\n\\n#Time = %%%s\\n\", out_format);\n sprintf(header, buffer, GH->cctk_time);\n dir = 0;\n if (CCTK_Equals(out2D_style, \"gnuplot f(t,x,y)\")) {\n sprintf(buffer, \"%%%s\\t\\t\", out_format);\n sprintf(format[0], buffer, (double)GH->cctk_time);\n sprintf(format[1], buffer, (double)GH->cctk_time);\n dir = strlen(format[0]);\n }\n if (have_coords) {\n sprintf(format[0] + dir, \"%%%s\\t\\t%%%s\\t\\t%%d\", out_format, out_format);\n sprintf(format[1] + dir, \"%%%s\\t\\t%%%s\\t\\t%%%s\", out_format, out_format,\n out_format);\n } else {\n sprintf(format[0] + dir, \"%%d\\t\\t%%d\\t\\t%%d\");\n sprintf(format[1] + dir, \"%%d\\t\\t%%d\\t\\t%%%s\", out_format);\n }\n sprintf(format[2], \"\\t\\t%%%s\", out_format);\n\n /* processor 0 opens the files on the first trip through */\n fileset = NULL;\n myproc = CCTK_MyProc(GH);\n if (myproc == 0) {\n fileset = OpenFile(GH, fullname, alias, gdata.dim,\n have_coords ? coord_lower : NULL, maxdir);\n }\n\n /* get the extents of the variable */\n if (gdata.grouptype == CCTK_GF || gdata.disttype != CCTK_DISTRIB_CONSTANT)\n CCTK_GroupgshVI(GH, gdata.dim, extent_int, vindex);\n else\n CCTK_GrouplshVI(GH, gdata.dim, extent_int, vindex);\n\n /* get the total number of grid points to check for zero-sized variables */\n for (dir = 0, hsize[0] = 1; dir < gdata.dim; dir++) {\n hsize[0] *= extent_int[dir];\n }\n\n /* now do the actual I/O looping over all directions */\n for (dir = 0; dir < maxdir; dir++) {\n if (hsize[0] <= 0) {\n continue;\n }\n\n /* get the directions to span the hyperslab */\n if (dir == 0) {\n dir_i = 0;\n dir_j = 1; /* xy */\n downsample[0] = out_downsample_x;\n downsample[1] = out_downsample_y;\n } else if (dir == 1) {\n dir_i = 0;\n dir_j = 2; /* xz */\n downsample[0] = out_downsample_x;\n downsample[1] = out_downsample_z;\n } else {\n dir_i = 1;\n dir_j = 2; /* yz */\n downsample[0] = out_downsample_y;\n downsample[1] = out_downsample_z;\n }\n\n /* set the extent vector */\n extent[0] = extent_int[dir_i];\n extent[1] = extent_int[dir_j];\n\n /* set the origin using the slice center from IOUtil */\n memset(origin, 0, sizeof(origin));\n if (have_coords) {\n origin[maxdir - dir - 1] = myGH->sp2xyz[gdata.dim - 1][dir];\n }\n\n /* set the direction vector */\n memset(direction, 0, sizeof(direction));\n direction[dir_i] = direction[gdata.dim + dir_j] = 1;\n\n mapping =\n Hyperslab_GlobalMappingByIndex(GH, vindex, 2, direction, origin, extent,\n downsample, -1, /* table handle */\n NULL /* conversion fn */, hsize);\n if (mapping < 0) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOASCII_Write2D: Failed to define hyperslab mapping for \"\n \"variable '%s'\",\n fullname);\n continue;\n }\n total_hsize = hsize[0] * hsize[1];\n if (total_hsize <= 0) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOASCII_Write2D: selected hyperslab has zero size for \"\n \"variable '%s' direction %d\",\n fullname, dir);\n Hyperslab_FreeMapping(mapping);\n continue;\n }\n\n hdata[0] = hdata[1] = hdata[2];\n if (myproc == 0) {\n /* allocate hyperslab buffers */\n hdata[0] = malloc(total_hsize * CCTK_VarTypeSize(gdata.vartype));\n hdata[1] =\n have_coords ? malloc(2 * total_hsize * sizeof(CCTK_REAL)) : NULL;\n hdata[2] = (CCTK_REAL *)hdata[1] + total_hsize;\n }\n\n /* get the hyperslabs */\n vindices[0] = vindex;\n vindices[1] = coord_index[dir_i];\n vindices[2] = coord_index[dir_j];\n num_returned_hslabs =\n Hyperslab_GetList(GH, mapping, num_requested_hslabs, NULL, vindices,\n NULL, NULL, hdata, NULL);\n\n /* release the mapping structure */\n Hyperslab_FreeMapping(mapping);\n\n /* and dump the data to file */\n if (fileset) {\n if (num_returned_hslabs == num_requested_hslabs) {\n WriteData(gdata.vartype, header, format, hsize, hdata, fileset[dir]);\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOASCII_Write2D: Failed to extract hyperslab for \"\n \"variable '%s'\",\n fullname);\n }\n\n /* clean up */\n free(hdata[0]);\n free(hdata[1]);\n\n } /* end of outputting the data by processor 0 */\n\n } /* end of looping through xyz directions */\n\n free(fullname);\n\n return (0);\n}\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\n/*@@\n @routine OpenFile\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Opens a set of ASCII files for a given alias name.\n If this is the first time through, it will create the files,\n write some header information, and advertise them to IOUtil.\n @enddesc\n\n @returntype FILE **\n @returndesc\n the set of open file descriptors,<BR>\n or NULL if a file couldn't be created\n @endreturndesc\n @@*/\nstatic FILE **OpenFile(const cGH *GH, const char *fullname, const char *alias,\n int dim, const CCTK_REAL *coord_lower, int maxdir) {\n int dir;\n FILE **fileset;\n char *filename;\n asciiioGH *myGH;\n ioAdvertisedFileDesc advertised_file;\n char slicename[30], zlabel_fmt_string[30], buffer[128];\n const char *extensions[] = {\"xy\", \"xz\", \"yz\"};\n DECLARE_CCTK_PARAMETERS\n\n /* get handle for IOASCII extension */\n myGH = CCTK_GHExtension(GH, \"IOASCII\");\n\n /* see if we are the first time through */\n fileset = (FILE **)GetNamedData(myGH->fileList_2D, alias);\n if (fileset) {\n return (fileset);\n }\n\n sprintf(zlabel_fmt_string, \" (%%c = %%%s),\", out_format);\n fileset = malloc(3 * sizeof(FILE *));\n filename =\n malloc(strlen(myGH->out2D_dir) + strlen(alias) + sizeof(slicename) + 20);\n\n /* open/create files for each slice */\n for (dir = 0; dir < maxdir; dir++) {\n if (new_filename_scheme) {\n if (dim == 2) {\n strcpy(slicename, \"2D\");\n } else {\n /* give the slice origin as range [1 .. n] */\n sprintf(slicename, \"%s_[%d]\", extensions[dir],\n myGH->sp2xyz[dim - 1][dir]);\n }\n\n sprintf(filename, \"%s%s_%s.asc\", myGH->out2D_dir, alias, slicename);\n } else {\n if (dim == 2) {\n sprintf(filename, \"%s%s_2D.gnuplot\", myGH->out2D_dir, alias);\n } else {\n sprintf(filename, \"%s%s_2d_%s.gnuplot\", myGH->out2D_dir, alias,\n extensions[dir]);\n }\n }\n\n /* if restart from recovery, try to open an existing file ... */\n fileset[dir] = fopen(filename, IO_TruncateOutputFiles(GH) ? \"w\" : \"a\");\n if (!fileset[dir]) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Cannot open 2D output file '%s'\", filename);\n free(fileset);\n free(filename);\n return (NULL);\n }\n\n /* advertise the file for downloading and write file info */\n advertised_file.slice = new_filename_scheme ? slicename : extensions[dir];\n advertised_file.thorn = CCTK_THORNSTRING;\n advertised_file.varname = fullname;\n advertised_file.description = \"Two-dimensional slice plots\";\n advertised_file.mimetype = \"application/gnuplot\";\n\n IOUtil_AdvertiseFile(GH, filename, &advertised_file);\n\n if (CCTK_Equals(out_fileinfo, \"parameter filename\") ||\n CCTK_Equals(out_fileinfo, \"all\")) {\n buffer[0] = 0;\n CCTK_ParameterFilename(sizeof(buffer), buffer);\n fprintf(fileset[dir], \"#Parameter file %s\\n\", buffer);\n }\n if (CCTK_Equals(out_fileinfo, \"creation date\") ||\n CCTK_Equals(out_fileinfo, \"all\")) {\n buffer[0] = 0;\n Util_CurrentDate(sizeof(buffer), buffer);\n fprintf(fileset[dir], \"#Created %s \", buffer);\n Util_CurrentTime(sizeof(buffer), buffer);\n fprintf(fileset[dir], \"%s\\n\", buffer);\n }\n if (CCTK_Equals(out_fileinfo, \"axis labels\") ||\n CCTK_Equals(out_fileinfo, \"all\")) {\n fprintf(fileset[dir], \"#x-label %c\\n\", extensions[dir][0]);\n fprintf(fileset[dir], \"#y-label %c\\n\", extensions[dir][1]);\n fprintf(fileset[dir], \"#z-label %s\", advertised_file.varname);\n if (dim != 2) {\n if (coord_lower) {\n fprintf(fileset[dir], zlabel_fmt_string, 'x' + (maxdir - dir - 1),\n coord_lower[maxdir - dir - 1] +\n GH->cctk_delta_space[maxdir - dir - 1] *\n myGH->sp2xyz[dim - 1][dir]);\n }\n fprintf(fileset[dir], \" (%ci = %d)\", 'x' + (maxdir - dir - 1),\n myGH->sp2xyz[dim - 1][dir]);\n }\n }\n }\n\n /* store file desriptors in database */\n StoreNamedData(&myGH->fileList_2D, alias, fileset);\n\n free(filename);\n\n return (fileset);\n}\n\n/*@@\n @routine WriteData\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Writes the given hyperslabs into the appropriate output files.\n @enddesc\n @@*/\nstatic void WriteData(int vtype, const char *header, char format[3][64],\n const CCTK_INT hsize[2], void *const *const hdata,\n FILE *file) {\n int is_complex;\n char complex_fmt_string[30];\n DECLARE_CCTK_PARAMETERS\n\n is_complex = !strncmp(CCTK_VarTypeName(vtype), \"CCTK_VARIABLE_COMPLEX\", 21);\n sprintf(complex_fmt_string, \"\\t\\t%%%s\", out_format);\n\n /* print out header */\n fputs(header, file);\n\n if (vtype == CCTK_VARIABLE_BYTE) {\n WRITE_DATA(CCTK_BYTE, int, format[0]);\n } else if (vtype == CCTK_VARIABLE_INT) {\n WRITE_DATA(CCTK_INT, int, format[0]);\n } else if (vtype == CCTK_VARIABLE_REAL || vtype == CCTK_VARIABLE_COMPLEX) {\n WRITE_DATA(CCTK_REAL, double, format[1]);\n }\n#ifdef HAVE_CCTK_INT1\n else if (vtype == CCTK_VARIABLE_INT1) {\n WRITE_DATA(CCTK_INT1, int, format[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_INT2\n else if (vtype == CCTK_VARIABLE_INT2) {\n WRITE_DATA(CCTK_INT2, int, format[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_INT4\n else if (vtype == CCTK_VARIABLE_INT4) {\n WRITE_DATA(CCTK_INT4, int, format[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_INT8\n else if (vtype == CCTK_VARIABLE_INT8) {\n WRITE_DATA(CCTK_INT8, int, format[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_INT16\n else if (vtype == CCTK_VARIABLE_INT16) {\n WRITE_DATA(CCTK_INT16, int, format[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_REAL4\n else if (vtype == CCTK_VARIABLE_REAL4 || vtype == CCTK_VARIABLE_COMPLEX8) {\n WRITE_DATA(CCTK_REAL4, double, format[1]);\n }\n#endif\n\n#ifdef HAVE_CCTK_REAL8\n else if (vtype == CCTK_VARIABLE_REAL8 || vtype == CCTK_VARIABLE_COMPLEX16) {\n WRITE_DATA(CCTK_REAL8, double, format[1]);\n }\n#endif\n\n#ifdef HAVE_CCTK_REAL16\n else if (vtype == CCTK_VARIABLE_REAL16 || vtype == CCTK_VARIABLE_COMPLEX32) {\n WRITE_DATA(CCTK_REAL16, double, format[1]);\n }\n#endif\n\n else {\n CCTK_WARN(1, \"Unsupported variable type\");\n }\n\n /* keep the file open but flush it */\n fflush(file);\n}\n", |
| "Output3D.c": "/*@@\n @file Output3D.c\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Functions to deal with 3D ASCII output of variables\n @enddesc\n @version $Id$\n@@*/\n\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Parameters.h\"\n#include \"util_String.h\"\n#include \"CactusBase/IOUtil/src/ioutil_Utils.h\"\n#include \"ioASCIIGH.h\"\n\n/* the rcs ID and its dummy function to use it */\nstatic const char *rcsid = \"$Id$\";\nCCTK_FILEVERSION(CactusBase_IOASCII_Output3D_c)\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\nstatic int CheckOutputVar(int vindex);\nstatic void SetOutputFlag(int vindex, const char *optstring, void *arg);\n\n/*@@\n @routine IOASCII_Output3DGH\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Loops over all variables and outputs them if necessary\n @enddesc\n @calls IOASCII_TimeFor3D\n IOASCII_Write3D\n\n @var GH\n @vdesc pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n the number of variables which were output at this iteration\n (or 0 if it wasn't time to output yet)\n @endreturndesc\n@@*/\nint IOASCII_Output3DGH(const cGH *GH) {\n int vindex, retval;\n const asciiioGH *myGH;\n\n retval = 0;\n myGH = (const asciiioGH *)CCTK_GHExtension(GH, \"IOASCII\");\n\n /* loop over all variables */\n for (vindex = CCTK_NumVars() - 1; vindex >= 0; vindex--) {\n if (IOASCII_TimeFor3D(GH, vindex) &&\n IOASCII_Write3D(GH, vindex, CCTK_VarName(vindex)) == 0) {\n /* register variable as having 3D output this iteration */\n myGH->out3D_last[vindex] = GH->cctk_iteration;\n retval++;\n }\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOASCII_Output3DVarAs\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Unconditional output of a variable\n using the IOASCII 3D output method\n @enddesc\n @calls IOASCII_Write3D\n\n @var GH\n @vdesc pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var fullname\n @vdesc complete name of variable to output\n @vtype const char *\n @vio in\n @endvar\n @var alias\n @vdesc alias name of variable to output\n (used to generate output filename)\n @vtype const char *\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n return code of @seeroutine IOASCII_Write3D, or<BR>\n -1 if variable cannot be output by IOASCII_3D\n @endreturndesc\n@@*/\nint IOASCII_Output3DVarAs(const cGH *GH, const char *fullname,\n const char *alias) {\n int vindex, retval;\n\n retval = -1;\n vindex = CCTK_VarIndex(fullname);\n if (vindex < 0) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"There is no such variable %s. Ignoring IOASCII 3D output.\",\n fullname);\n } else if (CheckOutputVar(vindex) == 0) {\n retval = IOASCII_Write3D(GH, vindex, alias);\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOASCII_TimeFor3D\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Decides if it is time to output a variable\n using the IOASCII 3D output method\n @enddesc\n\n @var GH\n @vdesc pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var vindex\n @vdesc index of variable\n @vtype int\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n 1 if output should take place at this iteration, or<BR>\n 0 if not\n @endreturndesc\n@@*/\nint IOASCII_TimeFor3D(const cGH *GH, int vindex) {\n int retval;\n char *fullname;\n asciiioGH *myGH;\n\n myGH = (asciiioGH *)CCTK_GHExtension(GH, \"IOASCII\");\n IOASCII_CheckSteerableParameters3D(myGH);\n\n /* check if this variable should be output */\n retval = myGH->out3D_every[vindex] > 0 &&\n GH->cctk_iteration % myGH->out3D_every[vindex] == 0;\n if (retval) {\n /* check if variable wasn't already output this iteration */\n if (myGH->out3D_last[vindex] == GH->cctk_iteration) {\n fullname = CCTK_FullName(vindex);\n CCTK_VWarn(5, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Already done IOASCII 3D output for '%s' in current \"\n \"iteration (probably via triggers)\",\n fullname);\n free(fullname);\n retval = 0;\n }\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOASCII_TriggerOutput3D\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Triggers the output of a variable\n using the IOASCII 3D output method\n @enddesc\n @calls IOASCII_Write3D\n\n @var GH\n @vdesc pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var vindex\n @vdesc index of variable to output\n @vtype int\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n return code of @seeroutine IOASCII_Write3D\n @endreturndesc\n@@*/\nint IOASCII_TriggerOutput3D(const cGH *GH, int vindex) {\n int retval;\n asciiioGH *myGH;\n\n /* do the 3D output */\n retval = IOASCII_Write3D(GH, vindex, CCTK_VarName(vindex));\n if (retval == 0) {\n /* register variables as having 3D output this iteration */\n myGH = (asciiioGH *)CCTK_GHExtension(GH, \"IOASCII\");\n myGH->out3D_last[vindex] = GH->cctk_iteration;\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOASCII_CheckSteerableParameters3D\n @date Tue 8 June 2004\n @author Thomas Radke\n @desc\n Check if steerable IOASCII 3D parameters have changed\n @enddesc\n @calls CCTK_TraverseString\n\n @var myGH\n @vdesc Pointer to IOASCII GH\n @vtype asciiioGH *\n @vio inout\n @endvar\n@@*/\nvoid IOASCII_CheckSteerableParameters3D(asciiioGH *myGH) {\n int i, num_vars;\n char *fullname, *msg;\n DECLARE_CCTK_PARAMETERS\n\n /* how often to output */\n i = myGH->out3D_every_default;\n myGH->out3D_every_default = out3D_every >= 0 ? out3D_every : out_every;\n\n /* report if frequency changed */\n if (myGH->out3D_every_default != i && !CCTK_Equals(verbose, \"none\")) {\n if (myGH->out3D_every_default > 0) {\n CCTK_VInfo(CCTK_THORNSTRING, \"Periodic 3D output every %d \"\n \"iterations\",\n myGH->out3D_every_default);\n } else {\n CCTK_INFO(\"Periodic 3D output turned off\");\n }\n }\n\n /* re-parse the 'out3D_vars' parameter if it was changed */\n if (strcmp(out3D_vars, myGH->out3D_vars) || myGH->out3D_every_default != i) {\n num_vars = CCTK_NumVars();\n memset(myGH->out3D_every, 0, num_vars * sizeof(CCTK_INT));\n if (CCTK_TraverseString(out3D_vars, SetOutputFlag, myGH,\n CCTK_GROUP_OR_VAR) < 0) {\n CCTK_WARN(myGH->stop_on_parse_errors ? 0 : 1,\n \"error while parsing parameter 'IOASCII::out3D_vars'\");\n }\n\n if (myGH->out3D_every_default == i || !CCTK_Equals(verbose, \"none\")) {\n msg = NULL;\n for (i = 0; i < num_vars; i++) {\n if (myGH->out3D_every[i] > 0) {\n fullname = CCTK_FullName(i);\n if (!msg) {\n Util_asprintf(&msg, \"Periodic 3D output requested for \"\n \"'%s'\",\n fullname);\n } else {\n char *tmp = msg;\n Util_asprintf(&msg, \"%s, '%s'\", msg, fullname);\n free(tmp);\n }\n free(fullname);\n }\n }\n if (msg) {\n CCTK_INFO(msg);\n free(msg);\n }\n }\n\n /* save the last setting of 'out3D_vars' parameter */\n free(myGH->out3D_vars);\n myGH->out3D_vars = strdup(out3D_vars);\n }\n}\n\n/**************************** local functions ******************************/\n/* check if this variable can be output (static conditions) */\nstatic int CheckOutputVar(int vindex) {\n int groupindex;\n cGroup groupinfo;\n char *fullname;\n const char *errormsg;\n\n /* get the variable group information */\n groupindex = CCTK_GroupIndexFromVarI(vindex);\n CCTK_GroupData(groupindex, &groupinfo);\n\n /* check if variable is grid array type with 3 dimensions */\n errormsg = NULL;\n if (groupinfo.dim != 3) {\n errormsg = \"dim != 3\";\n } else if (groupinfo.grouptype != CCTK_GF &&\n groupinfo.grouptype != CCTK_ARRAY) {\n errormsg = \"not a grid function or array\";\n }\n\n if (errormsg) {\n fullname = CCTK_FullName(vindex);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"No IOASCII 3D output for '%s': %s\", fullname, errormsg);\n free(fullname);\n }\n\n return (errormsg != NULL);\n}\n\n/* callback for CCTK_TraverseString() to set the output flag\n for the given variable */\nstatic void SetOutputFlag(int vindex, const char *optstring, void *arg) {\n const asciiioGH *myGH = (const asciiioGH *)arg;\n\n if (CheckOutputVar(vindex) == 0) {\n myGH->out3D_every[vindex] = myGH->out3D_every_default;\n\n if (optstring) {\n IOUtil_ParseOutputFrequency(\"3D IOASCII\", \"IOASCII::out3D_vars\",\n myGH->stop_on_parse_errors, vindex, optstring,\n &myGH->out3D_every[vindex], NULL);\n }\n }\n}\n", |
| "ChooseOutput.c": "/*@@\n @file ChooseOutput.c\n @author Gabrielle Allen\n @date July 6 2000\n @desc\n Choose what 1D slices and 2D planes to output by IOASCII.\n @enddesc\n\n @version $Id$\n @@*/\n\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Arguments.h\"\n#include \"cctk_Parameters.h\"\n#include \"CactusBase/IOUtil/src/ioutil_Utils.h\"\n#include \"ioASCIIGH.h\"\n\n/* the rcs ID and its dummy function to use it */\nstatic const char *rcsid = \"$Header$\";\nCCTK_FILEVERSION(CactusBase_IOASCII_ChooseOutput_c)\n\n/********************************************************************\n ******************** Macro Definitions ************************\n ********************************************************************/\n/* macro to choose origin according actual parameter settings:\n 1. Indices from IOASCII\n 2. Indices from IOUtil\n 3. Coords from IOASCII\n 4. Coords from IOUtil\n */\n#define GET_SLICE(IOASCII_param, IOUtil_param, index, coord) \\\n { \\\n index = IOASCII_param##i >= 0 ? IOASCII_param##i : IOUtil_param##i; \\\n coord = IOASCII_param != -424242 ? IOASCII_param : IOUtil_param; \\\n }\n\n/********************************************************************\n ******************** External Routines ************************\n ********************************************************************/\nvoid IOASCII_Choose1D(CCTK_ARGUMENTS);\nvoid IOASCII_Choose2D(CCTK_ARGUMENTS);\n\n/*@@\n @routine IOASCII_Choose1D\n @author Gabrielle Allen\n @date July 6 2000\n @desc\n Use parameters to choose the 1D slices through the output data.\n @enddesc\n\n @calls IOUtil_1DLines\n\n @var GH\n @vdesc pointer to CCTK grid hierarchy\n @vtype const cGH *\n @vio in\n @endvar\n@@*/\nvoid IOASCII_Choose1D(CCTK_ARGUMENTS) {\n int i, j, maxdim;\n asciiioGH *myGH;\n int *origin_index[3];\n CCTK_REAL *origin_phys[3];\n DECLARE_CCTK_PARAMETERS\n\n /* allocate arrays for origins */\n origin_phys[0] = calloc(3 * 3, sizeof(CCTK_REAL));\n origin_phys[1] = origin_phys[0] + 3;\n origin_phys[2] = origin_phys[1] + 3;\n origin_index[0] = calloc(3 * 3, sizeof(int));\n origin_index[1] = origin_index[0] + 3;\n origin_index[2] = origin_index[1] + 3;\n\n /* get slice points */\n GET_SLICE(out1D_xline_y, out_xline_y, origin_index[0][1], origin_phys[0][1]);\n GET_SLICE(out1D_xline_z, out_xline_z, origin_index[0][2], origin_phys[0][2]);\n GET_SLICE(out1D_yline_x, out_yline_x, origin_index[1][0], origin_phys[1][0]);\n GET_SLICE(out1D_yline_z, out_yline_z, origin_index[1][2], origin_phys[1][2]);\n GET_SLICE(out1D_zline_x, out_zline_x, origin_index[2][0], origin_phys[2][0]);\n GET_SLICE(out1D_zline_y, out_zline_y, origin_index[2][1], origin_phys[2][1]);\n\n maxdim = CCTK_MaxDim();\n myGH = CCTK_GHExtension(cctkGH, \"IOASCII\");\n myGH->spxyz = malloc(maxdim * sizeof(int **));\n\n for (i = 0; i < maxdim; i++) {\n myGH->spxyz[i] = malloc((i + 1) * sizeof(int *));\n\n for (j = 0; j <= i; j++) {\n myGH->spxyz[i][j] = calloc(i + 1, sizeof(int));\n }\n\n if (i < 3) {\n IOUtil_1DLines(cctkGH, i + 1, origin_index, origin_phys, myGH->spxyz[i]);\n }\n }\n\n /* free allocated resources */\n free(origin_phys[0]);\n free(origin_index[0]);\n}\n\n/*@@\n @routine IOASCII_Choose2D\n @author Gabrielle Allen\n @date July 6 2000\n @desc\n Use parameters to choose the 2D slices through the output data.\n @enddesc\n\n @calls IOUtil_2DPlanes\n\n @var GH\n @vdesc Pointer to CCTK grid hierarchy\n @vtype const cGH *\n @vio in\n @endvar\n @@*/\nvoid IOASCII_Choose2D(CCTK_ARGUMENTS) {\n int i, maxdim;\n asciiioGH *myGH;\n int origin_index[3];\n CCTK_REAL origin_phys[3];\n DECLARE_CCTK_PARAMETERS\n\n GET_SLICE(out2D_xyplane_z, out_xyplane_z, origin_index[0], origin_phys[0]);\n GET_SLICE(out2D_xzplane_y, out_xzplane_y, origin_index[1], origin_phys[1]);\n GET_SLICE(out2D_yzplane_x, out_yzplane_x, origin_index[2], origin_phys[2]);\n\n maxdim = CCTK_MaxDim();\n myGH = CCTK_GHExtension(cctkGH, \"IOASCII\");\n myGH->sp2xyz = malloc(maxdim * sizeof(int *));\n\n for (i = 0; i < maxdim; i++) {\n myGH->sp2xyz[i] = calloc(i + 1, sizeof(int));\n\n if (i == 2) {\n IOUtil_2DPlanes(cctkGH, i + 1, origin_index, origin_phys,\n myGH->sp2xyz[i]);\n }\n }\n}\n", |
| "ioASCIIGH.h": "/*@@\n @header ioASCIIGH.h\n @date Tue 9th Jan 1999\n @author Gabrielle Allen\n @desc\n The extensions to the GH structure from IOASCII.\n @version $Header$\n@@*/\n\n#ifndef _IOASCII_IOASCIIGH_H_\n#define _IOASCII_IOASCIIGH_H_ 1\n\n#include \"StoreNamedData.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct IOASCIIGH {\n /* default number of times to output */\n int out1D_every_default, out2D_every_default, out3D_every_default;\n\n /* number of times to output every variable */\n CCTK_INT *out1D_every, *out2D_every, *out3D_every;\n\n /* lists of variables to output */\n char *out1D_vars, *out2D_vars, *out3D_vars;\n\n /* directories in which to output */\n char *out1D_dir, *out2D_dir, *out3D_dir;\n\n /* the last iteration output for var [i] */\n int *out1D_last, *out2D_last, *out3D_last;\n\n /* database for names of output files that were already created */\n pNamedData *filenameList1D, *fileList_2D, *fileList_3D;\n\n /* for 1D lines, we define the index where to start the line:\n spxyz[maxdim][XYZdirection][xyzstart_index] */\n int ***spxyz;\n\n /* for 2D planes, we define the index where to locate the plane\n sp2xyz[maxdim][perpendicular direction] */\n int **sp2xyz;\n\n /* stop on I/O parameter parsing errors ? */\n int stop_on_parse_errors;\n\n} asciiioGH;\n\n/* prototypes of functions to be registered as I/O methods */\nint IOASCII_Output1DGH(const cGH *GH);\nint IOASCII_TriggerOutput1D(const cGH *GH, int);\nint IOASCII_TimeFor1D(const cGH *GH, int);\nint IOASCII_Output1DVarAs(const cGH *GH, const char *var, const char *alias);\nint IOASCII_Output2DGH(const cGH *GH);\nint IOASCII_TriggerOutput2D(const cGH *GH, int);\nint IOASCII_TimeFor2D(const cGH *GH, int);\nint IOASCII_Output2DVarAs(const cGH *GH, const char *var, const char *alias);\nint IOASCII_Output3DGH(const cGH *GH);\nint IOASCII_TriggerOutput3D(const cGH *GH, int);\nint IOASCII_TimeFor3D(const cGH *GH, int);\nint IOASCII_Output3DVarAs(const cGH *GH, const char *var, const char *alias);\n\n/* other function prototypes */\nint IOASCII_Write1D(const cGH *GH, int vindex, const char *alias);\nint IOASCII_Write2D(const cGH *GH, int vindex, const char *alias);\nint IOASCII_Write3D(const cGH *GH, int vindex, const char *alias);\n\nvoid IOASCII_CheckSteerableParameters1D(asciiioGH *myGH);\nvoid IOASCII_CheckSteerableParameters2D(asciiioGH *myGH);\nvoid IOASCII_CheckSteerableParameters3D(asciiioGH *myGH);\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n#endif /* _IOASCII_IOASCIIGH_H_ */\n", |
| "Write3D.c": "/*@@\n @file Write3D.c\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Three-dimensional output of variables in ASCII gnuplot format.\n @enddesc\n @version $Id$\n @@*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Parameters.h\"\n#include \"util_Table.h\"\n#include \"CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h\"\n#include \"ioASCIIGH.h\"\n\n/* the rcs ID and its dummy function to use it */\nstatic const char *rcsid = \"$Header$\";\nCCTK_FILEVERSION(CactusBase_IOASCII_Write3D_c)\n\n/********************************************************************\n ******************** Macro Definitions ************************\n ********************************************************************/\n/* Macro to output a 3D array (with coordinates if available) as typed data\n For readability, the macro definition implicitely uses the following\n variables (which are defined in the calling routine):\n hdata, hsize, is_complex, format[2], file */\n#define WRITE_DATA(cctk_type, c_type, fmt) \\\n { \\\n int _i, _j, _k; \\\n const cctk_type *_hdata = (const cctk_type *)hdata[0]; \\\n const CCTK_REAL *_coord[3]; \\\n \\\n _coord[0] = (const CCTK_REAL *)hdata[1]; \\\n _coord[1] = (const CCTK_REAL *)hdata[2]; \\\n _coord[2] = (const CCTK_REAL *)hdata[3]; \\\n for (_k = 0; _k < hsize[2]; _k++) { \\\n for (_j = 0; _j < hsize[1]; _j++) { \\\n for (_i = 0; _i < hsize[0]; _i++) { \\\n if (_coord[0]) { \\\n fprintf(file, fmt, (double)*_coord[0]++, (double)*_coord[1]++, \\\n (double)*_coord[2]++, (c_type)*_hdata++); \\\n } else { \\\n fprintf(file, fmt, _i, _j, _k, (c_type)*_hdata++); \\\n } \\\n \\\n if (is_complex) { \\\n fprintf(file, format[2], (c_type)*_hdata++); \\\n } \\\n fputc('\\n', file); \\\n } \\\n fputc('\\n', file); \\\n } \\\n fputc('\\n', file); \\\n } \\\n fputc('\\n', file); \\\n }\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\nstatic FILE *OpenFile(const cGH *GH, const char *fullname, const char *alias);\nstatic void WriteData(int vtype, const char *header, char format[3][64],\n const CCTK_INT hsize[3], void *const *const hdata,\n FILE *file);\n\n/*@@\n @routine IOASCII_Write3D\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Writes the 3D volume of a variable into a gnuplot ASCII file.\n @enddesc\n @calls Hyperslab_GlobalMappingByIndex\n Hyperslab_FreeMapping\n Hyperslab_GetList\n OpenFile\n WriteData\n\n @var GH\n @vdesc Pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var vindex\n @vdesc index of variable to output\n @vtype int\n @vio in\n @endvar\n @var alias\n @vdesc alias name of variable to output\n @vtype const char *\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n 0 for success, or<BR>\n -1 if variable has no storage assigned<BR>\n -2 if output file couldn't be opened<BR>\n -3 if hyperslab for coordinates and/or variable couldn't be\n extracted\n @endreturndesc\n@@*/\nint IOASCII_Write3D(const cGH *GH, int vindex, const char *alias) {\n int i, total_hsize;\n int myproc, gindex, have_coords;\n int num_requested_hslabs, num_returned_hslabs;\n char header[40], buffer[30];\n char format[3][64];\n FILE *file;\n cGroup gdata;\n CCTK_INT coord_system_handle, coord_handles[3];\n char *fullname, *groupname;\n void *hdata[4];\n int extent_int[3];\n int mapping;\n CCTK_INT vindices[4], extent[3], downsample[3], hsize[3];\n const CCTK_INT origin[] = {0, 0, 0},\n direction[] = {1, 0, 0, 0, 1, 0, 0, 0, 1};\n DECLARE_CCTK_PARAMETERS\n\n /* get the variable group information */\n fullname = CCTK_FullName(vindex);\n gindex = CCTK_GroupIndexFromVarI(vindex);\n CCTK_GroupData(gindex, &gdata);\n\n /* check if variable has storage assigned */\n if (!CCTK_QueryGroupStorageI(GH, gindex)) {\n CCTK_VWarn(2, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"No IOASCII 3D output for '%s' (no storage)\", fullname);\n free(fullname);\n return (-1);\n }\n\n vindices[0] = vindex;\n have_coords = CCTK_IsFunctionAliased(\"Coord_GroupSystem\");\n if (have_coords) {\n /* get the coordinate system associated with this grid variable */\n groupname = CCTK_GroupName(gindex);\n coord_system_handle = Coord_GroupSystem(GH, groupname);\n free(groupname);\n\n have_coords = coord_system_handle >= 0 &&\n Util_TableGetIntArray(coord_system_handle, 3, coord_handles,\n \"COORDINATES\") >= 0;\n }\n if (have_coords) {\n /* get the coordinate functions and coordinate physical minimum */\n for (i = 1; i <= 3; i++) {\n vindices[i] = -1;\n Util_TableGetInt(coord_handles[i - 1], &vindices[i], \"GAINDEX\");\n have_coords &= vindices[i] >= 0;\n }\n }\n num_requested_hslabs = have_coords ? 4 : 1;\n\n /* set header and data format strings */\n sprintf(buffer, \"#Time = %%%s\\n\", out_format);\n sprintf(header, buffer, (double)GH->cctk_time);\n i = 0;\n if (CCTK_Equals(out3D_style, \"gnuplot f(t,x,y,z)\")) {\n sprintf(buffer, \"%%%s\\t\\t\", out_format);\n sprintf(format[0], buffer, (double)GH->cctk_time);\n sprintf(format[1], buffer, (double)GH->cctk_time);\n i = (int)strlen(format[0]);\n }\n if (have_coords) {\n sprintf(format[0] + i, \"%%%s\\t\\t%%%s\\t\\t%%d\\t\\t%%d\", out_format,\n out_format);\n sprintf(format[1] + i, \"%%%s\\t\\t%%%s\\t\\t%%%s\\t\\t%%%s\", out_format,\n out_format, out_format, out_format);\n } else {\n sprintf(format[0] + i, \"%%d\\t\\t%%d\\t\\t%%d\\t\\t%%d\");\n sprintf(format[1] + i, \"%%d\\t\\t%%d\\t\\t%%d\\t\\t%%%s\", out_format);\n }\n sprintf(format[2], \"\\t\\t%%%s\", out_format);\n\n /* What processor are we on? */\n myproc = CCTK_MyProc(GH);\n\n /* Open the file on processor 0 */\n file = myproc == 0 ? OpenFile(GH, fullname, alias) : NULL;\n\n /* get the total number of grid points to check for zero-sized variables */\n /* set the extent vector (copy from 'int' to 'CCTK_INT' */\n if (gdata.grouptype == CCTK_GF || gdata.disttype != CCTK_DISTRIB_CONSTANT)\n CCTK_GroupgshVI(GH, gdata.dim, extent_int, vindex);\n else\n CCTK_GrouplshVI(GH, gdata.dim, extent_int, vindex);\n for (i = 0, total_hsize = 1; i < 3; i++) {\n total_hsize *= extent_int[i];\n extent[i] = extent_int[i];\n }\n if (total_hsize <= 0) {\n free(fullname);\n return (0);\n }\n\n downsample[0] = out_downsample_x;\n downsample[1] = out_downsample_y;\n downsample[2] = out_downsample_z;\n\n /* get the hyperslab mapping */\n mapping =\n Hyperslab_GlobalMappingByIndex(GH, vindex, 3, direction, origin, extent,\n downsample, -1, /* table handle */\n NULL /* conversion fn */, hsize);\n if (mapping < 0) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOASCII_Write3D: Failed to define hyperslab mapping for \"\n \"variable '%s'\",\n fullname);\n free(fullname);\n return (-1);\n }\n total_hsize = hsize[0] * hsize[1] * hsize[2];\n if (total_hsize <= 0) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOASCII_Write3D: selected hyperslab has zero size for \"\n \"variable '%s'\",\n fullname);\n Hyperslab_FreeMapping(mapping);\n free(fullname);\n return (-1);\n }\n\n hdata[0] = hdata[1] = hdata[2] = hdata[3];\n if (myproc == 0) {\n /* allocate hyperslab buffers */\n hdata[0] = malloc(total_hsize * CCTK_VarTypeSize(gdata.vartype));\n hdata[1] = have_coords ? malloc(3 * total_hsize * sizeof(CCTK_REAL)) : NULL;\n hdata[2] = (CCTK_REAL *)hdata[1] + 1 * total_hsize;\n hdata[3] = (CCTK_REAL *)hdata[1] + 2 * total_hsize;\n }\n\n /* get the hyperslabs */\n num_returned_hslabs =\n Hyperslab_GetList(GH, mapping, num_requested_hslabs, NULL, vindices, NULL,\n NULL, hdata, NULL);\n\n /* And dump the data to file */\n if (myproc == 0) {\n if (num_returned_hslabs == num_requested_hslabs) {\n WriteData(gdata.vartype, header, format, hsize, hdata, file);\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOASCII_Write3D: Failed to extract hyperslab for \"\n \"variable '%s'\",\n fullname);\n }\n\n /* clean up */\n free(hdata[0]);\n free(hdata[1]);\n } /* end of outputting the data by processor 0 */\n\n free(fullname);\n\n return (0);\n}\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\n/*@@\n @routine OpenFile\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Opens an ASCII file for a given alias name.\n If this is the first time through, it will create the file,\n write some header information, and advertise it to IOUtil.\n @enddesc\n\n @returntype FILE *\n @returndesc\n the file descriptor, or NULL if the file couldn't be created\n @endreturndesc\n @@*/\nstatic FILE *OpenFile(const cGH *GH, const char *fullname, const char *alias) {\n FILE **file;\n char *filename;\n char buffer[128];\n asciiioGH *myGH;\n ioAdvertisedFileDesc advertised_file;\n DECLARE_CCTK_PARAMETERS\n\n /* get handle for IOASCII extension */\n myGH = CCTK_GHExtension(GH, \"IOASCII\");\n\n /* see if we are the first time through */\n file = GetNamedData(myGH->fileList_3D, alias);\n if (file) {\n return (*file);\n }\n\n file = malloc(sizeof(FILE *));\n filename = malloc(strlen(myGH->out3D_dir) + strlen(alias) + 9);\n\n /* open/create the file */\n sprintf(filename, \"%s%s_3D.asc\", myGH->out3D_dir, alias);\n\n /* if restart from recovery, try to open an existing file ... */\n *file = fopen(filename, IO_TruncateOutputFiles(GH) ? \"w\" : \"a\");\n if (!*file) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Cannot open 3D IOASCII output file '%s'\", filename);\n return (NULL);\n }\n\n /* advertise the file for downloading and write file info */\n advertised_file.slice = \"\";\n advertised_file.thorn = CCTK_THORNSTRING;\n advertised_file.varname = fullname;\n advertised_file.description = \"Full-dimensional variable contents\";\n advertised_file.mimetype = \"application/gnuplot\";\n\n IOUtil_AdvertiseFile(GH, filename, &advertised_file);\n\n if (CCTK_Equals(out_fileinfo, \"parameter filename\") ||\n CCTK_Equals(out_fileinfo, \"all\")) {\n buffer[0] = 0;\n CCTK_ParameterFilename(sizeof(buffer), buffer);\n fprintf(*file, \"#Parameter file %s\\n\", buffer);\n }\n if (CCTK_Equals(out_fileinfo, \"creation date\") ||\n CCTK_Equals(out_fileinfo, \"all\")) {\n buffer[0] = 0;\n Util_CurrentDate(sizeof(buffer), buffer);\n fprintf(*file, \"#Created %s \", buffer);\n Util_CurrentTime(sizeof(buffer), buffer);\n fprintf(*file, \"%s\\n\", buffer);\n }\n if (CCTK_Equals(out_fileinfo, \"axis labels\") ||\n CCTK_Equals(out_fileinfo, \"all\")) {\n fprintf(*file, \"#z-label %s\\n\", advertised_file.varname);\n }\n if (CCTK_Equals(out_fileinfo, \"all\")) {\n fprintf(*file, \"\\n\\n\");\n }\n\n /* store file desriptors in database */\n StoreNamedData(&myGH->fileList_3D, alias, file);\n\n free(filename);\n\n return (*file);\n}\n\n/*@@\n @routine WriteData\n @date Wed 12 Dec 2001\n @author Thomas Radke\n @desc\n Writes the given hyperslab data into a file.\n @enddesc\n @@*/\nstatic void WriteData(int vtype, const char *header, char format[3][64],\n const CCTK_INT hsize[3], void *const *const hdata,\n FILE *file) {\n int is_complex;\n\n if (file == NULL) {\n return;\n }\n\n is_complex = !strncmp(CCTK_VarTypeName(vtype), \"CCTK_VARIABLE_COMPLEX\", 21);\n\n /* print out header */\n fputs(header, file);\n\n if (vtype == CCTK_VARIABLE_BYTE) {\n WRITE_DATA(CCTK_BYTE, int, format[0]);\n } else if (vtype == CCTK_VARIABLE_INT) {\n WRITE_DATA(CCTK_INT, int, format[0]);\n } else if (vtype == CCTK_VARIABLE_REAL || vtype == CCTK_VARIABLE_COMPLEX) {\n WRITE_DATA(CCTK_REAL, double, format[1]);\n }\n\n#ifdef HAVE_CCTK_INT1\n else if (vtype == CCTK_VARIABLE_INT1) {\n WRITE_DATA(CCTK_INT1, int, format[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_INT2\n else if (vtype == CCTK_VARIABLE_INT2) {\n WRITE_DATA(CCTK_INT2, int, format[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_INT4\n else if (vtype == CCTK_VARIABLE_INT4) {\n WRITE_DATA(CCTK_INT4, int, format[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_INT8\n else if (vtype == CCTK_VARIABLE_INT8) {\n WRITE_DATA(CCTK_INT8, int, format[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_INT16\n else if (vtype == CCTK_VARIABLE_INT16) {\n WRITE_DATA(CCTK_INT16, int, format[0]);\n }\n#endif\n\n#ifdef HAVE_CCTK_REAL4\n else if (vtype == CCTK_VARIABLE_REAL4 || vtype == CCTK_VARIABLE_COMPLEX8) {\n WRITE_DATA(CCTK_REAL4, double, format[1]);\n }\n#endif\n\n#ifdef HAVE_CCTK_REAL8\n else if (vtype == CCTK_VARIABLE_REAL8 || vtype == CCTK_VARIABLE_COMPLEX16) {\n WRITE_DATA(CCTK_REAL8, double, format[1]);\n }\n#endif\n\n#ifdef HAVE_CCTK_REAL16\n else if (vtype == CCTK_VARIABLE_REAL16 || vtype == CCTK_VARIABLE_COMPLEX32) {\n WRITE_DATA(CCTK_REAL16, double, format[1]);\n }\n#endif\n\n else {\n CCTK_WARN(1, \"Unsupported variable type\");\n }\n\n /* keep the file open but flush it */\n fflush(file);\n}\n", |
| "Output1D.c": "/*@@\n @file IO_Output1D.c\n @date Tue Jan 9 1999\n @author Gabrielle Allen\n @desc\n Functions to deal with 1D ASCII output of variables\n @enddesc\n @version $Id$\n@@*/\n\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Parameters.h\"\n#include \"util_String.h\"\n#include \"CactusBase/IOUtil/src/ioutil_Utils.h\"\n#include \"ioASCIIGH.h\"\n\n/* the rcs ID and its dummy function to use it */\nstatic const char *rcsid = \"$Id$\";\nCCTK_FILEVERSION(CactusBase_IOASCII_Output1D_c)\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\nstatic int CheckOutputVar(int vindex);\nstatic void SetOutputFlag(int vindex, const char *optstring, void *arg);\n\n/*@@\n @routine IOASCII_Output1DGH\n @date Sat March 6 1999\n @author Gabrielle Allen\n @desc\n Loops over all variables and outputs them if necessary\n @enddesc\n @calls IOASCII_TimeFor1D\n IOASCII_Write1D\n\n @var GH\n @vdesc Pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n the number of variables which were output at this iteration\n (or 0 if it wasn't time to output yet)\n @endreturndesc\n@@*/\nint IOASCII_Output1DGH(const cGH *GH) {\n int vindex, retval;\n const asciiioGH *myGH;\n\n retval = 0;\n myGH = (const asciiioGH *)CCTK_GHExtension(GH, \"IOASCII\");\n\n /* loop over all variables */\n for (vindex = CCTK_NumVars() - 1; vindex >= 0; vindex--) {\n if (IOASCII_TimeFor1D(GH, vindex) &&\n IOASCII_Write1D(GH, vindex, CCTK_VarName(vindex)) == 0) {\n /* register variable as having 1D output this iteration */\n myGH->out1D_last[vindex] = GH->cctk_iteration;\n retval++;\n }\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOASCII_Output1DVarAs\n @date Sat March 6 1999\n @author Gabrielle Allen\n @desc\n Unconditional output of a variable\n using the IOASCII output method\n @enddesc\n @calls IOASCII_Write1D\n\n @var GH\n @vdesc Pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var fullname\n @vdesc complete name of variable to output\n @vtype const char *\n @vio in\n @endvar\n @var alias\n @vdesc alias name of variable to output\n (used to generate output filename)\n @vtype const char *\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n return code of @seeroutine IOASCII_Write1D, or<BR>\n -1 if variable cannot be output by IOASCII_1D\n @endreturndesc\n@@*/\nint IOASCII_Output1DVarAs(const cGH *GH, const char *fullname,\n const char *alias) {\n int vindex, retval;\n\n retval = -1;\n vindex = CCTK_VarIndex(fullname);\n if (vindex < 0) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"There is no such variable %s. Ignoring IOASCII 1D output.\",\n fullname);\n } else if (CheckOutputVar(vindex)) {\n retval = IOASCII_Write1D(GH, vindex, alias);\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOASCII_TimeFor1D\n @date Sat March 6 1999\n @author Gabrielle Allen\n @desc\n Decides if it is time to output a variable\n using the IO 1D output method\n @enddesc\n\n @var GH\n @vdesc Pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var vindex\n @vdesc index of variable\n @vtype int\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n 1 if output should take place at this iteration, or<BR>\n 0 if not\n @endreturndesc\n@@*/\nint IOASCII_TimeFor1D(const cGH *GH, int vindex) {\n int retval;\n char *fullname;\n asciiioGH *myGH;\n\n myGH = (asciiioGH *)CCTK_GHExtension(GH, \"IOASCII\");\n IOASCII_CheckSteerableParameters1D(myGH);\n\n /* check if this variable should be output */\n retval = myGH->out1D_every[vindex] > 0 &&\n GH->cctk_iteration % myGH->out1D_every[vindex] == 0;\n if (retval) {\n /* check if this variable wasn't already output this iteration */\n if (myGH->out1D_last[vindex] == GH->cctk_iteration) {\n fullname = CCTK_FullName(vindex);\n CCTK_VWarn(5, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Already done IOASCII 1D output for '%s' in current \"\n \"iteration (probably via triggers)\",\n fullname);\n free(fullname);\n retval = 0;\n }\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOASCII_TriggerOutput1D\n @date Sat March 6 1999\n @author Gabrielle Allen\n @desc\n Triggers the output a variable\n using the IOASCII output method method\n @enddesc\n @calls IOASCII_Write1D\n\n @var GH\n @vdesc Pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var vindex\n @vdesc index of variable to output\n @vtype int\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n return code of @seeroutine IOASCII_Write1D\n @endreturndesc\n@@*/\nint IOASCII_TriggerOutput1D(const cGH *GH, int vindex) {\n int retval;\n asciiioGH *myGH;\n\n retval = IOASCII_Write1D(GH, vindex, CCTK_VarName(vindex));\n if (retval == 0) {\n /* register variables as having 1D output this iteration */\n myGH = (asciiioGH *)CCTK_GHExtension(GH, \"IOASCII\");\n myGH->out1D_last[vindex] = GH->cctk_iteration;\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOASCII_CheckSteerableParameters1D\n @date Tue 8 June 2004\n @author Thomas Radke\n @desc\n Check if steerable IOASCII 1D parameters have changed\n @enddesc\n @calls CCTK_TraverseString\n\n @var myGH\n @vdesc Pointer to IOASCII GH\n @vtype asciiioGH *\n @vio inout\n @endvar\n@@*/\nvoid IOASCII_CheckSteerableParameters1D(asciiioGH *myGH) {\n int i, num_vars;\n char *fullname, *msg;\n DECLARE_CCTK_PARAMETERS\n\n /* how often to output */\n i = myGH->out1D_every_default;\n myGH->out1D_every_default = out1D_every >= 0 ? out1D_every : out_every;\n\n /* report if frequency changed */\n if (myGH->out1D_every_default != i && !CCTK_Equals(verbose, \"none\")) {\n if (myGH->out1D_every_default > 0) {\n CCTK_VInfo(CCTK_THORNSTRING, \"Periodic 1D output every %d \"\n \"iterations\",\n myGH->out1D_every_default);\n } else {\n CCTK_INFO(\"Periodic 1D output turned off\");\n }\n }\n\n /* re-parse the 'out1D_vars' parameter if it was changed */\n if (strcmp(out1D_vars, myGH->out1D_vars) || myGH->out1D_every_default != i) {\n num_vars = CCTK_NumVars();\n memset(myGH->out1D_every, 0, num_vars * sizeof(CCTK_INT));\n if (CCTK_TraverseString(out1D_vars, SetOutputFlag, myGH,\n CCTK_GROUP_OR_VAR) < 0) {\n CCTK_WARN(myGH->stop_on_parse_errors ? 0 : 1,\n \"error while parsing parameter 'IOASCII::out1D_vars'\");\n }\n\n if (myGH->out1D_every_default == i || !CCTK_Equals(verbose, \"none\")) {\n msg = NULL;\n for (i = 0; i < num_vars; i++) {\n if (myGH->out1D_every[i] > 0) {\n fullname = CCTK_FullName(i);\n if (!msg) {\n Util_asprintf(&msg, \"Periodic 1D output requested for \"\n \"'%s'\",\n fullname);\n } else {\n char *tmp = msg;\n Util_asprintf(&msg, \"%s, '%s'\", msg, fullname);\n free(tmp);\n }\n free(fullname);\n }\n }\n if (msg) {\n CCTK_INFO(msg);\n free(msg);\n }\n }\n\n /* save the last setting of 'out1D_vars' parameter */\n free(myGH->out1D_vars);\n myGH->out1D_vars = strdup(out1D_vars);\n }\n}\n\n/**************************** local functions ******************************/\n/* check if this variable can be output (static conditions) */\nstatic int CheckOutputVar(int vindex) {\n int retval;\n int grouptype;\n char *fullname;\n\n /* check the variable type */\n grouptype = CCTK_GroupTypeFromVarI(vindex);\n retval = grouptype == CCTK_GF || grouptype == CCTK_ARRAY;\n if (!retval) {\n fullname = CCTK_FullName(vindex);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"No IOASCII 1D output for '%s': not a grid function or an \"\n \"array\",\n fullname);\n free(fullname);\n }\n\n return (retval);\n}\n\n/* callback for CCTK_TraverseString() to set the output flag\n for the given variable */\nstatic void SetOutputFlag(int vindex, const char *optstring, void *arg) {\n const asciiioGH *myGH = (const asciiioGH *)arg;\n\n if (CheckOutputVar(vindex)) {\n myGH->out1D_every[vindex] = myGH->out1D_every_default;\n\n if (optstring) {\n IOUtil_ParseOutputFrequency(\"1D IOASCII\", \"IOASCII::out1D_vars\",\n myGH->stop_on_parse_errors, vindex, optstring,\n &myGH->out1D_every[vindex], NULL);\n }\n }\n}\n", |
| "Output2D.c": "/*@@\n @file Output2D.c\n @date Thu May 11 2000\n @author Thomas Radke\n @desc\n Functions to deal with 2D ASCII output of variables\n @enddesc\n @version $Id$\n@@*/\n\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Parameters.h\"\n#include \"util_String.h\"\n#include \"CactusBase/IOUtil/src/ioutil_Utils.h\"\n#include \"ioASCIIGH.h\"\n\n/* the rcs ID and its dummy function to use it */\nstatic const char *rcsid = \"$Id$\";\nCCTK_FILEVERSION(CactusBase_IOASCII_Output2D_c)\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\nstatic int CheckOutputVar(int vindex);\nstatic void SetOutputFlag(int vindex, const char *optstring, void *arg);\n\n/*@@\n @routine IOASCII_Output2DGH\n @date Sat March 6 1999\n @author Gabrielle Allen\n @desc\n Loops over all variables and outputs them if necessary\n @enddesc\n @calls IOASCII_TimeFor2D\n IOASCII_Write2D\n\n @var GH\n @vdesc pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n the number of variables which were output at this iteration\n (or 0 if it wasn't time to output yet)\n @endreturndesc\n@@*/\nint IOASCII_Output2DGH(const cGH *GH) {\n int vindex, retval;\n const asciiioGH *myGH;\n\n retval = 0;\n myGH = (const asciiioGH *)CCTK_GHExtension(GH, \"IOASCII\");\n\n /* loop over all variables */\n for (vindex = CCTK_NumVars() - 1; vindex >= 0; vindex--) {\n if (IOASCII_TimeFor2D(GH, vindex) &&\n IOASCII_Write2D(GH, vindex, CCTK_VarName(vindex)) == 0) {\n /* register variable as having 2D output this iteration */\n myGH->out2D_last[vindex] = GH->cctk_iteration;\n retval++;\n }\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOASCII_Output2DVarAs\n @date Sat March 6 1999\n @author Gabrielle Allen\n @desc\n Unconditional output of a variable\n using the IOASCII 2D output method\n @enddesc\n @calls IOASCII_Write2D\n\n @var GH\n @vdesc pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var fullname\n @vdesc complete name of variable to output\n @vtype const char *\n @vio in\n @endvar\n @var alias\n @vdesc alias name of variable to output\n (used to generate output filename)\n @vtype const char *\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n return code of @seeroutine IOASCII_Write2D, or<BR>\n -1 if variable cannot be output by IOASCII_2D\n @endreturndesc\n@@*/\nint IOASCII_Output2DVarAs(const cGH *GH, const char *fullname,\n const char *alias) {\n int vindex, retval;\n\n retval = -1;\n vindex = CCTK_VarIndex(fullname);\n if (vindex < 0) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"There is no such variable %s. Ignoring IOASCII 2D output.\",\n fullname);\n } else if (CheckOutputVar(vindex) == 0) {\n retval = IOASCII_Write2D(GH, vindex, alias);\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOASCII_TimeFor2D\n @date Sat March 6 1999\n @author Gabrielle Allen\n @desc\n Decides if it is time to output a variable\n using the IOASCII 2D output method\n @enddesc\n\n @var GH\n @vdesc pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var vindex\n @vdesc index of variable\n @vtype int\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n 1 if output should take place at this iteration, or<BR>\n 0 if not\n @endreturndesc\n@@*/\nint IOASCII_TimeFor2D(const cGH *GH, int vindex) {\n int retval;\n char *fullname;\n asciiioGH *myGH;\n\n myGH = (asciiioGH *)CCTK_GHExtension(GH, \"IOASCII\");\n IOASCII_CheckSteerableParameters2D(myGH);\n\n /* check if this variable should be output */\n retval = myGH->out2D_every[vindex] > 0 &&\n GH->cctk_iteration % myGH->out2D_every[vindex] == 0;\n if (retval) {\n /* check if variable wasn't already output this iteration */\n if (myGH->out2D_last[vindex] == GH->cctk_iteration) {\n fullname = CCTK_FullName(vindex);\n CCTK_VWarn(5, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Already done IOASCII 2D output for '%s' in current \"\n \"iteration (probably via triggers)\",\n fullname);\n free(fullname);\n retval = 0;\n }\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOASCII_TriggerOutput2D\n @date Sat March 6 1999\n @author Gabrielle Allen\n @desc\n Triggers the output of a variable\n using the IOASCII 2D output method\n @enddesc\n @calls IOASCII_Write2D\n\n @var GH\n @vdesc pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var vindex\n @vdesc index of variable to output\n @vtype int\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n return code of @seeroutine IOASCII_Write2D\n @endreturndesc\n@@*/\nint IOASCII_TriggerOutput2D(const cGH *GH, int vindex) {\n int retval;\n asciiioGH *myGH;\n\n /* do the 2D output */\n retval = IOASCII_Write2D(GH, vindex, CCTK_VarName(vindex));\n if (retval == 0) {\n /* register variable as having 2D output this iteration */\n myGH = (asciiioGH *)CCTK_GHExtension(GH, \"IOASCII\");\n myGH->out2D_last[vindex] = GH->cctk_iteration;\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOASCII_CheckSteerableParameters2D\n @date Tue 8 June 2004\n @author Thomas Radke\n @desc\n Check if steerable IOASCII 2D parameters have changed\n @enddesc\n @calls CCTK_TraverseString\n\n @var myGH\n @vdesc Pointer to IOASCII GH\n @vtype asciiioGH *\n @vio inout\n @endvar\n@@*/\nvoid IOASCII_CheckSteerableParameters2D(asciiioGH *myGH) {\n int i, num_vars;\n char *fullname, *msg;\n DECLARE_CCTK_PARAMETERS\n\n /* how often to output */\n i = myGH->out2D_every_default;\n myGH->out2D_every_default = out2D_every >= 0 ? out2D_every : out_every;\n\n /* report if frequency changed */\n if (myGH->out2D_every_default != i && !CCTK_Equals(verbose, \"none\")) {\n if (myGH->out2D_every_default > 0) {\n CCTK_VInfo(CCTK_THORNSTRING, \"Periodic 2D output every %d \"\n \"iterations\",\n myGH->out2D_every_default);\n } else {\n CCTK_INFO(\"Periodic 2D output turned off\");\n }\n }\n\n /* re-parse the 'out2D_vars' parameter if it was changed */\n if (strcmp(out2D_vars, myGH->out2D_vars) || myGH->out2D_every_default != i) {\n num_vars = CCTK_NumVars();\n memset(myGH->out2D_every, 0, num_vars * sizeof(CCTK_INT));\n if (CCTK_TraverseString(out2D_vars, SetOutputFlag, myGH,\n CCTK_GROUP_OR_VAR) < 0) {\n CCTK_WARN(myGH->stop_on_parse_errors ? 0 : 1,\n \"error while parsing parameter 'IOASCII::out2D_vars'\");\n }\n\n if (myGH->out2D_every_default == i || !CCTK_Equals(verbose, \"none\")) {\n msg = NULL;\n for (i = 0; i < num_vars; i++) {\n if (myGH->out2D_every[i]) {\n fullname = CCTK_FullName(i);\n if (!msg) {\n Util_asprintf(&msg, \"Periodic 2D output requested for \"\n \"'%s'\",\n fullname);\n } else {\n char *tmp = msg;\n Util_asprintf(&msg, \"%s, '%s'\", msg, fullname);\n free(tmp);\n }\n free(fullname);\n }\n }\n if (msg) {\n CCTK_INFO(msg);\n free(msg);\n }\n }\n\n /* save the last setting of 'out2D_vars' parameter */\n free(myGH->out2D_vars);\n myGH->out2D_vars = strdup(out2D_vars);\n }\n}\n\n/**************************** local functions ******************************/\n/* check if this variable can be output (static conditions) */\nstatic int CheckOutputVar(int vindex) {\n int groupindex;\n cGroup groupinfo;\n char *fullname;\n const char *errormsg;\n\n /* get the variable group information */\n groupindex = CCTK_GroupIndexFromVarI(vindex);\n CCTK_GroupData(groupindex, &groupinfo);\n\n errormsg = NULL;\n if (groupinfo.dim < 2 || groupinfo.dim > 3) {\n errormsg = \"dim != [2,3]\";\n } else if (groupinfo.grouptype != CCTK_GF &&\n groupinfo.grouptype != CCTK_ARRAY) {\n errormsg = \"not a grid function or array\";\n }\n\n if (errormsg) {\n fullname = CCTK_FullName(vindex);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"No IOASCII 2D output for '%s': %s\", fullname, errormsg);\n free(fullname);\n }\n\n return (errormsg != NULL);\n}\n\n/* callback for CCTK_TraverseString() to set the output flag\n for the given variable */\nstatic void SetOutputFlag(int vindex, const char *optstring, void *arg) {\n const asciiioGH *myGH = (const asciiioGH *)arg;\n\n if (CheckOutputVar(vindex) == 0) {\n myGH->out2D_every[vindex] = myGH->out2D_every_default;\n\n if (optstring) {\n IOUtil_ParseOutputFrequency(\"2D IOASCII\", \"IOASCII::out2D_vars\",\n myGH->stop_on_parse_errors, vindex, optstring,\n &myGH->out2D_every[vindex], NULL);\n }\n }\n}\n", |
| "Startup.c": "/*@@\n @file Startup.c\n @date Sat Feb 6 1999\n @author Gabrielle Allen\n @desc\n Startup routines for IOASCII.\n @enddesc\n @version $Id$\n@@*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_IOMethods.h\"\n#include \"cctk_Parameters.h\"\n#include \"CactusBase/IOUtil/src/ioutil_Utils.h\"\n#include \"ioASCIIGH.h\"\n\n/* the rcs ID and its dummy function to use it */\nstatic const char *rcsid = \"$Id$\";\nCCTK_FILEVERSION(CactusBase_IOASCII_Startup_c)\n\n/********************************************************************\n ******************** Macro Definitions ************************\n ********************************************************************/\n#define CREATE_OUTDIR(dim, dir) \\\n { \\\n const char *_dir = dir; \\\n \\\n /* check whether \"dir\" was set; if not default to \"IO::out_dir\" */ \\\n if (*_dir == 0) { \\\n _dir = out_dir; \\\n } \\\n \\\n /* omit the directory name if it's the current working dir */ \\\n if (strcmp(_dir, \".\") == 0) { \\\n myGH->dir = strdup(\"\"); \\\n } else { \\\n myGH->dir = malloc(strlen(_dir) + 2); \\\n sprintf(myGH->dir, \"%s/\", _dir); \\\n } \\\n \\\n /* create the directory */ \\\n i = IOUtil_CreateDirectory(GH, myGH->dir, 0, 0); \\\n if (i < 0) { \\\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, \\\n \"IOASCII_SetupGH: Problem creating directory '%s' \" \\\n \"for %dD output\", \\\n myGH->dir, dim); \\\n } else if (i >= 0 && CCTK_Equals(verbose, \"full\")) { \\\n CCTK_VInfo(CCTK_THORNSTRING, \"%dD output to directory '%s'\", dim, \\\n myGH->dir); \\\n } \\\n }\n\n/********************************************************************\n ******************** External Routines ************************\n ********************************************************************/\nint IOASCII_Startup(void);\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\nstatic void *IOASCII_SetupGH(tFleshConfig *config, int conv_level, cGH *GH);\n\n/*@@\n @routine IOASCII_Startup\n @date Sat Feb 6 1999\n @author Gabrielle Allen\n @desc\n The startup registration routine for IOASCII.\n Registers the GH extensions needed for IOASCII\n along with its setup routine.\n @enddesc\n @calls CCTK_RegisterGHExtension\n CCTK_RegisterGHExtensionSetupGH\n@@*/\nint IOASCII_Startup(void) {\n CCTK_RegisterGHExtensionSetupGH(CCTK_RegisterGHExtension(\"IOASCII\"),\n IOASCII_SetupGH);\n return 0;\n}\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\n/*@@\n @routine IOASCII_SetupGH\n @date Sat Feb 6 1999\n @author Gabrielle Allen\n @desc\n Allocates and sets up IOASCII's GH extension structure\n @enddesc\n\n @calls CCTK_RegisterIOMethod\n CCTK_RegisterIOMethodOutputGH\n CCTK_RegisterIOMethodOutputVarAs\n CCTK_RegisterIOMethodTimeToOutput\n CCTK_RegisterIOMethodTriggerOutput\n\n @var config\n @vdesc the CCTK configuration as provided by the flesh\n @vtype tFleshConfig *\n @vio unused\n @endvar\n @var conv_level\n @vdesc the convergence level\n @vtype int\n @vio unused\n @endvar\n @var GH\n @vdesc Pointer to CCTK grid hierarchy\n @vtype cGH *\n @vio in\n @endvar\n\n @returntype void *\n @returndesc\n pointer to the allocated GH extension structure\n @endreturndesc\n@@*/\nstatic void *IOASCII_SetupGH(tFleshConfig *config, int conv_level, cGH *GH) {\n int i, maxdim, numvars;\n asciiioGH *myGH;\n DECLARE_CCTK_PARAMETERS\n\n /* suppress compiler warnings about unused variables */\n (void)(config + 0);\n (void)(conv_level + 0);\n (void)(GH + 0);\n\n /* allocate the GH extension and its components */\n myGH = malloc(sizeof(asciiioGH));\n if (!myGH) {\n CCTK_WARN(0, \"IOASCII_SetupGH: Unable to allocate memory for GH\");\n }\n\n /* register the IOASCII routines as output methods */\n i = CCTK_RegisterIOMethod(\"IOASCII_1D\");\n CCTK_RegisterIOMethodOutputGH(i, IOASCII_Output1DGH);\n CCTK_RegisterIOMethodOutputVarAs(i, IOASCII_Output1DVarAs);\n CCTK_RegisterIOMethodTimeToOutput(i, IOASCII_TimeFor1D);\n CCTK_RegisterIOMethodTriggerOutput(i, IOASCII_TriggerOutput1D);\n\n /* only register N-D IOASCII I/O methods\n if at least N-dimensional grid variables are defined by thorns */\n maxdim = CCTK_MaxDim();\n if (maxdim >= 2) {\n i = CCTK_RegisterIOMethod(\"IOASCII_2D\");\n CCTK_RegisterIOMethodOutputGH(i, IOASCII_Output2DGH);\n CCTK_RegisterIOMethodOutputVarAs(i, IOASCII_Output2DVarAs);\n CCTK_RegisterIOMethodTimeToOutput(i, IOASCII_TimeFor2D);\n CCTK_RegisterIOMethodTriggerOutput(i, IOASCII_TriggerOutput2D);\n }\n\n if (maxdim >= 3) {\n i = CCTK_RegisterIOMethod(\"IOASCII_3D\");\n CCTK_RegisterIOMethodOutputGH(i, IOASCII_Output3DGH);\n CCTK_RegisterIOMethodOutputVarAs(i, IOASCII_Output3DVarAs);\n CCTK_RegisterIOMethodTimeToOutput(i, IOASCII_TimeFor3D);\n CCTK_RegisterIOMethodTriggerOutput(i, IOASCII_TriggerOutput3D);\n }\n\n numvars = CCTK_NumVars();\n myGH->out1D_every = malloc(numvars * sizeof(CCTK_INT));\n myGH->out2D_every = malloc(numvars * sizeof(CCTK_INT));\n myGH->out3D_every = malloc(numvars * sizeof(CCTK_INT));\n myGH->out1D_last = malloc(numvars * sizeof(int));\n myGH->out2D_last = malloc(numvars * sizeof(int));\n myGH->out3D_last = malloc(numvars * sizeof(int));\n\n for (i = 0; i < numvars; i++) {\n myGH->out1D_last[i] = -1;\n myGH->out2D_last[i] = -1;\n myGH->out3D_last[i] = -1;\n }\n\n myGH->out1D_vars = strdup(\"\");\n myGH->out2D_vars = strdup(\"\");\n myGH->out3D_vars = strdup(\"\");\n myGH->out1D_every_default = out1D_every - 1;\n myGH->out2D_every_default = out2D_every - 1;\n myGH->out3D_every_default = out3D_every - 1;\n\n myGH->filenameList1D = NULL;\n myGH->fileList_2D = NULL;\n myGH->fileList_3D = NULL;\n\n myGH->stop_on_parse_errors = strict_io_parameter_check;\n if (!CCTK_Equals(verbose, \"none\")) {\n CCTK_INFO(\"I/O Method 'IOASCII_1D' registered: output of 1D lines of grid \"\n \"functions/arrays to ASCII files\");\n }\n IOASCII_CheckSteerableParameters1D(myGH);\n if (maxdim >= 2) {\n if (!CCTK_Equals(verbose, \"none\")) {\n CCTK_INFO(\"I/O Method 'IOASCII_2D' registered: output of 2D planes of \"\n \"grid functions/arrays to ASCII files\");\n }\n IOASCII_CheckSteerableParameters2D(myGH);\n }\n if (maxdim >= 3) {\n if (!CCTK_Equals(verbose, \"none\")) {\n CCTK_INFO(\"I/O Method 'IOASCII_3D' registered: output of 3D grid \"\n \"functions/arrays to ASCII files\");\n }\n IOASCII_CheckSteerableParameters3D(myGH);\n }\n myGH->stop_on_parse_errors = 0;\n\n /* make sure all output directories exist */\n CREATE_OUTDIR(1, out1D_dir);\n CREATE_OUTDIR(2, out2D_dir);\n CREATE_OUTDIR(3, out3D_dir);\n\n return (myGH);\n}\n" |
| }, |
| "test": { |
| "test.ccl": "EXTENSIONS gnuplot xl yl zl dl xg asc\n" |
| }, |
| "doc": { |
| "documentation.tex": "\\documentclass{article}\n\n% Use the Cactus ThornGuide style file\n% (Automatically used from Cactus distribution, if you have a \n% thorn without the Cactus Flesh download this from the Cactus\n% homepage at www.cactuscode.org)\n\\usepackage{../../../../doc/latex/cactus}\n\n\\begin{document}\n\n\\title{Simple Plain Text Output with IOASCII}\n\\author{Thomas Radke, Gabrielle Allen}\n\\date{$ $Date$ $}\n\n\\maketitle\n\n% Do not delete next line\n% START CACTUS THORNGUIDE\n\n\\begin{abstract}\nThorn {\\bf IOASCII} provides I/O methods for 1D, 2D, and 3D output of\ngrid arrays and grid functions into files in ASCII format. The precise\nformat is designed for visualisation using the clients {\\tt\nxgraph}~\\cite{cactusbase_ioascii_xgraph} or {\\tt\ngnuplot}~\\cite{cactusbase_ioascii_gnuplot}.\n\\end{abstract}\n\n\\section{Purpose}\nThorn {\\bf IOASCII} registers three I/O methods named {\\tt\nIOASCII\\_1D}, {\\tt IOASCII\\_2D}, and {\\tt IOASCII\\_3D} with the I/O\ninterface in the flesh.\n\n\\begin{itemize}\n \\item {\\tt IOASCII\\_1D}\\\\\n creates one-dimensional output of 1D, 2D and\n 3D grid functions and arrays by slicing through the edge (in the\n octant case) or center (in all origin centered cases) of the grid in\n the coordinate directions. In addition, output is provided\n along a diagonal of the grid, in this case the diagonal always starts\n at the first grid point (that is, in Fortran notation {\\tt var(1,1,1)})\n and the line taken uses grid points increasing by 1 in each direction.\n [NOTE: The diagonal output is not available for staggered variables].\\\\\n Output for each direction can be selected individually via parameters.\\\\\n Data is written in ASCII format and goes into files with the names:\n \\begin{center}\n {\\tt <variable\\_name>\\_<slice>\\_[<center\\_i>][<center\\_j>].\\{asc|xg\\}}\n \\end{center}\n and for diagonals:\n \\begin{center}{\\tt <variable\\_name>\\_3D\\_diagonal.\\{asc|xg\\}} \n \\end{center}\n These files can be processed directly by either xgraph or gnuplot\n (you can select the style of output via parameter settings).\n\n \\item {\\tt IOASCII\\_2D}\n outputs two-dimensional slices of grid functions and arrays planes.\n Again, slicing is done through the edge (in the octant case) or center\n (in all origin centered cases).\\\\\n Data is written in ASCII format and goes into files named\n\\begin{center}\n {\\tt <variable\\_name>\\_<plane>\\_[<center>].\\{asc|xg\\}}\n\\end{center}\n These files can be visualized by gnuplot using its {\\it splot} command.\n\n \\item {\\tt IOASCII\\_3D}\n outputs three-dimensional grid functions and arrays as a whole.\\\\\n Data is written in ASCII format and goes into files named\n\\begin{center}\n {\\tt <variable\\_name>\\_3D.\\{asc|xg\\}}\n\\end{center}\n These files can be visualized by gnuplot using its {\\it splot} command.\n\\end{itemize}\n%\n%\n\\section{{\\bf IOASCII} Parameters}\n%\nGeneral parameters to control all {\\bf IOASCII}'s I/O methods are:\n\\begin{itemize}\n \\item {\\tt IOASCII::out[123]D\\_every} (steerable)\\\\\n How often to do periodic {\\tt IOASCII} output. If this parameter is set in the\n parameter file, it will override the setting of the shared\n {\\tt IO::out\\_every} parameter. The output frequency can also be set\n for individual variables using the {\\tt out\\_every} option in an option string appended to the {\\tt IOASCII::out[123]D\\_vars} parameter.\n \\item {\\tt IOASCII::out[123]D\\_vars} (steerable)\\\\\n The list of variables to output using an {\\bf IOASCII} I/O method.\n The variables must be given by their fully qualified variable or group\n name. The special keyword {\\it all} requests {\\tt IOASCII} output for\n all variables. Multiple names must be separated by whitespaces.\\\\\n An option string can be appended in curly braces to the\n group/variable name. The only option supported so far is {\\tt out\\_every}\n which sets the output frequency for an individual variable (overriding\n {\\tt IOASCII::out[123]D\\_every} and {\\tt IO::out\\_every}).\n \\item {\\tt IOASCII::out[123]D\\_dir}\\\\\n The directory in which to place the {\\tt IOASCII} output files.\n If the directory doesn't exist at startup it will be created.\\\\\n If this parameter is set to an empty string {\\tt IOASCII} output will go\n to the standard output directory as specified in {\\tt IO::out\\_dir}.\n \\item {\\tt IOASCII::out\\_format} (steerable)\\\\\n The output format for floating-point numbers in {\\tt IOASCII} output.\\\\\n This parameter conforms to the format modifier of the C library routine\n {\\it fprintf(3)}. You can set the format for outputting floating-point\n numbers (fixed or exponential) as well as their precision (number of\n digits).\n \\item {\\tt IOASCII::out[123]D\\_style}\\\\\n The output style for {\\tt IOASCII} output.\\\\\n This parameter chooses between {\\tt gnuplot}- and {\\tt xgraph}-suitable\n output style, and -- for {\\tt gnuplot} -- determines whether to also\n plot the physical time in the output data or not.\n\\end{itemize}\n%\nAdditional parameters to control the {\\tt IOASCII\\_1D} I/O method are:\n\\begin{itemize}\n \\item {\\tt IOASCII::out1D\\_[xyzd]} (steerable)\\\\\n Chooses the directions to output in 1D {\\tt IOASCII} format ({\\tt d}\n stands for diagonal direction).\n \\item {\\tt IOASCII::out1D\\_[xyz]line\\_[xyz], IOASCII::out1D\\_[xyz]line\\_[xyz]i}\\\\\n Chooses the slice centers for 1D lines from {\\tt IOASCII\\_1D}. These\n can be set either in physical or index coordinates. If they are set\n these parameters will override the default slice center parameters\n {\\tt IO::out\\_[xyz]line[xyz], IO::out\\_[xyz]line[xyz]i}.\n Note that the slice center can only be set for grid functions so far.\n For {\\tt CCTK\\_ARRAY} variables the slices will always start in the\n origin, ie. (0, 0, 0) in C ordering.\n\\end{itemize}\n%\nAdditional parameters to control the {\\tt IOASCII\\_2D} I/O method are:\n\\begin{itemize}\n \\item {\\tt IOASCII::out2D\\_[{xy}{xz}{yz}]plane\\_[xyz], IOASCII::out2D\\_[{xy}{xz}{yz}]plane\\_[xyz]i}\\\\\n Chooses the slice centers for 2D planes from {\\tt IOASCII\\_2D}. These\n can be set either in physical or index coordinates. If they are set\n these parameters will override the default slice center parameters\n {\\tt IO::out\\_[{xy}{xz}{yz}]plane[xyz], IO::out\\_[{xy}{xz}{yz}]plane[xyz]i}.\n\\end{itemize}\n%\n%\n\\section{Comments}\n%\n{\\bf Getting Output from {\\bf IOBasic}'s I/O Mehtods}\\\\\n%\nYou obtain output by an I/O method by either\n%\n\\begin{itemize}\n \\item setting the appropriate I/O parameters\n \\item calling one the routines of the I/O function interface provided by the flesh\n\\end{itemize}\n%\nFor a description of basic I/O parameters and the I/O function interface to\ninvoke I/O methods by application thorns please see the documentation of thorn\n{\\bf IOUtil} and the flesh.\\\\[3ex]\n%\n{\\bf Building Cactus configurations with {\\bf IOBasic}}\\\\\n%\nSince {\\bf IOASCII} uses parameters from {\\bf IOUtil} it also needs this I/O\nhelper thorn be compiled into Cactus and activated at runtime in the\n{\\tt ActiveThorns} parameter in your parameter file.\n%\n%\n\\section{Examples}\n\nIn this section we include example output for different parameter combinations.\nNote that all these examples were generated for just a couple of timesteps for an extremely small 3D grid.\n\n\\subsection{One-dimensional xgraph}\n\nThese options produce data suitable for using with the xgraph\nvisualization client in the format\\\\\n\\texttt{x~f(t=fixed,x,y=fixed,z=fixed)}:\n\n\\begin{verbatim}\n IOASCII::out1D_every = 1\n IOASCII::out1D_vars = \"wavetoy::phi\"\n IOASCII::out1D_style = \"xgraph\"\n\\end{verbatim}\n\n\\noindent\n{\\bf Output File: phi\\_x\\_[1][1].xg}\n\n\\begin{verbatim}\n \"Parameter file wavetoy.par\n \"Created Sun 19 Aug 2001 16:31:43\n \"x-label x\n \"y-label WAVETOY::phi (y = 0.0000000000000, z = 0.0000000000000), (yi = 1, zi = 1)\n\n\n \"Time = 0.0000000000000\n -0.5000000000000\t\t0.0000000000139\n 0.0000000000000\t\t1.0000000000000\n 0.5000000000000\t\t0.0000000000139\n\n\n \"Time = 0.2500000000000\n -0.5000000000000\t\t0.0000000000000\n 0.0000000000000\t\t0.4980695458846\n 0.5000000000000\t\t0.0000000000000\n\n\n \"Time = 0.5000000000000\n -0.5000000000000\t\t0.0019304541362\n 0.0000000000000\t\t-0.7509652270577\n 0.5000000000000\t\t0.0019304541362\n\\end{verbatim}\n\n\n\\subsection{One-dimensional gnuplot}\n\nThese options produce data suitable for using with the gnuplot visualization client in the format\\\\ {\\tt x f(t,x,y=fixed,z=fixed)}:\n\n\\begin{verbatim}\n IOASCII::out1D_every = 1\n IOASCII::out1D_vars = \"wavetoy::phi\"\n IOASCII::out1D_style = \"gnuplot f(x)\"\n\\end{verbatim}\n\n\\noindent\n{\\bf Output File: phi\\_x\\_[1][1].asc}\n\n\\begin{verbatim}\n #Parameter file wavetoy.par\n #Created Sun 19 Aug 2001 16:33:07\n #x-label x\n #y-label WAVETOY::phi (y = 0.0000000000000, z = 0.0000000000000), (yi = 1, zi = 1)\n\n #Time = 0.0000000000000\n -0.5000000000000\t\t0.0000000000139\n 0.0000000000000\t\t1.0000000000000\n 0.5000000000000\t\t0.0000000000139\n\n #Time = 0.2500000000000\n -0.5000000000000\t\t0.0000000000000\n 0.0000000000000\t\t0.4980695458846\n 0.5000000000000\t\t0.0000000000000\n\n #Time = 0.5000000000000\n -0.5000000000000\t\t0.0019304541362\n 0.0000000000000\t\t-0.7509652270577\n 0.5000000000000\t\t0.0019304541362\n\\end{verbatim}\n\n\n\\subsection{One-dimensional gnuplot (including time)}\n\nThese options produce data suitable for using with the gnuplot visualization client in the format\\\\ {\\tt t x f(t,x,y=fixed,z=fixed)}:\n\n\\begin{verbatim}\n IOASCII::out1D_every = 1\n IOASCII::out1D_vars = \"wavetoy::phi\"\n IOASCII::out1D_style = \"gnuplot f(t,x)\"\n\\end{verbatim}\n\n\\noindent\n{\\bf Output file: phi\\_x\\_[1][1].asc}\n\n\\begin{verbatim}\n #Parameter file wavetoy.par\n #Created Sun 19 Aug 2001 16:34:48\n #x-label x\n #y-label WAVETOY::phi (y = 0.0000000000000, z = 0.0000000000000), (yi = 1, zi = 1)\n\n #Time = 0.0000000000000\n 0.0000000000000\t\t-0.5000000000000\t\t0.0000000000139\n 0.0000000000000\t\t0.0000000000000\t\t1.0000000000000\n 0.0000000000000\t\t0.5000000000000\t\t0.0000000000139\n\n #Time = 0.2500000000000\n 0.2500000000000\t\t-0.5000000000000\t\t0.0000000000000\n 0.2500000000000\t\t0.0000000000000\t\t0.4980695458846\n 0.2500000000000\t\t0.5000000000000\t\t0.0000000000000\n\n #Time = 0.5000000000000\n 0.5000000000000\t\t-0.5000000000000\t\t0.0019304541362\n 0.5000000000000\t\t0.0000000000000\t\t-0.7509652270577\n 0.5000000000000\t\t0.5000000000000\t\t0.0019304541362\n\\end{verbatim}\n\n\n\\subsection{Two-dimensional gnuplot}\n\nThese options produce data suitable for using with the gnuplot visualization client in the format\\\\ {\\tt x y f(t,x,y,z=fixed)}:\n\n\\begin{verbatim}\n IOASCII::out2D_every = 1\n IOASCII::out2D_vars = \"wavetoy::phi\"\n IOASCII::out2D_style = \"gnuplot f(x,y)\"\n\\end{verbatim}\n\n\\noindent\n{\\bf Output file: phi\\_xy\\_[1].asc}\n\n\\begin{verbatim}\n #Parameter file wavetoy.par\n #Created Sun 19 Aug 2001 16:31:43\n #x-label x\n #y-label y\n #z-label WAVETOY::phi (z = 0.0000000000000), (zi = 1)\n\n\n #Time = 0.0000000000000\n -0.5000000000000\t\t-0.5000000000000\t\t0.0000000000000\n 0.0000000000000\t\t-0.5000000000000\t\t0.0000000000139\n 0.5000000000000\t\t-0.5000000000000\t\t0.0000000000000\n\n -0.5000000000000\t\t0.0000000000000\t\t0.0000000000139\n 0.0000000000000\t\t0.0000000000000\t\t1.0000000000000\n 0.5000000000000\t\t0.0000000000000\t\t0.0000000000139\n\n -0.5000000000000\t\t0.5000000000000\t\t0.0000000000000\n 0.0000000000000\t\t0.5000000000000\t\t0.0000000000139\n 0.5000000000000\t\t0.5000000000000\t\t0.0000000000000\n\n\n\n #Time = 0.2500000000000\n -0.5000000000000\t\t-0.5000000000000\t\t0.0000000000000\n 0.0000000000000\t\t-0.5000000000000\t\t0.0000000000000\n 0.5000000000000\t\t-0.5000000000000\t\t0.0000000000000\n\n -0.5000000000000\t\t0.0000000000000\t\t0.0000000000000\n 0.0000000000000\t\t0.0000000000000\t\t0.4980695458846\n 0.5000000000000\t\t0.0000000000000\t\t0.0000000000000\n\n -0.5000000000000\t\t0.5000000000000\t\t0.0000000000000\n 0.0000000000000\t\t0.5000000000000\t\t0.0000000000000\n 0.5000000000000\t\t0.5000000000000\t\t0.0000000000000\n\n\n\n #Time = 0.5000000000000\n -0.5000000000000\t\t-0.5000000000000\t\t0.0000000008425\n 0.0000000000000\t\t-0.5000000000000\t\t0.0019304541362\n 0.5000000000000\t\t-0.5000000000000\t\t0.0000000008425\n\n -0.5000000000000\t\t0.0000000000000\t\t0.0019304541362\n 0.0000000000000\t\t0.0000000000000\t\t-0.7509652270577\n 0.5000000000000\t\t0.0000000000000\t\t0.0019304541362\n\n -0.5000000000000\t\t0.5000000000000\t\t0.0000000008425\n 0.0000000000000\t\t0.5000000000000\t\t0.0019304541362\n 0.5000000000000\t\t0.5000000000000\t\t0.0000000008425\n\\end{verbatim}\n\n\n\\subsection{Two-dimensional gnuplot (including time)}\n\nThese options produce data suitable for using with the gnuplot visualization client in the format\\\\ {\\tt t x y f(t,x,y,z=fixed)}:\n\n\\begin{verbatim}\n IOASCII::out2D_every = 1\n IOASCII::out2D_vars = \"wavetoy::phi\"\n IOASCII::out2D_style = \"gnuplot f(t,x,y)\"\n\\end{verbatim}\n\n\n\\noindent\n{\\bf Output file: phi\\_xy\\_[1].asc}\n\n\\begin{verbatim}\n #Parameter file wavetoy.par\n #Created Sun 19 Aug 2001 16:33:07\n #x-label x\n #y-label y\n #z-label WAVETOY::phi (z = 0.0000000000000), (zi = 1)\n\n\n #Time = 0.0000000000000\n 0.0000000000000\t\t-0.5000000000000\t\t-0.5000000000000\t\t0.0000000000000\n 0.0000000000000\t\t0.0000000000000\t\t-0.5000000000000\t\t0.0000000000139\n 0.0000000000000\t\t0.5000000000000\t\t-0.5000000000000\t\t0.0000000000000\n\n 0.0000000000000\t\t-0.5000000000000\t\t0.0000000000000\t\t0.0000000000139\n 0.0000000000000\t\t0.0000000000000\t\t0.0000000000000\t\t1.0000000000000\n 0.0000000000000\t\t0.5000000000000\t\t0.0000000000000\t\t0.0000000000139\n\n 0.0000000000000\t\t-0.5000000000000\t\t0.5000000000000\t\t0.0000000000000\n 0.0000000000000\t\t0.0000000000000\t\t0.5000000000000\t\t0.0000000000139\n 0.0000000000000\t\t0.5000000000000\t\t0.5000000000000\t\t0.0000000000000\n\n\n\n #Time = 0.2500000000000\n 0.2500000000000\t\t-0.5000000000000\t\t-0.5000000000000\t\t0.0000000000000\n 0.2500000000000\t\t0.0000000000000\t\t-0.5000000000000\t\t0.0000000000000\n 0.2500000000000\t\t0.5000000000000\t\t-0.5000000000000\t\t0.0000000000000\n\n 0.2500000000000\t\t-0.5000000000000\t\t0.0000000000000\t\t0.0000000000000\n 0.2500000000000\t\t0.0000000000000\t\t0.0000000000000\t\t0.4980695458846\n 0.2500000000000\t\t0.5000000000000\t\t0.0000000000000\t\t0.0000000000000\n\n 0.2500000000000\t\t-0.5000000000000\t\t0.5000000000000\t\t0.0000000000000\n 0.2500000000000\t\t0.0000000000000\t\t0.5000000000000\t\t0.0000000000000\n 0.2500000000000\t\t0.5000000000000\t\t0.5000000000000\t\t0.0000000000000\n\n\n\n #Time = 0.5000000000000\n 0.5000000000000\t\t-0.5000000000000\t\t-0.5000000000000\t\t0.0000000008425\n 0.5000000000000\t\t0.0000000000000\t\t-0.5000000000000\t\t0.0019304541362\n 0.5000000000000\t\t0.5000000000000\t\t-0.5000000000000\t\t0.0000000008425\n\n 0.5000000000000\t\t-0.5000000000000\t\t0.0000000000000\t\t0.0019304541362\n 0.5000000000000\t\t0.0000000000000\t\t0.0000000000000\t\t-0.7509652270577\n 0.5000000000000\t\t0.5000000000000\t\t0.0000000000000\t\t0.0019304541362\n\n 0.5000000000000\t\t-0.5000000000000\t\t0.5000000000000\t\t0.0000000008425\n 0.5000000000000\t\t0.0000000000000\t\t0.5000000000000\t\t0.0019304541362\n 0.5000000000000\t\t0.5000000000000\t\t0.5000000000000\t\t0.0000000008425\n\\end{verbatim}\n\n\\begin{thebibliography}{9}\n\n\\bibitem{cactusbase_ioascii_xgraph}\n{\\tt http://www.cactuscode.org/VizTools/xgraph.html}, {\\tt http://jean-luc.aei.mpg.de/Codes/xgraph/}\n\n\\bibitem{cactusbase_ioascii_gnuplot}\n{\\tt http://www.cactuscode.org/VizTools/Gnuplot.html}, {\\tt http://www.gnuplot.info}\n\\end{thebibliography}\n\n\n% Do not delete next line\n% END CACTUS THORNGUIDE\n\n\\end{document}\n" |
| } |
| } |