diff options
author | allen <allen@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 1999-09-21 11:27:32 +0000 |
---|---|---|
committer | allen <allen@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 1999-09-21 11:27:32 +0000 |
commit | 1940d71782b4cc3519972ebf4504bbe4486cf7d0 (patch) | |
tree | bc11dc4e95891c19d3e88c0b15bb4ebf068d1d45 /src/WriteGF.c | |
parent | ac667e93729515249ec4d81961d1c83e2a0e217d (diff) |
This commit was generated by cvs2svn to compensate for changes in r2, which
included commits to RCS files with non-trunk default branches.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@3 b589c3ab-70e8-4b4d-a09f-cba2dd200880
Diffstat (limited to 'src/WriteGF.c')
-rw-r--r-- | src/WriteGF.c | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/src/WriteGF.c b/src/WriteGF.c new file mode 100644 index 0000000..4580947 --- /dev/null +++ b/src/WriteGF.c @@ -0,0 +1,121 @@ +/*@@ + @routine WriteGF + @date Tue Apr 1 16:45:35 1997 + @author Paul Walker + @desc + Dumps the "0D" data. + @enddesc + @calls + @calledby + @history + @hauthor Thomas Radke @hdate 17 Mar 1999 + @hdesc included "cctk_Comm.h" to overload CCTK_GetMyProc() properly + @hendhistory +@@*/ + +#include <stdio.h> + +#include "cctk.h" +#include "cctk_Flesh.h" +#include "cctk_parameters.h" +#include "cctk_GHExtensions.h" +#include "cctk_Misc.h" +#include "cctk_Comm.h" +#include "cctk_WarnLevel.h" +#include "cctk_Reduction.h" +#include "iobasicGH.h" + +void IOBasic_WriteGF (cGH *GH, int index, const char *alias) +{ + DECLARE_CCTK_PARAMETERS + CCTK_REAL tt[1]; + int i; + int reduce_handle; + char *openmode; + FILE *file[4]; + + /* Open the file (we write only on proc0) */ + if (CCTK_MyProc (GH) == 0) { + + char fname[256]; + int handle; + iobasicGH *myGH; + + myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; + + /* see if output files for this alias name were already created */ + if (GetNamedData (myGH->filenameListScalar, alias) == NULL) { + /* just store a non-NULL pointer in database */ + StoreNamedData (&myGH->filenameListScalar, alias, (void *) 1); + openmode = "w"; + } else + openmode = "a"; + + sprintf (fname, "%s/%s_max.tl", myGH->outpfx_Scalar, alias); + file[0] = fopen(fname,openmode); + + sprintf(fname,"%s/%s_min.tl", myGH->outpfx_Scalar, alias); + file[1] = fopen(fname,openmode); + + sprintf(fname,"%s/%s_nm1.tl", myGH->outpfx_Scalar, alias); + file[2] = fopen(fname,openmode); + + sprintf(fname,"%s/%s_nm2.tl", myGH->outpfx_Scalar, alias); + file[3] = fopen(fname,openmode); + + if (*openmode == 'w') { + char title_start_char; + + if (CCTK_Equals(outScalar_style,"gnuplot")) + title_start_char = '#'; + else { + if (! CCTK_Equals(outScalar_style,"xgraph")) + CCTK_WARN(3,"Don't understand outScalar_style ... using xgraph"); + title_start_char = 34; + } + + fprintf (file[0],"%c%s max v time\n",title_start_char,alias); + fprintf (file[1],"%c%s min v time\n",title_start_char,alias); + fprintf (file[2],"%c%s norm1 v time\n",title_start_char,alias); + fprintf (file[3],"%c%s norm2 v time\n",title_start_char,alias); + } + + } + + reduce_handle = CCTK_ReductionHandle("maximum"); + if (reduce_handle > -1) + { + CCTK_Reduce(GH,-1,reduce_handle,1,CCTK_VARIABLE_REAL,tt,1,index); + if (CCTK_MyProc(GH) == 0) + fprintf(file[0],"%f %25.13f\n",GH->cctk_time,tt[0]); + } + + reduce_handle = CCTK_ReductionHandle("minimum"); + if (reduce_handle > -1) + { + CCTK_Reduce(GH,-1,reduce_handle,1,CCTK_VARIABLE_REAL,tt,1,index); + if (CCTK_MyProc(GH) == 0) + fprintf(file[1],"%f %25.13f\n",GH->cctk_time,tt[0]); + } + + reduce_handle = CCTK_ReductionHandle("norm1"); + if (reduce_handle > -1) + { + CCTK_Reduce(GH,-1,reduce_handle,1,CCTK_VARIABLE_REAL,tt,1,index); + if (CCTK_MyProc(GH) == 0) + fprintf(file[2],"%f %25.13f\n",GH->cctk_time,tt[0]); + } + + reduce_handle = CCTK_ReductionHandle("norm2"); + if (reduce_handle > -1) + { + CCTK_Reduce(GH,-1,reduce_handle,1,CCTK_VARIABLE_REAL,tt,1,index); + if (CCTK_MyProc(GH) == 0) + fprintf(file[3],"%f %25.13f\n",GH->cctk_time,tt[0]); + } + + if (CCTK_MyProc (GH) == 0) + for (i=0;i<4;i++) + fclose(file[i]); +} + |