diff options
-rw-r--r-- | COPYRIGHT | 352 | ||||
-rw-r--r-- | README | 23 | ||||
-rw-r--r-- | doc/documentation.tex | 57 | ||||
-rw-r--r-- | interface.ccl | 6 | ||||
-rw-r--r-- | param.ccl | 126 | ||||
-rw-r--r-- | schedule.ccl | 10 | ||||
-rw-r--r-- | src/GHExtension.c | 276 | ||||
-rw-r--r-- | src/Output1D.c | 289 | ||||
-rw-r--r-- | src/Output2D.c | 289 | ||||
-rw-r--r-- | src/Startup.c | 76 | ||||
-rw-r--r-- | src/Write1D.c | 433 | ||||
-rw-r--r-- | src/Write2D.c | 365 | ||||
-rw-r--r-- | src/ioASCIIGH.h | 53 | ||||
-rw-r--r-- | src/make.code.defn | 5 | ||||
-rw-r--r-- | src/make.configuration.defn | 11 |
15 files changed, 2371 insertions, 0 deletions
diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..57b2896 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,352 @@ + + +This thorn is (c) Copyright the authors listed in the sources files. This +thorn is distributed under the GNU GPL with the specific exception that +the GNU GPL does not migrate to code linking to or using infrastructure +from this thorn. + +- The Cactus Team <cactus@cactuscode.org> + +************************************************************************** + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + + @@ -0,0 +1,23 @@ +Cactus Code Thorn IOASCII +Authors : Gabrielle Allen, Tom Goodale, Thomas Radke +CVS info : $Header$ +-------------------------------------------------------------------------- + +1. Purpose of the thorn + +This thorn does 1D and 2D output of 3D variables in ASCII format. + +1D output slices through the edge (in octant mode) or center +(in all origin-centered modes) of the grid in the x,y, and z directions. +If the grid is cubed it will also slice in the diagonal direction. +Ouput files can be processed with either gnuplot or xgraph. + +2D output is done for the xy, xz, and yz plane. +Ouput files can be processed with the splot command in gnuplot. + +The IO methods "IOASCII_1D" and "IOASCII_2D" are registered +which can be called by other thorns via CCTK_OutputVarAsByMethod() +to output a variable without specifying it in the parameter file. + + +2. Additional information diff --git a/doc/documentation.tex b/doc/documentation.tex new file mode 100644 index 0000000..cfd5919 --- /dev/null +++ b/doc/documentation.tex @@ -0,0 +1,57 @@ +% Thorn documentation template +\documentclass{article} +\begin{document} + +\title{IOASCII} +\author{Paul Walker} +\date{1998-1999} +\maketitle + +\abstract{Thorn IOASCII provides an IO method for 1D and 2D output of +grid arrays into files in ASCII format.} + +\section{Purpose} +Thorn IOASCII registers two IO methods named {\tt IOASCII\_1D} and +{\tt IOASCII\_2D} with the IO interface in the flesh.\\ +{\tt IOASCII\_1D} creates one-dimensional output of 3D grid functions and arrays +by slicing through the edge (in the octant case) or center (in all +origin centered cases) of the grid in the x, y, and z directions. +If your grid is cubed it will also slice in the diagonal direction. +Output for each direction can be selected individually via parameters.\\ +Data is written in ASCII format and goes into files named +{\tt "<GF\_name>.[xyzd]l"}. These files can be processed directly by either +xgraph or gnuplot (you can select the style of output via parameter +settings).\\\\ +% +{\tt IOASCII\_2D} outputs two-dimensional slices of grid functions and arrays +as xy, xz, and yz planes. Again, slicing is done through the edge +(in the octant case) or center (in all origin centered cases).\\ +Data is written in ASCII format and goes into files named +{\tt "<varname>\_2d\_[{xy}{xz}{yz}.gnuplot"}. These files can be visualized +by gnuplot using its {\it splot} command. +% +\newline +% +You obtain output by an IO method by either +% +\begin{itemize} + \item setting the appropriate IO parameters + \item calling one the routines of the IO function interface provided by the flesh +\end{itemize} +% +For a description of basic IO parameters and the IO function interface to +invoke IO methods by application thorns please see the documentation of thorn +IOUtil and the flesh. +% +\section{Comments} +% +Since IOASCII uses parameters from IOUtil +it also needs this IO skeleton thorn be compiled into Cactus and activated. +% +% Automatically created from the ccl files +% Do not worry for now. +\include{interface} +\include{param} +\include{schedule} + +\end{document} diff --git a/interface.ccl b/interface.ccl new file mode 100644 index 0000000..71a1a93 --- /dev/null +++ b/interface.ccl @@ -0,0 +1,6 @@ +# Interface definition for thorn IOASCII +# $Header$ + +implements: IOASCII +inherits: IO + diff --git a/param.ccl b/param.ccl new file mode 100644 index 0000000..aaf27db --- /dev/null +++ b/param.ccl @@ -0,0 +1,126 @@ +# Parameter definitions for thorn IOASCII +# $Header$ + + +############################################################################# +### declare IOASCII parameters +############################################################################# +private: + +########################## +# Directories to output to (overriden by outdir) +########################## +STRING outdir1D "Name of 1D ASCII output directory, overrides outdir" +{ + .* :: A regex which matces everything +} "." + +STRING outdir2D "Name of 2D ASCII output directory, overrides outdir" +{ + .* :: A regex which matces everything +} "." + + +########################## +# What variables to output +########################## +STRING out1D_vars "Variables to output in 1D ASCII file format" STEERABLE = ALWAYS +{ + .* :: A regex which matces everything +} "" + +STRING out2D_vars "Variables to output in 2D ASCII file format" STEERABLE = ALWAYS +{ + .* :: A regex which matces everything +} "" + + +######################## +# How often to do output +######################## +INT out1D_every "How often to do 1D ASCII output, overrides out_every" STEERABLE = ALWAYS +{ + -1:* :: "Values <= 0 disable 1D output" +} -1 + +INT out2D_every "How often to do 2D ASCII output, overrides out_every" STEERABLE = ALWAYS +{ + -1:* :: "Values <= 0 disable 2D output" +} -1 + + +################# +# output style +################# +KEYWORD out_style "Which style for 1D ASCII output" +{ + "gnuplot" :: "output readable by gnuplot" + "xgraph" :: "output readable by xgraph" +} "xgraph" + +KEYWORD out_format "Which format for ASCII output" STEERABLE = ALWAYS +{ + "e" :: "output in exponential notation" + "f" :: "output in floating point notation" +} "f" + +####################### +# Specific to 1D output +# Choosing what output to do +####################### +BOOLEAN out1D_x "Do 1D IOASCII output in the x-direction" STEERABLE = ALWAYS +{ +} "yes" +BOOLEAN out1D_y "Do 1D IOASCII output in the y-direction" STEERABLE = ALWAYS +{ +} "yes" +BOOLEAN out1D_z "Do 1D IOASCII output in the z-direction" STEERABLE = ALWAYS +{ +} "yes" +BOOLEAN out1D_d "Do 1D IOASCII output in the diagonal-direction" STEERABLE = ALWAYS +{ +} "yes" + + +############################################################################# +### import grid parameters +############################################################################# +shares: grid + +USES KEYWORD domain "" +{ +} + +USES KEYWORD bitant_plane "" +{ +} + + +############################################################################# +### import IOUtil parameters +############################################################################# +shares: IO + +#################### +# Output directories +#################### +USES STRING outdir "" +{ +} + + +######################## +# How often to do output +######################## +USES INT out_every "" +{ + : :: +} + + +################ +# various things +################ +USES BOOLEAN verbose "" +{ +} diff --git a/schedule.ccl b/schedule.ccl new file mode 100644 index 0000000..6044fcb --- /dev/null +++ b/schedule.ccl @@ -0,0 +1,10 @@ +# Schedule definitions for thorn IOASCII +# $Header$ + +######################################################################## +### register IOASCII routines +######################################################################## +schedule IOASCII_Startup at STARTUP after IOUtil_Startup +{ + LANG:C +} "Startup routine" diff --git a/src/GHExtension.c b/src/GHExtension.c new file mode 100644 index 0000000..0444233 --- /dev/null +++ b/src/GHExtension.c @@ -0,0 +1,276 @@ + /*@@ + @file GHExtension.c + @date Tue 9th Feb 1999 + @author Gabrielle Allen + @desc + IO GH extension stuff. + @enddesc + @history + @hauthor Thomas Radke @hdate 16 Mar 1999 + @hdesc Added parameters for 2D and 3D output + @hauthor Thomas Radke @hdate 01 Apr 1999 + @hdesc check parameter symmetry instead of grid in Automatic1DLines() + @hauthor Gerd Lanfermann @hdate 01 Apr 2000 + @hdesc fixed out in bitant / octant mode + @endhistory + @@*/ + +/*#define DEBUGME*/ + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "CactusBase/IOUtil/src/ioGH.h" +#include "ioASCIIGH.h" + + +/* local function prototypes */ +void Automatic1DLines (cGH *GH); + + +void *IOASCII_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) +{ + asciiioGH *newGH; + + newGH = (asciiioGH *) malloc (sizeof (asciiioGH)); + newGH->do_out1D = (char *) malloc (CCTK_NumVars () * sizeof (char)); + newGH->do_out2D = (char *) malloc (CCTK_NumVars () * sizeof (char)); + newGH->out1D_last = (int *) malloc (CCTK_NumVars () * sizeof (int)); + newGH->out2D_last = (int *) malloc (CCTK_NumVars () * sizeof (int)); + + return newGH; +} + + +int IOASCII_InitGH (cGH *GH) +{ + DECLARE_CCTK_PARAMETERS + int i; + asciiioGH *myGH; + const cParamData *paramdata; + + + /* get the handle for IOASCII extensions */ + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + /* How often to output */ + myGH->out1D_every = out_every > 0 ? out_every : -1; + if (out1D_every > 0) + { + myGH->out1D_every = out1D_every; + } + myGH->out2D_every = out_every > 0 ? out_every : -1; + if (out2D_every > 0) + { + myGH->out2D_every = out2D_every; + } + + ParseVarsForOutput (out1D_vars, myGH->do_out1D); + ParseVarsForOutput (out2D_vars, myGH->do_out2D); + + /* Deal with the output directories */ + /* Check whether "outdirXD" was set. + If so take this dir otherwise default to "IO::outdir" */ + paramdata = CCTK_ParameterData ("outdir1D", CCTK_THORNSTRING); + myGH->outdir1D = (paramdata && paramdata->n_set > 0) ? + strdup (outdir1D) : strdup (outdir); + paramdata = CCTK_ParameterData ("outdir2D", CCTK_THORNSTRING); + myGH->outdir2D = (paramdata && paramdata->n_set > 0) ? + strdup (outdir2D) : strdup (outdir); + + /* create the output dir */ + if (CCTK_MyProc (GH) == 0) + { + i = CCTK_CreateDirectory (0755, myGH->outdir1D); + if (i < 0) + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Problem creating 1D output directory '%s'", myGH->outdir1D); + if (i > 0) + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "1D output directory '%s' already exists", myGH->outdir1D); + i = CCTK_CreateDirectory (0755, myGH->outdir2D); + if (i < 0) + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Problem creating 2D output directory '%s'", myGH->outdir2D); + if (i > 0) + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "2D output directory '%s' already exists", myGH->outdir2D); + } + + for (i=0; i<CCTK_NumVars(); i++) + { + myGH->out1D_last[i] = -1; + myGH->out2D_last[i] = -1; + } + + myGH->filenameList1D = NULL; + myGH->fileList_2D = NULL; + + /* Set up lines to plot */ + Automatic1DLines (GH); + + return 0; +} + + +/****************************************************************************/ +/* local routines */ +/****************************************************************************/ + /*@@ + @routine Automatic1DLines + @date Fri Apr 7 16:27:13 2000 + @author Gerd Lanfermann/Thomas Radke + @desc + 1D lines in Cactus are output along the center coordinate lines. + Here, the initial index to start the 1d slice is calculated and saved + int the GHextension, called IOASCII. + The structure spxyz[3][3]. (spxyz for slicing point ?), where the first + slot takes the direction to slice along (0~x, 1~y,...). The second + slot takes the starting coordinates. For example octant, + start at 1,1,1 (skip ghosts(0,0,0) and start "lower left corner"). + + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +void Automatic1DLines (cGH *GH) +{ + DECLARE_CCTK_PARAMETERS + int dim, dir; + asciiioGH *myGH; +#define SLICE_LOW(GH, dim) ((GH)->cctk_nghostzones [(dim)]) +#define SLICE_MED(GH, dim) ((GH)->cctk_gsh [(dim)] >> 1) + + + /* Get the handle for IOASCII extensions */ + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + /* 1D lines for Full mode */ + if (CCTK_Equals (domain, "full")) + { + for (dir = 0; dir < 3; dir++) + for (dim = 0; dim < 3; dim++) + if (dim == dir) + myGH->spxyz [dir][dim] = 0; + else + myGH->spxyz [dir][dim] = (GH->cctk_lsh [dim] == 1) ? + 0 : SLICE_MED (GH, dim); +for (dir = 0; dir < 3; dir++) +{ + printf ("spxyz [%d] = ", dir); + for (dim = 0; dim < 3; dim++) + printf ("%d ", myGH->spxyz [dir][dim]); + printf ("\n"); +} + } + /* 1D lines for Octant */ + else if (CCTK_Equals (domain, "octant")) + { + for (dir = 0; dir < 3; dir++) + for (dim = 0; dim < 3; dim++) + if (dim == dir) + myGH->spxyz [dir][dim] = 0; + else + myGH->spxyz [dir][dim] = (GH->cctk_lsh [dim] == 1) ? + 0 : SLICE_LOW (GH, dim); + } + /* 1D lines for Bitant (xy,xz,yx) */ + else if (CCTK_Equals (domain, "bitant")) + { + if (CCTK_Equals (bitant_plane, "xy")) + { + /* slice X-line */ + myGH->spxyz[0][0] = SLICE_LOW (GH, 0); + myGH->spxyz[0][1] = SLICE_MED (GH, 1); + myGH->spxyz[0][2] = SLICE_LOW (GH, 2); + + /* slice Y-line */ + myGH->spxyz[1][0] = SLICE_MED (GH, 0); + myGH->spxyz[1][1] = SLICE_LOW (GH, 1); + myGH->spxyz[1][2] = SLICE_LOW (GH, 2); + + /* slice Z-line */ + myGH->spxyz[2][0] = SLICE_MED (GH, 0); + myGH->spxyz[2][1] = SLICE_MED (GH, 1); + myGH->spxyz[2][2] = SLICE_LOW (GH, 2); + } + else if (CCTK_Equals(bitant_plane, "xz")) + { + /* slice X-line */ + myGH->spxyz[0][0] = SLICE_LOW (GH, 0); + myGH->spxyz[0][1] = SLICE_LOW (GH, 1); + myGH->spxyz[0][2] = SLICE_MED (GH, 2); + + /* slice Y-line */ + myGH->spxyz[1][0] = SLICE_MED (GH, 0); + myGH->spxyz[1][1] = SLICE_LOW (GH, 1); + myGH->spxyz[1][2] = SLICE_MED (GH, 2); + + /* slice Z-line */ + myGH->spxyz[2][0] = SLICE_MED (GH, 0); + myGH->spxyz[2][1] = SLICE_LOW (GH, 1); + myGH->spxyz[2][2] = SLICE_LOW (GH, 2); + } + else if (CCTK_Equals(bitant_plane, "yz")) + { + /* slice X-line */ + myGH->spxyz[0][0] = SLICE_LOW (GH, 0); + myGH->spxyz[0][1] = SLICE_MED (GH, 1); + myGH->spxyz[0][2] = SLICE_MED (GH, 2); + + /* slice Y-line */ + myGH->spxyz[1][0] = SLICE_LOW (GH, 0); + myGH->spxyz[1][1] = SLICE_LOW (GH, 1); + myGH->spxyz[1][2] = SLICE_MED (GH, 2); + + /* slice Z-line */ + myGH->spxyz[2][0] = SLICE_LOW (GH, 0); + myGH->spxyz[2][1] = SLICE_MED (GH, 1); + myGH->spxyz[2][2] = SLICE_LOW (GH, 2); + } + else + { + CCTK_WARN(1,"1D slicing not possible for this bitant. Gibs nich"); + } + } + /* 1D lines for quadrant, very untested, hardcoded quadrant */ + else if (CCTK_Equals (domain, "quadrant")) + { + /* slice X-line */ + myGH->spxyz[0][0] = SLICE_LOW (GH, 0); + myGH->spxyz[0][1] = SLICE_LOW (GH, 1); + myGH->spxyz[0][2] = SLICE_MED (GH, 2); + + /* slice Y-line */ + myGH->spxyz[1][0] = SLICE_LOW (GH, 0); + myGH->spxyz[1][1] = SLICE_LOW (GH, 1); + myGH->spxyz[1][2] = SLICE_MED (GH, 2); + + /* slice Z-line */ + myGH->spxyz[2][0] = SLICE_LOW (GH, 0); + myGH->spxyz[2][1] = SLICE_LOW (GH, 1); + myGH->spxyz[2][2] = SLICE_LOW (GH, 2); + } + else + { + CCTK_WARN(1,"No 1d slicing for that grid layout supported"); + } + +#ifdef DEBUGME + printf("X Slicing center: %d %d %d \n", + myGH->spxyz[0][0], myGH->spxyz[0][1], myGH->spxyz[0][2]); + printf("Y Slicing center: %d %d %d \n", + myGH->spxyz[1][0], myGH->spxyz[1][1], myGH->spxyz[1][2]); + printf("Z Slicing center: %d %d %d \n", + myGH->spxyz[2][0], myGH->spxyz[2][1], myGH->spxyz[2][2]); +#endif + +} diff --git a/src/Output1D.c b/src/Output1D.c new file mode 100644 index 0000000..c42c5a6 --- /dev/null +++ b/src/Output1D.c @@ -0,0 +1,289 @@ + /*@@ + @file IO_Output1D.c + @date Tue Jan 9 1999 + @author Gabrielle Allen + @desc + Functions to deal with 1D output of GFs + @enddesc + @@*/ + +/*#define IO_DEBUG*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "CactusBase/IOUtil/src/ioGH.h" +#include "ioASCIIGH.h" + +/* function prototypes */ +int IOASCII_TimeFor1D (cGH *GH, int index); +static void CheckSteerableParameters (asciiioGH *myGH); + + +/*@@ + @routine IOASCII_Output1DGH + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Loops over all variables and outputs them if necessary + @enddesc + @calledby CCTK_OutputGH ("IOASCII") + @history + + @endhistory + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @endvar +@@*/ +int IOASCII_Output1DGH (cGH *GH) +{ + int index; + asciiioGH *myGH; + const char *name; + + + /* Get the GH extensions for IOUtil and IOASCII */ + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + CheckSteerableParameters (myGH); + + /* Return if no output is required */ + if (myGH->out1D_every <= 0) + { + return (0); + } + + /* Loop over all variables */ + for (index = 0; index < CCTK_NumVars (); index++) + { + + /* Check if this variable should be output */ + if (! IOASCII_TimeFor1D (GH, index)) + { + continue; + } + + /* Get the variable name for this index (for filename) */ + name = CCTK_VarName (index); + +#ifdef IO_DEBUG + printf ("\nIn IOASCII Output1DGH\n---------------------\n"); + printf (" Index = %d\n", index); + printf (" Variable = -%s-\n", name); + printf (" On iteration %d\n", GH->cctk_iteration); + printf (" Last output iteration was = %d\n", myGH->out1D_last [index]); +#endif + + /* Make the IO call */ + IOASCII_Write1D (GH, index, name); + + /* Register GF as having 1D output this iteration */ + myGH->out1D_last [index] = GH->cctk_iteration; + + } /* end of loop over all variables */ + + return (0); + + +} + + +/*@@ + @routine IOASCII_Output1DVarAs + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + unconditional output of a variable using the IOASCII output method + @enddesc + @calledby IOASCII_Output1DGH, CCTK_OutputVarAsByMethod ("IOASCII") + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @vcomment + @endvar + @var fullname + @vdesc complete name of variable to output + @vtype const char * + @vio in + @vcomment + @endvar + @var alias + @vdesc alias name of variable to output (used to generate output filename) + @vtype const char * + @vio in + @vcomment + @endvar +@@*/ +int IOASCII_Output1DVarAs (cGH *GH, const char *fullname, const char *alias) +{ + int index; + + + index = CCTK_VarIndex (fullname); + +#ifdef IO_DEBUG + printf ("\nIn IOASCII Output1DVarAs\n-------------------\n"); + printf (" Fullname = -%s-\n", fullname); + printf (" Alias = -%s-\n", alias); + printf (" Index = %d\n", index); +#endif + + IOASCII_Write1D (GH, index, alias); + + return (0); +} + + + /*@@ + @routine IOASCII_TimeFor1D + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Decides if it is time to output a variable using the IO 1D output + method + @enddesc + @calledby IOASCII_Output1DGH + @history + + @endhistory + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @vcomment + @endvar + @var index + @vdesc index of variable + @vtype int + @vio in + @vcomment + @endvar +@@*/ +int IOASCII_TimeFor1D (cGH *GH, int index) +{ + int return_type; + int grouptype; + asciiioGH *myGH; + DECLARE_CCTK_PARAMETERS + + + /* Default is do not do output */ + return_type = 0; + + /* Get the GH extensions for IOUtil and IOASCII */ + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + CheckSteerableParameters (myGH); + + /* return if no output requested */ + if (myGH->out1D_every <= 0) + return (0); + + grouptype = CCTK_GroupTypeFromVarI (index); + + /* Check this GF should be output */ + if (myGH->do_out1D [index] && grouptype == GROUP_GF + && (GH->cctk_iteration%myGH->out1D_every == 0)) + { + + /* Check GF not already output this iteration */ + if (myGH->out1D_last[index] == GH->cctk_iteration) + { + CCTK_WARN(2,"Already done 1D output in IO"); + } + else + { + return_type = 1; + } + } + + return (return_type); +} + + +/*@@ + @routine IOASCII_TriggerOutput1D + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Triggers the output a variable using the IOASCII output method + method + @enddesc + @calledby CCTK scheduler + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @vcomment + @endvar + @var index + @vdesc index of variable to output + @vtype int + @vio in + @vcomment + @endvar +@@*/ +int IOASCII_TriggerOutput1D (cGH *GH, int index) +{ + const char *var; + asciiioGH *myGH; + + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + var = CCTK_VarName (index); + + /* Do the 1D output */ +#ifdef IO_DEBUG + printf ("\nIn IOASCII TriggerOutput1D\n---------------------\n"); + printf (" Index = %d\n", index); + printf (" Variable = -%s-\n", var); +#endif + + IOASCII_Write1D (GH, index, var); + + /* Register variables as having 1D output this iteration */ + myGH->out1D_last [index] = GH->cctk_iteration; + + return (0); +} + + +/**************************** local functions ******************************/ +static void CheckSteerableParameters (asciiioGH *myGH) +{ + DECLARE_CCTK_PARAMETERS + const cParamData *paramdata; + static int out1D_vars_lastset = 0; + + + /* How often to output */ + myGH->out1D_every = out_every > 0 ? out_every : -1; + if (out1D_every > 0) + { + myGH->out1D_every = out1D_every; + } + + /* Check the 'out1D_vars' parameter */ + paramdata = CCTK_ParameterData ("out1D_vars", CCTK_THORNSTRING); + if (! paramdata) + { + CCTK_WARN (1, "Couldn't get info on parameter 'out1D_vars'"); + return; + } + + /* re-parse the 'out1D_vars' parameter if it was changed */ + if (paramdata->n_set != out1D_vars_lastset) + { + ParseVarsForOutput (out1D_vars, myGH->do_out1D); + + /* Save the last setting of 'out1D_vars' parameter */ + out1D_vars_lastset = paramdata->n_set; + } + +} diff --git a/src/Output2D.c b/src/Output2D.c new file mode 100644 index 0000000..273de3f --- /dev/null +++ b/src/Output2D.c @@ -0,0 +1,289 @@ + /*@@ + @file Output2D.c + @date Thu May 11 2000 + @author Thomas Radke + @desc + Functions to deal with 2D ASCII output of variables + @enddesc + @@*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "CactusBase/IOUtil/src/ioGH.h" +#include "ioASCIIGH.h" + +/*#define IOASCII_DEBUG*/ + +/* function prototypes */ +int IOASCII_TimeFor2D (cGH *GH, int index); +static void CheckSteerableParameters (asciiioGH *myGH); + + +/*@@ + @routine IOASCII_Output2DGH + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Loops over all variables and outputs them if necessary + @enddesc + @calledby CCTK_OutputGH ("IOASCII") + @history + + @endhistory + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @endvar +@@*/ +int IOASCII_Output2DGH (cGH *GH) +{ + int index; + asciiioGH *myGH; + const char *name; + + + /* Get the GH extensions for IOUtil and IOASCII */ + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + CheckSteerableParameters (myGH); + + /* Return if no output is required */ + if (myGH->out2D_every <= 0) + { + return (0); + } + + /* Loop over all variables */ + for (index = 0; index < CCTK_NumVars (); index++) + { + + /* Check if this variable should be output */ + if (! IOASCII_TimeFor2D (GH, index)) + { + continue; + } + + /* Get the variable name for this index (for filename) */ + name = CCTK_VarName (index); + +#ifdef IO_DEBUG + printf ("\nIn IOASCII Output2DGH\n---------------------\n"); + printf (" Index = %d\n", index); + printf (" Variable = -%s-\n", name); + printf (" On iteration %d\n", GH->cctk_iteration); + printf (" Last output iteration was = %d\n", myGH->out2D_last [index]); +#endif + + /* Make the IO call */ + IOASCII_Write2D (GH, index, name); + + /* Register GF as having 2D output this iteration */ + myGH->out2D_last [index] = GH->cctk_iteration; + + } /* end of loop over all variables */ + + return (0); + + +} + + +/*@@ + @routine IOASCII_Output2DVarAs + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + unconditional output of a variable using the IOASCII output method + @enddesc + @calledby IOASCII_Output2DGH, CCTK_OutputVarAsByMethod ("IOASCII") + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @vcomment + @endvar + @var fullname + @vdesc complete name of variable to output + @vtype const char * + @vio in + @vcomment + @endvar + @var alias + @vdesc alias name of variable to output (used to generate output filename) + @vtype const char * + @vio in + @vcomment + @endvar +@@*/ +int IOASCII_Output2DVarAs (cGH *GH, const char *fullname, const char *alias) +{ + int index; + + + index = CCTK_VarIndex (fullname); + +#ifdef IO_DEBUG + printf ("\nIn IOASCII Output2DVarAs\n-------------------\n"); + printf (" Fullname = -%s-\n", fullname); + printf (" Alias = -%s-\n", alias); + printf (" Index = %d\n", index); +#endif + + IOASCII_Write2D (GH, index, alias); + + return (0); +} + + + /*@@ + @routine IOASCII_TimeFor2D + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Decides if it is time to output a variable using the IO 2D output + method + @enddesc + @calledby IOASCII_Output2DGH + @history + + @endhistory + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @vcomment + @endvar + @var index + @vdesc index of variable + @vtype int + @vio in + @vcomment + @endvar +@@*/ +int IOASCII_TimeFor2D (cGH *GH, int index) +{ + int return_type; + int grouptype; + asciiioGH *myGH; + DECLARE_CCTK_PARAMETERS + + + /* Default is do not do output */ + return_type = 0; + + /* Get the GH extensions for IOUtil and IOASCII */ + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + CheckSteerableParameters (myGH); + + /* return if no output requested */ + if (myGH->out2D_every <= 0) + return (0); + + grouptype = CCTK_GroupTypeFromVarI (index); + + /* Check this GF should be output */ + if (myGH->do_out2D [index] && grouptype == GROUP_GF + && (GH->cctk_iteration%myGH->out2D_every == 0)) + { + + /* Check GF not already output this iteration */ + if (myGH->out2D_last[index] == GH->cctk_iteration) + { + CCTK_WARN(2,"Already done 2D output in IO"); + } + else + { + return_type = 1; + } + } + + return (return_type); +} + + +/*@@ + @routine IOASCII_TriggerOutput2D + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Triggers the output a variable using the IOASCII output method + method + @enddesc + @calledby CCTK scheduler + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @vcomment + @endvar + @var index + @vdesc index of variable to output + @vtype int + @vio in + @vcomment + @endvar +@@*/ +int IOASCII_TriggerOutput2D (cGH *GH, int index) +{ + const char *var; + asciiioGH *myGH; + + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + var = CCTK_VarName (index); + + /* Do the 2D output */ +#ifdef IO_DEBUG + printf ("\nIn IOASCII TriggerOutput2D\n---------------------\n"); + printf (" Index = %d\n", index); + printf (" Variable = -%s-\n", var); +#endif + + IOASCII_Write2D (GH, index, var); + + /* Register variables as having 2D output this iteration */ + myGH->out2D_last [index] = GH->cctk_iteration; + + return (0); +} + + +/**************************** local functions ******************************/ +static void CheckSteerableParameters (asciiioGH *myGH) +{ + DECLARE_CCTK_PARAMETERS + const cParamData *paramdata; + static int out2D_vars_lastset = 0; + + + /* How often to output */ + myGH->out2D_every = out_every > 0 ? out_every : -1; + if (out2D_every > 0) + { + myGH->out2D_every = out2D_every; + } + + /* Check the 'out2D_vars' parameter */ + paramdata = CCTK_ParameterData ("out2D_vars", CCTK_THORNSTRING); + if (! paramdata) + { + CCTK_WARN (1, "Couldn't get info on parameter 'out2D_vars'"); + return; + } + + /* re-parse the 'out2D_vars' parameter if it was changed */ + if (paramdata->n_set != out2D_vars_lastset) + { + ParseVarsForOutput (out2D_vars, myGH->do_out2D); + + /* Save the last setting of 'out2D_vars' parameter */ + out2D_vars_lastset = paramdata->n_set; + } + +} diff --git a/src/Startup.c b/src/Startup.c new file mode 100644 index 0000000..32ad4e9 --- /dev/null +++ b/src/Startup.c @@ -0,0 +1,76 @@ + /*@@ + @file Startup.c + @date Sat Feb 6 1999 + @author Gabrielle Allen + @desc + Startup routines for IO. + @enddesc + @@*/ + + +#include <stdio.h> +#include <string.h> + +#include "cctk.h" +#include "cctk_IOMethods.h" +#include "cctk_Parameters.h" + +/* prototypes of functions to be registered */ +int IOASCII_Output1DGH (cGH *GH); +int IOASCII_TriggerOutput1D (cGH *GH, int); +int IOASCII_TimeFor1D (cGH *GH, int); +int IOASCII_Output1DVarAs (cGH *GH, const char *var, const char *alias); +int IOASCII_Output2DGH (cGH *GH); +int IOASCII_TriggerOutput2D (cGH *GH, int); +int IOASCII_TimeFor2D (cGH *GH, int); +int IOASCII_Output2DVarAs (cGH *GH, const char *var, const char *alias); +void *IOASCII_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH); +int IOASCII_InitGH (cGH *GH); + + /*@@ + @routine IOASCII_Startup + @date Sat Feb 6 1999 + @author Gabrielle Allen + @desc + The startup registration routine for IO. + Registers the GH extensions needed for IO and + the registerable routines used for each method of IO. + IO does not overload any functions. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +void IOASCII_Startup (void) +{ + int IOMethod; + int IO_GHExtension; + + + if (CCTK_GHExtensionHandle ("IO") < 0) + { + CCTK_WARN (1, "Thorn IOUtil was not activated. " + "No IOASCII IO methods will be enabled."); + return; + } + + IO_GHExtension = CCTK_RegisterGHExtension ("IOASCII"); + CCTK_RegisterGHExtensionSetupGH (IO_GHExtension, IOASCII_SetupGH); + CCTK_RegisterGHExtensionInitGH (IO_GHExtension, IOASCII_InitGH); + + /* Register the IOASCII routines as output methods */ + IOMethod = CCTK_RegisterIOMethod ("IOASCII_1D"); + CCTK_RegisterIOMethodOutputGH (IOMethod, IOASCII_Output1DGH); + CCTK_RegisterIOMethodOutputVarAs (IOMethod, IOASCII_Output1DVarAs); + CCTK_RegisterIOMethodTimeToOutput (IOMethod, IOASCII_TimeFor1D); + CCTK_RegisterIOMethodTriggerOutput (IOMethod, IOASCII_TriggerOutput1D); + + IOMethod = CCTK_RegisterIOMethod ("IOASCII_2D"); + CCTK_RegisterIOMethodOutputGH (IOMethod, IOASCII_Output2DGH); + CCTK_RegisterIOMethodOutputVarAs (IOMethod, IOASCII_Output2DVarAs); + CCTK_RegisterIOMethodTimeToOutput (IOMethod, IOASCII_TimeFor2D); + CCTK_RegisterIOMethodTriggerOutput (IOMethod, IOASCII_TriggerOutput2D); +} diff --git a/src/Write1D.c b/src/Write1D.c new file mode 100644 index 0000000..52dfadb --- /dev/null +++ b/src/Write1D.c @@ -0,0 +1,433 @@ + +/*@@ + @routine Write1D.c + @author Paul Walker + @date March 1997 + @desc + This pulls slices out of all the processors, collects those slices + onto processor 0, and then writes them into an xgraph file. + <p> + The scoop: We use MPI_Gather and MPI_Gatherv to allow us to + easily do the collection. Many processors (ones which contain no + slice) send a 0 length vector, but that is OK. Then since the + gather operation will line everything up, off we go and spew out + the data into a text file. Everyone loves ascii slices... + <p> + This routine underwent a pretty major rewrite on Dec 31 97 - Jan 1 98 + to generally take out all the little hacks which had been put in place over + the 9 months since it was first written. Also, comments were added. + The two biggest changes were that: + <ol> + <li>MPI and Non-MPI versions are much more tightly interwoven. + This means the Non-MPI version has to do a couple of + extra memory copies, but makes the code much nicer... + <li>Staggered and Non-Staggered grids should both work with + one code chunk. This is an untested assumption... + </ol> + @enddesc + + @history + @hauthor Thomas Radke @hdate 01 Apr 1999 + @hdesc The Non-MPI version now avoids the extra memory copies + by simply assigning the send buffer pointer to the plot_data pointer. + @hauthor Thomas Radke @hdate 30 May 2000 + @hdesc Get rid of all the PUGH stuff by using thorn Hyperslab. + @hendhistory + @version $Header$ +@@*/ + +/*$#define DEBUG_IOASCII$*/ + + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> /* stat(2) */ + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "CactusBase/IOUtil/src/ioGH.h" +#include "Development/Hyperslab/src/Hyperslab.h" +#include "ioASCIIGH.h" + + +/* the rcs ID and its dummy function to use it */ +static char *rcsid = "$Header$"; +CCTK_FILEVERSION(CactusPUGHIO_IOASCII_Write1D_c) + + +/* macro to output a line as typed data */ +#define OUTPUT_TYPED_DATA(hsize, coord_data, stagger_offset, \ + cctk_type, c_type, data, fmt_string, file) \ + { \ + int i; \ + cctk_type *typed_data = (cctk_type *) data; \ + \ + \ + for (i = 0; i < hsize; i++) \ + fprintf (file, fmt_string, \ + (double) (coord_data [i] + stagger_offset), \ + (c_type) typed_data [i]); \ + } + + +/*@@ + @routine IOASCII_Write1D + @date March 1999 + @author Gabrielle Allen + @desc + This routine does 1D output for a variable. + <p> + It creates/appends to ASCII files (suitable for gnuplot and xgraph) + named after the given alias name, suffixed with ".xl", ".yl", ".zl", + and ".dl" for the different slices. A header telling the physical + time prefixes the output data. + @enddesc + @calledby Output1DGH Output1DVarAs TriggerOutput1D + @history + + @endhistory + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @vcomment + @endvar + @var index + @vdesc global index of variable + @vtype int + @vio in + @endvar + @var alias + @vdesc alias name (used for creating the output filename) + @vtype const char * + @vio in + @endvar +@@*/ + +void IOASCII_Write1D (cGH *GH, int index, const char *alias) +{ + DECLARE_CCTK_PARAMETERS + asciiioGH *myGH; /* IOASCII extension handle */ + ioGH *ioUtilGH; /* IOUtil extension handle */ + int myproc; /* identify processor */ + int i, dir; /* Loopers */ + int timelevel; /* timelevel of variable to output */ + int groupindex; /* variable's group index */ + cGroup groupinfo; /* variable's group info */ + const char *header_fmt_string; /* header format string */ + const char *data_fmt_string_int; /* data format string for int types */ + const char *data_fmt_string_real; /* data format string for float types */ + char title_start_char; /* character to prefix title in output */ + FILE *file [4]; /* file descriptors for x,y,z,d output */ + int Do_it [4]; /* flags indicating actual work */ + int coord_index [3]; /* x,y,z coordinate variable indices */ + int is_cubic; /* true if variable lives on cubic grid */ + CCTK_INT **groupsizes; /* the global sizes for array variables */ + const char *errormsg; /* error message string */ + + + /* get the variable's group information */ + groupindex = CCTK_GroupIndexFromVarI (index); + CCTK_GroupData (groupindex, &groupinfo); + + /* check if variable is of dimension 3 and has storage assigned */ + errormsg = NULL; + if (groupinfo.dim != 3) + errormsg = "No IOASCII 1D output for '%s' (dim != 3)"; + else if (! CCTK_QueryGroupStorageI (GH, groupindex)) + errormsg = "No IOASCII 1D output for '%s' (no storage)"; + + if (errormsg) + { + char *fullname = CCTK_FullName (index); + + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, errormsg, fullname); + free (fullname); + return; + } + + /* see what slices should be output */ + Do_it [0] = out1D_x; + Do_it [1] = out1D_y; + Do_it [2] = out1D_z; + /* diagonal slice is done only if grid is cubic and non-staggered. */ + is_cubic = 1; + if (groupinfo.grouptype == GROUP_GF) + { + for (i = 1; i < groupinfo.dim; i++) + is_cubic &= GH->cctk_gsh [i] == GH->cctk_gsh [0]; + } + else + { + groupsizes = CCTK_GroupSizesI (groupindex); + for (i = 1; i < groupinfo.dim; i++) + is_cubic &= *groupsizes [i] == *groupsizes [0]; + } + Do_it [3] = out1D_d && is_cubic && groupinfo.stagtype == 0; + + /* return if nothing to do */ + if (! (Do_it [0] || Do_it [1] || Do_it [2] || Do_it [3])) + { + return; + } + + /* set header and data format strings */ + if (CCTK_Equals (out_format, "f")) + { + header_fmt_string = "\n\n%cTime = %f\n"; + data_fmt_string_int = "%f\t\t%d\n"; + data_fmt_string_real = "%f\t\t%.13f\n"; + } + else + { + header_fmt_string = "\n\n%cTime = %e\n"; + data_fmt_string_int = "%e\t\t%d\n"; + data_fmt_string_real = "%e\t\t%.13e\n"; + } + + /* set title_start_char */ + title_start_char = CCTK_Equals (out_style, "gnuplot") ? '#' : 34; + +#ifdef DEBUG_IOASCII + printf ("\nIn IOASCII Write1D\n------------------\n"); + printf (" Variable index is %d\n",index); + printf (" Alias is -%s-\n",alias); + fflush (stdout); +#endif + + /* Get the handles for IOUtil and IOASCII extensions */ + ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + /* What processor are we on? */ + myproc = CCTK_MyProc (GH); + + /* Processor 0 opens the files with the appropriate name */ + if (myproc == 0) + { + int len; + + + len = strlen (myGH->outdir1D) + strlen (alias) + +#if 0 + FIXME: pughGH->identity_string should be moved into cGH + strlen (pughGH->identity_string); +#else + 0; +#endif + + for (i = 0; i < 4; i++) + { + if (Do_it [i]) + { + struct stat fileinfo; + const char *openmode; + const char *extensions [] = {"xl", "yl", "zl", "dl"}; + char *fname = (char *) malloc (len + strlen (extensions [i]) + 3); + + if (! fname) + CCTK_WARN (0, "Out of memory"); + +#if 0 + FIXME: pughGH->identity_string should be moved into cGH + sprintf (fname, "%s/%s%s.%s", myGH->outdir1D, alias, + pughGH->identity_string, extensions [i]); +#else + sprintf (fname, "%s/%s.%s", myGH->outdir1D, alias, extensions [i]); +#endif + + /* see if output file was already created */ + if (GetNamedData (myGH->filenameList1D, fname) == NULL) + { + /* if restart from recovery, all existing files are opened + in append mode */ + if (ioUtilGH->recovered) + openmode = stat (fname, &fileinfo) == 0 ? "a" : "w"; + else + openmode = "w"; + + /* just store a non-NULL pointer in database */ + StoreNamedData (&myGH->filenameList1D, fname, (void *) 1); + } + else { + openmode = "a"; + } + + if (! (file [i] = fopen (fname, openmode))) + { + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Cannot open 1D output file '%s'", fname); + } + else + { + /* advertise new files for downloading */ + if (*openmode == 'w') + { + IOUtil_AdvertisedFileDesc_t advertisedFile; + + + advertisedFile.slice = (char *) extensions [i]; + advertisedFile.thorn = CCTK_THORNSTRING; + advertisedFile.varname = CCTK_FullName (index); + advertisedFile.description = "One-dimensional line plots"; + advertisedFile.mimetype = CCTK_Equals (out_style, "gnuplot") ? + "application/gnuplot" : "application/x-graph"; + + IOUtil_AdvertiseFile (GH, fname, &advertisedFile); + + free (advertisedFile.varname); + } + } + free (fname); + } + } + } + + /* get the coordinate indices */ + coord_index [0] = CCTK_CoordIndex ("x"); + coord_index [1] = CCTK_CoordIndex ("y"); + coord_index [2] = CCTK_CoordIndex ("z"); + + /* get the current time level */ + timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1; + if (timelevel > 0) + timelevel--; + + /* OK so actually do the I/O in each direction */ + for (dir = 0; dir < 4; dir++) + { + const int length = -1; + const int downsample = 1; + const int *origin; + const int zero_point [3] = {0, 0, 0}; + int directions [3]; + int hsize; + int coord_timelevel; + void *data; + CCTK_REAL *coord_data; + + + /* skip empty slices */ + if (! Do_it [dir]) + continue; + + /* get the coordinate's 1D data (in xyz direction only) */ + if (dir < 3) + { + /* set the origin of the line */ + origin = myGH->spxyz [dir]; + + /* set the direction vector for the 1D line */ + memset (directions, 0, sizeof (directions)); + directions [dir] = 1; + + /* get the current time level for the coordinates */ + coord_timelevel = CCTK_NumTimeLevelsFromVarI (coord_index [dir]) - 1; + if (coord_timelevel > 0) + coord_timelevel--; + + if (Hyperslab_GetHyperslab (GH, 0, coord_index [dir], coord_timelevel, + 1, origin, directions, &length, &downsample, + (void **) &coord_data, &hsize) < 0) + { + char *fullname = CCTK_FullName (coord_index [dir]); + + + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Failed to extract hyperslab for variable '%s'", fullname); + free (fullname); + continue; + } + } + else + { + /* set the origin of the line */ + origin = zero_point; + + /* set the direction vector for the diagonal 1D line */ + for (i = 0; i < 3; i++) + directions [i] = 1; + + coord_data = NULL; + } + + /* get the variable's 1D data */ + if (Hyperslab_GetHyperslab (GH, 0, index, timelevel, 1, origin, + directions, &length, &downsample, + &data, &hsize) < 0) + { + char *fullname = CCTK_FullName (index); + + + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Failed to extract hyperslab for variable '%s'", fullname); + free (fullname); + if (coord_data) + free (coord_data); + continue; + } + + /* And write it out on processor 0 */ + if (myproc == 0 && file [dir] != NULL) + { + CCTK_REAL lower, offset; + + + if (dir < 3) + { + /* get the staggering offset for the coordinates */ + offset = CCTK_StaggerDirIndex (dir, groupinfo.stagtype) * + 0.5 * GH->cctk_delta_space [dir]; + } + else + { + /* get the diagonal coordinates */ + coord_data = (CCTK_REAL *) malloc (hsize * sizeof (CCTK_REAL)); + CCTK_CoordRange (GH, &lower, &offset, "x"); + coord_data [0] = 0.0; + offset = GH->cctk_delta_space [0] * sqrt (3); + for (i = 1; i < hsize; i++) + coord_data [i] = coord_data [i-1] + offset; + offset = lower * sqrt (3); + } + + /* print out header */ + fprintf (file [dir], header_fmt_string, title_start_char, GH->cctk_time); + + /* and then loop through the line points */ + switch (groupinfo.vartype) + { + case CCTK_VARIABLE_CHAR: + OUTPUT_TYPED_DATA (hsize, coord_data, offset, CCTK_CHAR, + int, data, data_fmt_string_int, file [dir]); + break; + + case CCTK_VARIABLE_INT: + OUTPUT_TYPED_DATA (hsize, coord_data, offset, CCTK_INT, + int, data, data_fmt_string_int, file [dir]); + break; + + case CCTK_VARIABLE_REAL: + OUTPUT_TYPED_DATA (hsize, coord_data, offset, CCTK_REAL, + double, data, data_fmt_string_real, file[dir]); + break; + + default: + CCTK_WARN (1, "Unsupported variable type"); + break; + } + + /* close the output file */ + fclose (file [dir]); + + /* clean up */ + free (data); + free (coord_data); + } + + } /* end of loop through all directions */ + +} diff --git a/src/Write2D.c b/src/Write2D.c new file mode 100644 index 0000000..5668ad4 --- /dev/null +++ b/src/Write2D.c @@ -0,0 +1,365 @@ +/*@@ + @file Write2D.c + @date Thu May 11 2000 + @author Thomas Radke + @desc + Output two-dimensional slices in ASCII gnuplot format. + @enddesc + @@*/ + + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "Development/Hyperslab/src/Hyperslab.h" +#include "CactusBase/IOUtil/src/ioGH.h" +#include "ioASCIIGH.h" + + + +/* enable debug output */ +/*#define IOASCII_DEBUG*/ + + +/* macro to output a time slice as typed data */ +#define OUTPUT_TYPED_DATA(coord_hsizes, coord_i, coord_j, stagger_offset_i, \ + stagger_offset_j, data_hsizes, cctk_type, c_type, \ + data, fmt_string, file) \ + { \ + int i, j; \ + cctk_type *typed_data = (cctk_type *) data; \ + \ + \ + for (j = 0; j < data_hsizes [1]; j++) \ + { \ + for (i = 0; i < data_hsizes [0]; i++) \ + { \ + fprintf (file, fmt_string, \ + (double) (*coord_i++ + stagger_offset_i), \ + (double) (*coord_j++ + stagger_offset_j), \ + (c_type) *typed_data++); \ + } \ + fprintf (file, "\n"); \ + coord_i += coord_hsizes [0] - data_hsizes [0]; \ + coord_j += coord_hsizes [0] - data_hsizes [0]; \ + } \ + coord_i -= coord_hsizes [0] * data_hsizes [1]; \ + coord_j -= coord_hsizes [0] * data_hsizes [1]; \ + } + + +/*@@ + @routine IOASCII_Write2D + @date Thu May 11 2000 + @author Thomas Radke + @desc Writes the 2D slices of a variable into separate ASCII files + @enddesc + @calledby IOASCII_Output2DVarAs + IOASCII_TriggerOutput2D + @history + @endhistory + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @vcomment + @endvar + @var index + @vdesc index of variable to output + @vtype int + @vio in + @vcomment + @endvar + @var alias + @vdesc alias name of variable to output + @vtype const char * + @vio in + @vcomment + @endvar +@@*/ +void IOASCII_Write2D (cGH *GH, int index, const char *alias) +{ + DECLARE_CCTK_PARAMETERS + int myproc; + ioGH *ioUtilGH; + asciiioGH *myGH; + const char *header_fmt_string; /* header format string */ + const char *data_fmt_string_int; /* data format string for int types */ + const char *data_fmt_string_real; /* data format string for float types */ + int dir; + int timelevel; + int groupindex; + cGroup groupinfo; + FILE **fdset_2D; /* array of output file pointers */ + int coord_index [3]; /* variable indices for xyz coordinates */ + int coord_timelevel [3]; /* coordinates' current timelevels */ + int origin [3]; /* the slice origin */ + const char *errormsg; /* error message string */ + + + /* to make the compiler happy */ + fdset_2D = NULL; + + /* get the variable group indormation */ + groupindex = CCTK_GroupIndexFromVarI (index); + CCTK_GroupData (groupindex, &groupinfo); + + /* check if variable is of dimension 3 and has storage assigned */ + errormsg = NULL; + if (groupinfo.dim != 3) + errormsg = "No IOASCII 2D output for '%s' (dim != 3)"; + else if (! CCTK_QueryGroupStorageI (GH, groupindex)) + errormsg = "No IOASCII 2D output for '%s' (no storage)"; + + if (errormsg) + { + char *fullname = CCTK_FullName (index); + + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, errormsg, fullname); + free (fullname); + return; + } + + /* Get the handles for IOUtil and IOASCII extensions */ + ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + /* set header and data format strings */ + if (CCTK_Equals (out_format, "f")) + { + header_fmt_string = "\n\n#Time = %f\n"; + data_fmt_string_int = "%.13f\t\t%.13f\t\t%d\n"; + data_fmt_string_real = "%.13f\t\t%.13f\t\t%.13f\n"; + } + else + { + header_fmt_string = "\n\n#Time = %e\n"; + data_fmt_string_int = "%.13e\t\t%.13e\t\t%d\n"; + data_fmt_string_real = "%.13e\t\t%.13e\t\t%.13e\n"; + } + + /* What processor are we on? */ + myproc = CCTK_MyProc (GH); + + /* Open the files on the first trip through if we are proc. 0 */ + if (myproc == 0) + { + + /* see if output file for this alias name was already created */ + fdset_2D = (FILE **) GetNamedData (myGH->fileList_2D, alias); + if (fdset_2D == NULL) + { + char *fname; + + fdset_2D = (FILE **) malloc (3 * sizeof (FILE *)); + fname = (char *) malloc (strlen (myGH->outdir2D) + strlen (alias) + +#if 0 +FIXME: get rid of PUGH here + strlen (pughGH->identity_string) + 20); +#else + 20); +#endif + + /* Open/Create files */ + for (dir = 0; dir < 3; dir++) + { + IOUtil_AdvertisedFileDesc_t advertised_file; + const char *extensions [3] = {"yz", "xz", "xy"}; + +#if 0 + sprintf (fname, "%s/%s_2d_%s%s.gnuplot", myGH->outdir2D, alias, + extensions [dir], pughGH->identity_string); +#else + sprintf (fname, "%s/%s_2d_%s.gnuplot", myGH->outdir2D, alias, + extensions [dir]); +#endif + + /* if restart from recovery, try to open an existing file ... */ + fdset_2D [dir] = NULL; + if (ioUtilGH->recovered) + fdset_2D [dir] = fopen (fname, "a"); + + /* otherwise or if that failed, create a new one */ + if (! fdset_2D [dir]) + fdset_2D [dir] = fopen (fname, "w"); + if (! fdset_2D [dir]) + { + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Cannot open 2D output file '%s'", fname); + return; + } + + /* advertise the file for downloading */ + advertised_file.slice = (char *) extensions [dir]; + advertised_file.thorn = CCTK_THORNSTRING; + advertised_file.varname = CCTK_FullName (index); + advertised_file.description = "One-dimensional line plots"; + advertised_file.mimetype = "application/gnuplot"; + + IOUtil_AdvertiseFile (GH, fname, &advertised_file); + + free (advertised_file.varname); + } + + /* store file desriptors in database */ + StoreNamedData (&myGH->fileList_2D, alias, fdset_2D); + + free (fname); + } + } + + /* get the coordinate indices */ + coord_index [0] = CCTK_CoordIndex ("x"); + coord_index [1] = CCTK_CoordIndex ("y"); + coord_index [2] = CCTK_CoordIndex ("z"); + + /* get the coordinate timelevels */ + for (dir = 0; dir < 3; dir++) + { + coord_timelevel [dir] = CCTK_NumTimeLevelsFromVarI (coord_index [dir]) - 1; + if (coord_timelevel [dir] > 0) + coord_timelevel [dir]--; + } + + /* get the timelevel for the variable to output */ + timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1; + if (timelevel > 0) + timelevel--; + + for (dir = 0; dir < 3; dir++) + { + int dir_i, dir_j; + int directions [3]; + const int lengths [2] = {-1, -1}; + const int downsamples [2] = {1, 1}; + int coord_hsizes [2], data_hsizes [2]; + CCTK_REAL *coord_data_i, *coord_data_j; + void *data; + + + /* get the directions to span the hyperslab */ + if (dir == 0) + { + dir_i = 1; dir_j = 2; /* yz */ + } + else if (dir == 1) + { + dir_i = 0; dir_j = 2; /* xz */ + } + else + { + dir_i = 0; dir_j = 1; /* xy */ + } + + /* set the origin using the slice center from IOUtil */ + memset (origin, 0, GH->cctk_dim * sizeof (int)); + origin [dir] = ioUtilGH->sp2xyz [dir]; + + /* set the directions vector */ + memset (directions, 0, sizeof (directions)); + directions [dir] = 1; + + /* get the i-coordinate slice */ + if (Hyperslab_GetHyperslab (GH, 0, coord_index [dir_i], + coord_timelevel [dir_i], 2, origin, directions, + lengths, downsamples, + (void **) &coord_data_i, coord_hsizes) < 0) + { + char *fullname = CCTK_FullName (coord_index [dir_i]); + + + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Failed to extract 2D hyperslab for variable '%s'", fullname); + free (fullname); + return; + } + + /* get the j-coordinate slice */ + if (Hyperslab_GetHyperslab (GH, 0, coord_index [dir_j], + coord_timelevel [dir_j], 2, origin, directions, + lengths, downsamples, + (void **) &coord_data_j, coord_hsizes) < 0) + { + char *fullname = CCTK_FullName (coord_index [dir_j]); + + + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Failed to extract 2D hyperslab for variable '%s'", fullname); + free (fullname); + free (coord_data_i); + return; + } + + /* get the variable slice */ + if (Hyperslab_GetHyperslab (GH, 0, index, timelevel, 2, origin, directions, + lengths, downsamples, &data, data_hsizes) < 0) + { + char *fullname = CCTK_FullName (index); + + + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Failed to extract 2D hyperslab for variable '%s'", fullname); + free (fullname); + free (coord_data_i); + free (coord_data_j); + return; + } + + /* proc 0 writes */ + if (myproc == 0) + { + CCTK_REAL stagger_offset_i, stagger_offset_j; + + + /* get the staggering offset for the coordinates */ + stagger_offset_i = CCTK_StaggerDirIndex (dir_i, groupinfo.stagtype) * + 0.5 * GH->cctk_delta_space [dir_i]; + stagger_offset_j = CCTK_StaggerDirIndex (dir_j, groupinfo.stagtype) * + 0.5 * GH->cctk_delta_space [dir_j]; + + /* print out header */ + fprintf (fdset_2D [dir], header_fmt_string, GH->cctk_time); + + switch (groupinfo.vartype) + { + case CCTK_VARIABLE_CHAR: + OUTPUT_TYPED_DATA (coord_hsizes, coord_data_i, coord_data_j, + stagger_offset_i, stagger_offset_j, + data_hsizes, CCTK_CHAR, int, data, + data_fmt_string_int, fdset_2D [dir]); + break; + + case CCTK_VARIABLE_INT: + OUTPUT_TYPED_DATA (coord_hsizes, coord_data_i, coord_data_j, + stagger_offset_i, stagger_offset_j, + data_hsizes, CCTK_INT, int, data, + data_fmt_string_int, fdset_2D [dir]); + break; + + case CCTK_VARIABLE_REAL: + OUTPUT_TYPED_DATA (coord_hsizes, coord_data_i, coord_data_j, + stagger_offset_i, stagger_offset_j, + data_hsizes, CCTK_REAL, double, data, + data_fmt_string_real, fdset_2D [dir]); + break; + + default: + CCTK_WARN (1, "Unsupported variable type"); + break; + } + + /* keep the file open but flush it */ + fflush (fdset_2D [dir]); + + free (data); + free (coord_data_j); + free (coord_data_i); + + } /* end of outputting the data by processor 0 */ + + } /* end of looping through xyz directions */ + +} diff --git a/src/ioASCIIGH.h b/src/ioASCIIGH.h new file mode 100644 index 0000000..8593022 --- /dev/null +++ b/src/ioASCIIGH.h @@ -0,0 +1,53 @@ + /*@@ + @header ioASCIIGH.h + @date Tue 9th Jan 1999 + @author Gabrielle Allen + @desc + The extensions to the GH structure from IO. + @history + @hauthor Thomas Radke @hdate 16 Mar 1999 + @hdesc Added parameters for 2D and 3D output + @hauthor Thomas Radke @hdate 17 Mar 1999 + @hdesc Changed naming: IEEEIO -> FlexIO + @hauthor Thomas Radke @hdate 30 Mar 1999 + @hdesc Undefined DI macro + @endhistory + @version $Header$ + @@*/ + +#include "StoreNamedData.h" + +/* supported gridtypes: full,octant,quadrant,bitant */ + +typedef struct IOASCIIGH { + + /* the number of times output */ + int out1D_every; + int out2D_every; + + /* flags indicating output for var [i] */ + char *do_out1D; + char *do_out2D; + + /* directories in which to output */ + char *outdir1D; + char *outdir2D; + + /* the last iteration output for var [i] */ + int *out1D_last; + int *out2D_last; + + /* database for names of output files that were already created */ + pNamedData *filenameList1D; + pNamedData *fileList_2D; + + /* for 1d lines, we define the index where to start the line: + spxyz[XYZdirection][xyzstart_index] */ + int spxyz[3][3]; + +} asciiioGH; + + +/* function prototypes */ +void IOASCII_Write1D (cGH *GH, int index, const char *alias); +void IOASCII_Write2D (cGH *GH, int index, const char *alias); diff --git a/src/make.code.defn b/src/make.code.defn new file mode 100644 index 0000000..2a4fafd --- /dev/null +++ b/src/make.code.defn @@ -0,0 +1,5 @@ +# Main make.code.defn file for thorn IOASCII +# $Header$ + +# Source files in this directory +SRCS = Startup.c GHExtension.c Output1D.c Write1D.c Output2D.c Write2D.c diff --git a/src/make.configuration.defn b/src/make.configuration.defn new file mode 100644 index 0000000..f159ebd --- /dev/null +++ b/src/make.configuration.defn @@ -0,0 +1,11 @@ +# make.configuration.defn for IOASCII + +# make sure that IOASCII was configured with thorn Hyperslab + +ifeq ($(findstring Development/Hyperslab,$(THORNS)),) +.pseudo: MissingHyperslabInIOASCII +MissingHyperslabInIOASCII: + @echo "IOASCII: requires thorn Hyperslab" + @echo "IOASCII: Please add Development/Hyperslab or remove IOASCII from Thornlist !" + exit 2 +endif |