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
|
/*@@
@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_DefineThorn.h"
#include "cctk_Parameters.h"
#include "CactusBase/IOUtil/src/ioGH.h"
#include "CactusPUGH/PUGH/src/include/pugh.h"
#include "ioPandaGH.h"
void Panda_Create(int, int);
void *IOPanda_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH)
{
int i, 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);
}
int IOPanda_InitGH (cGH *GH)
{
DECLARE_CCTK_PARAMETERS
int i;
ioGH *ioUtilGH;
pandaGH *myGH;
const cParamData *paramdata;
/* 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;
ParseVarsForOutput (out3D_vars, myGH->do_out3D);
/* Deal with the output directories */
/* Check whether "outdir3D" was set.
If so take this dir otherwise default to "IO::outdir" */
paramdata = CCTK_ParameterData ("outdir3D", CCTK_THORNSTRING);
if (paramdata && paramdata->n_set > 0)
myGH->outdir3D = strdup (outdir3D);
else
myGH->outdir3D = strdup (outdir);
/* create the output dir */
if (CCTK_MyProc (GH) == 0) {
FILE *fp;
i = CCTK_mkdir (myGH->outdir3D);
if (i < 0)
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Problem creating IOPanda 3D output directory '%s'", myGH->outdir3D);
else if (i > 0)
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"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);
}
|