diff options
author | lanfer <lanfer@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 1999-12-16 15:39:01 +0000 |
---|---|---|
committer | lanfer <lanfer@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 1999-12-16 15:39:01 +0000 |
commit | b875046735df1734331e58b4dc3256302d389bb4 (patch) | |
tree | 3ebe37d314f089b4191be07f78d1f9b24b10e5ae /src/OutputInfo.c | |
parent | dacd91bb5504ab769340bd20fb6b56a1eb689258 (diff) |
automatic switch into the e-notation if numbers to stdout are getting two small/big
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@19 b589c3ab-70e8-4b4d-a09f-cba2dd200880
Diffstat (limited to 'src/OutputInfo.c')
-rw-r--r-- | src/OutputInfo.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/src/OutputInfo.c b/src/OutputInfo.c index 6eaae92..12545eb 100644 --- a/src/OutputInfo.c +++ b/src/OutputInfo.c @@ -28,6 +28,10 @@ int IOBasic_OutputInfoGH (cGH *GH) char *name=NULL; iobasicGH *myGH; + /* the number at which to switch from decimal to exp notation*/ + CCTK_REAL hprec,lprec; + hprec = 1.0e-8; + lprec =-1.0e-8; /* Get the GH extensions for IOBasic */ myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; @@ -41,9 +45,9 @@ int IOBasic_OutputInfoGH (cGH *GH) { char l1[1024],l2[1024],l3[1024]; - sprintf (l1," it | |"); - sprintf (l2," | t |"); - sprintf (l3,"--------------"); + sprintf (l1," it | |"); + sprintf (l2," | t |"); + sprintf (l3,"----------------"); for (i = 0; i < CCTK_NumVars (); i++) { @@ -62,9 +66,15 @@ int IOBasic_OutputInfoGH (cGH *GH) first = 0; } - /* Print the timestep information for all variables */ - printf("%4d |%7.3f|",GH->cctk_iteration,GH->cctk_time); + /* Print the timestep information for all variables */ + if ((GH->cctk_time>hprec)|| + (GH->cctk_time<lprec)|| + (GH->cctk_time==0.0)) + printf("%4d |%9.3f|",GH->cctk_iteration,GH->cctk_time); + else + printf("%4d |%7.3e|",GH->cctk_iteration,GH->cctk_time); + /* Loop over all variables */ for (i = 0; i < CCTK_NumVars (); i++) { @@ -75,8 +85,13 @@ int IOBasic_OutputInfoGH (cGH *GH) /* Check variable not already output this iteration */ if (myGH->outInfo_last [i] == GH->cctk_iteration) { - printf("%12.8f |%12.8f |",myGH->infovals[i][0],myGH->infovals[i][1]); - + if ((myGH->infovals[i][0]>hprec)|| + (myGH->infovals[i][0]<lprec)|| + (myGH->infovals[i][0]>hprec)==0.0) + printf("%12.8f |%12.8f |",myGH->infovals[i][0],myGH->infovals[i][1]); + else + printf("%10.6e |%10.6e |",myGH->infovals[i][0],myGH->infovals[i][1]); + } else { /* Get the variable name for this index (for filename) */ @@ -93,7 +108,14 @@ int IOBasic_OutputInfoGH (cGH *GH) myGH->infovals[i][0]=IOBasic_WriteInfo (GH, i, "minimum", name); myGH->infovals[i][1]=IOBasic_WriteInfo (GH, i, "maximum", name); - printf("%12.8f |%12.8f |",myGH->infovals[i][0],myGH->infovals[i][1]); + + + if ((myGH->infovals[i][0]>hprec)|| + (myGH->infovals[i][0]<lprec)|| + (myGH->infovals[i][0]>hprec)==0.0) + printf("%12.8f |%12.8f |",myGH->infovals[i][0],myGH->infovals[i][1]); + else + printf("%10.6e |%10.6e |",myGH->infovals[i][0],myGH->infovals[i][1]); /* Register GF as having info output this iteration */ myGH->outInfo_last [i] = GH->cctk_iteration; |