1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/*@@
@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_parameters.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->outdirScalar, alias);
file[0] = fopen(fname,openmode);
sprintf(fname,"%s/%s_min.tl", myGH->outdirScalar, alias);
file[1] = fopen(fname,openmode);
sprintf(fname,"%s/%s_nm1.tl", myGH->outdirScalar, alias);
file[2] = fopen(fname,openmode);
sprintf(fname,"%s/%s_nm2.tl", myGH->outdirScalar, 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]);
}
|