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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
/*@@
@file GHExtension.c
@date 01 Oct 1999
@author Jonghyun Lee
@desc IOPanda GH extension stuff
@enddesc
@history
@endhistory
@@*/
/*#define DEBUG_IO*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "cctk.h"
#include "cctk_Parameters.h"
#include "CactusBase/IOUtil/src/ioGH.h"
#include "ioPandaGH.h"
void Panda_Create(int, int);
/*@@
@routine IOPanda_SetupGH
@date Fri 01 Oct 1999
@author Jonghyun Lee
@desc
Allocates the IOPanda GH extension structure.
@enddesc
@calledby CCTK scheduler at CCTK_INITIALIZE
@var config
@vdesc flesh configuration structure (unused)
@vtype tFleshConfig *
@vio in
@endvar
@var convergence_level
@vdesc convergence level (unused)
@vtype int
@vio in
@endvar
@var GH
@vdesc pointer to grid hierarchy
@vtype cGH *
@vio in
@endvar
@history
@endhistory
@@*/
void *IOPanda_SetupGH (tFleshConfig *config,
int convergence_level,
cGH *GH)
{
int numvars;
pandaGH *newGH;
numvars = CCTK_NumVars ();
newGH = (pandaGH *) malloc (sizeof (pandaGH));
newGH->do_out3D = (char *) malloc (numvars * sizeof (char));
newGH->out3D_last = (int *) malloc (numvars * sizeof (int));
return (newGH);
}
/*@@
@routine IOPanda_InitGH
@date Fri 01 Oct 1999
@author Jonghyun Lee
@desc
The GH initialization routine for IOFlexIO.
Necessary output dirs are created.
@enddesc
@calledby CCTK scheduler at CCTK_INITIALIZE
@var GH
@vdesc pointer to grid hierarchy
@vtype cGH *
@vio in
@endvar
@history
@endhistory
@@*/
int IOPanda_InitGH (cGH *GH)
{
DECLARE_CCTK_PARAMETERS
int i;
ioGH *ioUtilGH;
pandaGH *myGH;
/* get the handles for IOUtil and IOPanda extensions */
ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
myGH = (pandaGH *) GH->extensions [CCTK_GHExtensionHandle ("IOPanda")];
/* How often to output */
myGH->out3D_every = out_every > 0 ? out_every : -1;
if (out3D_every > 0)
{
myGH->out3D_every = out3D_every;
}
/* Check whether "outdir3D" was set.
If so take this dir otherwise default to "IO::outdir" */
if (CCTK_ParameterQueryTimesSet ("outdir3D", CCTK_THORNSTRING) > 0)
{
myGH->outdir3D = strdup (outdir3D);
}
else
{
myGH->outdir3D = strdup (outdir);
}
/* Create the output directory */
if (CCTK_MyProc (GH) == 0)
{
FILE *fp;
i = CCTK_CreateDirectory (0755, myGH->outdir3D);
if (i < 0)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOPanda_InitGH: Problem creating IOPanda 3D output "
"directory '%s'", myGH->outdir3D);
}
else if (i > 0)
{
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOPanda_InitGH: IOPanda 3D output directory '%s' already "
"exists", myGH->outdir3D);
}
fp = fopen ("FILEPREFIX", "w");
fprintf (fp, "%s", myGH->outdir3D);
fclose (fp);
}
for (i = 0; i < CCTK_NumVars (); i++)
{
myGH->out3D_last [i] = -1;
}
Panda_Create (ioUtilGH->ioproc_every, 1);
return (0);
}
|