aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlanfer <lanfer@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2000-03-02 15:44:41 +0000
committerlanfer <lanfer@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2000-03-02 15:44:41 +0000
commitb32ca03ec667173fef1c91928059de98912e0b15 (patch)
treebc7c8a335d79b1c43a073e555053fdb00324fca8 /src
parent5bbae845df0f9f1202ad7ac5cc788d2291294a8e (diff)
allow exponential format in output
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@39 b589c3ab-70e8-4b4d-a09f-cba2dd200880
Diffstat (limited to 'src')
-rw-r--r--src/Write.c13
-rw-r--r--src/WriteGF.c10
2 files changed, 20 insertions, 3 deletions
diff --git a/src/Write.c b/src/Write.c
index d10d69e..322cc62 100644
--- a/src/Write.c
+++ b/src/Write.c
@@ -27,7 +27,10 @@ void IOBasic_Write (cGH *GH, int index, const char *alias)
FILE *file;
CCTK_REAL *data_real;
CCTK_INT *data_int;
+ int decnot;
+ /* check if decimal or exponential notation desired*/
+ decnot=CCTK_Equals(out_format,"f")?1:0;
/* first, check if variable has storage assigned */
if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index))) {
@@ -82,11 +85,17 @@ void IOBasic_Write (cGH *GH, int index, const char *alias)
switch (CCTK_VarTypeI(index)) {
case CCTK_VARIABLE_REAL:
data_real = ((CCTK_REAL ***) GH->data) [index][0];
- fprintf(file,"%f %25.13f\n",GH->cctk_time,*data_real);
+ if (decnot)
+ fprintf(file,"%f %25.13f\n",GH->cctk_time,*data_real);
+ else
+ fprintf(file,"%e %25.13e\n",GH->cctk_time,*data_real);
break;
case CCTK_VARIABLE_INT:
data_int = ((CCTK_INT ***) GH->data) [index][0];
- fprintf(file,"%f %d\n",GH->cctk_time,*data_int);
+ if (decnot)
+ fprintf(file,"%f %d\n",GH->cctk_time,*data_int);
+ else
+ fprintf(file,"%e %d\n",GH->cctk_time,*data_int);
break;
default:
CCTK_WARN (3, "Unsupported data type");
diff --git a/src/WriteGF.c b/src/WriteGF.c
index 8c7ed8c..b9cb1e5 100644
--- a/src/WriteGF.c
+++ b/src/WriteGF.c
@@ -30,6 +30,8 @@ void IOBasic_WriteGF (cGH *GH, int index, const char *alias)
char *filename;
char title_start_char;
int reduction_handle;
+ int decnot;
+
CCTK_REAL reduction_value;
/* add more reductions to this table if you want, telling it
- the reduction operator
@@ -45,8 +47,11 @@ void IOBasic_WriteGF (cGH *GH, int index, const char *alias)
{"norm1", "norm1", "nm1"},
{"norm2", "norm2", "nm2"},
};
+
#define NUM_REDUCTIONS (sizeof (reductions) / sizeof (reductions [0]))
+ /* check if decimal or exponential format desired */
+ decnot = CCTK_Equals(out_format,"f")?1:0;
/* first, check if variable has storage assigned */
if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index))) {
@@ -116,7 +121,10 @@ void IOBasic_WriteGF (cGH *GH, int index, const char *alias)
}
/* write the data and close the file */
- fprintf (file, "%f %25.13f\n", GH->cctk_time, reduction_value);
+ if (decnot)
+ fprintf (file, "%f %25.13f\n", GH->cctk_time, reduction_value);
+ else
+ fprintf (file, "%e %25.13e\n", GH->cctk_time, reduction_value);
fclose (file);
}
}