aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/WriteScalar.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/WriteScalar.c b/src/WriteScalar.c
index c34143c..d857af4 100644
--- a/src/WriteScalar.c
+++ b/src/WriteScalar.c
@@ -266,6 +266,7 @@ void IOBasic_WriteScalarGS (const cGH *GH, int vindex, const char *alias)
void *data;
iobasicGH *myGH;
char *fullname, *filename;
+ const char *file_extension;
char format_str_real[15], format_str_int[15];
@@ -293,10 +294,22 @@ void IOBasic_WriteScalarGS (const cGH *GH, int vindex, const char *alias)
/* get the GH extensions for IOBasic */
myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic");
+ /* set the output file extension according to the output style */
+ if (new_filename_scheme)
+ {
+ file_extension = CCTK_Equals (outScalar_style, "gnuplot") ? ".asc" : ".xg";
+ }
+ else
+ {
+ file_extension = ".tl";
+ }
+
/* build the output filename */
- filename = (char *) malloc (strlen (myGH->outdirScalar) + strlen (alias) + 4);
- sprintf (filename, "%s%s.tl", myGH->outdirScalar, alias);
+ filename = (char *) malloc (strlen (myGH->outdirScalar) + strlen (alias) +
+ strlen (file_extension) + 1);
+ sprintf (filename, "%s%s%s", myGH->outdirScalar, alias, file_extension);
+ /* create/reopen the file */
file = OpenScalarFile (GH, vindex, filename, "tl", "Scalar value", alias);
if (file)
{