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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
/*@@
@file GHExtension.c
@date Tue 9th Feb 1999
@author Gabrielle Allen
@desc
IOUtil GH extension stuff.
@enddesc
@version $Id$
@@*/
/*#define DEBUG_IO 1*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "cctk.h"
#include "cctk_Parameters.h"
#include "util_String.h"
#include "StoreNamedData.h"
#include "CactusBase/IOUtil/src/ioutil_Utils.h"
#include "ioGH.h"
static const char *rcsid = "$Header$";
CCTK_FILEVERSION(CactusBase_IOUtil_GHExtension_c)
/********************************************************************
********************* External Routines **********************
********************************************************************/
int IOUtil_InitGH (cGH *GH);
void *IOUtil_SetupGH (tFleshConfig *config,
int convergence_level,
cGH *GH);
/*@@
@routine IOUtil_SetupGH
@date Tue May 09 2000
@author Thomas Radke
@desc
Allocates the IOUtil 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
@@*/
void *IOUtil_SetupGH (tFleshConfig *config,
int convergence_level,
cGH *GH)
{
/* avoid compiler warnings about unused parameters */
config = config;
convergence_level = convergence_level;
GH = GH;
return (malloc (sizeof (ioGH)));
}
/*@@
@routine IOUtil_InitGH
@date Tue May 09 2000
@author Thomas Radke
@desc
The GH initialization routine for IOUtil.
Necessary output dirs are created.
Checkpoint/recovery timers are created
if timing information was requested.
@enddesc
@calledby CCTK scheduler at CCTK_INITIALIZE
@var GH
@vdesc pointer to grid hierarchy
@vtype cGH *
@vio in
@endvar
@@*/
int IOUtil_InitGH (cGH *GH)
{
DECLARE_CCTK_PARAMETERS
int i;
int maxdim;
ioGH *myGH;
myGH = (ioGH *) CCTK_GHExtension (GH, "IO");
if (CCTK_Equals (out3D_mode, "proc"))
{
myGH->ioproc = CCTK_MyProc (GH);
myGH->nioprocs = CCTK_nProcs (GH);
myGH->ioproc_every = 1;
}
else if (CCTK_Equals (out3D_mode, "np"))
{
if (out3D_procs > CCTK_nProcs (GH))
{
myGH->ioproc_every = CCTK_nProcs (GH);
CCTK_VInfo (CCTK_THORNSTRING, "Reducing 'IO::ioproc_every' to %d",
myGH->ioproc_every);
}
else
{
myGH->ioproc_every = out3D_procs;
}
myGH->nioprocs = CCTK_nProcs (GH) / myGH->ioproc_every +
(CCTK_nProcs (GH) % myGH->ioproc_every ? 1 : 0);
myGH->ioproc = CCTK_MyProc (GH) -
CCTK_MyProc (GH) % myGH->ioproc_every;
}
else /* IO::out3D_mode = "onefile" */
{
myGH->ioproc = 0;
myGH->nioprocs = 1;
myGH->ioproc_every = CCTK_nProcs (GH);
}
/* For now we can only have unchunked for a single output file */
if (out3D_unchunked || CCTK_nProcs (GH) == 1)
{
if (myGH->ioproc_every >= CCTK_nProcs (GH))
{
myGH->unchunked = 1;
}
else
{
CCTK_INFO ("Unchunked output not supported for multiple "
"output files. Output will be chunked.");
myGH->unchunked = 0;
}
}
else
{
myGH->unchunked = 0;
}
/* create the checkpoint directory */
i = IOUtil_CreateDirectory (GH, checkpoint_dir,
! CCTK_Equals (out3D_mode, "onefile"),
myGH->ioproc);
if (i < 0)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Problem creating checkpoint directory '%s'",
checkpoint_dir);
}
else if (i > 0 && CCTK_Equals (newverbose, "full"))
{
CCTK_VInfo (CCTK_THORNSTRING,
"IOUtil_InitGH: checkpoint directory '%s' already exists",
checkpoint_dir);
}
/* save downsampling parameters in ioUtilGH because they are temporarily
reset during checkpointing */
/* for now we have only parameters for the first 3 dimensions
the rest is constantly initialized to 1 */
maxdim = CCTK_MaxDim ();
myGH->downsample = (int *) malloc (maxdim * sizeof (int));
i = maxdim > 3 ? 3 : maxdim;
switch (i)
{
case 3 : myGH->downsample [2] = out3D_downsample_z;
case 2 : myGH->downsample [1] = out3D_downsample_y;
case 1 : myGH->downsample [0] = out3D_downsample_x;
}
for (i = 3; i < maxdim; i++)
{
myGH->downsample [i] = 1;
}
/* evaluate the 'IO::out_single' parameter only
if Cactus was compiled with double precision */
#ifdef SINGLE_PRECISION
myGH->out_single = 0;
#else
myGH->out_single = out3D_single;
#endif
/* reset the flag incidicating restart from recovery */
myGH->recovered = 0;
/* reset the flags array for the file reader */
myGH->do_inVars = NULL;
return (0);
}
|