diff options
author | tradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 2001-03-19 23:28:53 +0000 |
---|---|---|
committer | tradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 2001-03-19 23:28:53 +0000 |
commit | 8e915effdbd2b082fc2fbd100f9c0d9219ea2b37 (patch) | |
tree | be1f69523230492ec115a062550f0b1fffeac09d /src/WriteGF.c | |
parent | 41ff08ada1a4e9bbfc561fc4d34f759ec68291da (diff) |
Added the parameter filename, the creation date, and the axis labels
as comments at the top of the output files.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@83 b589c3ab-70e8-4b4d-a09f-cba2dd200880
Diffstat (limited to 'src/WriteGF.c')
-rw-r--r-- | src/WriteGF.c | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/WriteGF.c b/src/WriteGF.c index 946d593..45c0a29 100644 --- a/src/WriteGF.c +++ b/src/WriteGF.c @@ -48,7 +48,7 @@ CCTK_FILEVERSION(CactusBase_IOBasic_WriteGF_c) @vtype cGH * @vio in @endvar - @var index + @var vindex @vdesc CCTK index of the variable to output @vtype int @vio in @@ -60,7 +60,7 @@ CCTK_FILEVERSION(CactusBase_IOBasic_WriteGF_c) @endvar @@*/ void IOBasic_WriteGF (cGH *GH, - int index, + int vindex, const char *alias) { DECLARE_CCTK_PARAMETERS @@ -73,10 +73,10 @@ void IOBasic_WriteGF (cGH *GH, char *reduction_op; char *string_start; char *string_end; - char title_start_char; - char *format_str; + char comment_char; + char format_str[15]; const char *file_extension; - char *fullname; + char *fullname, buffer[128]; struct stat fileinfo; ioAdvertisedFileDesc advertised_file; CCTK_REAL reduction_value; @@ -87,9 +87,9 @@ void IOBasic_WriteGF (cGH *GH, /* first, check if variable has storage assigned */ - if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index))) + if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (vindex))) { - fullname = CCTK_FullName (index); + fullname = CCTK_FullName (vindex); CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "IOBasic_WriteGF: No scalar output for '%s' (no storage)", fullname); @@ -97,19 +97,19 @@ void IOBasic_WriteGF (cGH *GH, return; } - /* check if decimal or exponential format desired */ - format_str = CCTK_Equals (out_format, "f") ? "%f %25.13f\n" : "%e %25.13e\n"; + /* set output format */ + sprintf (format_str, "%%%s\t%%%s\n", out_format, out_format); /* set the output file extension and the output style */ if (CCTK_Equals (outScalar_style, "gnuplot")) { file_extension = ".asc"; - title_start_char = '#'; + comment_char = '#'; } else { file_extension = ".xg"; - title_start_char = 34; + comment_char = '"'; } /* get the GH extension handle for IOBasic */ @@ -159,7 +159,7 @@ void IOBasic_WriteGF (cGH *GH, /* do the reduction (all processors) */ ierr = CCTK_Reduce (GH, 0, reduction_handle, 1, CCTK_VARIABLE_REAL, - &reduction_value, 1, index); + &reduction_value, 1, vindex); /* dump the reduction value to file by processor 0 */ if (ierr == 0 && CCTK_MyProc (GH) == 0) @@ -226,23 +226,31 @@ void IOBasic_WriteGF (cGH *GH, continue; } - /* when creating the file, write the header, - advertise the file, and save the filename in the database */ + /* when creating the file, advertise it for downloading, + write the header and the file info, + and save the filename in the database */ if (*openmode == 'w') { - fprintf (file, "%c%s %s v time\n", title_start_char, alias, - reduction_op); - /* advertise the file for downloading */ advertised_file.slice = reduction_op; advertised_file.thorn = CCTK_THORNSTRING; - advertised_file.varname = CCTK_FullName (index); + advertised_file.varname = CCTK_FullName (vindex); advertised_file.description = "Reduction on Grid Functions"; advertised_file.mimetype = CCTK_Equals (outScalar_style, "gnuplot") ? "application/gnuplot" : "application/x-graph"; IOUtil_AdvertiseFile (GH, filename, &advertised_file); + CCTK_ParameterFilename (sizeof (buffer), buffer); + fprintf (file, "%cParameter file %s\n", comment_char, buffer); + Util_CurrentTime (sizeof (buffer), buffer); + fprintf (file, "%cCreated %s\n", comment_char, buffer); + fprintf (file, "%cx-label time\n", comment_char); + fprintf (file, "%cy-label %s\n", + comment_char, advertised_file.varname); + fprintf (file, "%c%s %s v time\n", comment_char, alias, + reduction_op); + free (advertised_file.varname); /* just store a non-NULL pointer in database */ |