{ "thorn_name": "CactusBase/IOUtil", "url": "https://bitbucket.org/cactuscode/cactusbase.git", "configuration": "# Configuration definitions for thorn IOUTIL\n# $Header$\n\n# In future we can hopefully use function aliasing instead.\n\nPROVIDES IOUTIL\n{\n SCRIPT\n LANG\n}\n", "interface": "# Interface definitions for thorn IOUtil\n# $Header$\n\nimplements: IO\n\n\n# aliased functions required from Coordinate base thorn\n\nCCTK_INT FUNCTION Coord_GetDefaultSystem \\\n (CCTK_POINTER_TO_CONST IN GH, \\\n CCTK_INT IN systemdim)\n\nUSES FUNCTION Coord_GetDefaultSystem\n\n\nCCTK_INT FUNCTION IO_TruncateOutputFiles \\\n (CCTK_POINTER_TO_CONST IN GH)\n\nPROVIDES FUNCTION IO_TruncateOutputFiles \\\n WITH IOUtil_TruncateOutputFiles \\\n LANGUAGE C\n", "param": "# Parameter definitione for thorn IOUtil\n# $Header$\n\n#############################################################################\n### declare IOUtil parameters\n### These are declared protected so that they can be seen by other I/O thorns.\n#############################################################################\nrestricted:\n\n####################\n# Output directories\n####################\nSTRING out_dir \"Default output directory\" STEERABLE = RECOVER\n{\n \".+\" :: \"A valid directory name\"\n} \".\"\n\nCCTK_INT max_entries_per_subdir \"Number of processes that can access the same directory\"\n{\n 0 :: \"unlimited\"\n 2:* :: \"at most that many processes\"\n} 0\n\n########################\n# How often to do output\n########################\nKEYWORD out_criterion \"Criterion to select output intervals\"\n{\n \"never\" :: \"Never output\"\n \"iteration\" :: \"Output every so many iterations\"\n \"time\" :: \"Output every that much coordinate time\"\n} \"iteration\"\nINT out_every \"How often to do output by default\" STEERABLE = ALWAYS\n{\n 1:* :: \"Every so many iterations\"\n -1:0 :: \"Disable output\"\n} -1\nREAL out_dt \"How often to do output by default\" STEERABLE = ALWAYS\n{\n (0:* :: \"In intervals of that much coordinate time\"\n 0 :: \"As often as possible\"\n -1 :: \"Disable output\"\n -2 :: \"Disable output\"\n} -2\n\n################\n# various things\n################\nKEYWORD verbose \"Level of screen output for I/O\" STEERABLE = ALWAYS\n{\n \"none\" :: \"No output\"\n \"standard\" :: \"Initial description for each I/O method\"\n \"full\" :: \"Maximal output\"\n} \"standard\"\nBOOLEAN print_timing_info \"Print timing information on I/O operations.\" STEERABLE = RECOVER\n{\n} \"no\"\nBOOLEAN new_filename_scheme \"Use the new filename scheme for output files ?\" STEERABLE = RECOVER\n{\n} \"yes\"\nBOOLEAN require_empty_output_directory \"Require that IO::out_dir is empty at startup ?\" STEERABLE = RECOVER\n{\n} \"no\"\nBOOLEAN strict_io_parameter_check \"Stop on errors while parsing I/O parameters from parameter file ?\" STEERABLE = RECOVER\n{\n} \"yes\"\nBOOLEAN abort_on_io_errors \"Abort on I/O errors (rather than just print a warning) ?\" STEERABLE = ALWAYS\n{\n} \"no\"\nKEYWORD out_fileinfo \"Add some useful file information to output files ?\" STEERABLE = RECOVER\n{\n \"none\" :: \"no file information\"\n \"creation date\" :: \"add creation date\"\n \"parameter filename\" :: \"add parameter filename\"\n \"axis labels\" :: \"add axis labels information to output files\"\n \"all\" :: \"add all available file information\"\n} \"all\"\nSTRING out_group_separator \"String to separate group name from variable name in file name\" STEERABLE = ALWAYS\n{\n \"\" :: \"Note: The old default was'::'\"\n} \"-\"\n\n#######################\n# Specific to 3D output\n#######################\nKEYWORD out_mode \"Which mode to use for output\" STEERABLE = RECOVER\n{\n \"proc\" :: \"Every processor writes its share of data into a separate file\"\n \"np\" :: \"Data is collected and written by every N'th processor into a separate file, where N is specified by the parameter IO::out_proc_every\"\n \"onefile\" :: \"All output is written into a single file by processor 0\"\n} \"proc\"\n\nINT out_proc_every \"Do output on every N processors\" STEERABLE = RECOVER\n{\n 1:* :: \"A number between [1, nprocs)\"\n} 8\nINT out_timesteps_per_file \"How many timesteps to write to a single file\" STEERABLE = RECOVER\n{\n# 1:* :: \"Number of timesteps per file\"\n 1:1 :: \"Number of timesteps per file (can only be 1 so far)\"\n -1: :: \"All timesteps in a single file\"\n} -1\nBOOLEAN out3D_septimefiles \"Write one file per time slice, as opposed to all data in one file\" STEERABLE = RECOVER\n{\n} \"no\"\nBOOLEAN out_unchunked \"Don't write data in chunks. This parameter is ignored for single-processor runs where output is always done in unchunked mode.\" STEERABLE = RECOVER\n{\n} \"no\"\nKEYWORD out_save_parameters \"Save current parameter settings in output files ?\" STEERABLE = RECOVER\n{\n \"all\" :: \"Save all parameter settings\"\n \"only set\" :: \"Only save parameters which have been set before\"\n \"no\" :: \"Don't save parameter settings\"\n} \"only set\"\n\n\n##############################################\n# Downsampling parameters (only for 3D output)\n##############################################\nINT out_downsample_x \"Factor by which to downsample output in x direction. Point (0,0,0) is always included.\" STEERABLE = ALWAYS\n{\n 1:* :: \"A positive integer\"\n} 1\nINT out_downsample_y \"Factor by which to downsample output in y direction. Point (0,0,0) is always included.\" STEERABLE = ALWAYS\n{\n 1:* :: \"A positive integer\"\n} 1\nINT out_downsample_z \"Factor by which to downsample output in z direction. Point (0,0,0) is always included.\" STEERABLE = ALWAYS\n{\n 1:* :: \"A positive integer\"\n} 1\nBOOLEAN out_single_precision \"Output data in single precision ?\" STEERABLE = ALWAYS\n{\n} \"no\"\n\n\n###################################\n# Checkpointing/recovery parameters\n###################################\nBOOLEAN checkpoint_ID \"Checkpoint initial data ?\" STEERABLE = RECOVER\n{\n} \"no\"\nKEYWORD recover \"Recover from a checkpoint file ?\" STEERABLE = RECOVER\n{\n \"no\" :: \"Don't recover\"\n \"manual\" :: \"Recover from the checkpoint file as given in IO::recover_dir and IO::recover_file\"\n \"auto\" :: \"Automatically recover from the latest checkpoint file found in \"\n \"autoprobe\" :: \"Probe for checkpoint files and automatically recover, continue as usual if nothing was found\"\n} \"no\"\nINT checkpoint_every \"How often to checkpoint\" STEERABLE = ALWAYS\n{\n 1:* :: \"Every so many iterations\"\n -1:0 :: \"Disable periodic checkpointing\"\n} -1\nREAL checkpoint_every_walltime_hours \"How often to checkpoint\" STEERABLE = ALWAYS\n{\n (0:* :: \"After so much walltime has passed\"\n -1 :: \"Disable periodic walltime checkpointing\"\n} -1\nBOOLEAN checkpoint_on_terminate \"Checkpoint after last iteration\" STEERABLE = ALWAYS\n{\n} \"no\"\nINT checkpoint_keep \"How many checkpoint files to keep\" STEERABLE = ALWAYS\n{\n 1:* :: \"1 overwrites the latest checkpoint file\"\n -1: :: \"Keep all checkpoint files\"\n} 1\nSTRING checkpoint_file \"File name for regular checkpoint\" STEERABLE = ALWAYS\n{\n \".+\" :: \"A valid filename\"\n} \"checkpoint.chkpt\"\nSTRING checkpoint_ID_file \"File name for initial data checkpoint\" STEERABLE = ALWAYS\n{\n \".+\" :: \"A valid filename\"\n} \"checkpoint.chkpt\"\nSTRING recover_file \"Basename of recovery file\" STEERABLE = ALWAYS\n{\n \".+\" :: \"A valid filename\"\n} \"checkpoint.chkpt\"\nSTRING checkpoint_dir \"Output directory for checkpoint files\" STEERABLE = ALWAYS\n{\n \".+\" :: \"A valid directory name\"\n} \".\"\nSTRING recover_dir \"Directory to look for recovery files\" STEERABLE = RECOVER\n{\n \".+\" :: \"A valid directory name\"\n} \".\"\nSTRING filereader_ID_dir \"Directory to look for input files\" STEERABLE = RECOVER\n{\n \".+\" :: \"A valid directory name\"\n} \".\"\nSTRING filereader_ID_files \"List of basenames of files to read in as initial data (e.g. omit the filename extention here)\" STEERABLE = RECOVER\n{\n \".+\" :: \"Space-separated list of initial data filenames (basenames, e.g. excluding the file name extention)\"\n \"^$\" :: \"An empty string for not recovering initial data\"\n} \"\"\nSTRING filereader_ID_vars \"List of variables to read in from the given initial data files\" STEERABLE = RECOVER\n{\n \"all\" :: \"Read all variables contained in the initial data files\"\n \".+\" :: \"Space-separated list of fully qualified variable/group names\"\n \"^$\" :: \"An empty string for not recovering initial data\"\n} \"all\"\nBOOLEAN recover_and_remove \"Remove checkpoint file after successful recovery ?\" STEERABLE = RECOVER\n{\n} \"no\"\n\n\n###################################\n# Parameter file writing parameters\n###################################\nKEYWORD parfile_write \"Write a parameter file to 'IO::out_dir'\" STEERABLE = RECOVER\n{\n \"no\" :: \"Do not write a parameter file\"\n \"copy\" :: \"Copy the original parameter file\"\n \"generate\" :: \"Generate a parameter file from the current settings\"\n# \"verbose generate\" :: \"Like \\\"generate\\\" but describe all parameters in detail\"\n} \"copy\"\nSTRING parfile_name \"Filename for the parameter file to be written\" STEERABLE = RECOVER\n{\n \".+\" :: \"A valid filename\"\n \"^$\" :: \"An empty string to choose the original parameter filename\"\n} \"\"\nINT parfile_update_every \"How often to update the parameter file for steered parameters\" STEERABLE = ALWAYS\n{\n 1:* :: \"Every so many iterations\"\n 0: :: \"Disable updating\"\n} 0\n\n\n#######################################\n# 1D line slice center setup parameters\n#######################################\nREAL out_xline_y \"y-coord for 1D lines in x-direction\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [ymin, ymax]\"\n} 0.0\nREAL out_xline_z \"z-coord for 1D lines in x-direction\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [zmin, zmax]\"\n} 0.0\nREAL out_yline_x \"x-coord for 1D lines in y-direction\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [xmin, xmax]\"\n} 0.0\nREAL out_yline_z \"z-coord for 1D lines in y-direction\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [zmin, zmax]\"\n} 0.0\nREAL out_zline_x \"x-coord for 1D lines in z-direction\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [xmin, xmax]\"\n} 0.0\nREAL out_zline_y \"y-coord for 1D lines in z-direction\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [ymin, ymax]\"\n} 0.0\n\nINT out_xline_yi \"y-index (from 0) for 1D lines in x-direction, overrides IO::out_xline_y\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, ny)\"\n -1: :: \"Default to physical coordinate IO::out_xline_y if it is within grid bounds, otherwise revert to using 0\"\n -2: :: \"Default to physical coordinate IO::out_xline_y if it is within grid bounds, otherwise revert to using the y-center of the box\"\n} -2\nINT out_xline_zi \"z-index (from 0) for 1D lines in x-direction, overrides IO::out_xline_z\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, nz)\"\n -1: :: \"Default to physical coordinate IO::out_xline_z if it is within grid bounds, otherwise revert to using 0\"\n -2: :: \"Default to physical coordinate IO::out_xline_z if it is within grid bounds, otherwise revert to using the z-center of the box\"\n} -2\nINT out_yline_xi \"x-index (from 0) for 1D lines in y-direction, overrides IO::out_yline_x\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, nx)\"\n -1: :: \"Default to physical coordinate IO::out_yline_x if it is within grid bounds, otherwise revert to using 0\"\n -2: :: \"Default to physical coordinate IO::out_yline_x if it is within grid bounds, otherwise revert to using the x-center of the box\"\n} -2\nINT out_yline_zi \"z-index (from 0) for 1D lines in y-direction, overrides IO::out_yline_z\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, nz)\"\n -1: :: \"Default to physical coordinate IO::out_yline_z if it is within grid bounds, otherwise revert to using 0\"\n -2: :: \"Default to physical coordinate IO::out_yline_z if it is within grid bounds, otherwise revert to using the z-center of the box\"\n} -2\nINT out_zline_xi \"x-index (from 0) for 1D lines in z-direction, overrides IO::out_zline_x\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, nx)\"\n -1: :: \"Default to physical coordinate IO::out_zline_x if it is within grid bounds, otherwise revert to using 0\"\n -2: :: \"Default to physical coordinate IO::out_zline_x if it is within grid bounds, otherwise revert to using the x-center of the box\"\n} -2\nINT out_zline_yi \"y-index (from 0) for 1D lines in z-direction, overrides IO::out_zline_y\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, ny)\"\n -1: :: \"Default to physical coordinate IO::out_zline_y if it is within grid bounds, otherwise revert to using 0\"\n -2: :: \"Default to physical coordinate IO::out_zline_y if it is within grid bounds, otherwise revert to using the y-center of the box\"\n} -2\n\n\n##################################\n# 2D plane center setup parameters\n##################################\nREAL out_yzplane_x \"x-coord for 2D planes in yz\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [xmin, xmax]\"\n} 0.0\nREAL out_xzplane_y \"y-coord for 2D planes in xz\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [ymin, ymax]\"\n} 0.0\nREAL out_xyplane_z \"z-coord for 2D planes in xy\" STEERABLE = RECOVER\n{\n *:* :: \"A value between [zmin, zmax]\"\n} 0.0\n\nINT out_yzplane_xi \"x-index (from 0) for 2D planes in yz, overrrides IO::out_yzplane_x\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, nx)\"\n -1: :: \"Default to physical coordinate IO::out_yzplane_x if it is within grid bounds, otherwise revert to using 0\"\n -2: :: \"Default to physical coordinate IO::out_yzplane_x if it is within grid bounds, otherwise revert to using the x-center of the box\"\n} -2\nINT out_xzplane_yi \"y-index (from 0) for 2D planes in xz, overrrides IO::out_xzplane_y\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, ny)\"\n -1: :: \"Default to physical coordinate IO::out_xzplane_y if it is within grid bounds, otherwise revert to using 0\"\n -2: :: \"Default to physical coordinate IO::out_xzplane_y if it is within grid bounds, otherwise revert to using the y-center of the box\"\n} -2\nINT out_xyplane_zi \"z-index (from 0) for 2D planes in xy, overrrides IO::out_xyplane_z\" STEERABLE = RECOVER\n{\n 0:* :: \"An index between [0, nz)\"\n -1: :: \"Default to physical coordinate IO::out_xyplane_z if it is within grid bounds, otherwise revert to using 0\"\n -2: :: \"Default to physical coordinate IO::out_xyplane_z if it is within grid bounds, otherwise revert to using the z-center of the box\"\n} -2\n\n\nprivate:\n\nBOOLEAN truncate_files \"Truncate existing output files from previous runs (except when recovering) ?\" STEERABLE = ALWAYS\n{\n} \"yes\"\n\nBOOLEAN truncate_files_after_recovering \"Truncate existing output files after recovering ?\" STEERABLE = RECOVER\n{\n} \"no\"\n", "schedule": "# Schedule definitions for thorn IOUtil\n# $Header$\n\nschedule IOUtil_Startup at STARTUP after Driver_Startup\n{\n LANG:C\n} \"Startup routine\"\n\nif (! CCTK_Equals (recover, \"no\"))\n{\n schedule IOUtil_RecoverGH at RECOVER_VARIABLES\n {\n LANG:C\n OPTIONS: level\n } \"Checkpoint recovery routine\"\n}\n\nif (*filereader_ID_files && *filereader_ID_vars)\n{\n schedule IOUtil_RecoverIDFromDatafiles at INITIAL\n {\n LANG:C\n OPTIONS: level\n } \"Initial data recovery routine\"\n}\n\nif (! CCTK_Equals (parfile_write, \"no\") && parfile_update_every)\n{\n schedule IOUtil_UpdateParFile at POSTSTEP\n {\n LANG:C\n OPTIONS: meta\n } \"Append steered parameters to parameter file\"\n}\n", "src": { "make.code.defn": "# Main make.code.defn file for thorn IOUtil\n# $Header$\n\n# Source files in this directory\nSRCS = Startup.c CheckpointRecovery.cc AdvertisedFiles.c Utils.c\n", "ioutil_CheckpointRecovery.h": "/*@@\n @header ioutil_CheckpointRecovery.h\n @date Tue 19 Sep 2000\n @author Thomas Radke\n @desc\n Typedefs and function prototypes for checkpointing and recovery.\n @history\n @endhistory\n @version $Header$\n@@*/\n\n#ifndef _IOUTIL_CHECKPOINTRECOVERY_H_\n#define _IOUTIL_CHECKPOINTRECOVERY_H_\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* enums for checkpointing/recovery and filereader functions */\nenum {\n CP_INITIAL_DATA,\n CP_EVOLUTION_DATA,\n CP_RECOVER_PARAMETERS,\n CP_RECOVER_DATA,\n FILEREADER_DATA\n};\n\n/************************************************************************\n *\n * Function prototypes\n *\n ************************************************************************/\n\n/* create a checkpoint filename */\nchar *IOUtil_AssembleFilename(const cGH *GH, const char *basefilename,\n const char *postfix, const char *extension,\n int called_from, int file_ioproc,\n int file_unchunked);\n\n/* register a new recovery method */\nint IOUtil_RegisterRecover(const char *name,\n int (*func)(cGH *, const char *, int));\n\n/* recover variables from a list of data files */\nint IOUtil_RecoverVarsFromDatafiles(cGH *GH, const char *in_files,\n const char *in_vars);\n\n/* generic recovery routine called by other IO thorns */\nint IOUtil_RecoverParameters(int (*recoverFn)(cGH *GH, const char *basefilename,\n int called_from),\n const char *fileExtension, const char *fileType);\n\n/* return the parameter database as one single string */\nchar *IOUtil_GetAllParameters(const cGH *GH, int all);\n\n/* set all parameters contained in the given string */\nvoid IOUtil_SetAllParameters(const char *parameters);\n\n/* print the checkpoint/recovery timings to stdout */\nvoid IOUtil_PrintTimings(const char *description, int ntimers,\n const int *timers,\n const char *const *const timer_descriptions);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _IOUTIL_CHECKPOINTRECOVERY_H_ */\n", "ioGH.h": "/*@@\n @header ioGH.h\n @date Tue 9th Jan 1999\n @author Gabrielle Allen\n @desc\n The extensions to the GH structure from IOUtil.\n @enddesc\n @version $Header$\n@@*/\n\n#ifndef _IOUTIL_IOGH_H_\n#define _IOUTIL_IOGH_H_ 1\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* advertise that this is the new version of this API, which has 'alias'\n * members in the grid extension */\n#define IOUTIL_IOGH_HAS_ALIAS 1\n\n/* IOUtil's GH extension structure */\ntypedef struct {\n /* for full-dimensional parallel output */\n int ioproc; /* the I/O processor each proc belongs to */\n int nioprocs; /* total number of I/O processors */\n int ioproc_every; /* output by every N'th processor */\n int unchunked; /* if true generate unchunked output file */\n int *downsample; /* downsampling parameters array of size cctk_maxdim */\n int out_single; /* if true output 3D data in single precision */\n\n /* for recovery */\n int recovered; /* flag indicating restart after successful recovery */\n int stop_on_parse_errors; /* stop on I/O parameter parsing errors ? */\n\n /* for data file reader */\n CCTK_INT *do_inVars; /* flags indicating to read in variable i with\n iteration number do_inVars[i] (or -1 to read\n the last iteration */\n const char **alias; /* name under which a variable appears in data files.\n If NULL, use CCTK_FullName() */\n} ioGH;\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _IOUTIL_IOGH_H_ */\n", "ioutil_Utils.h": "/*@@\n @header ioutil_Utils.h\n @date Tue 19 Sep 2000\n @author Thomas Radke\n @desc\n Function prototypes for setting up slice centers.\n @enddesc\n @version $Header$\n@@*/\n\n#ifndef _IOUTIL_IOUTIL_UTILS_H_\n#define _IOUTIL_IOUTIL_UTILS_H_ 1\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* structure describing an I/O request (including hyperslab parameters) */\ntypedef struct {\n /* output frequency */\n CCTK_INT out_every;\n CCTK_REAL out_dt;\n\n /* index and timelevel of the variable */\n int vindex, timelevel;\n\n /* dimensionality of the variable and the hyperslab */\n CCTK_INT vdim, hdim;\n\n /* CCTK datatype for the hyperslab */\n int hdatatype;\n\n /* flag indicating whether an object to be written already exists\n (and remove it in that case) */\n int check_exist;\n\n /* flag indicating whether to include ghostzones in the hyperslab mapping */\n int with_ghostzones;\n\n /* flag indicating whether to output in chunked or unchunked format */\n int out_unchunked;\n\n /* compression level */\n CCTK_INT compression_level;\n\n /* pointer to allocated buffers */\n CCTK_INT *vectors;\n\n /* hyperslab mapping parameters */\n CCTK_INT *origin, *direction, *extent, *downsample;\n\n /* offset and sizes of hyperslab into the variable's dataspace */\n CCTK_INT *hoffset, *hsize, *hsize_chunk;\n\n /* bitmask for refinement levels to output */\n CCTK_INT refinement_levels;\n\n /* list of reductions to output */\n char *reductions;\n\n} ioRequest;\n\n/* Advertise that this is the new version of this API, which has\n 'out_dt' arguments in the IOUtil_* functions below */\n#define IOUTIL_PARSER_HAS_OUT_DT 1\n\n/* parse a given 'out_vars' parameter string */\nvoid IOUtil_ParseVarsForOutput(const cGH *GH, const char *method_name,\n const char *parameter_name,\n int stop_on_parse_errors, const char *out_vars,\n int out_every_default, CCTK_REAL out_dt_default,\n ioRequest *request_list[]);\n\n/* parse a given I/O parameter option string for the 'out_every' and\n 'out_dt' options */\nvoid IOUtil_ParseOutputFrequency(const char *method_name,\n const char *parameter_name,\n int stop_on_parse_errors, int vindex,\n const char *optstring, CCTK_INT *out_every,\n CCTK_REAL *out_dt);\n\n/* return the default I/O request description structure for a variable */\nioRequest *IOUtil_DefaultIORequest(const cGH *GH, int vindex,\n int out_every_default,\n CCTK_REAL out_dt_default);\n\n/* free an I/O request description */\nvoid IOUtil_FreeIORequest(ioRequest **request);\n\n/* set the slice center for 1D lines */\nint IOUtil_1DLines(const cGH *GH, int num_dims, int *const *const origin_index,\n CCTK_REAL *const *const origin_phys,\n int *const *const slice_center);\n\n/* set the slice center for 2D planes */\nint IOUtil_2DPlanes(const cGH *GH, int num_dims, const int *origin_index,\n const CCTK_REAL *origin_phys, int *slice_center);\n\n/* create an output directory on all I/O processors */\nint IOUtil_CreateDirectory(const cGH *GH, const char *dirname,\n int multiple_io_procs, int ioproc);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _IOUTIL_IOUTIL_UTILS_H_ */\n", "ioutil_AdvertisedFiles.h": "/*@@\n @header ioutil_AdvertisedFiles.h\n @date Tue 19 Sep 2000\n @author Thomas Radke\n @desc\n Structures and function prototypes for advertising files.\n @history\n @endhistory\n @version $Header$\n@@*/\n\n#ifndef _IOUTIL_ADVERTISED_FILES_H_\n#define _IOUTIL_ADVERTISED_FILES_H_\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* structure describing an advertised file\n It contains pointer to strings holding\n - the thorn which created the file\n - the variable name the file contents data belongs to\n - the MIME type for the file format used\n - a short slice string indication the dimensionality of the data\n - an arbitrary additional description of the file contents */\ntypedef struct {\n const char *thorn;\n const char *varname;\n const char *mimetype;\n const char *slice;\n const char *description;\n} ioAdvertisedFileDesc;\n\n/* structure containing function pointers for handling with advertised files\n For the moment it contains only a registration routine for new files to\n be advertised. In the future we might also want something like\n unadvertising, or notification when the contents of the file changed. */\ntypedef struct {\n int (*advertise)(const cGH *GH, const char *filename,\n const ioAdvertisedFileDesc *description);\n} ioAdvertisedFileListenerCallbacks;\n\n/* register a new listener with its own callbacks for file advertising */\nint IOUtil_RegisterAdvertisedFileListener(\n const cGH *GH, const char *listener,\n const ioAdvertisedFileListenerCallbacks *callbacks);\n\n/* advertise a file */\nint IOUtil_AdvertiseFile(const cGH *GH, const char *filename,\n const ioAdvertisedFileDesc *desc);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _IOUTIL_ADVERTISED_FILES_H_ */\n", "CheckpointRecovery.cc": "/*@@\n @file CheckpointRecovery.c\n @date Jun 04 1999\n @author Thomas Radke\n @desc\n Utility routines for checkpointing/recovery and the filereader\n The actual work is done by the IO thorns.\n @enddesc\n @@*/\n\n#include \n#include \n#include \n#include \n\n#include \"ioGH.h\"\n#include \"ioutil_CheckpointRecovery.h\"\n\n#include \n#include \n#include \n#include \n#include \n#ifdef HAVE_DIRENT_H\n#include \n#endif\n#ifdef HAVE_UNISTD_H\n#include \n#endif\n\nusing namespace std;\n\n/********************************************************************\n ******************** External Routines ************************\n ********************************************************************/\nextern \"C\" void IOUtil_RecoverGH(cGH *GH);\nextern \"C\" void IOUtil_RecoverIDFromDatafiles(cGH *GH);\nextern \"C\" void CCTK_FCALL CCTK_FNAME(IOUtil_RecoverVarsFromDatafiles)(\n int *result, cGH **GH, TWO_FORTSTRING_ARG);\n\n/********************************************************************\n ******************** Static Variables *************************\n ********************************************************************/\n\n/* Table to store registered recovery functions */\nstatic int recover_fn_table = -1;\nstatic int checkpoint_file_exists = 0;\n\n/********************************************************************\n ******************** Internal Typedefs ************************\n ********************************************************************/\ntypedef struct {\n char *basename;\n int iteration;\n} filelist_t;\n\ntypedef int (*recover_fn_t)(cGH *GH, const char *basefilename, int called_from);\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\nstatic char *EncodeString(const char *string);\nstatic char *DecodeString(const char *string);\nstatic int OctalDigitToInt(const char digit);\nstatic void SetInputFlag(int vindex, const char *optstring, void *arg);\n#ifdef HAVE_DIRENT_H\nstatic int CompareFiles(const void *a, const void *b);\n#endif\n\nstatic int ipow(int b, int x) {\n assert(x >= 0);\n int r = 1;\n while (x > 0) {\n r *= b;\n --x;\n }\n return r;\n}\n\n/* integer log, rounding down */\nstatic int ilog(int b, int x) {\n assert(b > 1);\n assert(x > 0);\n int r = 0;\n int y = 1;\n while (y * b <= x) {\n ++r;\n y *= b;\n }\n assert(ipow(b, r) <= x);\n assert(ipow(b, r + 1) > x);\n return r;\n}\n\n/************************************************************************\n *\n * Registration functions for Restoring from IO Files\n *\n ************************************************************************/\n\n/*@@\n @routine IOUtil_RegisterRecover\n @date Monday 21 June 1999\n @author Gabrielle Allen\n @desc\n Registers a new recovery method\n @enddesc\n @calls Util_GetHandle\n Util_NewHandle\n\n @var name\n @vdesc The name of the function for recovery\n @vtype const char *\n @vio in\n @endvar\n @var recover_fn\n @vdesc the recovery function to register\n @vtype recover_fn_t\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n 0 for success, or
\n -1 method with this name already registered\n @endreturndesc\n@@*/\nint IOUtil_RegisterRecover(const char *name, recover_fn_t recover_fn) {\n /* create the function pointer table on the first time through */\n if (recover_fn_table < 0) {\n recover_fn_table = Util_TableCreate(UTIL_TABLE_FLAGS_DEFAULT);\n }\n\n /* check that the method hasn't already been registered */\n int retval =\n Util_TableQueryValueInfo(recover_fn_table, NULL, NULL, name) ? -1 : 0;\n if (!retval) {\n Util_TableSetFnPointer(recover_fn_table, (CCTK_FPOINTER)recover_fn, name);\n }\n\n return retval;\n}\n\n/*@@\n @routine IOUtil_AssembleFilename\n @date 30 June 2004\n @author Thomas Radke\n @desc\n This routine assembles the full basename for checkpoint/recovery\n and filereader files, paying attention to the different types:\n\n * it returns the full filename (directory+filename)\n * for cp files it prepends the iteration number as \"it_%d\"\n * for chunked files it prepends the file number as \"file_%d\"\n\n This routine replaces the old routine IOUtil_PrepareFilename()\n which should not be used anymore.\n @enddesc\n\n @var GH\n @vdesc pointer to CCTK grid hierarchy\n @vtype const cGH *\n @vio in\n @endvar\n @var basefilename\n @vdesc basename of the file\n @vtype const char *\n @vio in\n @endvar\n @var postfix\n @vdesc optional postfix to append to the basename\n (eg. \".tmp\" for temporary files, or \"\" for no postfix)\n @vtype const char *\n @vio in\n @var extension\n @vdesc file extension to append to the basefilename\n (should be given with the dot, eg. as \".h5\")\n @vtype const char *\n @vio in\n @endvar\n @var called_from\n @vdesc indicates the caller function:\n * either Filereader (FILEREADER_DATA)\n * or IOUtil_RecoverGH() (CP_RECOVER_DATA)\n @vtype int\n @vio in\n @endvar\n @var file_ioproc\n @vdesc the IO processor number (for chunked files)\n @vtype int\n @vio in\n @endvar\n @var file_unchunked\n @vdesc flag to indicate whether file mode is unchunked or not\n @vtype int\n @vio in\n @endvar\n\n @returntype char *\n @returndesc\n the filename (must be freed after use)\n @endreturndesc\n@@*/\nchar *IOUtil_AssembleFilename(const cGH *GH, const char *basefilename,\n const char *postfix, const char *extension,\n int called_from, int file_ioproc,\n int file_unchunked) {\n DECLARE_CCTK_PARAMETERS;\n\n /* get the right parameters */\n const char *dir = NULL;\n const char *basename = NULL;\n switch (called_from) {\n case CP_INITIAL_DATA: {\n dir = checkpoint_dir;\n basename = checkpoint_ID_file;\n int ierr = CCTK_CreateDirectory(0755, checkpoint_dir);\n if (ierr < 0) {\n CCTK_VERROR(\n \"Checkpoint directory %s could not be created (error code %d)\",\n checkpoint_dir, ierr);\n }\n break;\n }\n\n case CP_EVOLUTION_DATA: {\n dir = checkpoint_dir;\n basename = checkpoint_file;\n int ierr = CCTK_CreateDirectory(0755, checkpoint_dir);\n if (ierr < 0) {\n CCTK_VERROR(\n \"Checkpoint directory %s could not be created (error code %d)\",\n checkpoint_dir, ierr);\n }\n break;\n }\n\n case CP_RECOVER_DATA:\n case CP_RECOVER_PARAMETERS:\n dir = recover_dir;\n basename = basefilename ? basefilename : recover_file;\n break;\n case FILEREADER_DATA:\n dir = filereader_ID_dir;\n basename = basefilename ? basefilename : recover_file;\n break;\n\n default:\n CCTK_VERROR(\"IOUtil_AssembleFilename: unknown calling mode %d\",\n called_from);\n break;\n }\n\n if (!dir) {\n CCTK_ERROR(\"Directory name is null\");\n }\n if (!basename) {\n CCTK_ERROR(\"Basename is null\");\n }\n if (!postfix) {\n CCTK_ERROR(\"Postfix is null\");\n }\n if (!extension) {\n CCTK_ERROR(\"Extension is null\");\n }\n\n ostringstream filenamebuf;\n filenamebuf << dir;\n if (!file_unchunked && max_entries_per_subdir > 0) {\n /* Create intermediate subdirectory structure */\n\n /* During recovery, we do not know yet how many I/O processes\n there are. Therefore we pessimistically always assume that each\n process in as I/O proces. */\n int myproc = CCTK_MyProc(GH);\n int nprocs = CCTK_nProcs(GH);\n assert(myproc >= 0 && myproc < nprocs);\n\n /* Number of intermediate directory levels that need to be created */\n /* We need sufficiently many levels such that\n ipow(processes_per_directory, nlevels+1) can hold nioprocs\n files. We also don't want too many levels. Note that the case\n nioprocs==1 is special in the expression above, since\n nlevels==-1 does not make sense. */\n int nlevels = nprocs == 1 ? 0 : ilog(max_entries_per_subdir, nprocs - 1);\n /* ensure we have sufficiently many levels */\n assert(ipow(max_entries_per_subdir, nlevels + 1) >= nprocs);\n /* ensure we don't have too many levels */\n assert(nprocs == 1 || ipow(max_entries_per_subdir, nlevels) < nprocs);\n\n for (int level = 0; level < nlevels; ++level) {\n int stride = ipow(max_entries_per_subdir, nlevels - level);\n int entry = (myproc / stride) % max_entries_per_subdir;\n filenamebuf << \"/level_\" << level << \".group_\" << entry * stride;\n if (called_from == CP_INITIAL_DATA || called_from == CP_EVOLUTION_DATA) {\n string filename = filenamebuf.str();\n int ierr = CCTK_CreateDirectory(0755, filename.c_str());\n if (ierr < 0) {\n CCTK_VERROR(\n \"Checkpoint directory %s could not be created (error code %d)\",\n filename.c_str(), ierr);\n }\n }\n }\n }\n\n filenamebuf << \"/\" << basename << postfix;\n\n /* If this is a checkpoint filename, merge in the iteration number,\n and for chunked files also the file number */\n if (called_from == CP_INITIAL_DATA || called_from == CP_EVOLUTION_DATA) {\n filenamebuf << \".it_\" << GH->cctk_iteration;\n }\n\n if (!file_unchunked) {\n filenamebuf << \".file_\" << file_ioproc;\n }\n\n filenamebuf << extension;\n string filename = filenamebuf.str();\n size_t filenamelen = filename.length();\n char *cfilename = static_cast(malloc(filenamelen + 1));\n strcpy(cfilename, filename.c_str());\n\n return cfilename;\n}\n\n/*@@\n @routine IOUtil_RecoverFromFile\n @date Jun 14 1999\n @author Thomas Radke\n @desc\n Recover from a given file.\n This routine loops through all XXX_RecoverGH routines\n registered by IO thorns.\n @enddesc\n @calls Util_GetHandledData\n \n\n @var GH\n @vdesc pointer to CCTK grid hierarchy\n @vtype cGH *\n @vio in\n @endvar\n @var basefilename\n @vdesc basefilename of the file(s) to recover from\n @vtype const char *\n @vio in\n @endvar\n @var called_from\n @vdesc indicates the caller function:\n * either Filereader (FILEREADER_DATA)\n * or IOUtil_RecoverGH() (CP_RECOVER_DATA)\n @vtype int\n @vio in\n @endvar\n@@*/\nstatic int IOUtil_RecoverFromFile(cGH *GH, const char *basefilename,\n int called_from) {\n int keylen, ihandle, retval;\n char *key;\n CCTK_FPOINTER func;\n recover_fn_t recover_fn;\n\n if (Util_TableQueryNKeys(recover_fn_table) <= 0) {\n CCTK_WARN(CCTK_WARN_ALERT,\n \"IOUtil_RecoverFromFile: No recovery routines were registered\");\n return -1;\n }\n\n keylen = Util_TableQueryMaxKeyLength(recover_fn_table) + 1;\n key = (char *)malloc(keylen);\n\n for (ihandle = Util_TableItCreate(recover_fn_table), retval = -1;\n Util_TableItQueryIsNonNull(ihandle) > 0 && retval < 0;\n Util_TableItAdvance(ihandle)) {\n Util_TableItQueryKeyValueInfo(ihandle, keylen, key, NULL, NULL);\n Util_TableGetFnPointer(recover_fn_table, &func, key);\n if (func) {\n recover_fn = (recover_fn_t)func;\n retval = recover_fn(GH, basefilename, called_from);\n }\n }\n free(key);\n Util_TableItDestroy(ihandle);\n\n return (retval);\n}\n\n/*@@\n @routine IOUtil_RecoverGH\n @date Jun 14 1999\n @author Thomas Radke\n @desc\n The rfr-registered recovery routine.\n Just calls IOUtil_RecoverFromFile()\n with called_from == CP_RECOVER_DATA.\n @enddesc\n @calls IOUtil_RecoverFromFile\n\n @var GH\n @vdesc pointer to CCTK grid hierarchy\n @vtype cGH *\n @vio in\n @endvar\n@@*/\nvoid IOUtil_RecoverGH(cGH *GH) {\n if (checkpoint_file_exists) {\n /* stop if recovery failed */\n if (IOUtil_RecoverFromFile(GH, NULL, CP_RECOVER_DATA) < 0) {\n CCTK_ERROR(\"Failed to restart from recovery!\");\n }\n }\n}\n\n/*@@\n @routine IOUtil_RecoverVarsFromDatafiles\n @date Wed Apr 19 2000\n @author Thomas Radke\n @desc\n IOUtil's function interface to recover variables from data files.\n Any thorn can call this routine with a list of datafile names\n and a list of variables to read in from these files.
\n\n It just calls IOUtil_RecoverFromFile() with\n called_from == FILEREADER_DATA for each data file\n from the given file list.\n @enddesc\n\n @var GH\n @vdesc pointer to CCTK grid hierarchy\n @vtype cGH *\n @vio in\n @endvar\n @var in_files\n @vdesc list of filenames to process (separated by spaces)\n @vtype const char *\n @vio in\n @endvar\n @var in_vars\n @vdesc list of variable fullnames to read in from the files\n @vtype const char *\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n total number of recovered variables\n @endreturndesc\n@@*/\nint IOUtil_RecoverVarsFromDatafiles(cGH *GH, const char *in_files,\n const char *in_vars) {\n int retval, num_recovered_vars;\n ioGH *myGH;\n char *basefilename, *delim, delim_char;\n DECLARE_CCTK_PARAMETERS\n\n myGH = static_cast(CCTK_GHExtension(GH, \"IO\"));\n if (!myGH) {\n CCTK_ERROR(\n \"invalid cctkGH pointer passed into IOUtil_RecoverVarsFromDatafiles()\");\n }\n\n if (CCTK_NumVars() > 0) {\n void *calldata[2];\n myGH->do_inVars =\n static_cast(calloc(CCTK_NumVars(), sizeof(CCTK_INT)));\n myGH->alias =\n static_cast(calloc(CCTK_NumVars(), sizeof(char *)));\n calldata[0] = myGH->do_inVars;\n calldata[1] = myGH->alias;\n if (CCTK_TraverseString(in_vars, SetInputFlag, calldata,\n CCTK_GROUP_OR_VAR) < 0) {\n CCTK_WARN(myGH->stop_on_parse_errors ? 0 : 1,\n \"error while parsing parameter 'IO::filereader_ID_vars'\");\n }\n } else {\n myGH->do_inVars = NULL;\n myGH->alias = NULL;\n }\n\n num_recovered_vars = 0;\n\n /* duplicate the filename list and parse it */\n basefilename = strdup(in_files);\n while (basefilename && *basefilename) {\n /* skip leading spaces */\n while (isspace((int)*basefilename)) {\n basefilename++;\n }\n if (!*basefilename) {\n break;\n }\n\n /* find delimiter for current filename and cut there */\n for (delim = basefilename + 1; !isspace((int)*delim) && *delim; delim++)\n ;\n delim_char = *delim;\n *delim = 0;\n\n if (!CCTK_Equals(verbose, \"none\")) {\n CCTK_VINFO(\"Reading variables from file with base name '%s'\",\n basefilename);\n }\n\n retval = IOUtil_RecoverFromFile(GH, basefilename, FILEREADER_DATA);\n if (retval >= 0) {\n num_recovered_vars += retval;\n } else {\n CCTK_VWARN(CCTK_WARN_ALERT,\n \"Failed to read variables from data file with base name '%s'\",\n basefilename);\n }\n\n *delim = delim_char;\n basefilename = delim;\n }\n\n if (basefilename) {\n free(basefilename - strlen(in_files));\n }\n\n if (myGH->do_inVars) {\n free(myGH->do_inVars);\n myGH->do_inVars = NULL;\n }\n\n if (myGH->alias) {\n const int numVars = CCTK_NumVars();\n for (int i = 0; i < numVars; i++) {\n if (myGH->alias[i])\n free(const_cast(myGH->alias[i]));\n }\n free(myGH->alias);\n myGH->alias = NULL;\n }\n\n return (num_recovered_vars);\n}\n\nvoid CCTK_FCALL CCTK_FNAME(IOUtil_RecoverVarsFromDatafiles)(\n int *result, cGH **GH, TWO_FORTSTRING_ARG) {\n TWO_FORTSTRING_CREATE(in_files, in_vars)\n *result = IOUtil_RecoverVarsFromDatafiles(*GH, in_files, in_vars);\n free(in_files);\n free(in_vars);\n}\n\n/*@@\n @routine IOUtil_RecoverIDFromDatafiles\n @date Wed Apr 19 2000\n @author Thomas Radke\n @desc\n The rfr-registered initial data recovery routine.\n Just calls IOUtil's generic routine\n IOUtil_RecoverVarsFromDatafiles() with the filereader_ID_XXX\n parameters.\n @enddesc\n @var GH\n @vdesc pointer to CCTK grid hierarchy\n @vtype cGH *\n @vio in\n @endvar\n@@*/\nvoid IOUtil_RecoverIDFromDatafiles(cGH *GH) {\n ioGH *myGH;\n DECLARE_CCTK_PARAMETERS\n\n myGH = static_cast(CCTK_GHExtension(GH, \"IO\"));\n myGH->stop_on_parse_errors = strict_io_parameter_check;\n IOUtil_RecoverVarsFromDatafiles(GH, filereader_ID_files, filereader_ID_vars);\n myGH->stop_on_parse_errors = 0;\n}\n\n/*@@\n @routine IOUtil_RecoverParameters\n @date Apr 22 2000\n @author Thomas Radke\n @desc\n The generic parameter recovery routine.\n It is called by the IO thorns' parameter recovery routines\n scheduled at CCTK_RECOVER_PARAMETERS, and simply calls\n the given callback routine with its arguments\n plus a checkpoint filename.\n @enddesc\n\n @var recover_fn\n @vdesc callback function for recovery of parameters\n from a given checkpoint file\n @vtype int (*) (cGH *, const char *, int)\n @vio in\n @endvar\n @var fileExtension\n @vdesc extension of valid checkpoint files for given callback\n @vtype const char *\n @vio in\n @endvar\n @var fileType\n @vdesc string to describe the type of checkpoint file\n (used for warning/info messages)\n @vtype const char *\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n 0 if in \"autoprobe\" mode and no cp files were found, or
\n +1 if parameter recovery was successful for some cp file,
\n -1 if in \"auto\" mode and no checkpoint files were found,\n or if parameter recovery failed for some cp file,
\n -2 if in \"auto*\" mode and recovery dir doesn't exist\n @endreturndesc\n@@*/\nint IOUtil_RecoverParameters(int (*recover_fn)(cGH *GH,\n const char *basefilename,\n int called_from),\n const char *fileExtension, const char *fileType) {\n int retval;\n#ifdef HAVE_DIRENT_H\n int len, recover_file_len;\n unsigned int num_files;\n const char *p, *q;\n DIR *dir;\n struct dirent *file;\n filelist_t *filelist, *tmp;\n#endif\n DECLARE_CCTK_PARAMETERS\n#ifdef HAVE_DIRENT_H\n bool verbose_full = CCTK_Equals(verbose, \"full\");\n#endif\n\n if (CCTK_Equals(recover, \"auto\") || CCTK_Equals(recover, \"autoprobe\")) {\n#ifdef HAVE_DIRENT_H\n if (verbose_full) {\n if (recover_dir[0] == '/') {\n CCTK_VINFO(\"Searching for %s checkpoint files with basefilename '%s' \"\n \"in directory '%s'\",\n fileType, recover_file, recover_dir);\n } else {\n char *cwd =\n#ifdef HAVE_UNISTD_H\n getcwd(NULL, 0);\n#else\n strdup(\".\");\n#endif\n CCTK_VINFO(\"Searching for %s checkpoint files with basefilename '%s' \"\n \"in directory '%s/%s'\",\n fileType, recover_file, cwd, recover_dir);\n free(cwd);\n }\n }\n\n dir = opendir(recover_dir);\n if (!dir) {\n /* The recovery directory does not exist */\n if (CCTK_Equals(recover, \"autoprobe\")) {\n /* This is harmless when \"autoprobe\" is used */\n CCTK_VINFO(\"Recovery directory '%s' doesn't exist\", recover_dir);\n return 0;\n } else {\n /* This is an error when \"auto\" is used */\n CCTK_VWARN(CCTK_WARN_ALERT, \"Recovery directory '%s' doesn't exist\",\n recover_dir);\n return -2;\n }\n }\n\n /* get the list of potential recovery files */\n recover_file_len = strlen(recover_file);\n num_files = 0;\n filelist = NULL;\n\n while ((file = readdir(dir)) != NULL) {\n /* first check the file prefix */\n if (strncmp(file->d_name, recover_file, recover_file_len) ||\n strncmp(file->d_name + recover_file_len, \".it\", 3)) {\n continue;\n }\n\n /* now check if there is an iteration number following the file prefix */\n p = file->d_name + recover_file_len + 3;\n for (; *p == '_'; p++)\n ;\n const char *const it = p;\n for (; isdigit(*p); p++)\n ;\n\n /* check for a '.file_' suffix for chunked output */\n q = p;\n if (!strncmp(q, \".file_\", 6)) {\n /* read past the number */\n for (q = q + 6; *q && *q != '.'; q++) {\n if (!isdigit((int)*q)) {\n break;\n }\n }\n }\n\n /* finally check the file extension suffix */\n if (*q != '.' || strcmp(q, fileExtension)) {\n continue;\n }\n\n /* found a recovery file by that basename */\n if (num_files == 0) {\n tmp = static_cast(malloc(sizeof(filelist_t)));\n } else {\n tmp = (static_cast(\n realloc(filelist, (num_files + 1) * sizeof(filelist_t))));\n }\n if (tmp == NULL) {\n CCTK_VWARN(CCTK_WARN_ALERT, \"Failed to allocate memory for file list\");\n continue;\n }\n filelist = tmp;\n filelist[num_files].basename = strdup(file->d_name);\n /* cut the filename after the iteration number field */\n len = p - file->d_name;\n filelist[num_files].basename[len] = 0;\n assert(isdigit(*it));\n filelist[num_files].iteration = atoi(it);\n assert(*it == '0' || filelist[num_files].iteration > 0);\n if (verbose_full) {\n CCTK_VINFO(\"Found iteration %d\", filelist[num_files].iteration);\n }\n\n num_files++;\n }\n closedir(dir);\n\n retval = CCTK_Equals(recover, \"auto\") ? -1 : 0;\n if (num_files) {\n /* sort the list according to their iteration numbers */\n qsort(filelist, num_files, sizeof(filelist_t), CompareFiles);\n\n /* loop over all recovery files found and call the callback routine;\n skip all following files after the first successful recovery (when\n recover_fn() returned a positive value) */\n while (num_files--) {\n if (retval <= 0) {\n retval = recover_fn(NULL, filelist[num_files].basename,\n CP_RECOVER_PARAMETERS);\n }\n free(filelist[num_files].basename);\n }\n free(filelist);\n } else {\n CCTK_VWARN(retval ? 1 : 3,\n \"No %s checkpoint files with basefilename '%s' and file \"\n \"extension '%s' found in recovery directory '%s'\",\n fileType, recover_file, fileExtension, recover_dir);\n }\n#else\n fileExtension = fileExtension;\n\n /* No opendir(3) ??? It's probably a Windows box, so just give up ! */\n CCTK_ERROR(\"You cannot use 'IO::recover = \\\"auto*\\\"' on \"\n \"this architecture because it doesn't provide opendir(3) to \"\n \"automatically look for checkpoint files.\\n\"\n \"Please use 'IO::recover = \\\"manual\\\"' instead!\");\n retval = -1;\n#endif\n } else {\n /* just call the recovery routine */\n retval = (*recover_fn)(NULL, recover_file, CP_RECOVER_PARAMETERS);\n }\n\n if (retval < 0) {\n CCTK_VWARN(CCTK_WARN_ALERT,\n \"Could not recover parameters from %s checkpoint file(s) \"\n \"with basefilename '%s' and file extension '%s' in recovery \"\n \"directory '%s'\",\n fileType, recover_file, fileExtension, recover_dir);\n }\n\n /* remember parameter recovery status for later evaluation in\n IOUtil_RecoverGH() */\n checkpoint_file_exists = retval > 0;\n\n return (retval);\n}\n\n/*@@\n @routine IOUtil_GetAllParameters\n @date Mon Apr 10 2000\n @author Thomas Radke\n @desc\n Collect all parameters of active implementations\n into a single string which can then be dumped as an attribute.\n\n Each \" = \" pair in the resulting string\n is separated by a newline character from the next pair.\n The \"\" substring is encoded such that non-printable\n characters are contained as escape sequences, and a single\n '\\' character is escaped by another '\\' character.\n @enddesc\n\n @var GH\n @vdesc pointer to CCTK grid hierarchy\n @vtype const cGH *\n @vio in\n @endvar\n @var all\n @vdesc flag indicating whether to save all parameters or just the ones\n which have been set before\n @vtype int\n @vio in\n @endvar\n\n @returntype char *\n @returndesc the allocated string or NULL\n @endreturndesc\n@@*/\nchar *IOUtil_GetAllParameters(const cGH *GH, int all) {\n int i, first, add_len, current_len, max_len, ierr;\n char *param, *value, *encoded_value, *tmp, *retval;\n const char *thorn;\n const cParamData *pdata;\n DECLARE_CCTK_PARAMETERS\n\n /* avoid compiler warning about unused parameter */\n GH = GH;\n\n /* preallocate buffer for parameters, to prevent too many subsequent reallocs\n (causing unnecessary memory fragmentation) */\n max_len = 1024 * 1024;\n retval = static_cast(malloc(max_len));\n if (!retval) {\n CCTK_VERROR(\"Failed to allocate buffer of %d bytes\", max_len);\n }\n *retval = '\\0';\n current_len = 0;\n\n /* loop over all thorns */\n for (i = CCTK_NumCompiledThorns() - 1; i >= 0; i--) {\n thorn = CCTK_CompiledThorn(i);\n\n /* skip all inactive thorns */\n if (!CCTK_IsThornActive(thorn)) {\n continue;\n }\n\n /* now walk through all parameters of given thorn */\n first = 1;\n while ((ierr = CCTK_ParameterWalk(first, thorn, ¶m, &pdata)) == 0) {\n first = 0;\n\n /* if 'all' is false get only parameters which have been set */\n if (all || pdata->n_set > 0) {\n value = CCTK_ParameterValString(pdata->name, pdata->thorn);\n if (value == NULL) {\n CCTK_VWARN(CCTK_WARN_COMPLAIN,\n \"Couldn't get value for parameter '%s'\", param);\n } else {\n encoded_value = EncodeString(value);\n add_len = strlen(param) + strlen(encoded_value) + 5;\n if (current_len + add_len >= max_len) {\n /* double new buffer length until buffer is large enough */\n while (current_len + add_len >= max_len) {\n max_len *= 2;\n }\n tmp = static_cast(realloc(retval, max_len));\n if (!tmp) {\n CCTK_VERROR(\"Failed to allocate buffer of %d bytes\", max_len);\n }\n retval = tmp;\n }\n\n sprintf(retval + current_len, \"%s = %s\\n\", param, encoded_value);\n current_len += add_len - 1;\n\n free(encoded_value);\n free(value);\n }\n }\n\n free(param);\n\n } /* end of loop walking over all parameters of given thorn */\n assert(ierr >= 0);\n } /* end of looping over all thorns */\n\n return (retval);\n}\n\n/*@@\n @routine IOUtil_SetAllParameters\n @date Mon Apr 10 2000\n @author Thomas Radke\n @desc\n Parse the given string for parameters\n and call CCTK_SetParameter() for each.\n\n The input string is expected to follow the format of\n IOUtil_GetAllParameters() (see above) where each\n \" = \" pair is separated by a newline character\n from the next pair.\n The \"\" substring is encoded such that non-printable\n characters are contained as escape sequences, and a single\n '\\' character is escaped by another '\\' character. This\n encoding is undone before setting the a value of a parameter.\n @enddesc\n\n @var parameters\n @vdesc the parameter string\n @vtype const char *\n @vio in\n @endvar\n@@*/\nvoid IOUtil_SetAllParameters(const char *parameters) {\n char *tmp, *nextparam, *avalue, *decoded_value, *param;\n char oldchar;\n char *name, *thorn_impl, *parameter_string, *free_me;\n const char *thorn;\n const cParamData *paramdata;\n int ierr, steered_non_steerable;\n DECLARE_CCTK_PARAMETERS\n bool verbose_full = CCTK_Equals(verbose, \"full\");\n\n parameter_string = free_me = strdup(parameters);\n steered_non_steerable = 0;\n while (*parameter_string) {\n /* find the end of the current \" = \" pair substring */\n nextparam = parameter_string;\n while (*nextparam != '\\n' && *nextparam) {\n nextparam++;\n }\n oldchar = *nextparam;\n *nextparam = 0;\n\n /* find the end of \"\" */\n tmp = parameter_string;\n while (*tmp != ' ') {\n tmp++;\n }\n *tmp = 0;\n\n param = parameter_string;\n /* skip the \" = \" delimiter to get to \"\" */\n avalue = tmp + 3;\n\n name = thorn_impl = NULL;\n if (Util_SplitString(þ_impl, &name, param, \"::\") == 0) {\n /* find out the implementing thorn of the parameter given */\n thorn = CCTK_ActivatingThorn(thorn_impl);\n if (!thorn) {\n thorn = thorn_impl;\n }\n\n /* set parameter only if it belongs to an active implementation\n and is not an accumulator parameter */\n if (CCTK_IsThornActive(thorn)) {\n paramdata = CCTK_ParameterData(name, thorn);\n if (paramdata && !paramdata->accumulator_expression) {\n decoded_value = DecodeString(avalue);\n ierr = CCTK_ParameterSet(name, thorn, decoded_value);\n if (ierr == -10) {\n steered_non_steerable = 1;\n } else if (ierr < 0) {\n CCTK_VWARN(CCTK_WARN_COMPLAIN,\n \"Couldn't set parameter '%s' to '%s'\", param,\n decoded_value);\n }\n free(decoded_value);\n }\n } else if (verbose_full) {\n CCTK_VWARN(CCTK_WARN_COMPLAIN,\n \"Ignoring inactive parameter '%s' for recovery\", param);\n }\n\n if (name) {\n free(name);\n }\n if (thorn_impl) {\n free(thorn_impl);\n }\n }\n\n *nextparam = oldchar;\n parameter_string = nextparam;\n if (*parameter_string == '\\n') {\n parameter_string++;\n }\n }\n\n free(free_me);\n\n if (steered_non_steerable) {\n CCTK_ERROR(\"Attempted to steer non steerable parameters.\");\n }\n}\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\n/* encodes a C string with all the non-printable characters converted\n into a 4-char-long escape sequence representation \"\\xxx\" and\n the single '\\' character converted into \"\\\\\" */\nstatic char *EncodeString(const char *string) {\n size_t i, len = strlen(string);\n char *p, *retval;\n\n p = retval = static_cast(malloc(4 * len + 1));\n if (!retval) {\n CCTK_ERROR(\"Out of memory!\");\n }\n\n for (i = 0; i < len; i++) {\n if (!isprint(string[i])) {\n sprintf(p, \"\\\\%.03o\", (unsigned char)string[i]);\n p += 4;\n } else {\n *p++ = string[i];\n if (string[i] == '\\\\') {\n *p++ = string[i];\n }\n }\n }\n *p = 0;\n\n return (retval);\n}\n\n/* decodes a string encoded by EncodeString() back into a C string */\nstatic char *DecodeString(const char *string) {\n size_t i, len = strlen(string);\n char *p, *retval;\n int o1, o2, o3;\n\n p = retval = static_cast(malloc(len + 1));\n if (!retval) {\n CCTK_ERROR(\"Out of memory!\");\n }\n\n for (i = 0; i < len; i++) {\n if (string[i] != '\\\\') {\n *p++ = string[i];\n } else {\n if (i + 1 >= len)\n goto bail_out;\n if (string[i + 1] == '\\\\') {\n *p++ = '\\\\';\n i++;\n } else {\n if (i + 3 >= len)\n goto bail_out;\n o1 = OctalDigitToInt(string[i + 1]);\n o2 = OctalDigitToInt(string[i + 2]);\n o3 = OctalDigitToInt(string[i + 3]);\n if (o1 < 0 || o2 < 0 || o3 < 0)\n goto bail_out;\n *p++ = (char)(8 * 8 * o1 + 8 * o2 + o3);\n i += 3;\n }\n }\n }\n *p = 0;\n\n return (retval);\n\nbail_out:\n free(retval);\n CCTK_WARN(CCTK_WARN_ALERT, \"Malformed string\");\n return NULL;\n}\n\n/* callback for CCTK_TraverseString() to set the input flag\n for the given variable */\nstatic void SetInputFlag(int vindex, const char *optstring, void *calldata) {\n int table, iterator;\n char key[128];\n CCTK_INT type, nelems;\n void **flags = (void **)calldata;\n CCTK_INT *do_inVars = (CCTK_INT *)flags[0];\n const char **alias = (const char **)flags[1];\n\n /* default -1 is to read the last iteration number from the file */\n do_inVars[vindex] = -1;\n\n /* default is NULL to use CCTK_FullName() */\n alias[vindex] = NULL;\n\n if (optstring) {\n table = Util_TableCreateFromString(optstring);\n if (table >= 0) {\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"cctk_iteration\") >\n 0) {\n if (type == CCTK_VARIABLE_INT && nelems == 1) {\n Util_TableGetInt(table, &do_inVars[vindex], \"cctk_iteration\");\n\n /* if a specific iteration number was given then increment it\n to keep 0 as disabling value */\n if (do_inVars[vindex] >= 0) {\n do_inVars[vindex]++;\n }\n } else {\n CCTK_VWARN(CCTK_WARN_ALERT,\n \"Invalid value for option 'cctk_iteration' in option \"\n \"string '%s' (must be an integer)\",\n optstring);\n CCTK_WARN(CCTK_WARN_ALERT,\n \"Option will be ignored by file reader routines\");\n }\n Util_TableDeleteKey(table, \"cctk_iteration\");\n }\n\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"alias\") > 0) {\n if (type == CCTK_VARIABLE_CHAR) {\n char *buf = static_cast(malloc(nelems + 1));\n if (!buf) {\n CCTK_VERROR(\"Could not allocate %d bytes\", (int)nelems + 1);\n }\n int len = Util_TableGetString(table, nelems + 1, buf, \"alias\");\n if (len != nelems) {\n CCTK_VERROR(\"Unexpected length %d of 'alias' option value in '%s'. \"\n \"Expected length %d.\",\n len, optstring, (int)nelems);\n }\n\n alias[vindex] = buf;\n } else {\n CCTK_VWARN(CCTK_WARN_ALERT,\n \"Invalid value for option 'alias' in option \"\n \"string '%s' (must be a string)\",\n optstring);\n CCTK_WARN(CCTK_WARN_ALERT,\n \"Option will be ignored by file reader routines\");\n }\n Util_TableDeleteKey(table, \"alias\");\n }\n\n /* warn about other options */\n for (iterator = Util_TableItCreate(table);\n Util_TableItQueryIsNonNull(iterator) > 0 &&\n Util_TableItQueryKeyValueInfo(iterator, sizeof(key), key, 0, 0) > 0;\n Util_TableItAdvance(iterator)) {\n CCTK_VWARN(CCTK_WARN_ALERT,\n \"Found option with unrecognized key '%s' in option string \"\n \"'%s'\",\n key, optstring);\n CCTK_WARN(CCTK_WARN_ALERT,\n \"Option will be ignored by file reader routines\");\n }\n Util_TableItDestroy(iterator);\n\n Util_TableDestroy(table);\n } else {\n CCTK_VWARN(CCTK_WARN_ALERT, \"Couldn't parse option string '%s'\",\n optstring);\n CCTK_WARN(CCTK_WARN_ALERT,\n \"Option will be ignored by file reader routines\");\n }\n }\n}\n\n/* Convert an octal digit to an integer. Return -1 if this is not an\n octal digit. Note that this routine does not assume ASCII encoding\n (and thus cannot calculate digit-'0'), and does not use\n non-standard library function such as isoctal. */\nstatic int OctalDigitToInt(const char digit) {\n switch (digit) {\n case '0':\n return 0;\n case '1':\n return 1;\n case '2':\n return 2;\n case '3':\n return 3;\n case '4':\n return 4;\n case '5':\n return 5;\n case '6':\n return 6;\n case '7':\n return 7;\n }\n return -1;\n}\n\n#ifdef HAVE_DIRENT_H\n/* callback for qsort() to sort the list of recovery files found */\nstatic int CompareFiles(const void *a, const void *b) {\n return (((const filelist_t *)a)->iteration -\n ((const filelist_t *)b)->iteration);\n}\n#endif\n", "AdvertisedFiles.c": "/*@@\n @file AdvertisedFiles.c\n @date Mon 18 Sep 2000\n @author Thomas Radke\n @desc\n IOUtil file advertising stuff.\n @enddesc\n @history\n @endhistory\n@@*/\n\n#include \n\n#include \"cctk.h\"\n#include \"StoreNamedData.h\"\n#include \"ioGH.h\"\n#include \"ioutil_AdvertisedFiles.h\"\n\nstatic const char *rcsid = \"$Header$\";\nCCTK_FILEVERSION(CactusBase_IOUtil_AdvertisedFiles_c)\n\n/********************************************************************\n ********************* Local Data *****************************\n ********************************************************************/\n\n/* database holding all registered listeners for file advertising */\nstatic pNamedData *listener_DB = NULL;\n\n/*@@\n @routine IOUtil_RegisterAdvertisedFileListener\n @date Wed May 17 2000\n @author Thomas Radke\n @desc\n Registers a listener with its callbacks for\n advertised file handling\n @enddesc\n @history\n @endhistory\n @var GH\n @vdesc pointer to grid hierarchy\n @vtype const cGH *\n @vio in\n @endvar\n @var listener\n @vdesc identification of the listener to be registered\n @vtype const char *\n @vio in\n @endvar\n @var callbacks\n @vdesc structure containing the listener's callback routines\n @vtype const ioAdvertisedFileListenerCallbacks *\n @vio in\n @endvar\n @returntype int\n @returndesc This routine returns\n 0 on success\n -1 if memory allocation failed or NULL pointers were passed\n @endreturndesc\n@@*/\n\nint IOUtil_RegisterAdvertisedFileListener(\n const cGH *GH, const char *listener,\n const ioAdvertisedFileListenerCallbacks *callbacks) {\n int retval = -1;\n ioAdvertisedFileListenerCallbacks *new_callbacks;\n\n /* prevent compiler warning about unused parameter */\n GH = GH;\n\n if (listener && callbacks) {\n new_callbacks = (ioAdvertisedFileListenerCallbacks *)malloc(\n sizeof(ioAdvertisedFileListenerCallbacks));\n if (new_callbacks) {\n *new_callbacks = *callbacks;\n retval = StoreNamedData(&listener_DB, listener, new_callbacks);\n if (retval)\n free(new_callbacks);\n }\n }\n\n return (retval);\n}\n\n/*@@\n @routine IOUtil_AdvertiseFile\n @date Wed May 17 2000\n @author Thomas Radke\n @desc\n Adds a filename to the list of advertised files for downloading.\n The routine calls all listeners which are currently registered\n for advertised file handling.\n @enddesc\n @history\n @endhistory\n @var GH\n @vdesc pointer to grid hierarchy\n @vtype const cGH *\n @vio in\n @endvar\n @var filename\n @vdesc name of the file to advertise\n @vtype const char *\n @vio in\n @endvar\n @var description\n @vdesc structure which describes the file\n @vtype const ioAdvertisedFileDesc *\n @vio in\n @endvar\n @returntype int\n @returndesc This routine returns the logically OR'ed return values\n of all listeners' advertise callbacks called.\n @endreturndesc\n@@*/\n\nint IOUtil_AdvertiseFile(const cGH *GH, const char *filename,\n const ioAdvertisedFileDesc *description) {\n int retval = 0;\n pNamedData *listener;\n ioAdvertisedFileListenerCallbacks *callbacks;\n\n /* get the listener database from IOUtil's GH extension */\n listener = listener_DB;\n\n /* loop through all listeners' advertise() callbacks */\n while (listener) {\n callbacks = (ioAdvertisedFileListenerCallbacks *)listener->data;\n if (callbacks && callbacks->advertise)\n retval |= (callbacks->advertise)(GH, filename, description);\n listener = listener->next;\n }\n\n return (retval);\n}\n", "Utils.c": "/*@@\n @file Utils.c\n @date Tue 4th July 2000\n @author Gabrielle Allen\n @desc\n Utility routines which may be called by other I/O thorns.\n @enddesc\n @version $Id$\n @@*/\n\n#include \n#include \n#include \n\n#include \"cctk.h\"\n#include \"cctk_Parameters.h\"\n#include \"util_String.h\"\n#include \"util_Table.h\"\n#include \"ioGH.h\"\n#include \"ioutil_Utils.h\"\n#include \"ioutil_CheckpointRecovery.h\"\n\n/* the rcs ID and its dummy function to use it */\nstatic const char *rcsid = \"$Header$\";\nCCTK_FILEVERSION(CactusBase_IOUtil_Utils_c)\n\n/********************************************************************\n ******************** Macro Definitions ************************\n ********************************************************************/\n/* uncomment this if you want some debugging output */\n/* #define DEBUG_IOUTIL 1 */\n\n/********************************************************************\n ******************** Internal Typedefs ************************\n ********************************************************************/\ntypedef struct {\n const cGH *GH;\n ioRequest **request_list;\n const char *method_name;\n const char *parameter_name;\n int out_every_default;\n CCTK_REAL out_dt_default;\n} info_t;\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\nstatic void SetOutputVar(int vindex, const char *optstring, void *arg);\n\n/*@@\n @routine IOUtil_ParseVarsForOutput\n @date Fri 26 April 2002\n @author Thomas Radke\n @desc\n Parses the given 'out_vars' string as a list of variable and/or\n groupnames. If an option string is appended to a name this will\n be parsed for I/O request options.\n @enddesc\n\n @calls CCTK_TraverseString\n\n @var GH\n @vdesc pointer to CCTK grid hierarchy\n @vtype const cGH *\n @vio in\n @endvar\n @var method_name\n @vdesc name of the originating I/O method\n @vtype const char *\n @vio in\n @endvar\n @var parameter_name\n @vdesc name of the originating I/O parameter to parse\n @vtype const char *\n @vio in\n @endvar\n @var stop_on_parse_errors\n @vdesc flag indicating whether stop with a level-0 warning message\n on parsing errors\n @vtype int\n @vio in\n @endvar\n @var out_vars\n @vdesc string with list of variables and/or group names to parse\n @vtype const char *\n @vio in\n @endvar\n @var out_every_default\n @vdesc default output frequency to set the I/O request to\n @vtype int\n @vio in\n @endvar\n @var out_dt_default\n @vdesc default output frequency to set the I/O request to\n @vtype CCTK_REAL\n @vio in\n @endvar\n @var request_list\n @vdesc list of I/O requests to fill out\n @vtype ioRequest *[]\n @vio out\n @endvar\n@@*/\nvoid IOUtil_ParseVarsForOutput(const cGH *GH, const char *method_name,\n const char *parameter_name,\n int stop_on_parse_errors, const char *out_vars,\n int out_every_default, CCTK_REAL out_dt_default,\n ioRequest *request_list[]) {\n int i;\n info_t info;\n\n /* free current list of I/O requests */\n for (i = CCTK_NumVars() - 1; i >= 0; i--) {\n if (request_list[i]) {\n IOUtil_FreeIORequest(&request_list[i]);\n }\n }\n\n /* generate new list of I/O requests */\n info.GH = GH;\n info.request_list = request_list;\n info.method_name = method_name;\n info.parameter_name = parameter_name;\n info.out_every_default = out_every_default;\n info.out_dt_default = out_dt_default;\n if (CCTK_TraverseString(out_vars, SetOutputVar, &info, CCTK_GROUP_OR_VAR) <\n 0) {\n CCTK_VWarn(stop_on_parse_errors ? 0 : 1, __LINE__, __FILE__,\n CCTK_THORNSTRING, \"error while parsing parameter '%s'\",\n parameter_name);\n }\n}\n\n/*@@\n @routine IOUtil_FreeIORequest\n @date Fri 26 April 2002\n @author Thomas Radke\n @desc\n Frees an I/O request description.\n @enddesc\n\n @var request\n @vdesc pointer to the I/O request structure\n @vtype ioRequest **\n @vio inout\n @endvar\n@@*/\nvoid IOUtil_FreeIORequest(ioRequest **request) {\n free((*request)->reductions);\n free((*request)->vectors);\n free(*request);\n *request = NULL;\n}\n\n/*@@\n @routine IOUtil_ParseOutputFrequency\n @date Mon 27 May 2002\n @author Thomas Radke\n @desc\n Parses the option string for a given variable for the\n 'out_every' and 'out_dt' options and sets its output\n frequency.\n @enddesc\n\n @calls Util_TableCreateFromString\n\n @var method_name\n @vdesc name of the originating I/O method\n @vtype const char *\n @vio in\n @endvar\n @var parameter_name\n @vdesc name of the originating I/O parameter to parse\n @vtype const char *\n @vio in\n @endvar\n @var stop_on_parse_errors\n @vdesc flag indicating whether to stop with level-0 warning message\n on a parsing error\n @vtype int\n @vio in\n @endvar\n @var vindex\n @vdesc index of the variable to set the output frequency\n @vtype int\n @vio in\n @endvar\n @var optstring\n @vdesc option string to parse\n @vtype const char *\n @vio in\n @endvar\n @var out_every_ptr\n @vdesc pointer to the variable's output frequency flag\n @vtype int *\n @vio out\n @endvar\n @var out_dt_ptr\n @vdesc pointer to the variable's output frequency flag\n @vtype CCTK_REAL *\n @vio out\n @endvar\n@@*/\nvoid IOUtil_ParseOutputFrequency(const char *method_name,\n const char *parameter_name,\n int stop_on_parse_errors, int vindex,\n const char *optstring, CCTK_INT *out_every_ptr,\n CCTK_REAL *out_dt_ptr) {\n int table, iterator, warnlevel;\n char key[128];\n char *fullname;\n CCTK_INT type, nelems;\n DECLARE_CCTK_PARAMETERS\n\n warnlevel = stop_on_parse_errors ? 0 : 1;\n fullname = CCTK_FullName(vindex);\n table = Util_TableCreateFromString(optstring);\n if (table >= 0) {\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"out_every\") > 0) {\n if (type == CCTK_VARIABLE_INT && nelems == 1) {\n Util_TableGetInt(table, out_every_ptr, \"out_every\");\n } else {\n CCTK_VWarn(warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'out_every' in option string \"\n \"'%s' in parameter '%s' (must be an integer)\",\n optstring, parameter_name);\n CCTK_VWarn(warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option will be ignored for %s output of variable '%s'\",\n method_name, fullname);\n }\n Util_TableDeleteKey(table, \"out_every\");\n }\n\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"out_dt\") > 0) {\n if (type == CCTK_VARIABLE_REAL && nelems == 1) {\n Util_TableGetReal(table, out_dt_ptr, \"out_dt\");\n } else {\n CCTK_VWarn(warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'out_dt' in option string \"\n \"'%s' in parameter '%s' (must be real)\",\n optstring, parameter_name);\n CCTK_VWarn(warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option will be ignored for %s output of variable '%s'\",\n method_name, fullname);\n }\n Util_TableDeleteKey(table, \"out_dt\");\n }\n\n /* warn about other options */\n iterator = Util_TableItCreate(table);\n for (iterator = Util_TableItCreate(table);\n Util_TableItQueryIsNonNull(iterator) > 0 &&\n Util_TableItQueryKeyValueInfo(iterator, sizeof(key), key, 0, 0) > 0;\n Util_TableItAdvance(iterator)) {\n CCTK_VWarn(warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Found option with unrecognized key '%s' in option string \"\n \"'%s' in parameter '%s'\",\n key, optstring, parameter_name);\n CCTK_VWarn(warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option will be ignored for %s output of variable '%s'\",\n method_name, fullname);\n }\n Util_TableItDestroy(iterator);\n\n Util_TableDestroy(table);\n } else {\n CCTK_VWarn(warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Couldn't parse option string '%s' in parameter '%s'\", optstring,\n parameter_name);\n CCTK_VWarn(warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option string will be ignored for %s output of variable '%s'\",\n method_name, fullname);\n }\n free(fullname);\n}\n\n/*@@\n @routine IOUtil_1DLines\n @date July 4 2000\n @author Gabrielle Allen, Gerd Lanfermann, Thomas Radke\n @desc\n Fills out an array determining where to position 1D lines\n for output on a multidimensional regular Cartesian unigrid.\n The first slot of the array specifies the 1D line direction,\n the second slot fixes the indices of the starting point\n of that line on the grid.\n @enddesc\n\n @calls Coord_GetDefaultSystem\n\n @var GH\n @vdesc Pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var num_dims\n @vdesc number of dimensions of underlying grid\n @vtype int\n @vio in\n @endvar\n @var origin_index\n @vdesc origin for 1D lines given by grid point indices\n @vtype const int [num_dims][num_dims]\n @vio in\n @endvar\n @var origin_phys\n @vdesc origin for 1D lines given by physical coordinates\n @vtype const CCTK_REAL [num_dims][num_dims]\n @vio in\n @endvar\n @var slice_center\n @vdesc resulting 1D line slice center\n @vtype int [num_dims][num_dims]\n @vio out\n @endvar\n\n @returntype int\n @returndesc\n 0 for success\n -1 no coordinate system of given dimensions found\n @endreturndesc\n @@*/\nint IOUtil_1DLines(const cGH *GH, int num_dims, int *const *const origin_index,\n CCTK_REAL *const *const origin_phys,\n int *const *slice_center) {\n int dim, dir, coord_system_handle = -1, have_coords, have_origin_index, len;\n char *coord_system_name;\n CCTK_INT *coord_handles = NULL;\n CCTK_REAL *lower, *upper, *delta;\n\n /* get the default coordinate system associated with this grid dimension */\n coord_system_name = NULL;\n have_coords = CCTK_IsFunctionAliased(\"Coord_GetDefaultSystem\");\n if (have_coords) {\n coord_system_handle = Coord_GetDefaultSystem(GH, num_dims);\n coord_handles = malloc(num_dims * sizeof(CCTK_INT));\n have_coords = coord_system_handle >= 0 &&\n Util_TableGetIntArray(coord_system_handle, num_dims,\n coord_handles, \"COORDINATES\") >= 0;\n }\n if (have_coords) {\n len = Util_TableGetString(coord_system_handle, 0, NULL, \"NAME\");\n have_coords = len > 0;\n if (have_coords) {\n coord_system_name = malloc(len);\n Util_TableGetString(coord_system_handle, len, coord_system_name, \"NAME\");\n have_coords = Util_StrCmpi(coord_system_name, \"cart\");\n }\n }\n\n /* check that origin_index[] is valid */\n have_origin_index = origin_index != NULL;\n for (dir = 0; dir < num_dims && have_origin_index; dir++) {\n for (dim = 0; dim < num_dims && have_origin_index; dim++) {\n have_origin_index = origin_index[dir][dim] >= 0;\n }\n }\n\n /* if no coordinate info is available then origin_index[] must be given */\n if (!have_coords && !have_origin_index) {\n CCTK_VWarn(3, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOUtil_1DLines: Found no default Cartesian coordinate system \"\n \"associated with grid variables of dimension %d, and no slice \"\n \"center index coordinates were given either - slice center \"\n \"will not be set up for output of 1D lines from %dD variables\",\n num_dims, num_dims);\n for (dir = 0; dir < num_dims; dir++) {\n memset(slice_center[dir], 0, num_dims * sizeof(int));\n }\n\n free(coord_handles);\n free(coord_system_name);\n\n return (-1);\n }\n\n /* get the ranges in every direction */\n lower = calloc(3 * num_dims, sizeof(CCTK_REAL));\n upper = lower + 1 * num_dims;\n delta = lower + 2 * num_dims;\n if (!have_origin_index) {\n for (dir = 0; dir < num_dims; dir++) {\n if (Util_TableGetReal(coord_handles[dir], &lower[dir], \"COMPMIN\") < 0 ||\n Util_TableGetReal(coord_handles[dir], &upper[dir], \"COMPMAX\") < 0 ||\n Util_TableGetReal(coord_handles[dir], &delta[dir], \"DELTA\") < 0) {\n CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOUtil_1DLines: Could not get ranges for %c-direction \"\n \"of associated default coordinate system '%s'\",\n 'x' + dir, coord_system_name);\n }\n }\n }\n\n /* now set the slice center for each line\n according to origin_index[] or origin_phys[] */\n for (dir = 0; dir < num_dims; dir++) {\n for (dim = 0; dim < num_dims; dim++) {\n if (dim == dir) {\n /* line always starts at the first point */\n slice_center[dir][dim] = 0;\n } else if (origin_index[dir][dim] >= 0) {\n /* FIXME: check upper index bounds also ?? */\n slice_center[dir][dim] = origin_index[dir][dim];\n } else if (lower[dim] > origin_phys[dir][dim] ||\n upper[dim] < origin_phys[dir][dim]) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOUtil_1DLines: %c-coordinate (%f) for slice center of \"\n \"1D lines in %c-direction for %dD variables is out of \"\n \"grid coordinates range (%f, %f)\",\n 'x' + dim, (double)origin_phys[dir][dim], 'x' + dir,\n num_dims, (double)lower[dim], (double)upper[dim]);\n\n slice_center[dir][dim] =\n origin_index[dir][dim] == -1\n ? 0\n : lrint(ceil((upper[dim] - lower[dim]) / (2 * delta[dim]) -\n 1e-6));\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOUtil_1DLines: slice center will default to %c-index %d\",\n 'x' + dir, slice_center[dir][dim]);\n } else {\n /* Find index for first point above the chosen coordinate */\n slice_center[dir][dim] = lrint(\n ceil((origin_phys[dir][dim] - lower[dim]) / delta[dim] - 1e-6));\n\n#ifdef DEBUG_IOUTIL\n printf(\"spxyz for %c-coord of lines in %c-direction is %d\\n\", 'x' + dim,\n 'x' + dir, slice_center[dir][dim]);\n#endif\n }\n }\n }\n\n free(lower);\n free(coord_handles);\n free(coord_system_name);\n\n return (0);\n}\n\n/*@@\n @routine IOUtil_2DPlanes\n @date July 4 2000\n @author Gabrielle Allen, Gerd Lanfermann, Thomas Radke\n @desc\n Fills out an array determining where to position 2D planes\n for output on a multidimensional regular Cartesian unigrid.\n @enddesc\n\n @calls Coord_GetDefaultSystem\n\n @var GH\n @vdesc Pointer to CCTK GH\n @vtype const cGH *\n @vio in\n @endvar\n @var num_dims\n @vdesc number of dimensions of underlying grid\n @vtype int\n @vio in\n @endvar\n @var origin_index\n @vdesc origin for 2D planes given by grid point indices\n @vtype const int [num_dims]\n @vio in\n @endvar\n @var origin_phys\n @vdesc origin for 2D planes given by physical coordinates\n @vtype const CCTK_REAL [num_dims]\n @vio in\n @endvar\n @var slice_center\n @vdesc resulting 2D plane slice center\n @vtype int [num_dims]\n @vio out\n @endvar\n\n @returntype int\n @returndesc\n 0 for success\n -1 no coordinate system of given dimensions found\n @endreturndesc\n @@*/\nint IOUtil_2DPlanes(const cGH *GH, int num_dims, const int *origin_index,\n const CCTK_REAL *origin_phys, int *slice_center) {\n int have_coords, have_origin_index, len, coord_system_handle = -1, dir;\n char *coord_system_name;\n CCTK_INT *coord_handles = NULL;\n CCTK_REAL *lower, *upper, *delta;\n\n /* get the default coordinate system associated with this grid dimension */\n coord_system_name = NULL;\n have_coords = CCTK_IsFunctionAliased(\"Coord_GetDefaultSystem\");\n if (have_coords) {\n coord_system_handle = Coord_GetDefaultSystem(GH, num_dims);\n coord_handles = malloc(num_dims * sizeof(CCTK_INT));\n have_coords = coord_system_handle >= 0 &&\n Util_TableGetIntArray(coord_system_handle, num_dims,\n coord_handles, \"COORDINATES\") >= 0;\n }\n if (have_coords) {\n len = Util_TableGetString(coord_system_handle, 0, NULL, \"NAME\");\n have_coords = len > 0;\n if (have_coords) {\n coord_system_name = malloc(len);\n Util_TableGetString(coord_system_handle, len, coord_system_name, \"NAME\");\n have_coords = Util_StrCmpi(coord_system_name, \"cart\");\n }\n }\n\n /* check that origin_index[] is valid */\n have_origin_index = origin_index != NULL;\n for (dir = 0; dir < num_dims && have_origin_index; dir++) {\n have_origin_index = origin_index[dir] >= 0;\n }\n\n /* if no coordinate system is available then origin_index[] must be given */\n if (!have_coords && !have_origin_index) {\n CCTK_VWarn(3, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOUtil_2DPlanes: Found no default Cartesian coordinate system \"\n \"associated with grid variables of dimension %d, and no slice \"\n \"center index coordinates were given either - slice center \"\n \"will not be set up for output of 2D planes from %dD variables\",\n num_dims, num_dims);\n\n free(coord_handles);\n free(coord_system_name);\n\n return (-1);\n }\n\n /* get the ranges in every direction */\n lower = calloc(3 * num_dims, sizeof(CCTK_REAL));\n upper = lower + 1 * num_dims;\n delta = lower + 2 * num_dims;\n if (have_coords) {\n for (dir = 0; dir < num_dims; dir++) {\n if (Util_TableGetReal(coord_handles[dir], &lower[dir], \"COMPMIN\") < 0 ||\n Util_TableGetReal(coord_handles[dir], &upper[dir], \"COMPMAX\") < 0 ||\n Util_TableGetReal(coord_handles[dir], &delta[dir], \"DELTA\") < 0) {\n CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOUtil_2DPlanes: Could not get ranges/deltas for \"\n \"%c-direction of associated coordinate system '%s'\",\n 'x' + (num_dims - dir - 1), coord_system_name);\n }\n }\n }\n\n /* now set the slice center for each line\n according to origin_index[] or origin_phys[] */\n for (dir = 0; dir < num_dims; dir++) {\n if (origin_index && origin_index[dir] >= 0) {\n slice_center[dir] = origin_index[dir];\n } else if (lower[num_dims - 1 - dir] > origin_phys[dir] ||\n upper[num_dims - 1 - dir] < origin_phys[dir]) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOUtil_2DPlanes: %c-coordinate for slice center of 2D \"\n \"planes (%f) is out of grid coordinates range (%f, %f)\",\n 'x' + (num_dims - dir - 1), (double)origin_phys[dir],\n (double)lower[num_dims - 1 - dir],\n (double)upper[num_dims - 1 - dir]);\n\n slice_center[dir] = origin_index[dir] == -1\n ? 0\n : lrint(ceil((upper[num_dims - 1 - dir] -\n lower[num_dims - 1 - dir]) /\n (2 * delta[num_dims - 1 - dir]) -\n 1e-6));\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"IOUtil_2DPlanes: slice center will default to %c-index %d\",\n 'x' + dir, slice_center[dir]);\n } else {\n /* Find index for first point above the chosen coordinate */\n slice_center[dir] =\n lrint(ceil((origin_phys[dir] - lower[num_dims - 1 - dir]) /\n delta[num_dims - 1 - dir] -\n 1e-6));\n#ifdef DEBUG_IOUTIL\n printf(\"sp2xyz for planes perpendicular to %d-direction is %d\\n\", dir,\n slice_center[dir]);\n#endif\n }\n }\n\n free(lower);\n free(coord_handles);\n free(coord_system_name);\n\n return (0);\n}\n\n/*@@\n @routine IOUtil_PrintTimings\n @date Wed Jun 28 2000\n @author Thomas Radke\n @desc\n Gets the timing information for the given timers and prints it\n as INFO messages to screen.\n @enddesc\n @history\n @endhistory\n @var description\n @vdesc description of the timers\n @vtype const char *\n @vio in\n @endvar\n @var ntimers\n @vdesc number of timers passed in\n @vtype int\n @vio in\n @endvar\n @var timers\n @vdesc array of timers\n @vtype const int [ntimers]\n @vio in\n @endvar\n @var timer_descriptions\n @vdesc array of timer descriptions\n @vtype const char *const [ntimers]\n @vio in\n @endvar\n@@*/\n\nvoid IOUtil_PrintTimings(const char *description, int ntimers,\n const int *timers,\n const char *const *const timer_descriptions) {\n int i, j;\n cTimerData *info;\n\n info = CCTK_TimerCreateData();\n if (info) {\n CCTK_INFO(description);\n\n for (i = 0; i < info->n_vals; i++) {\n for (j = 0; j < ntimers; j++) {\n CCTK_TimerI(timers[j], info);\n if (j == 0) {\n CCTK_VInfo(CCTK_THORNSTRING, \" %s:\", info->vals[i].heading);\n }\n switch (info->vals[i].type) {\n case val_int:\n CCTK_VInfo(CCTK_THORNSTRING, \" %s %5d %s\", timer_descriptions[j],\n info->vals[i].val.i, info->vals[i].units);\n break;\n\n case val_long:\n CCTK_VInfo(CCTK_THORNSTRING, \" %s %5d %s\", timer_descriptions[j],\n (int)info->vals[i].val.l, info->vals[i].units);\n break;\n\n case val_double:\n CCTK_VInfo(CCTK_THORNSTRING, \" %s %5.1f %s\", timer_descriptions[j],\n info->vals[i].val.d, info->vals[i].units);\n break;\n\n default:\n CCTK_WARN(1, \"Unknown data type for timer info\");\n break;\n }\n }\n }\n CCTK_INFO(\"-----------------------------------------\");\n CCTK_TimerDestroyData(info);\n } else {\n CCTK_WARN(1, \"Couldn't create timer info structure ! \"\n \"No timing output available.\");\n }\n}\n\n/*@@\n @routine IOUtil_CreateDirectory\n @date Fri 10 Aug 2001\n @author Thomas Radke\n @desc\n Creates an output directory path and makes sure it is visible\n on all I/O processors.\n It is assumed that processor 0 is always an I/O processor.\n If there are other I/O processors, they will also try and\n create the directory themselfs. This guarantees the directory\n be created on all nodes in case the I/O processors don't share\n a common filesystem.\n @enddesc\n @calls CCTK_MyProc\n CCTK_CreateDirectory\n CCTK_Barrier\n\n @var GH\n @vdesc pointer to the GH extensions\n @vtype const cGH *\n @vio in\n @endvar\n @var dirname\n @vdesc the directory to create\n @vtype const char *\n @vio in\n @endvar\n @var multiple_io_procs\n @vdesc flag indicating that there will be I/O from multiple I/O procs\n @vtype int\n @vio in\n @endvar\n @var ioproc\n @vdesc I/O processor associated with this processor\n @vtype int\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n 0 for non-I/O processors, or\n return code of @seeroutine CCTK_CreateDirectory\n @endreturndesc\n@@*/\nint IOUtil_CreateDirectory(const cGH *GH, const char *dirname,\n int multiple_io_procs, int ioproc) {\n int myproc, retval;\n\n /* default return value for non-I/O processors */\n retval = 0;\n\n /* first, processor 0 creates the directory */\n myproc = CCTK_MyProc(GH);\n if (myproc == 0) {\n retval = CCTK_CreateDirectory(0755, dirname);\n }\n\n if (multiple_io_procs) {\n /* now the other I/O processors create the directory\n after syncing with processor 0 */\n CCTK_Barrier(GH);\n if (myproc == ioproc || ioproc != 0) {\n retval = CCTK_CreateDirectory(0755, dirname);\n }\n }\n\n return (retval);\n}\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\nstatic void SetOutputVar(int vindex, const char *optstring, void *arg) {\n int table, iterator;\n char key[128];\n CCTK_INT type, nelems;\n CCTK_INT *refinement_levels;\n char *fullname;\n const info_t *info = arg;\n ioRequest *request;\n DECLARE_CCTK_PARAMETERS\n\n /* allocate a new I/O request structure and initialize it with defaults */\n request = IOUtil_DefaultIORequest(info->GH, vindex, info->out_every_default,\n info->out_dt_default);\n\n if (!optstring) {\n info->request_list[vindex] = request;\n return;\n }\n\n fullname = CCTK_FullName(vindex);\n\n table = Util_TableCreateFromString(optstring);\n if (table >= 0) {\n /* check for option 'out_every' */\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"out_every\") > 0) {\n if (type == CCTK_VARIABLE_INT && nelems == 1) {\n Util_TableGetInt(table, &request->out_every, \"out_every\");\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'out_every' in option string \"\n \"'%s' in parameter '%s' (must be an integer)\",\n optstring, info->parameter_name);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option 'out_every' will be ignored for %s output of \"\n \"variable '%s'\",\n info->method_name, fullname);\n }\n Util_TableDeleteKey(table, \"out_every\");\n }\n\n /* check for option 'out_dt' */\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"out_dt\") > 0) {\n if (type == CCTK_VARIABLE_REAL && nelems == 1) {\n Util_TableGetReal(table, &request->out_dt, \"out_dt\");\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'out_dt' in option string \"\n \"'%s' in parameter '%s' (must be real)\",\n optstring, info->parameter_name);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option 'out_dt' will be ignored for %s output of \"\n \"variable '%s'\",\n info->method_name, fullname);\n }\n Util_TableDeleteKey(table, \"out_dt\");\n }\n\n /* check for boolean option 'out_unchunked' */\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"out_unchunked\") > 0) {\n int unchunked = -1;\n if (type == CCTK_VARIABLE_CHAR && nelems >= (int)sizeof(\"no\") - 1 &&\n nelems <= (int)sizeof(\"false\") - 1) {\n char value[sizeof(\"false\")];\n Util_TableGetString(table, sizeof(value), value, \"out_unchunked\");\n if (CCTK_Equals(value, \"yes\") || CCTK_Equals(value, \"true\")) {\n unchunked = 1;\n } else if (CCTK_Equals(value, \"no\") || CCTK_Equals(value, \"false\")) {\n unchunked = 0;\n }\n }\n if (unchunked >= 0) {\n request->out_unchunked = unchunked;\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'out_unchunked' in option string \"\n \"'%s' in parameter '%s' (must be a boolean)\",\n optstring, info->parameter_name);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option 'out_unchunked' will be ignored for %s output of \"\n \"variable '%s'\",\n info->method_name, fullname);\n }\n Util_TableDeleteKey(table, \"out_unchunked\");\n }\n\n /* check for hyperslab option 'direction' */\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"direction\") > 0) {\n if (type == CCTK_VARIABLE_INT && nelems > 0 &&\n nelems <= request->vdim * request->vdim &&\n nelems % request->vdim == 0) {\n request->hdim = nelems / request->vdim;\n Util_TableGetIntArray(table, nelems, request->direction, \"direction\");\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'direction' in option string \"\n \"'%s' in parameter '%s' (must be an integer array with \"\n \"%d x hdim elements, 1 <= hdim <= %d)\",\n optstring, info->parameter_name, (int)request->vdim,\n (int)request->vdim);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option 'direction' will be ignored for %s output of \"\n \"variable '%s'\",\n info->method_name, fullname);\n }\n Util_TableDeleteKey(table, \"direction\");\n }\n\n /* check for hyperslab option 'origin' */\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"origin\") > 0) {\n if (type == CCTK_VARIABLE_INT && nelems == request->vdim) {\n Util_TableGetIntArray(table, nelems, request->origin, \"origin\");\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'origin' in option string \"\n \"'%s' in parameter '%s' (must be an integer array with \"\n \"%d elements)\",\n optstring, info->parameter_name, (int)request->vdim);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option 'origin' will be ignored for %s output of \"\n \"variable '%s'\",\n info->method_name, fullname);\n }\n Util_TableDeleteKey(table, \"origin\");\n }\n\n /* check for hyperslab option 'extent' */\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"extent\") > 0) {\n if (type == CCTK_VARIABLE_INT && nelems == request->hdim) {\n Util_TableGetIntArray(table, nelems, request->extent, \"extent\");\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'extent' in option string \"\n \"'%s' in parameter '%s' (must be an integer array with \"\n \"%d elements)\",\n optstring, info->parameter_name, (int)request->hdim);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option 'extent' will be ignored for %s output of \"\n \"variable '%s'\",\n info->method_name, fullname);\n }\n Util_TableDeleteKey(table, \"extent\");\n }\n\n /* check for hyperslab option 'downsample' */\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"downsample\") > 0) {\n if (type == CCTK_VARIABLE_INT && nelems == request->hdim) {\n Util_TableGetIntArray(table, nelems, request->downsample, \"downsample\");\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'downsample' in option string \"\n \"'%s' in parameter '%s' (must be an integer array with \"\n \"%d elements)\",\n optstring, info->parameter_name, (int)request->hdim);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option 'downsample' will be ignored for %s output of \"\n \"variable '%s'\",\n info->method_name, fullname);\n }\n Util_TableDeleteKey(table, \"downsample\");\n }\n\n /* check for option 'refinement_levels' */\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"refinement_levels\") >\n 0) {\n request->refinement_levels = 0;\n if (type == CCTK_VARIABLE_INT && nelems > 0) {\n refinement_levels = malloc(nelems * sizeof(int));\n Util_TableGetIntArray(table, nelems, refinement_levels,\n \"refinement_levels\");\n while (--nelems >= 0) {\n if (refinement_levels[nelems] < 0) {\n request->refinement_levels = 0;\n break;\n }\n request->refinement_levels |= 1 << refinement_levels[nelems];\n }\n free(refinement_levels);\n }\n if (request->refinement_levels == 0) {\n if (CCTK_GroupTypeFromVarI(vindex) == CCTK_GF) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'refinement_levels' in option \"\n \"string '%s' in parameter '%s' (must be an array of \"\n \"positive integers)\",\n optstring, info->parameter_name);\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Meaningless option 'refinement_levels' in option \"\n \"string '%s' in parameter '%s' (only makes sense for \"\n \"grid functions)\",\n optstring, info->parameter_name);\n }\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option 'refinement_levels' will be ignored for %s output \"\n \"of variable '%s'\",\n info->method_name, fullname);\n request->refinement_levels = -1;\n }\n Util_TableDeleteKey(table, \"refinement_levels\");\n }\n\n /* check for option 'compression_level' */\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"compression_level\") >\n 0) {\n request->compression_level = -1;\n if (type == CCTK_VARIABLE_INT && nelems == 1) {\n Util_TableGetInt(table, &request->compression_level,\n \"compression_level\");\n if (request->compression_level < 0 || request->compression_level > 9) {\n type = -1;\n request->compression_level = -1;\n }\n }\n if (!(type == CCTK_VARIABLE_INT && nelems == 1)) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'compression_level' in option \"\n \"string '%s' in parameter '%s' (must be an integer in the \"\n \"range [0-9])\",\n optstring, info->parameter_name);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option 'compression_level' will be ignored for %s output \"\n \"of variable '%s'\",\n info->method_name, fullname);\n }\n Util_TableDeleteKey(table, \"compression_level\");\n }\n\n /* check for option 'reductions' */\n if (Util_TableQueryValueInfo(table, &type, &nelems, \"reductions\") > 0) {\n request->reductions = NULL;\n if (type == CCTK_VARIABLE_CHAR && nelems >= 0) {\n request->reductions = malloc(nelems + 1);\n Util_TableGetString(table, nelems + 1, request->reductions,\n \"reductions\");\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'reductions' in option \"\n \"string '%s' in parameter '%s' (must be a string)\",\n optstring, info->parameter_name);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option 'reductions' will be ignored for %s output \"\n \"of variable '%s'\",\n info->method_name, fullname);\n }\n Util_TableDeleteKey(table, \"reductions\");\n }\n\n /* warn about unrecognized options */\n iterator = Util_TableItCreate(table);\n for (iterator = Util_TableItCreate(table);\n Util_TableItQueryIsNonNull(iterator) > 0 &&\n Util_TableItQueryKeyValueInfo(iterator, sizeof(key), key, 0, 0) > 0;\n Util_TableItAdvance(iterator)) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Found option with unrecognized key '%s' in option string \"\n \"'%s' in parameter '%s'\",\n key, optstring, info->parameter_name);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option will be ignored for %s output of variable '%s'\",\n info->method_name, fullname);\n }\n Util_TableItDestroy(iterator);\n\n Util_TableDestroy(table);\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Couldn't parse option string '%s' in parameter '%s'\", optstring,\n info->parameter_name);\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option string will be ignored for %s output of variable '%s'\",\n info->method_name, fullname);\n }\n\n /* assign the new I/O request */\n info->request_list[vindex] = request;\n\n /* clean up */\n free(fullname);\n}\n\n/* return the default I/O request description structure for a variable */\nioRequest *IOUtil_DefaultIORequest(const cGH *GH, int vindex,\n int out_every_default,\n CCTK_REAL out_dt_default) {\n int vdim;\n int *extent_int;\n ioRequest *request;\n const ioGH *myGH;\n DECLARE_CCTK_PARAMETERS\n\n /* check for valid variable index */\n vdim = CCTK_GroupDimFromVarI(vindex);\n if (vdim < 0) {\n return (NULL);\n }\n\n myGH = CCTK_GHExtension(GH, \"IO\");\n\n /* allocate a new I/O request structure */\n request = malloc(sizeof(ioRequest));\n\n /* fill out the basics */\n request->vindex = vindex;\n request->timelevel = 0;\n request->check_exist = myGH->recovered;\n request->out_every = out_every_default;\n request->out_dt = out_dt_default;\n request->out_unchunked = out_unchunked;\n request->reductions = NULL;\n request->with_ghostzones = 0;\n request->refinement_levels = -1;\n request->compression_level = -1;\n\n /* get the I/O request datatype (will be single-precision if requested) */\n request->hdatatype = CCTK_VarTypeI(vindex);\n if (myGH->out_single && CCTK_GroupTypeFromVarI(vindex) != CCTK_SCALAR) {\n if (request->hdatatype == CCTK_VARIABLE_REAL) {\n request->hdatatype = CCTK_VARIABLE_REAL4;\n } else if (request->hdatatype == CCTK_VARIABLE_COMPLEX) {\n request->hdatatype = CCTK_VARIABLE_COMPLEX8;\n }\n#ifdef CCTK_INT2\n else if (request->hdatatype == CCTK_VARIABLE_INT) {\n request->hdatatype = CCTK_VARIABLE_INT2;\n }\n#endif\n }\n\n /* get the variable's dimension and extents */\n request->vdim = vdim;\n extent_int = NULL;\n if (request->vdim > 0) {\n extent_int = malloc(request->vdim * sizeof(int));\n CCTK_GroupgshVI(GH, request->vdim, extent_int, vindex);\n }\n\n /* allocate the arrays all in one go\n only initialize those which are mandatory for the Hyperslab API */\n request->vectors =\n calloc((request->vdim + 6) * request->vdim + 1, sizeof(CCTK_INT));\n request->hoffset = request->vectors + 0 * request->vdim;\n request->hsize = request->vectors + 1 * request->vdim;\n request->hsize_chunk = request->vectors + 2 * request->vdim;\n request->origin = request->vectors + 3 * request->vdim + 1;\n request->extent = request->vectors + 4 * request->vdim + 1;\n request->downsample = request->vectors + 5 * request->vdim + 1;\n request->direction = request->vectors + 6 * request->vdim + 1;\n\n for (request->hdim = 0; request->hdim < request->vdim; request->hdim++) {\n request->extent[request->hdim] = extent_int[request->hdim];\n request->direction[request->hdim * (request->vdim + 1)] = 1;\n\n /* take the downsampling parameters from IOUtil */\n if (request->hdim == 0) {\n request->downsample[request->hdim] = out_downsample_x;\n } else if (request->hdim == 1) {\n request->downsample[request->hdim] = out_downsample_y;\n } else if (request->hdim == 2) {\n request->downsample[request->hdim] = out_downsample_z;\n } else {\n request->downsample[request->hdim] = 1;\n }\n }\n\n /* clean up */\n if (extent_int) {\n free(extent_int);\n }\n\n return (request);\n}\n", "Startup.c": "/*@@\n @file Startup.c\n @date Sat Feb 6 1999\n @author Gabrielle Allen\n @desc\n Startup routines for IOUtil.\n @enddesc\n @version $Id$\n@@*/\n\n#include \"cctk.h\"\n#include \"cctk_Arguments.h\"\n#include \"cctk_Misc.h\"\n#include \"cctk_Version.h\"\n#include \"cctk_Parameters.h\"\n#include \"util_Network.h\"\n\n#include \n#include \n#include \n#include \n#include \n#ifdef HAVE_SYS_STAT_H\n#include \n#endif\n#ifdef HAVE_UNISTD_H\n#include \n#endif\n#ifdef HAVE_DIRENT_H\n#include \n#endif\n\n#include \"ioGH.h\"\n#include \"ioutil_Utils.h\"\n#include \"ioutil_AdvertisedFiles.h\"\n\n/* the rcs ID and its dummy funtion to use it */\nstatic const char *rcsid = \"$Header$\";\nCCTK_FILEVERSION(CactusBase_IOUtil_Startup_c)\n\n/********************************************************************\n ********************* External Routines **********************\n ********************************************************************/\nint IOUtil_Startup(void);\nvoid IOUtil_UpdateParFile(CCTK_ARGUMENTS);\n\n/********************************************************************\n ********************* Internal Typedefs **********************\n ********************************************************************/\n/* structure defining a single-linked list of parameters\n (stores the name of the parameter, its stringified value, and its type) */\ntypedef struct t_param_list {\n char *name;\n char *value;\n const char *format_string;\n struct t_param_list *next;\n} t_param_list;\n\n/********************************************************************\n ********************** Static Routines *********************\n ********************************************************************/\nstatic void *SetupGH(tFleshConfig *config, int convergence_level, cGH *GH);\nstatic int CopyParFile(int recovered);\nstatic int GenerateParFile(int recovered);\nstatic int DumpParameters(FILE *outfile);\n\n/*@@\n @routine IOUtil_Startup\n @date Sat Feb 6 1999\n @author Gabrielle Allen\n @desc\n The startup registration routine for IOUtil.
\n It registers the GH extension \"IO\" for IOUtil, along with its\n setup routine.\n It also advertises the original parameter file.\n @enddesc\n @calls CCTK_RegisterGHExtension\n CCTK_RegisterGHExtensionSetupGH\n CCTK_ParameterFilename\n IOUtil_AdvertiseFile\n@@*/\nint IOUtil_Startup(void) {\n char parfile[1024];\n ioAdvertisedFileDesc advertised_file;\n DECLARE_CCTK_PARAMETERS\n\n CCTK_RegisterGHExtensionSetupGH(CCTK_RegisterGHExtension(\"IO\"), SetupGH);\n\n /* advertise the parameter file */\n parfile[0] = 0;\n\n /* TODO: check the returned size; the function silently truncates\n * the filename if it doesn't fit in the buffer; I can't think of a\n * situation where this is useful. Even better, modify\n * CCTK_ParameterFilename to allocate memory for the string, like\n * many other Cactus functions do. */\n\n CCTK_ParameterFilename(sizeof(parfile), parfile);\n advertised_file.slice = \"\";\n advertised_file.thorn = CCTK_THORNSTRING;\n advertised_file.varname = \"\";\n advertised_file.description = \"Parameter File\";\n advertised_file.mimetype = \"text/plain\";\n IOUtil_AdvertiseFile(NULL, parfile, &advertised_file);\n\n return 0;\n}\n\n/*@@\n @routine IOUtil_UpdateParFile\n @date Tue 18 Dec 2001\n @author Thomas Radke\n @desc\n Updates the parameter file for all parameters which got steered\n during its last invocation.\n @enddesc\n\n @var GH\n @vdesc pointer to grid hierarchy\n @vtype const cGH *\n @vio in\n @endvar\n\n @returntype int\n @returndesc 0 for success\n @endreturndesc\n@@*/\nvoid IOUtil_UpdateParFile(CCTK_ARGUMENTS) {\n DECLARE_CCTK_PARAMETERS;\n const cGH *GH = cctkGH;\n\n /* check if it's time to update */\n if (CCTK_MyProc(GH) > 0 || GH->cctk_iteration % parfile_update_every) {\n return;\n }\n\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Not yet implemented: updating parameter file for steered \"\n \"parameters up to iteration %d\",\n GH->cctk_iteration);\n}\n\n/*@@\n @routine IOUtil_TruncateOutputFiles\n @date Wed 17 November 2004\n @author Thomas Radke\n @desc\n Aliased function 'IO_TruncateOutputFiles' which can be called\n by I/O methods to check whether to truncate existing output\n files or not.\n @enddesc\n\n @var GH\n @vdesc pointer to grid hierarchy\n @vtype const cGH *\n @vio in\n @endvar\n\n @returntype CCTK_INT\n @returndesc 1 or 0 for truncate or not\n @endreturndesc\n@@*/\nCCTK_INT IOUtil_TruncateOutputFiles(const CCTK_POINTER_TO_CONST GH) {\n const ioGH *myGH;\n DECLARE_CCTK_PARAMETERS\n\n myGH = CCTK_GHExtension(GH, \"IO\");\n if (!myGH) {\n CCTK_WARN(CCTK_WARN_ABORT, \"IOUtil_TruncateOutputFiles called before being \"\n \"fully initialized. Please make sure to only \"\n \"call me after the STARTUP bin has finished and \"\n \"the driver called CCTKi_InitGHExtensions.\");\n }\n\n return (myGH->recovered ? truncate_files_after_recovering : truncate_files);\n}\n\n/********************************************************************\n *********************** Local Functions ***********************\n ********************************************************************/\n/*@@\n @routine SetupGH\n @date Tue May 09 2000\n @author Thomas Radke\n @desc\n The GH allocation and initialization routine for IOUtil.
\n Necessary output dirs are created, checkpoint/recovery timers\n are created if timing information is wanted, and a parameter\n file is written to 'IO::out_dir' if requested.\n @enddesc\n @calls IOUtil_CreateDirectory\n CopyParFile\n GenerateParFile\n\n @var config\n @vdesc flesh configuration structure (unused)\n @vtype tFleshConfig *\n @vio in\n @endvar\n @var convergence_level\n @vdesc convergence level (unused)\n @vtype int\n @vio in\n @endvar\n @var GH\n @vdesc pointer to grid hierarchy\n @vtype cGH *\n @vio in\n @endvar\n\n @returntype void *\n @returndesc the pointer to IOUtil's GH extension structure, or
\n NULL if memory allocation failed\n @endreturndesc\n@@*/\nstatic void *SetupGH(tFleshConfig *config, int convergence_level, cGH *GH) {\n int i, maxdim, myproc;\n ioGH *myGH;\n#ifdef HAVE_DIRENT_H\n DIR *dir;\n struct dirent *file;\n#endif\n DECLARE_CCTK_PARAMETERS\n\n /* avoid compiler warnings about unused parameters */\n convergence_level = convergence_level;\n\n myproc = CCTK_MyProc(GH);\n myGH = calloc(1, sizeof(ioGH));\n if (!myGH) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Couldn't allocate GH extension structure for IOUtil\");\n return (NULL);\n }\n\n if (CCTK_Equals(out_mode, \"proc\")) {\n myGH->ioproc = myproc;\n myGH->nioprocs = CCTK_nProcs(GH);\n myGH->ioproc_every = 1;\n } else if (CCTK_Equals(out_mode, \"np\")) {\n myGH->ioproc_every = out_proc_every;\n if (out_proc_every > CCTK_nProcs(GH)) {\n myGH->ioproc_every = CCTK_nProcs(GH);\n CCTK_VInfo(CCTK_THORNSTRING, \"Reducing 'IO::out_proc_every' to %d\",\n myGH->ioproc_every);\n }\n\n myGH->nioprocs = CCTK_nProcs(GH) / myGH->ioproc_every +\n (CCTK_nProcs(GH) % myGH->ioproc_every ? 1 : 0);\n myGH->ioproc = myproc - (myproc % myGH->ioproc_every);\n } else /* IO::out_mode = \"onefile\" */\n {\n myGH->ioproc = 0;\n myGH->nioprocs = 1;\n myGH->ioproc_every = CCTK_nProcs(GH);\n }\n\n /* For now we can only have unchunked for a single output file */\n myGH->unchunked = 0;\n if (out_unchunked || CCTK_nProcs(GH) == 1) {\n if (myGH->ioproc_every >= CCTK_nProcs(GH)) {\n myGH->unchunked = 1;\n } else {\n CCTK_INFO(\"Unchunked output not supported for multiple \"\n \"output files. Output will be chunked.\");\n }\n }\n\n myGH->stop_on_parse_errors = 0;\n\n /* create the default output and checkpoint directories */\n i = IOUtil_CreateDirectory(GH, out_dir, !CCTK_Equals(out_mode, \"onefile\"),\n myGH->ioproc);\n if (i < 0) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Problem creating default output directory '%s'\", out_dir);\n } else if (i > 0) {\n if (CCTK_Equals(verbose, \"full\")) {\n CCTK_VInfo(CCTK_THORNSTRING,\n \"default output directory '%s' already exists\", out_dir);\n }\n if (require_empty_output_directory) {\n#ifdef HAVE_DIRENT_H\n i = 0;\n dir = opendir(out_dir);\n while ((file = readdir(dir)) != NULL) {\n if (strcmp(file->d_name, \".\") == 0 || strcmp(file->d_name, \"..\") == 0) {\n continue;\n }\n CCTK_VWarn(2, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Found file '%s' in already existing output directory '%s'\",\n file->d_name, out_dir);\n i++;\n }\n closedir(dir);\n if (i) {\n CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"You have set IO::out_dir = '%s' and \"\n \"IO::require_empty_output_directory = 'yes'. \"\n \"This output directory already exists and is non-empty.\",\n out_dir);\n }\n#else\n /* No opendir(3) ??? It's probably a Windows box, so just give up ! */\n CCTK_WARN(0, \"You cannot use 'IO::require_empty_output_directory = \"\n \"\\\"yes\\\"' on this architecture because it doesn't provide \"\n \"opendir(3) to browse the IO::out_dir directory.\\n\"\n \"Please use 'IO::require_empty_output_directories = \"\n \"\\\"no\\\"' instead !\");\n#endif\n }\n }\n i = IOUtil_CreateDirectory(GH, checkpoint_dir,\n !CCTK_Equals(out_mode, \"onefile\"), myGH->ioproc);\n if (i < 0) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Problem creating checkpoint directory '%s'\", checkpoint_dir);\n } else if (i > 0 && CCTK_Equals(verbose, \"full\")) {\n CCTK_VInfo(CCTK_THORNSTRING, \"checkpoint directory '%s' already exists\",\n checkpoint_dir);\n }\n\n /* save downsampling parameters in ioUtilGH because they are temporarily\n reset during checkpointing */\n /* for now we have only parameters for the first 3 dimensions\n the rest is constantly initialized to 1 */\n maxdim = CCTK_MaxDim();\n myGH->downsample = malloc(maxdim * sizeof(int));\n\n switch (maxdim > 3 ? 3 : maxdim) {\n case 3:\n myGH->downsample[2] = out_downsample_z;\n case 2:\n myGH->downsample[1] = out_downsample_y;\n case 1:\n myGH->downsample[0] = out_downsample_x;\n }\n\n for (i = 3; i < maxdim; i++) {\n myGH->downsample[i] = 1;\n }\n\n/* evaluate the 'IO::out_single_precision' parameter only\n if Cactus was compiled with double precision */\n#ifdef SINGLE_PRECISION\n myGH->out_single = 0;\n#else\n myGH->out_single = out_single_precision;\n#endif\n\n /* copy the 'recovered' flag to this GH extension */\n myGH->recovered = config->recovered;\n\n /* reset the flags array for the file reader */\n myGH->do_inVars = NULL;\n\n /* write the parameter file if requested */\n if (myproc == 0) {\n if (CCTK_Equals(parfile_write, \"copy\")) {\n CopyParFile(myGH->recovered);\n } else if (CCTK_Equals(parfile_write, \"generate\")) {\n GenerateParFile(myGH->recovered);\n }\n }\n\n return (myGH);\n}\n\n/*@@\n @routine CopyParFile\n @date Tue 18 Dec 2001\n @author Thomas Radke\n @desc\n Copies the original parameter file to a new one in 'IO::out_dir'.\n Note that the new parameter file will usually overwrite an\n existing file unless\n - the new parameter file is identical with the original one\n - this is a recovery run\n @enddesc\n @calls CCTK_ParameterFilename\n\n @returntype int\n @returndesc\n 0 for success, or
\n -1 if original parameter file couldn't be opened for reading,
\n -2 if new parameter file couldn't be opened for writing
\n @endreturndesc\n@@*/\nstatic int CopyParFile(int recovered) {\n int in_parfile, out_parfile, bytes, bytes_written, flags;\n char *out_parfilename, buffer[1024];\n const char *my_parfile_name;\n struct stat in_stat_buf, out_stat_buf;\n DECLARE_CCTK_PARAMETERS\n\n /* get the name of the original parfile and open it for reading */\n CCTK_ParameterFilename(sizeof(buffer), buffer);\n in_parfile = open(buffer, O_RDONLY);\n if (in_parfile < 0) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Couldn't open original parameter file '%s' (%s)\", buffer,\n strerror(errno));\n return (-1);\n }\n /* use the file mode of the original parfile to create the new one */\n if (fstat(in_parfile, &in_stat_buf)) {\n in_stat_buf.st_mode = 0644;\n }\n\n /* build the name of the output parfile */\n my_parfile_name = parfile_name;\n if (!*my_parfile_name) {\n /* cut off any path names */\n my_parfile_name = strrchr(buffer, '/');\n if (my_parfile_name) {\n my_parfile_name++;\n } else {\n my_parfile_name = buffer;\n }\n }\n out_parfilename = malloc(strlen(out_dir) + strlen(my_parfile_name) + 2);\n sprintf(out_parfilename, \"%s/%s\", out_dir, my_parfile_name);\n\n /* check whether input and output files are identical */\n if (!stat(out_parfilename, &out_stat_buf) &&\n in_stat_buf.st_ino == out_stat_buf.st_ino) {\n CCTK_VWarn(2, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Parameter file '%s' to be written into directory '%s' is \"\n \"identical with original parameter file. Parameter file will \"\n \"not be copied.\",\n my_parfile_name, out_dir);\n out_parfile = 0;\n } else {\n /* binary-copy the input parfile to the output parfile */\n flags = O_CREAT | O_TRUNC | O_WRONLY;\n if (recovered) {\n flags |= O_EXCL;\n }\n out_parfile = open(out_parfilename, flags, in_stat_buf.st_mode);\n if (out_parfile >= 0) {\n while ((bytes = read(in_parfile, buffer, sizeof(buffer))) > 0) {\n bytes_written = write(out_parfile, buffer, bytes);\n if (bytes_written != bytes) {\n if (bytes_written < 0) {\n CCTK_VWarn(3, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Error while writing parameter file '%s' (%s)\",\n out_parfilename, strerror(errno));\n } else {\n CCTK_VWarn(3, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Error while writing parameter file '%s'\",\n out_parfilename);\n }\n }\n }\n close(out_parfile);\n } else {\n CCTK_VWarn(3, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Couldn't write parameter file '%s' (%s)\", out_parfilename,\n strerror(errno));\n }\n }\n\n /* clean up */\n close(in_parfile);\n free(out_parfilename);\n\n return (out_parfile >= 0 ? 0 : -2);\n}\n\n/*@@\n @routine DumpParameters\n @date Tue 18 Dec 2001\n @author Thomas Radke\n @desc\n Generates a new parameter file in 'IO::out_dir' with an\n ActiveThorns list and a sorted list of all active parameters\n which have been set in the original parameter file.
\n Note that the new parameter file will usually overwrite an\n existing file unless\n - the new parameter file is identical with the original one\n - this is a recovery run\n @enddesc\n @calls CCTK_ParameterFilename\n\n @var recovered\n @vdesc flag indicating whether this is a recovery run\n @vtype int\n @vio in\n @endvar\n\n @returntype int\n @returndesc\n 0 for success, or
\n -1 if original parameter file couldn't be stat(2),
\n -2 if new parameter file couldn't be opened for writing
\n @endreturndesc\n@@*/\nstatic int GenerateParFile(int recovered) {\n FILE *outfile;\n int out_parfile, flags;\n char *out_parfilename, buffer[1024];\n const char *my_parfile_name;\n struct stat in_stat_buf, out_stat_buf;\n DECLARE_CCTK_PARAMETERS\n\n /* get the name of the original parfile and stat(2) it */\n CCTK_ParameterFilename(sizeof(buffer), buffer);\n if (stat(buffer, &in_stat_buf)) {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Couldn't stat(2) original parameter file '%s' (%s)\", buffer,\n strerror(errno));\n return (-1);\n }\n\n /* build the name of the output parfile */\n my_parfile_name = parfile_name;\n if (!*my_parfile_name) {\n /* cut off any path names */\n my_parfile_name = strrchr(buffer, '/');\n if (my_parfile_name) {\n my_parfile_name++;\n } else {\n my_parfile_name = buffer;\n }\n }\n out_parfilename = malloc(strlen(out_dir) + strlen(my_parfile_name) + 2);\n sprintf(out_parfilename, \"%s/%s\", out_dir, my_parfile_name);\n\n /* check whether input and output files are identical */\n if (!stat(out_parfilename, &out_stat_buf) &&\n in_stat_buf.st_ino == out_stat_buf.st_ino) {\n CCTK_VWarn(2, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Parameter file '%s' to be written into directory '%s' is \"\n \"identical with original parameter file. Parameter file will \"\n \"not be generated.\",\n my_parfile_name, out_dir);\n out_parfile = 0;\n } else {\n flags = O_CREAT | O_TRUNC | O_WRONLY;\n if (recovered) {\n flags |= O_EXCL;\n }\n\n out_parfile = open(out_parfilename, flags, in_stat_buf.st_mode);\n if (out_parfile >= 0) {\n outfile = fdopen(out_parfile, \"w\");\n }\n if (out_parfile >= 0 && outfile) {\n fprintf(outfile, \"# '%s' automatically generated by Cactus version %s\\n\",\n out_parfilename, CCTK_FullVersion());\n fprintf(outfile, \"# Original parameter file was '%s'\\n\", buffer);\n Util_CurrentTime(sizeof(buffer), buffer);\n fprintf(outfile, \"# Run time/date was %s \", buffer);\n Util_CurrentDate(sizeof(buffer), buffer);\n fprintf(outfile, \"%s \", buffer);\n Util_GetHostName(buffer, sizeof(buffer));\n fprintf(outfile, \"on host '%s' with %d processor(s)\\n\\n\", buffer,\n CCTK_nProcs(NULL));\n DumpParameters(outfile);\n fclose(outfile);\n } else {\n CCTK_VWarn(3, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Couldn't write parameter file '%s' (%s)\", out_parfilename,\n strerror(errno));\n }\n if (out_parfile >= 0) {\n close(out_parfile);\n }\n }\n\n /* clean up */\n free(out_parfilename);\n\n return (out_parfile >= 0 ? 0 : -2);\n}\n\n/*@@\n @routine DumpParameters\n @date Thu Oct 25 2001\n @author Thomas Radke\n @desc\n Dumps parameter settings of all active thorns into a file.\n @enddesc\n @calls CCTK_NumCompiledThorns\n CCTK_CompiledThorn\n CCTK_IsThornActive\n CCTK_ParameterWalk\n CCTK_ParameterValString\n\n @var parfile\n @vdesc open file descriptor for the output file\n @vtype FILE *\n @vio out\n @endvar\n\n @returntype int\n @returndesc\n 0 for success, or
\n -1 if file descriptor is invalid\n @endreturndesc\n@@*/\nstatic int DumpParameters(FILE *outfile) {\n int thorn, first, num_thorns;\n int len, maxname_len;\n const char *thornname;\n char *param;\n const cParamData *pdata;\n t_param_list *list, *last, *new;\n const char *quoted_format = \"%s::%-*s = \\\"%s\\\"\\n\",\n *non_quoted_format = \"%s::%-*s = %s\\n\";\n\n /* check passed file descriptor */\n if (outfile == NULL) {\n return (-1);\n }\n\n num_thorns = CCTK_NumCompiledThorns();\n\n /* loop over all thorns to print the 'ActiveThorns' list */\n first = 1;\n fputs(\"ActiveThorns = \\\"\", outfile);\n for (thorn = 0; thorn < num_thorns; thorn++) {\n thornname = CCTK_CompiledThorn(thorn);\n\n /* skip all inactive thorns and \"Cactus\" */\n if (strcmp(\"Cactus\", thornname) && CCTK_IsThornActive(thornname)) {\n if (!first) {\n putc(' ', outfile);\n }\n fputs(thornname, outfile);\n first = 0;\n }\n }\n fputs(\"\\\"\\n\", outfile);\n\n /* loop over all thorns */\n for (thorn = 0; thorn < num_thorns; thorn++) {\n thornname = CCTK_CompiledThorn(thorn);\n\n /* skip all inactive thorns */\n if (!CCTK_IsThornActive(thornname)) {\n continue;\n }\n\n /* now walk through all parameters of given thorn */\n maxname_len = 0;\n list = last = NULL;\n first = 1;\n while (CCTK_ParameterWalk(first, thornname, ¶m, &pdata) == 0) {\n first = 0;\n\n /* skip the parameters which weren't explicitely set */\n if (pdata->n_set > 0) {\n new = malloc(sizeof(t_param_list));\n if (new) {\n new->value = CCTK_ParameterValString(pdata->name, pdata->thorn);\n if (new->value) {\n new->format_string =\n pdata->type == PARAMETER_INT || pdata->type == PARAMETER_REAL\n ? non_quoted_format\n : quoted_format;\n new->name = pdata->name;\n len = strlen(new->name);\n if (len > maxname_len) {\n maxname_len = len;\n }\n if (last) {\n last->next = new;\n last = new;\n } else {\n list = last = new;\n }\n last->next = NULL;\n } else {\n CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Couldn't get value for parameter '%s'\", param);\n free(new);\n }\n } else {\n CCTK_WARN(1, \"Couldn't allocate list element\");\n }\n }\n free(param);\n } /* end of loop walking over all parameters of given thorn */\n\n /* finally dump out the list for this thorn */\n if (list) {\n fprintf(outfile, \"\\n# Parameters of thorn %s (implementing %s)\\n\",\n thornname, CCTK_ThornImplementation(thornname));\n }\n while (list) {\n fprintf(outfile, list->format_string, thornname, maxname_len, list->name,\n list->value);\n free(list->value);\n last = list->next;\n free(list);\n list = last;\n }\n } /* end of looping over all thorns */\n\n return (0);\n}\n" }, "test": {}, "doc": { "1Dlines_in_box.pdf": "%PDF-1.7\n%\uc3e2\n%%Invocation: gs -q -dSAFER -sAutoRotatePages=? -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress ? ? -\n5 0 obj\n<>\nstream\nxT=o\u001b1\f+8:A%%J\u0002En\u000fdJ\u0006]Y\u05d7}CQL=<\ue050o<\u001fvn\u0003\u0011|u,\u0263FP\";\u0004v%iF\f[A\bc0EI\"}\u001fn\u0003\u001a1\fAQ@A\u001c\u007fq\\\u0014^-@\u0286Dd\u0014?[nnFo\u000bF\u0541\tE\u000f\u001c\u001cu<\u0013|.\u0017~}Rs2\u001cH\u000bO> \u0672!\u0003R Wl\u0017\u03496KAR\u000e\u0016fKdaG\u001e(gl/,\u000e^,\u068dEa*!x`\u0011\u0013!y\u0619Qk$Jy\u0006\u0019\u00159AHb\u0274?K)TmO\u0007\u046dT-H\u0007\u001c\u022b6\u0010\u0013c\u001b'D4%Dcv\u000b\u0015}\u00118X3\u0007R\u001b65\u000fzCWbQ(!!@\u0001ci\u001b7/L\u007fH\u0019\u0003\u03e0\u001aIfKm7g\\,z\u0018a\u0007\u001fzVMRJJ?\flX$\f&Z~Vw+E=:{]]]\u0017K]M\n\u046d~\u001bh\n\u0005v](F\u0531 I*g\u000b\u0196B\u0017mpmGXn:\ue0a8N]g\u0003\u013en[q\u0012>\u001b\u00077Z8endstream\nendobj\n6 0 obj\n596\nendobj\n4 0 obj\n<>\n/Contents 5 0 R\n>>\nendobj\n3 0 obj\n<< /Type /Pages /Kids [\n4 0 R\n] /Count 1\n>>\nendobj\n1 0 obj\n<>\nendobj\n9 0 obj\n<>\nendobj\n7 0 obj\n<>\nendobj\n11 0 obj\n<>\nendobj\n8 0 obj\n<>\nendobj\n10 0 obj\n<>stream\nxkLg\u0018\u07ef\u0003\u000b\u0221\u068e\fSf\u001f,D3\u0003\u000f(\b[\u000bJ-J\u0003\u0014\u001eP@,B\naLLdD\u0017!\u0004\u0013\b\u06f2ds\t[Ub\u07bf}=\u000f\u0001\u0018 \b)\\.R\u0015/t:_go0!VhZ\u0001\u00c4\u05d2/\u0011\u0013f;\"w>*w8=33RUu\u00039o\u001d\u0012UD6|ZZ\u0010\u00142J.V\u0015H\u0015\u001ahVT$\u02a9U\u007f\u0000mZ]\\\u047e,\u0000\u0381\u0012P\n\u0012@\"\u0001\b\u0010\u0003\u0006A,\u0003\n@\u0014$D!QK,13N0:\u0019A/\f\u42a7m>'Px\u0007g`}@v\u0007U\u013918\u001fu\u001dwY\u0011L\u001aJvj5_\u0019nv6l\t.\u001c\u001f\u007fjd`1|gYRm\u001bPhjz\u06bd>\nJ\tVUhCNF`\u001aKJ\f\u0017\u001aX#\u0001j\b30fv\u00073U\u0018\u0006\u00adny\\@\u0002\nP_W 3PFhfgS\u03a3s!j05>stream\n\n\n\n\n\n2021-03-02T16:32:04-06:00\n2021-03-02T16:32:04-06:00\nfig2dev Version 3.2.8\n\n1Dlines_in_box.fig\n\n\n \n \n\nendstream\nendobj\n2 0 obj\n<>endobj\nxref\n0 13\n0000000000 65535 f \n0000000987 00000 n \n0000004193 00000 n \n0000000928 00000 n \n0000000796 00000 n \n0000000111 00000 n \n0000000777 00000 n \n0000001081 00000 n \n0000001518 00000 n \n0000001052 00000 n \n0000001793 00000 n \n0000001431 00000 n \n0000002921 00000 n \ntrailer\n<< /Size 13 /Root 1 0 R /Info 2 0 R\n/ID []\n>>\nstartxref\n4377\n%%EOF\n", "1Dlines_in_xyBitant.fig": "#FIG 3.2 Produced by xfig version 3.2.8\nLandscape\nCenter\nMetric\nLetter\n100.00\nSingle\n-2\n1200 2\n2 1 3 3 4 7 50 0 -1 8.000 0 0 7 1 0 2\n\t1 1 3.00 44.99 89.98\n\t 1238 3802 2363 3802\n2 1 3 3 4 7 50 0 -1 8.000 0 0 7 1 0 2\n\t1 1 3.00 44.99 89.98\n\t 1800 4365 1800 3802\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 2138 4500 2588 4218\n2 1 1 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 1463 4218 2588 4218\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 1010 3933 1460 3652\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 2138 3937 2588 3656\n2 1 0 2 10 7 50 0 -1 0.000 0 0 7 0 0 2\n\t 2588 3656 2588 4218\n2 1 1 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 1463 4218 1463 3656\n2 1 1 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 1013 4500 1463 4218\n2 1 3 3 4 7 50 0 -1 8.000 0 0 7 1 0 2\n\t1 1 3.00 44.99 89.98\n\t 1575 3937 2025 3656\n2 1 0 2 10 7 50 0 -1 0.000 0 0 7 0 0 2\n\t 1463 3656 2588 3656\n2 2 0 2 10 7 50 0 -1 0.000 0 0 7 0 0 5\n\t 1013 3937 2138 3937 2138 4500 1013 4500 1013 3937\n4 0 0 50 0 0 10 0.0000 4 105 75 1845 3892 y\\001\n4 0 0 50 0 0 10 0.0000 4 75 90 2295 3780 x\\001\n4 0 0 50 0 0 10 0.0000 4 75 75 2048 3751 z\\001\n4 0 0 50 0 0 10 0.0000 4 135 1035 440 4680 (-0.5, -0.5, -0.5)\\001\n4 0 0 50 0 0 10 0.0000 4 135 975 1913 4675 (0.5, -0.5, -0.5)\\001\n4 0 0 50 0 0 10 0.0000 4 135 915 2610 4289 (0.5, 0.5, -0.5)\\001\n4 0 0 50 0 0 10 0.0000 4 135 975 196 3756 (-0.5, -0.5, 0.0)\\001\n", "1Dlines_in_xyBitant.pdf": "%PDF-1.7\n%\uc3e2\n%%Invocation: gs -q -dSAFER -sAutoRotatePages=? -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress ? ? -\n5 0 obj\n<>\nstream\nxTn\u00131\u0010+|L+2x\uc671}EBDrj)\u0015JKyw.-\u0012\u0010E7o>@C\n\u001d\\D3\u0007q*JzD\u07ff (\u0017;\u0011\u0012\bE#\u0002S\u0019\u0223xJZO\u00191#\u0014=~}\u000be|pfJc#qN\u0004\u0012=!;va\u04d73EmCJ>\n/Contents 5 0 R\n>>\nendobj\n3 0 obj\n<< /Type /Pages /Kids [\n4 0 R\n] /Count 1\n>>\nendobj\n1 0 obj\n<>\nendobj\n9 0 obj\n<>\nendobj\n7 0 obj\n<>\nendobj\n11 0 obj\n<>\nendobj\n8 0 obj\n<>\nendobj\n10 0 obj\n<>stream\nxkLg\u0018\u07ef\u0003\u000b\u0221\u068e\fSf\u001f,D3\u0003\u000f(\b[\u000bJ-J\u0003\u0014\u001eP@,B\naLLdD\u0017!\u0004\u0013\b\u06f2ds\t[Ub\u07bf}=\u000f\u0001\u0018 \b)\\.R\u0015/t:_go0!VhZ\u0001\u00c4\u05d2/\u0011\u0013f;\"w>*w8=33RUu\u00039o\u001d\u0012UD6|ZZ\u0010\u00142J.V\u0015H\u0015\u001ahVT$\u02a9U\u007f\u0000mZ]\\\u047e,\u0000\u0381\u0012P\n\u0012@\"\u0001\b\u0010\u0003\u0006A,\u0003\n@\u0014$D!QK,13N0:\u0019A/\f\u42a7m>'Px\u0007g`}@v\u0007U\u013918\u001fu\u001dwY\u0011L\u001aJvj5_\u0019nv6l\t.\u001c\u001f\u007fjd`1|gYRm\u001bPhjz\u06bd>\nJ\tVUhCNF`\u001aKJ\f\u0017\u001aX#\u0001j\b30fv\u00073U\u0018\u0006\u00adny\\@\u0002\nP_W 3PFhfgS\u03a3s!j05>stream\n\n\n\n\n\n2021-03-02T16:31:11-06:00\n2021-03-02T16:31:11-06:00\nfig2dev Version 3.2.8\n\n1Dlines_in_xyBitant.fig\n\n\n \n \n\nendstream\nendobj\n2 0 obj\n<>endobj\nxref\n0 13\n0000000000 65535 f \n0000000971 00000 n \n0000004182 00000 n \n0000000912 00000 n \n0000000781 00000 n \n0000000111 00000 n \n0000000762 00000 n \n0000001065 00000 n \n0000001502 00000 n \n0000001036 00000 n \n0000001777 00000 n \n0000001415 00000 n \n0000002905 00000 n \ntrailer\n<< /Size 13 /Root 1 0 R /Info 2 0 R\n/ID [<074FEDE7923AE1CBCFC76D0A49B9C9CF><074FEDE7923AE1CBCFC76D0A49B9C9CF>]\n>>\nstartxref\n4371\n%%EOF\n", "1Dlines_in_box.fig": "#FIG 3.2 Produced by xfig version 3.2.8\nLandscape\nCenter\nMetric\nLetter\n100.00\nSingle\n-2\n1200 2\n2 1 3 3 4 7 50 0 -1 8.000 0 0 7 1 0 2\n\t1 1 3.00 55.82 111.63\n\t 5347 4354 6743 4354\n2 1 3 3 4 7 50 0 -1 8.000 0 0 7 1 0 2\n\t1 1 3.00 55.82 111.63\n\t 6045 5052 6045 3656\n2 2 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 5\n\t 5068 3824 6464 3824 6464 5219 5068 5219 5068 3824\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 6464 5219 7022 4870\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 7022 3475 7022 4870\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 6464 3824 7022 3475\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 5627 3475 7022 3475\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 5068 3824 5627 3475\n2 1 1 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 5627 4870 7022 4870\n2 1 1 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 5627 4870 5627 3475\n2 1 1 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 5068 5219 5627 4870\n2 1 3 3 4 7 50 0 -1 8.000 0 0 7 1 0 2\n\t1 1 3.00 55.82 111.63\n\t 5766 4522 6324 4187\n4 0 0 50 0 0 10 0.0000 0 135 915 7050 4912 (0.5, 0.5, -0.5)\\001\n4 0 0 50 0 0 10 0.0000 4 105 75 6101 3740 y\\001\n4 0 0 50 0 0 10 0.0000 4 75 75 6352 4243 z\\001\n4 0 0 50 0 0 10 0.0000 4 75 90 6631 4466 x\\001\n4 0 0 50 0 0 10 0.0000 0 135 1035 4505 5394 (-0.5, -0.5, -0.5)\\001\n4 0 0 50 0 0 10 0.0000 0 135 975 6185 5394 (0.5, -0.5, -0.5)\\001\n4 0 0 50 0 0 10 0.0000 0 135 975 4454 3511 (-0.5, -0.5, 0.5)\\001\n", "diagonal_in_cubic.fig": "#FIG 3.2 Produced by xfig version 3.2.8\nLandscape\nCenter\nMetric\nLetter\n100.00\nSingle\n-2\n1200 2\n2 1 3 3 4 7 50 0 -1 8.000 0 0 7 1 0 2\n\t1 1 3.00 51.75 103.50\n\t 1418 3181 3229 1577\n2 2 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 5\n\t 1418 1888 2712 1888 2712 3181 1418 3181 1418 1888\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 2712 3181 3229 2858\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 3229 1564 3229 2858\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 2712 1888 3229 1564\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 1935 1564 3229 1564\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 1418 1888 1935 1564\n2 1 1 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 1935 2858 3229 2858\n2 1 1 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 1935 2858 1935 1564\n2 1 1 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 1418 3181 1935 2858\n4 0 0 50 0 0 10 0.0000 4 105 75 2349 2519 d\\001\n4 0 0 50 0 0 10 0.0000 0 150 900 1558 3330 (nsize_x = 10)\\001\n4 0 0 50 0 0 10 0.0000 0 150 885 3048 3132 (nsize_y = 10)\\001\n4 0 0 50 0 0 10 0.0000 0 150 885 433 2534 (nsize_z = 10)\\001\n", "diagonal_in_cubic.pdf": "%PDF-1.7\n%\uc3e2\n%%Invocation: gs -q -dSAFER -sAutoRotatePages=? -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress ? ? -\n5 0 obj\n<>\nstream\nx=o@\fw\nN\u0000G\u001dyG\u000eY\n\u0014\u0013\u000b\u0014\u001di\u0010\u0007p2\u05d7gK\u001d[:{\u001d-&bL\u0019\u0006^N\u00122\u05c4\u03f7vqRvD\nHHjH@\u001c9\u0013)\u0202I\u0003}{~OpUI0W.$b:~k`#\udaea\udff0wuy\u000e%E\u000fBM<0\u0015\nVp1\u0014<\u0018j\u0005aS9S\u931du)\u01f7#\u001b+\u0016p\nXDwkYJ]U9\u001a>\n/Contents 5 0 R\n>>\nendobj\n3 0 obj\n<< /Type /Pages /Kids [\n4 0 R\n] /Count 1\n>>\nendobj\n1 0 obj\n<>\nendobj\n9 0 obj\n<>\nendobj\n7 0 obj\n<>\nendobj\n8 0 obj\n<>\nendobj\n10 0 obj\n<>stream\nxkLg\u0014\u07d7^WV\u0001\"\u0005m;\nA\u0007\n*ExA\u0017D\u0010@\u0016\u0017h\u000b--}(BKAK\u0001\u0005\u0016@P3\nt\u0787\u000bl\u0012cY!%>y\u03931\u001b8+N#\u4909\u07fcQ8\u030dZN\u0003HLocP\\\u0016\u0006X4,czz%\tzat\u001c\u0012\u0013o[{46>(88dD\u0015ff\u001bC\n\u001f~@&\u0014W\u0002D#\u0010\u000f\bsdu\"@\u0004@\u0000rC#\u0003d\u001a\u007fq|l\u0010\u0000.&aZ(\u0010-\u03b0g\\,\u0005H\u028fH\u000b!6{^8\u0014\u04a0\u001fv0?\u0003z\bI\"J,ho(^OU}@W\u0016n3(\u0004d\u0741\u0001wpc/GSL\u0014@\u007f\u0017xKye|GbNnFJTx\u059a}\u0007RRG\u04f6FoISwYD\u05e48^\u0004&\u0006.\u0528\u02c1?_|\n\"\u0000}3^mK\u001f9\u001a\u07ebQ?\u07d9\u0575}ov\u001a(\u001e~.y(l/\u001a>\u0018`T\u0016c?Gf\nendstream\nendobj\n11 0 obj\n<>stream\n\n\n\n\n\n2021-03-02T16:28:56-06:00\n2021-03-02T16:28:56-06:00\nfig2dev Version 3.2.8\n\ndiagonal_in_cubic.fig\n\n\n \n \n\nendstream\nendobj\n2 0 obj\n<>endobj\nxref\n0 12\n0000000000 65535 f \n0000000782 00000 n \n0000004353 00000 n \n0000000723 00000 n \n0000000591 00000 n \n0000000111 00000 n \n0000000572 00000 n \n0000000876 00000 n \n0000001243 00000 n \n0000000847 00000 n \n0000001539 00000 n \n0000003078 00000 n \ntrailer\n<< /Size 12 /Root 1 0 R /Info 2 0 R\n/ID [<8EF82C11E62E2515D49683DBE8E7988D><8EF82C11E62E2515D49683DBE8E7988D>]\n>>\nstartxref\n4540\n%%EOF\n", "diagonal_in_noncubic.fig": "#FIG 3.2 Produced by xfig version 3.2.8\nLandscape\nCenter\nMetric\nLetter\n100.00\nSingle\n-2\n1200 2\n2 1 3 3 4 7 50 0 -1 8.000 0 0 7 1 0 2\n\t1 1 3.00 52.75 105.49\n\t 1555 4803 2478 3986\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 2874 4803 3402 4473\n2 1 1 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 2083 4473 3402 4473\n2 1 1 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 1555 4803 2083 4473\n2 2 0 2 10 7 50 0 -1 0.000 0 0 7 0 0 5\n\t 1555 4144 2874 4144 2874 4803 1555 4803 1555 4144\n2 1 0 2 10 7 50 0 -1 0.000 0 0 7 0 0 2\n\t 3402 3814 3402 4473\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 1555 4144 2083 3814\n2 1 0 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 2874 4149 3402 3819\n2 1 0 2 10 7 50 0 -1 0.000 0 0 7 0 0 2\n\t 2083 3814 3402 3814\n2 1 1 2 10 7 50 0 -1 6.000 0 0 7 0 0 2\n\t 2083 4473 2083 3814\n4 0 0 50 0 0 10 0.0000 4 105 75 2505 4065 d\\001\n4 0 0 50 0 0 10 0.0000 0 150 810 689 4487 (nsize_z = 5)\\001\n4 0 0 50 0 0 10 0.0000 0 150 900 1854 4966 (nsize_x = 10)\\001\n4 0 0 50 0 0 10 0.0000 0 150 885 3217 4714 (nsize_y = 10)\\001\n", "diagonal_in_noncubic.pdf": "%PDF-1.7\n%\uc3e2\n%%Invocation: gs -q -dSAFER -sAutoRotatePages=? -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress ? ? -\n5 0 obj\n<>\nstream\nxS=O#A\f+\\\u0006\u03389\t]\n\u0012\u0005 \n\u00a7n#%\u0014\u03f3DZ\u03de\u0015\u0006b\f\u001eVP/\n[\\\u0002Y2b\u0281,)\u001eQ\u00141i!%J)F\u001e\u00021z<.\u0015\b\u0017\u01f8KJZ\n:i\tE7\u007f^{\u0001\\XW\u0018U\u0002H\u0012r\f6H\u0010uKPr\u0644_?\u0012\u0010\u001cT#\u001f\u001f\u0010[\u007fq\b\t2L\u001ffd\nJ,\u0014\u0007[RxrL|@\u000e'962;\"Q\u0012FVrEr\u0012X(>dUwWQU\u001b\u04b8\u0355Sv/\u07d3-s\u000e\u000fYt\u001f|\u0010\u001cUt*ulq=\u00dc9\u0018\u039b\u001b`lvw'WG\u0015:ww\u00138\u000e#\u043d)^,\u0013\u0016p\u0006\u0000\u000f\u0003\u001aendstream\nendobj\n6 0 obj\n408\nendobj\n4 0 obj\n<>\n/Contents 5 0 R\n>>\nendobj\n3 0 obj\n<< /Type /Pages /Kids [\n4 0 R\n] /Count 1\n>>\nendobj\n1 0 obj\n<>\nendobj\n9 0 obj\n<>\nendobj\n7 0 obj\n<>\nendobj\n8 0 obj\n<>\nendobj\n10 0 obj\n<>stream\nx{lU\u0018\u01bfomc\u0001\u001b\u001d-h[eCJA\u0018\u029c\u000ed\uc093A:\u001d[ok;rntu\u00edt\u0005\u0019t\u0004HSc%QC\u0005Mo{9}rHB$%i\u001f(PUS>a)=\u001c\\.\u0015\t >n\u029f\u000eEZ\u0000G\u0016\u0012\\|40YYkz`NP\nr\u0017iL+?\u079f,\u0014*uL..J\u0016\u000e(i{'\bbR[7\u001c\u02f2H\\ v\u0010\"(!\u0012\u0010\u0011ED:IG\u0012L\b.QCIS\u0016LsVqc\u07f8\u0003\u0004w\t4\u0585Xy\fpgBe*\u001bhh4t\u00021gb<\t,b\u0017c\u0003\u0011\u001aa@OP\nCkWX'\u0016D\u0006:\u000fz\u0010\u001f4\u0015Kh/r1i\u0016t9=\u0013\u04f0\u248cQ\f>\u00158\u001ej\u045b}c\u0017U{\u007f;\u007f8B`&P\nT\u06e1x\u001b/=\u001b\u007fo r'Lt@fdh\u0014\u000ehHhi\b\u0006\u001d\u0015E^&t\u001cu\u000f\u0013b\no.\u066b\\\"\u0013Jks8p,-\u0006\u000b&\u0011EHowV`\\X9Nu-LT8\\v\u001a\u0002\u0004&\u0003fKK\u0014D\u057c\bvTq\u0234\u00011_gbm\u0625d,pX\u02e4@NT6I\u060fF_Qn3t\u0019\u0005\u00113\u001cKp6-K#\u00060\u000f/\u01cb/o\u0000{#]\uf714M.Xy>\u0010 b\u001aj\u000f\u06d4y\u0010g._ywt$9sP&\u001e\"\u0675W\u0000:\u001f'\fLQG?\nh\u0012C{\u000bQ\u0011*\\K9@@%Wa)4b\u0006&\n\u0006I~#3K2>\u0004[k\u0007=_2\u0000\u04cf\u001f3%}|!o+\u0012\u01422\t6\ng]L\u0016u:2Z\u001fF\u0007\u0006tQ\u0185gI\u0589\u001cE){{O\u0010\u0003\u0004>cv0-g\u07c8\u0002t\u0007M$h\u0006\u04de4\u000f\u0017^@\u001e{]\u0000{N[F\u00136\u0004L\n\u001a$2\nq#\u000fr\u001cM\u001b@W\u06ceV2Y;6=Qk\fD\u0147b5A\u001dbTfF6rR\u0104dt\u0002.\u054d\u0015-{\u0007v'')\u007f\u0002K?!A6Sp\u02dbz)w\u0006suIOId5\u0015{s7TCloWY[sPC!e\u05af\u042f\u0425I\u001f\u0011(\u0b42g\u000f}\u0369_\u0010Co\u001f\u0016&,F*7\u0176mB\u001b/(*\u0124\u076dJ;5z\u0011?\u007f? \u0002\u0012a\u0011\nendstream\nendobj\n11 0 obj\n<>stream\n\n\n\n\n\n2021-03-02T16:27:52-06:00\n2021-03-02T16:27:52-06:00\nfig2dev Version 3.2.8\n\ndiagonal_in_noncubic.fig\n\n\n \n \n\nendstream\nendobj\n2 0 obj\n<>endobj\nxref\n0 12\n0000000000 65535 f \n0000000798 00000 n \n0000004500 00000 n \n0000000739 00000 n \n0000000608 00000 n \n0000000111 00000 n \n0000000589 00000 n \n0000000892 00000 n \n0000001261 00000 n \n0000000863 00000 n \n0000001562 00000 n \n0000003222 00000 n \ntrailer\n<< /Size 12 /Root 1 0 R /Info 2 0 R\n/ID []\n>>\nstartxref\n4690\n%%EOF\n", "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% home page at www.cactuscode.org)\n\\usepackage{../../../../doc/latex/cactus}\n\n\\begin{document}\n\n\\title{IOUtil}\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\\section{Introduction}\n\nThis document details the thorns provided in the standard Cactus distribution\nfor the output of grid variables, and describes how to set parameters for I/O\nand checkpointing/recovery using these thorns.\n\nInput and output of data (I/O) in Cactus is provided by infrastructure thorns,\nwhich interact with the flesh via a fixed interface, which is described in the\nUsers' Guide. The standard release of Cactus contains a number of thorns which\nprovide so-called I/O methods implementing the actual I/O in a variety of data\nformats and styles. All these provided I/O methods use thorn {\\bf IOUtil} which\nprovides general utilities for I/O (such as parsing\nparameter strings to decide which variables to output), and a general set of\nparameters which are inherited by the different I/O methods (such as the output\ndirectory). Thorn {\\bf IOUtil} by itself provides no I/O methods.\n\nMore information about I/O and visualisation of Cactus data can be found in the\nindividual I/O thorns, and in the {\\tt Visualization-HOWTO} available on the\nCactus web pages.\n\n\\section{I/O Methods in Cactus}\n\nCactus has several I/O methods for the output of grid variables in different\ndata formats and styles. Each I/O method comes with its own parameters by which\nit can be customised, and all methods are registered with the flesh, satisfying\nthe Cactus API, allowing them to be called directly from application thorns.\nAn I/O method registers itself with the flesh along with it's name, and these\nregistered names are the labels we now use to describe the various methods.\n\n\n\\begin{table}\n\\begin{center}\n\\begin{tabular}{|l|l|l|}\n \\hline\n {\\bf I/O method} & {\\bf Description} & {\\bf Providing Thorn}\\\\\n \\hline\n {\\tt Scalar} &\n output of scalars or grid array reductions in xgraph or gnuplot format &\n {\\tt CactusBase/IOBasic}\n\\\\\n {\\tt Info} &\n screen output of scalars or grid array reductions &\n {\\tt CactusBase/IOBasic}\n\\\\\n&&\\\\\n {\\tt IOASCII\\_1D} &\n 1D line output of grid arrays in xgraph or gnuplot format &\n {\\tt CactusBase/IOASCII}\n\\\\\n {\\tt IOASCII\\_2D} &\n 2D slice output of grid arrays in gnuplot format &\n {\\tt CactusBase/IOASCII}\n\\\\\n {\\tt IOASCII\\_3D} &\n full output of 3D grid arrays in gnuplot format &\n {\\tt CactusBase/IOASCII}\n\\\\\n&&\\\\\n {\\tt IOJpeg} &\n 2D slice output of grid arrays in jpeg image format &\n {\\tt CactusIO/IOJpeg}\n\\\\\n&&\\\\\n {\\tt IOHDF5} &\n full output of arbitrary grid variables in HDF5 format &\n {\\tt CactusPUGHIO/IOHDF5}\n\\\\\n&&\\\\\n {\\tt IOFlexIO\\_2D} &\n 2D slice output of grid arrays in FlexIO format &\n {\\tt CactusPUGHIO/IOFlexIO}\n\\\\\n {\\tt IOFlexIO} &\n full output of arbitrary grid variables in FlexIO format &\n {\\tt CactusPUGHIO/IOFlexIO}\n\\\\\n \\hline\n\\end{tabular}\n\\caption{Standard I/O methods provided with the Cactus distribution}\n\\label{one}\n\\end{center}\n\\end{table}\n\nThe standard provided Cactus I/O methods are shown in Table~\\ref{one}.\nAs described above, each of these I/O thorns inherit parameters from thorn\n{\\bf IOUtil}, which must be included in your ThornList\nand activated in your parameter files before any of these I/O methods\ncan be used. {\\bf IOUtil} allows you to set the default\nbehaviour for all the I/O methods described above, for example, setting\nthe parameter {\\tt IO::out\\_every = 1} will result in any chosen I/O method\nproviding output on each iteration. The default behaviour can be overridden\nby specific parameters for each method.\nFor example, you may want scalar and 1D output at every iteration\nbut computationally expensive 3D output only every 10th iteration,\nwith these files going into another directory on a scratch partition.\n\n\n\\section{Providing Your Own I/O Method}\n\nIf you as a Cactus developer have your own input/output routines and want to\nshare this functionality with other people you should do this by putting them\ninto an new I/O thorn and register them as an I/O method.\nA description on how to register a new I/O method with the flesh's I/O subsystem\ncan be found in the {\\it Infrastructure Thorn Writer's Guide} (as part of the\n{\\it Cactus User's Guide}).\n\nNew I/O thorns should always inherit from thorn {\\bf IOUtil} in order\nto reuse as much of the existing I/O infrastructure as possible, and to maintain\na uniform interface on how to use the I/O methods.\n\n\n%\\section{External Packages}\n%\n%NOTE: This section will not be filled out properly until the new treatment of external\n%packages is implemented.\n%\n%Some of the I/O methods used by Cactus require that external packages are installed and available\n%on your machine.\n%\n%\\begin{itemize}\n%\n%\\item{\\tt HDF5} {\\bf Hierarchical Data Format}\\\\\n%{\\tt http://hdf.ncsa.uiuc.edu/}\n%\n%\\item{\\tt IEEEIO} \\\\\n%{\\tt http://zeus.ncsa.uiuc.edu/}\n%\n%\\end{itemize}\n\n\\section{Standard Parameters}\n\nHere we describe a few of the standard parameters used by {\\bf IOUtil} to\ncontrol output.\n\\begin{itemize}\n\n \\item{\\tt IO::out\\_dir}\\\\\n The name of the directory to be used for output. All the I/O methods\n described here will write by default to this directory (which itself\n defaults to the current working directory). Individual methods have\n parameters which can direct their output to a different directory.\n\n \\item{\\tt IO::out\\_criterion}\\\\\n The criterion that decides when to output. The default is to\n output every so many iterations (see {\\tt IO::out\\_every}).\n\n \\item{\\tt IO::out\\_every}\\\\\n How often, in terms of iterations, each of the Cactus I/O methods\n will write\n output. Again, individual methods can set their own parameters to override\n this. The default is to never write output.\n\n \\item{\\tt IO::out\\_dt}\\\\\n How often, in terms of simulation time, each of the Cactus I/O\n methods will write output. Again, individual methods can set\n their own parameters to override this. The default is to never\n write output.\n\\end{itemize}\n\n\n\\section{Saving/Generating Parameter Files}\n\nThorn {\\bf IOUtil} can save a copy of the parameter file of a run, or can also\nautomatically generate a parameter file from all current parameter settings.\nThis is controlled by the {\\tt IO::parfile\\_write} parameter:\n\n\\begin{itemize}\n\n \\item{\\tt IO::parfile\\_write=\"copy\"}\\\\\n This is the default option, and makes an exact replica of the input\n parameter file in the standard output directory (this is particularly useful\n when the output directory is going to be archived).\n\n \\item{\\tt IO::parfile\\_write=\"generate\"}\\\\\n Generate a new parameter file from runtime information, containing the\n Cactus version, the name of the original parameter file, the run time/date,\n the host to run on, and the number of processors -- all on comment lines.\n Following this the parameter file contains the ActiveThorns list plus a\n sorted list of all active thorns' parameters which have been set in the\n original parameter file.\n\n \\item{\\tt IO::parfile\\_write=\"no\"}\\\\\n Switch off writing of a new parameter file.\n\n\\end{itemize}\n\nThe name of the new parameter file defaults to the original filename, unless the\nparameter {\\tt IO::parfile\\_name} is set. Note that an already existing file\nwith the chosen name will be overwritten unless it is identical with the\noriginal parameter file, or if Cactus was recovered from a checkpoint (in which\ncase you don't want to overwrite an existing parameter file with your recovery\nparameter file).\n\n\n\\section{I/O Modes}\n\\label{iomodes}\nFor a run on multiple processors, scalar, 1D, and 2D output will always be\nwritten from only processor zero (that is, required data from all other\nprocessors will be sent to processor zero, which then outputs all the gathered\ndata). For full-dimensional output of grid arrays this may become a quite expensive\noperation since output by only a single processor will probably result in an\nI/O bottleneck and delay further computation. For this reason Cactus offers\ndifferent I/O modes for such output which can be controlled by the\n{\\tt IO::out\\_mode} parameter, in combination with {\\tt IO::out\\_unchunked}\nand {\\tt IO::out\\_proc\\_every}. These parameters allow I/O to be optimised for\nyour particular machine architecture and needs:\n\n\\begin{itemize}\n \\item {\\tt IO::out\\_mode = \"onefile\"}\\\\\n As for the 1D and 2D I/O methods, writing to file is performed only\n by processor zero.\n This processor gathers all the output data from the other processors\n and then writes to a single file. The gathered grid array data from each\n processor can be either written in chunks ({\\tt IO::out\\_unchunked =\n \"no\"}) with each chunk containing the data from a single processor, or\n collected into a single global array before writing ({\\tt\n IO::out\\_unchunked = \"yes\"}). The default is to write the data in chunks.\n This can be changed by adding an option string to the group/variable name(s)\n in the {\\tt out\\_vars} parameter with the key {\\tt out\\_unchunked} and an\n associated string value {\\tt \"yes|no|true|false\"}.\n\n \\item {\\tt IO::out\\_mode = \"np\"}\\\\\n Output is written in parallel for groups of processors. Each group\n consists of {\\tt IO::out\\_proc\\_every} processors which have assigned one I/O\n processor which gathers data from the group and writes it to file. The\n chunked output will go into {\\tt IO::out\\_proc\\_every} files.\n The default number of processors in a group is eight.\n\n \\item {\\tt IO::out\\_mode = \"proc\"}\\\\\n This is the default output mode.\n Every processor writes its own chunk of data into a separate output file.\n\\end{itemize}\n\nProbably the single-processor {\\tt \"proc\"} mode is the most efficient output\nmode on machines with a fast I/O subsystem and many I/O nodes (e.g. a Linux\ncluster with local disks attached to each node) because it provides the highest\nparallelity for outputting data. Note that on very large numbers of processors\nyou may have to fall back to {\\tt \"np\"}, doing output by every so many processors,\nmode if the system limit of maximum open file descriptors is exceeded (this is\ntrue for large jobs on a T3E).\n\nWhile the {\\tt \"np\"} and {\\tt \"proc\"} I/O modes are fast for outputting large\namounts of data from all or a group of processors in parallel, they have\nthe disadvantage of writing chunked files. These files then have to be\nrecombined during a postprocessing phase so that the final unchunked data can be\nvisualized by standard tools. For that purpose a recombiner utility program is\nprovided by the thorns offering parallel I/O methods.\n\n\n\\section{Output of Hyperslab Data}\n\nWhile some I/O methods ({\\tt IOHDF5, IOFlexIO}) can dump the full\ncontents of a multidimensional CCTK variable, others such as {\\tt IOASCII\\_1D}\nand {\\tt IOASCII\\_2D} will output only a subset of the data (e.g. 1D lines or 2D\nplanes of 3D grid functions).\nSuch a subset (called a {\\it hyperslab}) is generally defined as an orthogonal\nregion into the multidimensional dataset, with a start point and a length in any\ndirection, and an optional downsampling factor.\n\nThorn {\\bf IOUtil} defines a set of hyperslab parameters for all\nI/O methods which determine the default positions of 1D line or 2D slice output\nalong the axes. I/O thorns can also define their own hyperslab parameters\nwhich then will overwrite the defaults provided by {\\bf IOUtil}.\n\n\\begin{itemize}\n \\item {\\tt IO::out\\_[xyz]line\\_[xyz]}\\\\\n specifies the slice center for 1D x,y,z-line output by coordinate values\n of the underlying physical grid\n \\item {\\tt IO::out\\_[xyz]line\\_[xyz]i}\\\\\n specifies the slice center of 1D x,y,z-line output by index points\n of the underlying computational grid\n \\item {\\tt IO::out\\_[\\{xy\\}\\{xz\\}\\{yz\\}]plane\\_[xyz]}\\\\\n specifies the slice center of 2D xy,xz,yz-plane output by coordinate values\n of the underlying physical grid\n \\item {\\tt IO::out\\_[\\{xy\\}\\{xz\\}\\{yz\\}]plane\\_[xyz]}i\\\\\n specifies the slice center of 2D xy,xz,yz-plane output by index points\n of the underlying computational grid\n \\item {\\tt IO::out\\_downsample\\_[xyz]}\\\\\n specifies the downsampling factor for output in every direction\n\\end{itemize}\n\nSetting the index points for the slice centers in a parameter file has\nprecedence over setting their location by coordinate values.\nIf nothing was specified the default values of {\\tt IO::out\\_[xyz]line\\_[xyz]}\nand {\\tt IO::out\\_[\\{xy\\}\\{xz\\}\\{yz\\}]plane\\_[xyz]} will be used.\nThese are set to be all zeros which causes the output to go through the\ncoordinate system's origin or the closest grid point to this (see figure\n\\ref{default_1D_output} for an example).\n\n\\begin{figure}[ht]\n\\begin{center}\n\\includegraphics{1Dlines_in_box}\n\\includegraphics{1Dlines_in_xyBitant}\n\\end{center}\n\\caption{Default 1D {\\it x,y,z}-line output for a 3D grid in box mode (left) and {\\it xy}-bitant mode (right)}\n\\label{default_1D_output}\n\\end{figure}\n\nIf the coordinate values specified in {\\tt IO::out\\_[xyz]line\\_[xyz]}\nor {\\tt IO::out\\_[\\{xy\\}\\{xz\\}\\{yz\\}]plane\\_[xyz]} lie outside the physical\ngrid, the slice center simply reverts to the center of the box in that\ndirection. This fallback method method can be changed to using 0-slices instead\nby setting the corresponding {\\tt IO::out\\_[xyz]line\\_[xyz]i}\nand {\\tt IO::out\\_[\\{xy\\}\\{xz\\}\\{yz\\}]plane\\_[xyz]i} parameter(s) to the value\n{\\tt -2}.\n\nAlthough they are not hyperslabs by the above definition, output of 1D diagonals\nfor 3D grid arrays is also supported by I/O method {\\tt IOASCII\\_1D} but has the\nrestriction that the line will always start in the bottom-left corner of the\ncomputational grid and steadily rise by one grid point in every direction (see\nfigure \\ref{default_diagonal_output} for an example).\n\n\\begin{figure}[ht]\n\\begin{center}\n\\includegraphics{diagonal_in_cubic}\n\\includegraphics{diagonal_in_noncubic}\n\\end{center}\n\\caption{1D diagonal output for a 3D cubical (left) and non-cubical (right)\ncomputational grid}\n\\label{default_diagonal_output}\n\\end{figure}\n\n\n\\section{Data Filenames}\n\nThe standard I/O thorns in Cactus make use of a consistent set of filenames\nand extensions, which identify the variables and data format used in the file.\nThe filenames are listed in the following table.\n%The filenames are listed in Table~\\ref{filename_table},\n%and the extensions in Table~\\ref{filename_extensions_table}\n\n\\begin{table}[htb]\n\\begin{center}\n\\label{filename_table}\n\\begin{tabular}{|l|l|}\n \\hline\n {\\bf I/O method} & {\\bf Filename for output of variable {\\tt var}}\\\\\n \\hline\n {\\tt Info} & only outputs to screen\\\\\n {\\tt Scalar} & {\\tt .\\{asc|xg\\}} for scalar variables\\\\\n & {\\tt \\_.\\{asc|xg\\}} for reduction values from grid arrays\\\\\n {\\tt IOASCII\\_1D} & {\\tt \\_\\_[][center\\_j>].\\{asc|xg\\}}\\\\\n {\\tt IOASCII\\_2D} & {\\tt \\_\\_[
].asc}\\\\\n {\\tt IOASCII\\_3D} & {\\tt \\_3D.asc}\\\\\n {\\tt IOJpeg} & {\\tt \\_\\_[
].jpeg}\\\\\n {\\tt IOHDF5} & {\\tt \\_3D.h5}\\\\\n {\\tt IOFlexIO\\_2D} & {\\tt \\_2D.ieee}\\\\\n {\\tt IOFlexIO} & {\\tt \\_3D.ieee}\\\\\n \\hline\n\\end{tabular}\n\\caption{Filenames used by standard I/O thorns}\n\\end{center}\n\\end{table}\n\n%\\begin{table}[htb]\n%\\begin{center}\n%\\label{filename_extensions_table}\n%\\begin{tabular}{|c|l|l|}\n%\\hline\n%{\\bf Extension} & {\\bf Description} & {\\bf Thorn} \\\\\n% \\hline\n% {\\tt .xl} & 1D line plots in {\\it x}-direction & {\\tt CactusBase/IOASCII}\\\\\n% {\\tt .yl} & 1D line plots in {\\it y}-direction & {\\tt CactusBase/IOASCII}\\\\\n% {\\tt .zl} & 1D line plots in {\\it z}-direction & {\\tt CactusBase/IOASCII}\\\\\n% {\\tt .dl} & 1D diagonal line plots & {\\tt CactusBase/IOASCII}\\\\\n% {\\tt .tl} & traceline plots over time & {\\tt CactusBase/IOBasic}\\\\\n% \\hline\n%\\end{tabular}\n%\\caption{File extensions used by the standard I/O thorns}\n%\\end{center}\n%\\end{table}\n\n\n\\section{Checkpointing and Recovery in Cactus}\n\\label{cp_recovery}\n\nThe I/O methods for arbitrary output of CCTK variables also provide functionality for {\\it checkpointing}\nand {\\it recovery}. A checkpoint is a snapshot of the current state of the\nsimulation ({\\it i.e.} the contents of all the grid variables and the parameter\nsettings) at a chosen timestep. Each checkpoint is saved into a\n{\\it checkpoint file} which can be used to restart a new simulation at a later\ntime, recreating the exact state at which it was checkpointed.\n\nCheckpointing is especially useful when running Cactus in batch queue systems\nwhere jobs get only limited CPU time. A more advanced use of checkpointing\nwould be to restart your simulation after a crash or a problem had developed,\nusing a different parameter set recovering from the latest stable timestep.\nAdditionally, for performing parameter studies, compute-intensive\ninitial data can be calculated just once and saved in a checkpoint file\nfrom which each job can be started.\n\nAgain, thorn {\\bf IOUtil} provides general checkpoint \\& recovery\nparameters. The most important ones are:\n\\begin{itemize}\n \\item {\\tt IO::checkpoint\\_every} (steerable)\\\\\n specifies how often to write a evolution checkpoint in terms of iteration\n number.\n \\item {\\tt IO::checkpoint\\_every\\_walltime\\_hours} (steerable)\\\\\n specifies how often to write a evolution checkpoint in terms of\n wall time. Checkpointing will be triggered if either of these\n conditions is met.\n \\item {\\tt IO::checkpoint\\_next} (steerable)\\\\\n triggers a checkpoint at the end of the current iteration. This\n flag will be reset afterwards.\n \\item {\\tt IO::checkpoint\\_ID}\\\\\n triggers a checkpoint of initial data\n \\item {\\tt IO::checkpoint\\_on\\_terminate} (steerable)\\\\\n triggers a checkpoint at the end of the last iteration of a simulation run\n \\item {\\tt IO::checkpoint\\_file} (steerable)\\\\\n holds the basename for evolution checkpoint file(s) to create\\\\\n Iteration number and file extension are appended by the individual I/O\n method used to write the checkpoint.\n \\item {\\tt IO::checkpoint\\_ID\\_file} (steerable)\\\\\n holds the basename for initial data checkpoint file(s) to create\\\\\n Iteration number and file extension are appended by the individual I/O\n method used to write the checkpoint.\n \\item {\\tt IO::checkpoint\\_dir}\\\\\n names the directory where checkpoint files are stored\n \\item {\\tt IO::checkpoint\\_keep} (steerable)\\\\\n specifies how many evolution checkpoints should be kept\\\\\n The default value of $1$ means that only the latest evolution checkpoint\n is kept and older checkpoints are removed in order to save disk space.\n Setting {\\tt IO::checkpoint\\_keep} to a positive value will keep so many\n evolution checkpoints around. A value of $-1$ will keep all (future) checkpoints.\n \\item {\\tt IO::recover\\_and\\_remove}\\\\\n determines whether the checkpoint file that the current simulation has\n been successfully recovered from, should also be subject of removal,\n according to the setting of {\\tt IO::checkpoint\\_keep}\n \\item {\\tt IO::recover}\\\\\n keyword parameter telling if/how to recover.\\\\\n Choices are {\\tt \"no\"}, {\\tt \"manual\"}, {\\tt \"auto\"}, and {\\tt \"autoprobe\"}.\n \\item {\\tt IO::recover\\_file}\\\\\n basename of the recovery file\\\\\n Iteration number and file extension are appended by the individual I/O\n method used to recover from the recovery file.\n \\item {\\tt IO::recover\\_dir}\\\\\n directory where the recovery file is located\n \\item {\\tt IO::truncate\\_files\\_after\\_recovering}\\\\\n whether or not to truncate already existing output files after recovering\n\\end{itemize}\n\nTo checkpoint your simulation, you need to enable checkpointing by setting\nthe boolean parameter {\\tt checkpoint}, for one of the appropriate I/O methods to\n{\\tt yes}.\nCheckpoint filenames consist of a basename (as specified in {\\tt\nIO::checkpoint\\_file}) followed by {\\tt \".chkpt.it\\_$<$iteration\\_number$>$\"}\nplus the file extension indicating the file format ({\\tt \"*.ieee\"} for IEEEIO\ndata from {\\tt CactusPUGHIO/IOFlexIO}, or {\\tt \"*.h5\"} for HDF5 data from\n{\\tt CactusPUGHIO/IOHDF5}).\n\nUse the {\\tt \"manual\"} mode to recover from a specific checkpoint file by adding\nthe iteration number to the basename parameter.\n\nThe {\\tt \"auto\"} recovery mode will automatically recover from the latest\ncheckpoint file found in the recovery directory.\nIn this case {\\tt IO::recover\\_file} should contain the basename only (without\nany iteration number).\n\nThe {\\tt \"autoprobe\"} recovery mode is similar to the {\\tt \"auto\"} mode except\nthat it would not stop the code if no checkpoint file was found but only print\na warning message and then continue with the simulation. This mode allows you\nto enable checkpointing and recovery in the same parameter file and use that\nwithout any changes to restart your simulation. On the other hand, you are\nresponsible now for making the checkpoint/recovery directory/file parameters\nmatch --- a mismatch will not be detected by Cactus in order to terminate it.\nInstead the simulation would always start from initial data without any\nrecovery.\n\nBecause the same I/O methods implement both output of arbitrary data and checkpoint\nfiles, the same I/O modes are used (see Section~\\ref{iomodes}).\nNote that the recovery routines in Cactus can process both chunked and unchunked\ncheckpoint files if you restart on the same number of processors --- no\nrecombination is needed here. That's why you should always use one of the\nparallel I/O modes for checkpointing. If you want to restart on a different\nnumber of processors, you first need to recombine the data in the checkpoint\nfile(s) to create a single file with unchunked data.\nNote that Cactus checkpoint files are platform independent so you can restart\nfrom your checkpoint file on a different machine/architecture.\n\nBy default, existing output files will be appended to rather than truncated after\nsuccessful recovery. If you don't want this, you can force I/O methods to\nalways truncate existing output files. Thorn {\\bf IOUtil} provides an aliased\nfunction for other I/O thorns to call:\n\\begin{verbatim}\n CCTK_INT FUNCTION IO_TruncateOutputFiles (CCTK_POINTER_TO_CONST IN cctkGH)\n\\end{verbatim}\nThis function simply returns 1 or 0 if output files should or should not be truncated.\n\n\\vskip .5cm\n\\noindent{\\bf WARNING:}\n\n\\noindent\nCheckpointing and recovery should {\\bf always} be tested for a new thorn set.\nThis is because only Cactus grid variables and parameters are saved in a\ncheckpoint file. If a thorn has made use of saved local variables, the state of\na recovered simulation may differ from the original run. To test checkpointing\nand recovery, simply perform one run of say 10 timesteps, and compare output\ndata with a checkpointed and recovered run at say the 5th timestep.\nThe output data should match exactly if recovery was successful.\n\n\n\\section{Reading Data from Files into Cactus}\n\nThe very same routines which implement checkpointing/recovery functionality\nin the {\\tt IOHDF5} and {\\tt IOFlexIO} thorns are also used to provide\nfile reader capabilities within Cactus. They enable users to read variables,\nwhose contents were written to files in HDF5 or IEEEIO data format, back into\nCactus at a later time. This is especially useful if compute-intensive\ninitial data is calculated only once and stored in a file. Such data\ncan then be read back in at startup and immediately used by following evolution\nruns.\n\nThe following {\\bf IOUtil} parameters exist to specify what variables should be\nread from file(s) as initial data:\n\n\\begin{itemize}\n \\item {\\tt IO::filereader\\_ID\\_dir}\\\\\n root directory for files to be read\n \\item {\\tt IO::filereader\\_ID\\_files}\\\\\n list of files to read in as initial data (multiple filenames must be\n separated by spaces)\\\\\n The same file naming conventions (what I/O mode used, which iteration\n number) apply as for checkpoint files.\n \\item {\\tt IO::filereader\\_ID\\_vars}\\\\\n list of CCTK variables to read in from the given initial data files\n (variables are identified by their full name, multiple variable names must\n be separated by spaces)\\\\\n This is useful if a datafile contains multiple variables but only some of\n them should be read. Thus it is possible to recover distinguished variables\n from a full checkpoint file.\\\\\n Note that if the file contains several timesteps of the same variable only\n the last one is taken by default. This can be changed by adding an option\n string with the key {\\tt cctk\\_iteration} and an associated integer scalar\n value to the variable name denoting the iteration number to choose, like in\n {\\tt IO::filereader\\_ID\\_vars = \"wavetoy::phi\\{ cctk\\_iteration = 10 \\}\"}.\n The file reader supports a further option {\\tt alias} and an associated\n string scalar value which can be used to set the dataset in the initial\n data files that will be read into this variable. For example {\\tt\n IO::filereader\\_ID\\_vars = \"wavetoy::phi\\{ alias='wavetoy::psi' \\}\"} will\n read the data of variable {\\tt wavetoy::psi} from file into \n {\\tt wavetoy::phi}. This option requires that explicit variable names are\n used, group names are not supported for the {\\tt alias} option.\n\\end{itemize}\n\nThorn {\\bf IOUtil} also provides a filereader API which can be called\nby any application thorn at any time. It gets passed the equivalent information\nto the filereader parameters, plus a pointer to the underlying CCTK grid\nhierarchy. The return code denotes the total number of variables recovered by\nthe filereader.\n\nC API:\n\\begin{verbatim}\n #include \"CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h\"\n\n\n int IOUtil_RecoverVarsFromDatafiles (cGH *GH,\n const char *in_files,\n const char *in_vars);\n\\end{verbatim}\n\nFortran API:\n\\begin{verbatim}\n call IOUtil_RecoverVarsFromDatafiles (result, GH, in_files, in_vars)\n\n integer result\n CCTK_POINTER GH\n character*(*) in_files\n character*(*) in_vars\n\\end{verbatim}\n\nIf data is to be imported from files which were not created by {\\tt IOHDF5} or\n{\\tt IOFlexIO} it needs to be converted first into the appropriate HDF5 or\nIEEEIO file format and the file layout which either one of these thorns uses.\nThis is described in detail in the thorns' documentation, along with a simple C\nsource file which can be used as a template to build your own data converter\nprogram.\n\n\n\\section{Example Parameter Files}\n\nHere we give examples of the parameters for the different I/O methods.\n\n\\begin{itemize}\n\\item{\\bf Output information to screen using {\\tt IOBasic's \"Info\"}} I/O method\n\\begin{verbatim}\n ActiveThorns = \"IOBasic IOUtil PUGHReduce ...\"\n\n # Output using all methods on iteration 0, 10, 20, ...\n IO::out_every = 10\n\n # Group of variables to output to screen\n IOBasic::outInfo_vars = \"evolve::vars\"\n\\end{verbatim}\n\n\\item{\\bf Scalar Output from {\\tt IOBasic's \"Scalar\"} I/O method}\n\\begin{verbatim}\n ActiveThorns = \"IOBasic IOUtil PUGHReduce ...\"\n\n # Output vars using scalar method on iteration 0, 10, 20, ...\n IOBasic::outScalar_every = 10\n\n # Group of variables to output to file\n IOBasic::outScalar_vars = \"evolve::vars\"\n\\end{verbatim}\n\n\\item{\\bf ASCII 1D and 2D Output with {\\tt IOASCII's \"IOASCII\\_1D\"} and\n{\\tt \"IOASCII\\_2D\"} I/O methods}\n\\begin{verbatim}\n ActiveThorns = \"IOASCII IOUtil PUGHSlab ...\"\n\n # Output vars in 1D on iteration 0, 10, 20, ...\n IOASCII::out1D_every = 10\n\n # Output vars in 2D on iteration 0, 50, 100, ...\n IOASCII::out2D_every = 50\n\\end{verbatim}\n\n\\item{\\bf HDF5 Output with {\\tt IOHDF5's \"IOHDF5\"} I/O method}\n\\begin{verbatim}\n ActiveThorns = \"IOHDF5 IOUtil PUGHSlab ...\"\n\n # Output vars in HDF5 format on iteration 0, 5, 10, ...\n IOHDF5::out_every = 5\n\n # Group of variables to output\n IOHDF5::out_vars = \"evolve::vars\"\n\n # Special I/O directory for HDF5 output\n IOHDF5::out_dir = \"/scratch/tmp\"\n\n # Full output unchunked to one file\n # (Only using a small number of processors)\n IO::out_mode = \"onefile\"\n IO::out_unchunked = \"yes\"\n\n # Downsample full data by a factor of 3 in each direction\n IO::out_downsample_x = 3\n IO::out_downsample_y = 3\n IO::out_downsample_z = 3\n\\end{verbatim}\n\n\\item{\\bf IEEEIO 2D hyperslab and full output using {\\tt IOFlexIO's \"IOFlexIO\\_2D\"} and {\\tt \"IOFlexIO\"} I/O methods}\n\\begin{verbatim}\n ActiveThorns = \"IOFlexIO FlexIO IOUtil PUGHSlab ...\"\n\n # Output vars in 2D IEEEIO format on iteration 0, 100, 200, ...\n IOFlexIO::out2D_every = 100\n\n # Output vars in IEEEIO format on iteration 0, 5, 10, ...\n IOFlexIO::out_every = 5\n\n # Group of variables to output to file for each method\n IOFlexIO::out2D_vars = \"evolve::vars\"\n IOFlexIO::out_vars = \"evolve::vars\"\n\n # 2D output goes into standard I/O directory\n IO::out_dir = \"test\"\n\n # Special I/O directory for full output\n IOFlexIO::out_dir = \"/scratch/tmp\"\n\n # Full output chunked to one file for every eight processors\n # (Run on large number of processors)\n IO::out_mode = \"np\"\n IO::out_proc_every = 8\n IO::out_unchunked = \"no\"\n\n # Downsample full data by a factor of 3 in each direction\n IO::out_downsample_x = 3\n IO::out_downsample_y = 3\n IO::out_downsample_z = 3\n\\end{verbatim}\n\n\\item{\\bf Checkpointing using thorn {\\tt IOFlexIO}}\n\\begin{verbatim}\n ActiveThorns = \"IOFlexIO FlexIO IOUtil PUGHSlab ...\"\n\n # Use IEEEIO data format for checkpoint files\n IOFlexIO::checkpoint = \"yes\"\n\n # Make a new checkpoint file every 300 iterations\n IO::checkpoint_every = 300\n\n # Name and directory of checkpoint file\n IO::checkpoint_file = \"run5\"\n IO::checkpoint_dir = \"/scratch/tmp\"\n\\end{verbatim}\n\n\\item{\\bf Recovering from a checkpoint file}\n\\begin{verbatim}\n ActiveThorns = \"IOFlexIO FlexIO IOUtil PUGHSlab ...\"\n\n # automatically choose the latest checkpoint file\n IO::recover = \"auto\"\n\n # Name and directory of checkpoint file to recover from\n IO::recover_file = \"run5\"\n IO::recover_dir = \"/scratch/tmp\"\n\\end{verbatim}\n\n\\end{itemize}\n\n\n\\section{Providing Your own Checkpointing/Recovery Method}\n\nThis section is for Cactus developers to describe how they can add a new method\nfor checkpointing/recovery using the existing I/O parameters and the function\nAPI of thorn {\\bf IOUtil}.\nInheriting this functionality from thorn {\\bf IOUtil} helps you to reuse\nexisting code and maintain a uniform user interface on how to invoke different\ncheckpointing/recovery methods.\n\n\\subsection{Adding a Checkpointing Method}\n\nCheckpointing is similar to performing full output of an individual grid\nvariable, except that\n\n\\begin{enumerate}\n \\item the output is done for all grid variables existing in a grid hierarchy\n \\item in addition to the contents of all variables, also the current setting\n of all parameters is saved as well as some other information necessary for\n recovering from the checkpoint at a later time\n\\end{enumerate}\n\nA thorn routine providing this checkpointing capability should register itself\nwith the flesh's scheduler at the {\\tt CPINITIAL} (for initial data\ncheckpoints), {\\tt CHECKPOINT} (for periodic checkpoints of evolution\ndata), and {\\tt TERMINATE} time bins (for checkpointing the last timestep\nof a simulation).\n\nIt should also decide whether checkpointing is needed by evaluating the\ncorresponding checkpoint parameters of {\\bf IOUtil} (see section\n\\ref{cp_recovery}).\n\nBefore dumping the contents of a distributed grid array into a checkpoint\nfile the variable should be synchronized in case synchronization was not done before\nimplicitly by the scheduler.\n\nTo gather the current parameter values you can use the C routine\n\\begin{verbatim}\n char *IOUtil_GetAllParameters (const cGH *GH, int all);\n\\end{verbatim}\nfrom thorn {\\bf IOUtil}. This routine returns the parameter settings in an\nallocated single large string. Its second argument {\\tt all} flags whether all\nparameter settings should be gathered ($!= 0$) or just the ones which have been\nset before ($== 0$). Note that you should always save all parameters in a\ncheckpoint in order to reproduce the same state after recovery.\n\nAs additional data necessary for proper recovery, the following information\nmust be saved in a checkpoint file:\n\\begin{itemize}\n \\item the current main loop index (used by the driver as the main evolution\n loop index)\n \\item the current CCTK iteration number ({\\tt GH->cctk\\_iteration})\n \\item the physical simulation time ({\\tt GH->cctk\\_time})\n\\end{itemize}\n\nMoreover, information about the I/O mode used to create the checkpoint\n(chunked/unchunked, serial versus parallel I/O), the active thorns list, or\nthis run's Cactus version ID (for compatibility checking at recovery time) could\nbe relevant to save in a checkpoint.\n\n\n\\subsection{Adding a Recovery Method}\n\nRecovering from a checkpoint is a two step operation:\n\\begin{enumerate}\n \\item Right after reading the parameter file and finding out if recovery was\n requested, all the parameters are restored from the checkpoint file\n (overwriting any previous settings for non-steerable parameters).\n \\item After the flesh has created the grid hierarchy with all containing grid\n variables and the driver has set up storage for these, their contents is\n restored from the checkpoint (overwriting any previously initialized\n contents).\n\\end{enumerate}\n\nThe flesh provides the special time bins {\\tt RECOVER\\_PARAMETERS} and\n{\\tt RECOVER\\_VARIABLES} for these two steps (see also the chapter on\n{\\it Adding a Checkpointing/Recovery Method} in the {\\it Infrastructure Thorn\nWriter's Guide} as part of the {\\it Cactus User's Guide}).\\\\\n\nThorn {\\bf IOUtil} evaluates the recovery parameters (determines the recovery\nmode to use, construct the name(s) of the recovery file(s) etc.).\nIt also controls the recovery process by invoking the recovery methods of\nother I/O thorns, one after another until one method succeeded.\\\\\n\nA recovery method must provide a routine with the following prototype:\n\n\\begin{verbatim}\n int Recover (cGH *GH, const char *basefilename, int called_from);\n\\end{verbatim}\n\nThis routine will be invoked by {\\bf IOUtil} with the following arguments:\n\n\\begin{itemize}\n \\item a GH pointer refer to the grid hierarchy and its grid variables\\\\\n Note that this can also be a {\\tt NULL} pointer if the routine was called\n at {\\tt CP\\_RECOVER\\_PARAMETERS} when no grid hierarchy exists yet.\n\n \\item the basename of the checkpoint file to recover from\\\\\n This name is constructed by {\\bf IOUtil} from the settings of {\\tt\n IO::recovery\\_dir} and {\\tt IO::recover\\_file}. It will also include an\n iteration number if one of the {\\tt auto} recovery modes is used.\n The filename extension by which checkpoint files of different recovery\n methods are distinguished must be appended explicitly.\n\n \\item a flag identifying when the routine was called\\\\\n This can be one of the keywords {\\tt CP\\_INITIAL\\_DATA, CP\\_EVOLUTION\\_DATA,\n CP\\_RECOVER\\_PARAMETERS, CP\\_RECOVER\\_DATA}, or {\\tt FILEREADER\\_DATA}).\n This flag tells the routine what it should do when it is being called by\n {\\bf IOUtil}. Note that {\\bf IOUtil} assumes that the recovery method can\n also be used as a filereader routine here which is essentially the same\n as recovering (individual) grid variables from (data) files.\n\\end{itemize}\n\n\nTo perform the first step of recovery process, a recovery method must register\na routine with the flesh's scheduler at the {\\tt RECOVER\\_PARAMETERS}\ntime bin. This routine itself should call the {\\bf IOUtil} API\n\n\\begin{verbatim}\n int IOUtil_RecoverParameters (int (*recover_fn) (cGH *GH,\n const char *basefilename,\n int called_from),\n const char *file_extension,\n const char *file_type)\n\\end{verbatim}\n\nwhich will determine the recovery filename(s) and in turn invoke the actual\nrecovery method's routine as a callback function. The arguments to pass to this\nroutine are\n\n\\begin{itemize}\n \\item a function pointer {\\tt recover\\_fn} as a reference to the recovery\n method's actual recovery routine (as described above)\n\n \\item {\\tt file\\_extension} -- the filename extension for recovery files\n which are accepted by this recovery method\\\\\n When {\\bf IOUtil} constructs the recovery filename and searches for\n potential recovery files (in the {\\tt auto} recovery modes) it will only\n match filenames with the basename as given in the {\\tt IO::recovery\\_file}\n parameter, appended by {\\tt file\\_extension}.\n\n \\item {\\tt file\\_type} -- the type of checkpoint files which are accepted by\n this recovery method\\\\\n This is just a descriptive string to print some info output during recovery.\n\\end{itemize}\n\nThe routine registered at {\\tt RECOVER\\_PARAMETERS} should return to\nthe scheduler a negative value if parameter recovery failed for this recovery\nmethod for some reason (e.g. if no appropriate recovery file was found).\nThe scheduler will then continue with the next recovery method until one\nfinally succeeds (a positive value is returned). If none of the available\nrecovery methods were successful the flesh would stop the code.\n\nA value of zero should be returned to the scheduler to indicate that no\nrecovery was requested.\\\\\n\nThe second step during recovery --- restoring the contents of grid variables\nfrom the recovery file --- is invoked by thorn {\\bf IOUtil} which registers\na routine at {\\tt RECOVER\\_VARIABLES}. This routine calls all recovery\nmethods which were registered before with {\\bf IOUtil} via the API\n\n\\begin{verbatim}\n int IOUtil_RegisterRecover (const char *name,\n int (*recover_fn) (cGH *GH,\n const char *basefilename,\n int called_from));\n\\end{verbatim}\n\nWith this registration, all recovery method's actual recovery routines are made\nknown to {\\bf IOUtil}, along with a descriptive name under which they are\nregistered.\n\nAt {\\tt RECOVER\\_VARIABLES} thorn {\\bf IOUtil} will loop over all \navailable recovery routines (passing the same arguments as for parameter\nrecovery) until one succeeds (returns a positive value).\n\n% Do not delete next line\n% END CACTUS THORNGUIDE\n\n\\end{document}\n" } }