aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2001-05-09 15:45:51 +0000
committertradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2001-05-09 15:45:51 +0000
commit754182350531a19e69cccd7af30df8e2e3e6e676 (patch)
tree999d5669312661c374f4a8f3403aa28a3e94d506 /src
parent2888f65eb55b121ed35e8346fcf7969ccf30c7c7 (diff)
Added coordinate information to the axis labels.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@58 94b1c47f-dcfd-45ef-a468-0854c0e9e350
Diffstat (limited to 'src')
-rw-r--r--src/Write1D.c281
-rw-r--r--src/Write2D.c146
2 files changed, 214 insertions, 213 deletions
diff --git a/src/Write1D.c b/src/Write1D.c
index 22aa976..18a7109 100644
--- a/src/Write1D.c
+++ b/src/Write1D.c
@@ -2,9 +2,9 @@
@file Write1D.c
@date March 1997
@author Paul Walker
- @desc
+ @desc
Output one-dimensional lines in ASCII xgraph/gnuplot format.
- @enddesc
+ @enddesc
@history
@hauthor Thomas Radke
@@ -13,11 +13,11 @@
Get rid of all the PUGH stuff by using thorn Hyperslab.
@endhdesc
@hendhistory
- @version $Id$
+ @version $Id$
@@*/
#include <stdlib.h>
-#include <math.h>
+#include <math.h> /* sqrt(3) */
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h> /* stat(2) */
@@ -74,13 +74,13 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write1D_c)
@routine IOASCII_Write1D
@date March 1999
@author Gabrielle Allen
- @desc
+ @desc
This routine does 1D line output along the orthogonals
and the diagonal (in case of a cubed grid).
<p>
It writes to ASCII files suitable for gnuplot and xgraph.
A header telling the physical time prefixes the output data.
- @enddesc
+ @enddesc
@calls IOUtil_RestartFromRecovery
IOUtil_AdvertiseFile
Hyperslab_GetHyperslab
@@ -89,20 +89,20 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write1D_c)
@vdesc Pointer to CCTK GH
@vtype cGH *
@vio in
- @endvar
+ @endvar
@var vindex
@vdesc global index of variable to output
@vtype int
@vio in
- @endvar
+ @endvar
@var alias
@vdesc alias name (used for creating the output filename)
@vtype const char *
@vio in
- @endvar
+ @endvar
@@*/
void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
-{
+{
DECLARE_CCTK_PARAMETERS
asciiioGH *myGH; /* IOASCII extension handle */
int Do_it[4]; /* flags indicating actual work */
@@ -119,11 +119,14 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
cGroupDynamicData group_dynamic_data;/* variable's group dynamic data */
char *fullname; /* variable's full name */
char header_fmt[18]; /* header format string */
+ char ylabel1_fmt[12]; /* y-label format string */
+ char ylabel2_fmt[12]; /* y-label format string */
char data_fmt_int[11]; /* data format string for int types */
char data_fmt_real[14]; /* data format string for float types */
const char *file_extension; /* filename extension */
char comment_char; /* character starting a comment */
FILE *file[8]; /* fds for x,y,z,d output (also COMPLEX)*/
+ CCTK_REAL coord_lower[3], offset;
int num_files;
int upper, lower;
struct stat fileinfo;
@@ -133,13 +136,13 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
ioAdvertisedFileDesc advertised_file;
- /* get the variable's group index */
+ /* get the variable's group index and its full name */
groupindex = CCTK_GroupIndexFromVarI (vindex);
+ fullname = CCTK_FullName (vindex);
/* check if variable has storage assigned */
- if (! CCTK_QueryGroupStorageI (GH, groupindex))
+ if (! CCTK_QueryGroupStorageI (GH, groupindex))
{
- fullname = CCTK_FullName (vindex);
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOASCII_Write1D: No IOASCII_1D output for '%s' (no storage)",
fullname);
@@ -166,12 +169,10 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
}
if (out1D_d && ! is_cubic)
{
- fullname = CCTK_FullName (vindex);
CCTK_VWarn (3, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOASCII_Write1D: No IOASCII_1D diagonal output for '%s' "
"(only implemented for cubic grids)",
fullname);
- free (fullname);
}
Do_it[3] = out1D_d &&
group_static_data.dim == 3 &&
@@ -181,6 +182,7 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
/* return if nothing to do */
if (! (Do_it[0] || Do_it[1] || Do_it[2] || Do_it[3]))
{
+ free (fullname);
return;
}
@@ -195,7 +197,9 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
comment_char = '"';
file_extension = ".xg";
}
- sprintf (header_fmt, "\n\n%cTime = %%%s\n", comment_char, out_format);
+ sprintf (header_fmt, "\n\n%cTime = %%%s\n", comment_char, out_format);
+ sprintf (ylabel1_fmt, " (%%c = %%%s", out_format);
+ sprintf (ylabel2_fmt, ", %%c = %%%s", out_format);
sprintf (data_fmt_int, "%%%s\t\t%%d\n", out_format);
sprintf (data_fmt_real, "%%%s\t\t%%%s\n", out_format, out_format);
@@ -206,29 +210,50 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
fflush (stdout);
#endif
+ /* get the coordinate indices for CCTK_GF variables */
+ if (group_static_data.grouptype == CCTK_GF)
+ {
+ sprintf (coord_system, "cart%dd", group_static_data.dim);
+ have_coords = 1;
+ for (i = 0; i < group_static_data.dim && i < 3; i++)
+ {
+ CCTK_CoordRange (GH, &coord_lower[i], &offset, i + 1, NULL, coord_system);
+ coord_index[i] = CCTK_CoordIndex (i + 1, NULL, coord_system);
+ have_coords &= coord_index[i] >= 0;
+ }
+
+ if (! have_coords)
+ {
+ CCTK_VWarn (8, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "IOASCII_Write1D: No coordinate ranges found for '%s'",
+ coord_system);
+ }
+ }
+ else
+ {
+ /* CCTK_ARRAY variables never have coordinates associated */
+ have_coords = 0;
+ }
+
/* What processor are we on? */
myproc = CCTK_MyProc (GH);
/* Processor 0 opens the files with the appropriate name */
- if (myproc == 0)
+ if (myproc == 0)
{
/* 20 extra characters should be enough for '/',
the type extension, the file extension, and the trailing '\0' */
- i = strlen (myGH->outdir1D) + strlen (alias) + sizeof (slicename) + 20 +
-#if 0
- /* FIXME: pughGH->identity_string should be moved into cGH */
- strlen (pughGH->identity_string);
-#else
- 0;
-#endif
- filename = (char *) malloc (i);
+ filename = (char *) malloc (strlen (myGH->outdir1D) + strlen (alias) +
+ sizeof (slicename) + 20);
num_files = group_static_data.vartype == CCTK_VARIABLE_COMPLEX ? 8 : 4;
for (i = 0; i < num_files; i++)
{
+ dir = i % 4;
+
/* skip empty slices */
- if (! Do_it[i % 4])
+ if (! Do_it[dir])
{
continue;
}
@@ -249,28 +274,25 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
{
type_extension = "";
}
-#if 0
- /* FIXME: pughGH->identity_string should be moved into cGH */
- sprintf (filename, "%s/%s%s%s.%s", myGH->outdir1D, alias,
- type_extension, pughGH->identity_string, extensions[i % 4]);
-#else
+
+ /* get the indices into spxyz[] */
+ lower = (dir + 1) % 3;
+ upper = (dir + 2) % 3;
+ if (upper < lower)
+ {
+ upper = lower;
+ lower = 0;
+ }
+
/* FIXME: this can go after the old filename scheme has gone */
if (new_filename_scheme)
{
if ((i + 1) % 4)
{
- /* get the indices into spxyz[] */
- lower = ((i % 4) + 1) % 3;
- upper = ((i % 4) + 2) % 3;
- if (upper < lower)
- {
- upper = lower;
- lower = 0;
- }
/* give the slice origin as range [1 .. n] */
- sprintf (slicename, "%s%c_[%d][%d]", type_extension, 'x' + i % 4,
- myGH->spxyz[group_static_data.dim-1][i % 4][lower] + 1,
- myGH->spxyz[group_static_data.dim-1][i % 4][upper] + 1);
+ sprintf (slicename, "%s%c_[%d][%d]", type_extension, 'x' + dir,
+ myGH->spxyz[group_static_data.dim-1][dir][lower] + 1,
+ myGH->spxyz[group_static_data.dim-1][dir][upper] + 1);
}
else
{
@@ -295,17 +317,16 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
if (strcmp (myGH->outdir1D, "."))
{
sprintf (filename, "%s/%s%s.%s", myGH->outdir1D, alias,
- type_extension, extensions[i % 4]);
+ type_extension, extensions[dir]);
}
else
{
- sprintf (filename, "%s%s.%s", alias, type_extension, extensions[i%4]);
+ sprintf (filename, "%s%s.%s", alias, type_extension, extensions[dir]);
}
}
-#endif
/* see if output file was already created */
- if (GetNamedData (myGH->filenameList1D, filename) == NULL)
+ if (GetNamedData (myGH->filenameList1D, filename) == NULL)
{
/* if restart from recovery, all existing files are opened
in append mode */
@@ -329,92 +350,94 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
if (! (file[i] = fopen (filename, openmode)))
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOASCII_Write1D: Cannot open 1D output file '%s'",
+ "IOASCII_Write1D: Cannot open 1D output file '%s'",
filename);
- }
- else
+ }
+ else if (*openmode == 'w')
{
/* advertise new files for downloading and add file info */
- if (*openmode == 'w')
+ /* FIXME: this can go after the old filename scheme has gone */
+ advertised_file.slice = new_filename_scheme ? slicename:extensions[dir];
+ advertised_file.thorn = CCTK_THORNSTRING;
+ advertised_file.varname = fullname;
+ advertised_file.description = "One-dimensional line plots";
+ advertised_file.mimetype = comment_char == '#' ?
+ "application/gnuplot" : "application/x-graph";
+
+ IOUtil_AdvertiseFile (GH, filename, &advertised_file);
+
+ /* add some file information to the output file */
+ if (CCTK_Equals (out_fileinfo, "parameter filename") ||
+ CCTK_Equals (out_fileinfo, "all"))
+ {
+ buffer[0] = 0;
+ CCTK_ParameterFilename (sizeof (buffer), buffer);
+ fprintf (file[i], "%cParameter file %s\n", comment_char, buffer);
+ }
+ if (CCTK_Equals (out_fileinfo, "creation date") ||
+ CCTK_Equals (out_fileinfo, "all"))
{
- /* FIXME: this can go after the old filename scheme has gone */
- advertised_file.slice = new_filename_scheme ?
- slicename : extensions[i % 4];
- advertised_file.thorn = CCTK_THORNSTRING;
- advertised_file.varname = CCTK_FullName (vindex);
- advertised_file.description = "One-dimensional line plots";
- advertised_file.mimetype = comment_char == '#' ?
- "application/gnuplot" : "application/x-graph";
-
- IOUtil_AdvertiseFile (GH, filename, &advertised_file);
-
- if (CCTK_Equals (out_fileinfo, "parameter filename") ||
- CCTK_Equals (out_fileinfo, "all"))
- {
- buffer[0] = 0;
- CCTK_ParameterFilename (sizeof (buffer), buffer);
- fprintf (file[i], "%cParameter file %s\n", comment_char, buffer);
+ buffer[0] = 0;
+ Util_CurrentDate (sizeof (buffer), buffer);
+ fprintf (file[i], "%cCreated %s ", comment_char, buffer);
+ Util_CurrentTime (sizeof (buffer), buffer);
+ fprintf (file[i], "%s\n", buffer);
+ }
+ if (CCTK_Equals (out_fileinfo, "axis labels") ||
+ CCTK_Equals (out_fileinfo, "all"))
+ {
+ if (dir < 3)
+ {
+ fprintf (file[i], "%cx-label %c\n", comment_char, 'x' + dir);
}
- if (CCTK_Equals (out_fileinfo, "creation date") ||
- CCTK_Equals (out_fileinfo, "all"))
- {
- buffer[0] = 0;
- Util_CurrentDate (sizeof (buffer), buffer);
- fprintf (file[i], "%cCreated %s ", comment_char, buffer);
- Util_CurrentTime (sizeof (buffer), buffer);
- fprintf (file[i], "%s\n", buffer);
+ else
+ {
+ fprintf (file[i], "%cx-label diagonal\n", comment_char);
}
- if (CCTK_Equals (out_fileinfo, "axis labels") ||
- CCTK_Equals (out_fileinfo, "all"))
+ fprintf (file[i], "%cy-label %s", comment_char, fullname);
+ if (dir < 3)
{
- if (i % 4 < 3)
+ if (group_static_data.dim > 1)
{
- fprintf (file[i], "%cx-label %c\n", comment_char, 'x' + i % 4);
+ if (have_coords)
+ {
+ fprintf (file[i], ylabel1_fmt, 'x' + lower,
+ coord_lower[lower] + GH->cctk_delta_space[dir] *
+ myGH->spxyz[group_static_data.dim-1][dir][lower]);
+ }
+ else
+ {
+ fprintf (file[i], " (%ci = %d", 'x' + lower,
+ myGH->spxyz[group_static_data.dim-1][dir][lower]);
+ }
}
- else
+ if (group_static_data.dim > 2)
{
- fprintf (file[i], "%cx-label diagonal\n", comment_char);
+ if (have_coords)
+ {
+ fprintf (file[i], ylabel2_fmt, 'x' + upper,
+ coord_lower[upper] + GH->cctk_delta_space[dir] *
+ myGH->spxyz[group_static_data.dim-1][dir][upper]);
+ }
+ else
+ {
+ fprintf (file[i], ", %ci = %d", 'x' + upper,
+ myGH->spxyz[group_static_data.dim-1][dir][upper]);
+ }
}
- fprintf (file[i], "%cy-label %s\n",
- comment_char, advertised_file.varname);
+ fprintf (file[i], ") \n");
}
-
- free (advertised_file.varname);
}
}
}
free (filename);
}
- /* get the coordinate indices for CCTK_GF variables */
- if (group_static_data.grouptype == CCTK_GF)
- {
- sprintf (coord_system, "cart%dd", group_static_data.dim);
- have_coords = 1;
- for (i = 0; i < group_static_data.dim; i++)
- {
- coord_index[i] = CCTK_CoordIndex (i + 1, NULL, coord_system);
- have_coords &= coord_index[i] >= 0;
- }
-
- if (! have_coords)
- {
- CCTK_VWarn (8, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOASCII_Write1D: No coordinate system '%s' found for '%s'",
- coord_system, CCTK_VarName (vindex));
- }
- }
- else
- {
- /* CCTK_ARRAY variables never have coordinates associated */
- have_coords = 0;
- }
-
/* get the current time level */
timelevel = CCTK_NumTimeLevelsFromVarI (vindex) - 1;
/* OK so actually do the I/O in each direction */
- for (dir = 0; dir < 4; dir++)
+ for (dir = 0; dir < 4; dir++)
{
const int length = -1;
const int downsample = 1;
@@ -422,7 +445,6 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
const int zero_point[3] = {0, 0, 0};
int directions[3];
int hsize;
- int coord_timelevel;
void *data;
CCTK_REAL *coord_data;
@@ -447,21 +469,13 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
if (have_coords)
{
- /* get the current time level for the coordinates */
- coord_timelevel = CCTK_NumTimeLevelsFromVarI (coord_index[dir]) - 1;
-
- if (Hyperslab_GetHyperslab (GH, 0, coord_index[dir],
- coord_timelevel, 1, origin, directions,
- &length, &downsample,
+ if (Hyperslab_GetHyperslab (GH, 0, coord_index[dir], 0, 1,
+ origin, directions, &length, &downsample,
(void **) &coord_data, &hsize) < 0)
{
- fullname = CCTK_FullName (coord_index[dir]);
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOASCII_Write1D: Failed to extract hyperslab for"
- " variable '%s'",
- fullname);
- free (fullname);
- continue;
+ "%c-coordinate", 'x' + dir);
}
}
else
@@ -505,11 +519,9 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
directions, &length, &downsample,
&data, &hsize) < 0)
{
- fullname = CCTK_FullName (vindex);
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOASCII_Write1D: Failed to extract hyperslab for "
"variable '%s'", fullname);
- free (fullname);
if (coord_data)
{
free (coord_data);
@@ -518,18 +530,15 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
}
/* And write it out on processor 0 */
- if (myproc == 0 && file[dir] != NULL)
+ if (myproc == 0 && file[dir] != NULL)
{
- CCTK_REAL coord_lower, offset;
-
-
if (group_static_data.grouptype == CCTK_GF)
{
if (dir < 3)
{
/* get the staggering offset for the xyz coordinates */
offset = CCTK_StaggerDirIndex (dir, group_static_data.stagtype) *
- 0.5 * GH->cctk_delta_space[dir];
+ 0.5 * GH->cctk_delta_space[dir];
if (! have_coords)
{
coord_data = (CCTK_REAL *) malloc (hsize * sizeof (CCTK_REAL));
@@ -550,8 +559,7 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
}
if (have_coords)
{
- CCTK_CoordRange (GH, &coord_lower, &offset, 1, NULL, "cart3d");
- offset = coord_lower * sqrt (3);
+ offset = coord_lower[0] * sqrt (3);
}
else
{
@@ -562,10 +570,6 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
/* print out header */
fprintf (file[dir], header_fmt, GH->cctk_time);
- if (group_static_data.vartype == CCTK_VARIABLE_COMPLEX)
- {
- fprintf (file[dir + 4], header_fmt, GH->cctk_time);
- }
/* and then loop through the line points */
switch (group_static_data.vartype)
@@ -592,6 +596,8 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
OUTPUT_TYPED_DATA (group_static_data.grouptype, hsize, coord_data,
offset, CCTK_COMPLEX, CCTK_CmplxReal, double, data,
data_fmt_real, file[dir]);
+ /* print out header */
+ fprintf (file[dir + 4], header_fmt, GH->cctk_time);
OUTPUT_TYPED_DATA (group_static_data.grouptype, hsize, coord_data,
offset, CCTK_COMPLEX, CCTK_CmplxImag, double, data,
data_fmt_real, file[dir + 4]);
@@ -616,6 +622,9 @@ void IOASCII_Write1D (cGH *GH, int vindex, const char *alias)
free (coord_data);
}
}
-
+
} /* end of loop through all directions */
+
+ /* free allocated resources */
+ free (fullname);
}
diff --git a/src/Write2D.c b/src/Write2D.c
index beead76..88c2015 100644
--- a/src/Write2D.c
+++ b/src/Write2D.c
@@ -2,9 +2,9 @@
@file Write2D.c
@date Thu May 11 2000
@author Thomas Radke
- @desc
+ @desc
Output two-dimensional slices in ASCII gnuplot format.
- @enddesc
+ @enddesc
@version $Id$
@@*/
@@ -30,15 +30,14 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write2D_c)
/* 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, grouptype, fmt_string, file) \
+ data, have_coords, fmt_string, file) \
{ \
int i, j; \
cctk_type *typed_data = (cctk_type *) (data); \
\
\
- /* grid functions are output along with their coordinates \
- grid array points are just indexed */ \
- if (grouptype == CCTK_GF) \
+ /* output coordinates if available otherwise just the indices */ \
+ if (have_coords) \
{ \
for (j = 0; j < data_hsizes[1]; j++) \
{ \
@@ -106,20 +105,24 @@ void IOASCII_Write2D (cGH *GH, int vindex, const char *alias)
int myproc;
asciiioGH *myGH;
char header_fmt_string[30]; /* header format string */
+ char zlabel_fmt_string[30]; /* z-label format string */
char data_fmt_string_int[30]; /* data format string for int types */
char data_fmt_string_real[30]; /* data format string for float types */
int dir;
int timelevel;
int groupindex;
+ int have_coords;
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 */
+ CCTK_REAL coord_lower[3]; /* coordinates' minima */
+ char coord_system[20]; /* name of the coordinate system */
int origin[3]; /* the slice origin */
+ CCTK_REAL dummy;
char *filename;
char *fullname;
char slicename[20];
- ioAdvertisedFileDesc advertised_file;
+ ioAdvertisedFileDesc advertised_file;
char buffer[128];
static char *extensions[3] = {"yz", "xz", "xy"};
@@ -132,7 +135,7 @@ void IOASCII_Write2D (cGH *GH, int vindex, const char *alias)
CCTK_GroupData (groupindex, &groupinfo);
/* check if variable has storage assigned */
- if (! CCTK_QueryGroupStorageI (GH, groupindex))
+ if (! CCTK_QueryGroupStorageI (GH, groupindex))
{
fullname = CCTK_FullName (vindex);
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
@@ -146,11 +149,37 @@ void IOASCII_Write2D (cGH *GH, int vindex, const char *alias)
/* set header and data format strings */
sprintf (header_fmt_string, "\n\n#Time = %%%s\n", out_format);
+ sprintf (zlabel_fmt_string, "#z-label %%s (%%c = %%%s)\n", out_format);
sprintf (data_fmt_string_int, "%%%s\t\t%%%s\t\t%%d\n",
out_format, out_format);
sprintf (data_fmt_string_real, "%%%s\t\t%%%s\t\t%%%s\n",
out_format, out_format, out_format);;
+ /* get the coordinate indices if we output a grid function */
+ if (groupinfo.grouptype == CCTK_GF)
+ {
+ sprintf (coord_system, "cart%dd", groupinfo.dim);
+ have_coords = 1;
+ for (dir = 0; dir < groupinfo.dim && dir < 3; dir++)
+ {
+ CCTK_CoordRange (GH, &coord_lower[dir], &dummy, dir+1, NULL,coord_system);
+ coord_index[dir] = CCTK_CoordIndex (dir + 1, NULL, coord_system);
+ have_coords &= coord_index[dir] >= 0;
+ }
+
+ if (! have_coords)
+ {
+ CCTK_VWarn (8, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "IOASCII_Write2D: No coordinate ranges found for '%s'",
+ coord_system);
+ }
+ }
+ else
+ {
+ /* CCTK_ARRAY variables never have coordinates associated */
+ have_coords = 0;
+ }
+
/* What processor are we on? */
myproc = CCTK_MyProc (GH);
@@ -160,26 +189,15 @@ void IOASCII_Write2D (cGH *GH, int vindex, const char *alias)
/* see if output file for this alias name was already created */
fdset_2D = (FILE **) GetNamedData (myGH->fileList_2D, alias);
- if (fdset_2D == NULL)
+ if (fdset_2D == NULL)
{
fdset_2D = (FILE **) malloc (3 * sizeof (FILE *));
filename = (char *) malloc (strlen (myGH->outdir2D) + strlen (alias) +
- sizeof (slicename) + 20 +
-#if 0
-FIXME: get rid of PUGH here
- strlen (pughGH->identity_string) + 20);
-#else
- 0);
-#endif
-
+ sizeof (slicename) + 20);
+
/* Open/Create files */
for (dir = 0; dir < 3; dir++)
{
-#if 0
- /* FIXME: move identity_string into cGH ?? */
- sprintf (filename, "%s/%s_2d_%s%s.gnuplot", myGH->outdir2D, alias,
- extensions[dir], pughGH->identity_string);
-#else
/* FIXME: this can go when we permanently switch the the
new filename scheme */
if (new_filename_scheme)
@@ -211,7 +229,6 @@ FIXME: get rid of PUGH here
sprintf (filename, "%s_2d_%s.gnuplot", alias, extensions[dir]);
}
}
-#endif
/* if restart from recovery, try to open an existing file ... */
fdset_2D[dir] = NULL;
@@ -225,7 +242,7 @@ FIXME: get rid of PUGH here
{
fdset_2D[dir] = fopen (filename, "w");
}
- if (! fdset_2D[dir])
+ if (! fdset_2D[dir])
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Cannot open 2D output file '%s'", filename);
@@ -265,7 +282,19 @@ FIXME: get rid of PUGH here
{
fprintf (fdset_2D[dir], "#x-label %c\n", extensions[dir][0]);
fprintf (fdset_2D[dir], "#y-label %c\n", extensions[dir][1]);
- fprintf (fdset_2D[dir], "#z-label %s\n", advertised_file.varname);
+ if (have_coords)
+ {
+ fprintf (fdset_2D[dir], zlabel_fmt_string,
+ advertised_file.varname, 'x' + dir,
+ coord_lower[dir] + GH->cctk_delta_space[dir] *
+ myGH->sp2xyz[groupinfo.dim-1][dir]);
+ }
+ else
+ {
+ fprintf (fdset_2D[dir], "#z-label %s (%c = %d)\n",
+ advertised_file.varname, 'x' + dir,
+ myGH->sp2xyz[groupinfo.dim-1][dir]);
+ }
}
free (advertised_file.varname);
@@ -278,38 +307,10 @@ FIXME: get rid of PUGH here
}
}
- /* get the coordinate indices if we output a grid function */
- if (groupinfo.grouptype == CCTK_GF)
- {
- switch (groupinfo.dim)
- {
- case 1:
- coord_index[0] = CCTK_CoordIndex (1, NULL, "cart1d");
- break;
- case 2:
- coord_index[0] = CCTK_CoordIndex (1, NULL, "cart2d");
- coord_index[1] = CCTK_CoordIndex (2, NULL, "cart2d");
- case 3:
- coord_index[0] = CCTK_CoordIndex (1, NULL, "cart3d");
- coord_index[1] = CCTK_CoordIndex (2, NULL, "cart3d");
- coord_index[2] = CCTK_CoordIndex (3, NULL, "cart3d");
- break;
- default:
- CCTK_WARN (4, "Cannot find appropriate coordinate system");
- break;
- }
-
- /* get the coordinate timelevels */
- for (dir = 0; dir < 3; dir++)
- {
- coord_timelevel[dir] = CCTK_NumTimeLevelsFromVarI (coord_index[dir]) - 1;
- }
- }
-
/* get the timelevel for the variable to output */
timelevel = CCTK_NumTimeLevelsFromVarI (vindex) - 1;
- for (dir = 0; dir < 3; dir++)
+ for (dir = 0; dir < 3; dir++)
{
int dir_i, dir_j;
int directions[3];
@@ -343,33 +344,27 @@ FIXME: get rid of PUGH here
directions[dir] = 1;
/* get the coordinates for grid function output */
- if (groupinfo.grouptype == CCTK_GF)
+ if (have_coords)
{
/* get the i-coordinate slice */
- if (Hyperslab_GetHyperslab (GH, 0, coord_index[dir_i],
- coord_timelevel[dir_i], 2, origin, directions,
- lengths, downsamples,
+ if (Hyperslab_GetHyperslab (GH, 0, coord_index[dir_i], 0, 2,
+ origin, directions, lengths, downsamples,
(void **) &coord_data_i, coord_hsizes) < 0)
{
- 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);
+ "Failed to extract 2D hyperslab for %c-coordinate",
+ 'x' + dir_i);
return;
}
/* get the j-coordinate slice */
- if (Hyperslab_GetHyperslab (GH, 0, coord_index[dir_j],
- coord_timelevel[dir_j], 2, origin, directions,
- lengths, downsamples,
+ if (Hyperslab_GetHyperslab (GH, 0, coord_index[dir_j], 0, 2,
+ origin, directions, lengths, downsamples,
(void **) &coord_data_j, coord_hsizes) < 0)
{
- 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);
+ "Failed to extract 2D hyperslab for %c-coordinate",
+ 'x' + dir_j);
free (coord_data_i);
return;
}
@@ -401,7 +396,7 @@ FIXME: get rid of PUGH here
}
/* proc 0 writes */
- if (myproc == 0)
+ if (myproc == 0)
{
CCTK_REAL stagger_offset_i, stagger_offset_j;
@@ -420,24 +415,21 @@ FIXME: get rid of PUGH here
case CCTK_VARIABLE_CHAR:
OUTPUT_TYPED_DATA (coord_hsizes, coord_data_i, coord_data_j,
stagger_offset_i, stagger_offset_j,
- data_hsizes, CCTK_BYTE, int, data,
- groupinfo.grouptype,
+ data_hsizes, CCTK_BYTE, int, data, have_coords,
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,
- groupinfo.grouptype,
+ data_hsizes, CCTK_INT, int, data, have_coords,
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,
- groupinfo.grouptype,
+ data_hsizes, CCTK_REAL, double, data, have_coords,
data_fmt_string_real, fdset_2D[dir]);
break;