Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
e7f0fdd9
Commit
e7f0fdd9
authored
Aug 20, 2016
by
Matthieu Schaller
Browse files
Eliminated warnings at -w3 level
parent
eaa22df7
Changes
12
Hide whitespace changes
Inline
Side-by-side
src/common_io.c
View file @
e7f0fdd9
...
...
@@ -515,13 +515,13 @@ void writeXMFgroupheader(FILE* xmfFile, char* hdfFileName, size_t N,
fprintf
(
xmfFile
,
"
\n
<Grid Name=
\"
%s
\"
GridType=
\"
Uniform
\"
>
\n
"
,
particle_type_names
[
ptype
]);
fprintf
(
xmfFile
,
"<Topology TopologyType=
\"
Polyvertex
\"
Dimensions=
\"
%z
i
\"
/>
\n
"
,
N
);
"<Topology TopologyType=
\"
Polyvertex
\"
Dimensions=
\"
%z
u
\"
/>
\n
"
,
N
);
fprintf
(
xmfFile
,
"<Geometry GeometryType=
\"
XYZ
\"
>
\n
"
);
fprintf
(
xmfFile
,
"<DataItem Dimensions=
\"
%z
i
3
\"
NumberType=
\"
Double
\"
"
"<DataItem Dimensions=
\"
%z
u
3
\"
NumberType=
\"
Double
\"
"
"Precision=
\"
8
\"
"
"Format=
\"
HDF
\"
>%s:/PartType%d/Coordinates</DataItem>
\n
"
,
N
,
hdfFileName
,
ptype
);
N
,
hdfFileName
,
(
int
)
ptype
);
fprintf
(
xmfFile
,
"</Geometry>
\n
<!-- Done geometry for %s, start of particle fields "
"list -->
\n
"
,
...
...
@@ -555,12 +555,12 @@ void writeXMFline(FILE* xmfFile, const char* fileName,
name
,
dim
==
1
?
"Scalar"
:
"Vector"
);
if
(
dim
==
1
)
fprintf
(
xmfFile
,
"<DataItem Dimensions=
\"
%z
i
\"
NumberType=
\"
Double
\"
"
"<DataItem Dimensions=
\"
%z
u
\"
NumberType=
\"
Double
\"
"
"Precision=
\"
%d
\"
Format=
\"
HDF
\"
>%s:%s/%s</DataItem>
\n
"
,
N
,
type
==
FLOAT
?
4
:
8
,
fileName
,
partTypeGroupName
,
name
);
else
fprintf
(
xmfFile
,
"<DataItem Dimensions=
\"
%z
i
%d
\"
NumberType=
\"
Double
\"
"
"<DataItem Dimensions=
\"
%z
u
%d
\"
NumberType=
\"
Double
\"
"
"Precision=
\"
%d
\"
Format=
\"
HDF
\"
>%s:%s/%s</DataItem>
\n
"
,
N
,
dim
,
type
==
FLOAT
?
4
:
8
,
fileName
,
partTypeGroupName
,
name
);
fprintf
(
xmfFile
,
"</Attribute>
\n
"
);
...
...
@@ -582,7 +582,7 @@ void prepare_dm_gparts(struct gpart* const gparts, size_t Ndm) {
for
(
size_t
i
=
0
;
i
<
Ndm
;
++
i
)
{
/* 0 or negative ids are not allowed */
if
(
gparts
[
i
].
id_or_neg_offset
<=
0
)
error
(
"0 or negative ID for DM particle %z
d
: ID=%lld"
,
i
,
error
(
"0 or negative ID for DM particle %z
u
: ID=%lld"
,
i
,
gparts
[
i
].
id_or_neg_offset
);
}
}
...
...
@@ -650,7 +650,7 @@ void collect_dm_gparts(const struct gpart* const gparts, size_t Ntot,
/* Check that everything is fine */
if
(
count
!=
Ndm
)
error
(
"Collected the wrong number of dm particles (%z
d
vs. %z
d
expected)"
,
error
(
"Collected the wrong number of dm particles (%z
u
vs. %z
u
expected)"
,
count
,
Ndm
);
}
...
...
src/debug.c
View file @
e7f0fdd9
...
...
@@ -71,7 +71,7 @@ void printParticle(const struct part *parts, struct xpart *xparts,
/* Look for the particle. */
for
(
size_t
i
=
0
;
i
<
N
;
i
++
)
if
(
parts
[
i
].
id
==
id
)
{
printf
(
"## Particle[%z
d
]:
\n
id=%lld "
,
i
,
parts
[
i
].
id
);
printf
(
"## Particle[%z
u
]:
\n
id=%lld "
,
i
,
parts
[
i
].
id
);
hydro_debug_particle
(
&
parts
[
i
],
&
xparts
[
i
]);
found
=
1
;
break
;
...
...
@@ -100,13 +100,13 @@ void printgParticle(const struct gpart *gparts, const struct part *parts,
/* Look for the particle. */
for
(
size_t
i
=
0
;
i
<
N
;
i
++
)
if
(
gparts
[
i
].
id_or_neg_offset
==
id
)
{
printf
(
"## gParticle[%z
d
] (DM) :
\n
id=%lld"
,
i
,
id
);
printf
(
"## gParticle[%z
u
] (DM) :
\n
id=%lld"
,
i
,
id
);
gravity_debug_particle
(
&
gparts
[
i
]);
found
=
1
;
break
;
}
else
if
(
gparts
[
i
].
id_or_neg_offset
<
0
&&
parts
[
-
gparts
[
i
].
id_or_neg_offset
].
id
==
id
)
{
printf
(
"## gParticle[%z
d
] (hydro) :
\n
id=%lld"
,
i
,
id
);
printf
(
"## gParticle[%z
u
] (hydro) :
\n
id=%lld"
,
i
,
id
);
gravity_debug_particle
(
&
gparts
[
i
]);
found
=
1
;
break
;
...
...
@@ -159,7 +159,7 @@ int checkSpacehmax(struct space *s) {
/* Now all particles. */
float
part_h_max
=
0
.
0
f
;
for
(
in
t
k
=
0
;
k
<
s
->
nr_parts
;
k
++
)
{
for
(
size_
t
k
=
0
;
k
<
s
->
nr_parts
;
k
++
)
{
if
(
s
->
parts
[
k
].
h
>
part_h_max
)
{
part_h_max
=
s
->
parts
[
k
].
h
;
}
...
...
@@ -178,7 +178,7 @@ int checkSpacehmax(struct space *s) {
}
}
for
(
in
t
k
=
0
;
k
<
s
->
nr_parts
;
k
++
)
{
for
(
size_
t
k
=
0
;
k
<
s
->
nr_parts
;
k
++
)
{
if
(
s
->
parts
[
k
].
h
>
cell_h_max
)
{
message
(
"part %lld is inconsistent (%f > %f)"
,
s
->
parts
[
k
].
id
,
s
->
parts
[
k
].
h
,
cell_h_max
);
...
...
src/engine.c
View file @
e7f0fdd9
...
...
@@ -296,7 +296,7 @@ void engine_redistribute(struct engine *e) {
parts
[
k
].
x
[
2
]
*
iwidth
[
2
]);
#ifdef SWIFT_DEBUG_CHECKS
if
(
cid
<
0
||
cid
>=
s
->
nr_cells
)
error
(
"Bad cell id %i for part %z
i
at [%.3e,%.3e,%.3e]."
,
cid
,
k
,
error
(
"Bad cell id %i for part %z
u
at [%.3e,%.3e,%.3e]."
,
cid
,
k
,
parts
[
k
].
x
[
0
],
parts
[
k
].
x
[
1
],
parts
[
k
].
x
[
2
]);
#endif
...
...
@@ -352,7 +352,7 @@ void engine_redistribute(struct engine *e) {
gparts
[
k
].
x
[
2
]
*
iwidth
[
2
]);
#ifdef SWIFT_DEBUG_CHECKS
if
(
cid
<
0
||
cid
>=
s
->
nr_cells
)
error
(
"Bad cell id %i for part %z
i
at [%.3e,%.3e,%.3e]."
,
cid
,
k
,
error
(
"Bad cell id %i for part %z
u
at [%.3e,%.3e,%.3e]."
,
cid
,
k
,
gparts
[
k
].
x
[
0
],
gparts
[
k
].
x
[
1
],
gparts
[
k
].
x
[
2
]);
#endif
...
...
@@ -587,7 +587,7 @@ void engine_redistribute(struct engine *e) {
int
my_cells
=
0
;
for
(
int
k
=
0
;
k
<
nr_cells
;
k
++
)
if
(
cells
[
k
].
nodeID
==
nodeID
)
my_cells
+=
1
;
message
(
"node %i now has %z
i
parts and %z
i
gparts in %i cells."
,
nodeID
,
message
(
"node %i now has %z
u
parts and %z
u
gparts in %i cells."
,
nodeID
,
nr_parts
,
nr_gparts
,
my_cells
);
}
...
...
@@ -878,7 +878,7 @@ void engine_exchange_cells(struct engine *e) {
/* Count the number of particles we need to import and re-allocate
the buffer if needed. */
in
t
count_parts_in
=
0
,
count_gparts_in
=
0
;
size_
t
count_parts_in
=
0
,
count_gparts_in
=
0
;
for
(
int
k
=
0
;
k
<
nr_proxies
;
k
++
)
for
(
int
j
=
0
;
j
<
e
->
proxies
[
k
].
nr_cells_in
;
j
++
)
{
count_parts_in
+=
e
->
proxies
[
k
].
cells_in
[
j
]
->
count
;
...
...
@@ -968,7 +968,7 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts,
if
(
pid
<
0
)
{
error
(
"Do not have a proxy for the requested nodeID %i for part with "
"id=%ll
u
, x=[%e,%e,%e]."
,
"id=%ll
d
, x=[%e,%e,%e]."
,
node_id
,
s
->
parts
[
offset_parts
+
k
].
id
,
s
->
parts
[
offset_parts
+
k
].
x
[
0
],
s
->
parts
[
offset_parts
+
k
].
x
[
1
],
s
->
parts
[
offset_parts
+
k
].
x
[
2
]);
...
...
@@ -1032,7 +1032,7 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts,
count_gparts_in
+=
e
->
proxies
[
k
].
nr_gparts_in
;
}
if
(
e
->
verbose
)
{
message
(
"sent out %z
i
/%z
i
parts/gparts, got %i/%i back."
,
*
Npart
,
*
Ngpart
,
message
(
"sent out %z
u
/%z
u
parts/gparts, got %i/%i back."
,
*
Npart
,
*
Ngpart
,
count_parts_in
,
count_gparts_in
);
}
if
(
offset_parts
+
count_parts_in
>
s
->
size_parts
)
{
...
...
@@ -1126,13 +1126,13 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts,
reqs_in
[
pid
+
1
]
==
MPI_REQUEST_NULL
&&
reqs_in
[
pid
+
2
]
==
MPI_REQUEST_NULL
)
{
/* Copy the particle data to the part/xpart/gpart arrays. */
struct
proxy
*
p
=
&
e
->
proxies
[
pid
/
3
];
memcpy
(
&
s
->
parts
[
offset_parts
+
count_parts
],
p
->
parts_in
,
sizeof
(
struct
part
)
*
p
->
nr_parts_in
);
memcpy
(
&
s
->
xparts
[
offset_parts
+
count_parts
],
p
->
xparts_in
,
sizeof
(
struct
xpart
)
*
p
->
nr_parts_in
);
memcpy
(
&
s
->
gparts
[
offset_gparts
+
count_gparts
],
p
->
gparts_in
,
sizeof
(
struct
gpart
)
*
p
->
nr_gparts_in
);
struct
proxy
*
p
rox
=
&
e
->
proxies
[
pid
/
3
];
memcpy
(
&
s
->
parts
[
offset_parts
+
count_parts
],
p
rox
->
parts_in
,
sizeof
(
struct
part
)
*
p
rox
->
nr_parts_in
);
memcpy
(
&
s
->
xparts
[
offset_parts
+
count_parts
],
p
rox
->
xparts_in
,
sizeof
(
struct
xpart
)
*
p
rox
->
nr_parts_in
);
memcpy
(
&
s
->
gparts
[
offset_gparts
+
count_gparts
],
p
rox
->
gparts_in
,
sizeof
(
struct
gpart
)
*
p
rox
->
nr_gparts_in
);
/* for (int k = offset; k < offset + count; k++)
message(
"received particle %lli, x=[%.3e %.3e %.3e], h=%.3e, from node %i.",
...
...
@@ -1140,8 +1140,8 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts,
s->parts[k].x[2], s->parts[k].h, p->nodeID); */
/* Re-link the gparts. */
for
(
int
k
=
0
;
k
<
p
->
nr_gparts_in
;
k
++
)
{
struct
gpart
*
gp
=
&
s
->
gparts
[
offset_gparts
+
count_gparts
+
k
];
for
(
int
k
k
=
0
;
k
k
<
p
rox
->
nr_gparts_in
;
k
k
++
)
{
struct
gpart
*
gp
=
&
s
->
gparts
[
offset_gparts
+
count_gparts
+
k
k
];
if
(
gp
->
id_or_neg_offset
<=
0
)
{
struct
part
*
p
=
&
s
->
parts
[
offset_gparts
+
count_parts
-
gp
->
id_or_neg_offset
];
...
...
@@ -1151,8 +1151,8 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts,
}
/* Advance the counters. */
count_parts
+=
p
->
nr_parts_in
;
count_gparts
+=
p
->
nr_gparts_in
;
count_parts
+=
p
rox
->
nr_parts_in
;
count_gparts
+=
p
rox
->
nr_gparts_in
;
}
}
...
...
@@ -2021,8 +2021,8 @@ void engine_print_task_counts(struct engine *e) {
printf
(
" %s=%i"
,
taskID_names
[
k
],
counts
[
k
]);
printf
(
" skipped=%i ]
\n
"
,
counts
[
task_type_count
]);
fflush
(
stdout
);
message
(
"nr_parts = %z
i
."
,
e
->
s
->
nr_parts
);
message
(
"nr_gparts = %z
i
."
,
e
->
s
->
nr_gparts
);
message
(
"nr_parts = %z
u
."
,
e
->
s
->
nr_parts
);
message
(
"nr_gparts = %z
u
."
,
e
->
s
->
nr_gparts
);
}
/**
...
...
@@ -2489,11 +2489,11 @@ void engine_step(struct engine *e) {
if
(
e
->
nodeID
==
0
)
{
/* Print some information to the screen */
printf
(
" %6d %14e %14e %10z
d
%10z
d
%21.3f
\n
"
,
e
->
step
,
e
->
time
,
printf
(
" %6d %14e %14e %10z
u
%10z
u
%21.3f
\n
"
,
e
->
step
,
e
->
time
,
e
->
timeStep
,
e
->
updates
,
e
->
g_updates
,
e
->
wallclock_time
);
fflush
(
stdout
);
fprintf
(
e
->
file_timesteps
,
" %6d %14e %14e %10z
d
%10z
d
%21.3f
\n
"
,
e
->
step
,
fprintf
(
e
->
file_timesteps
,
" %6d %14e %14e %10z
u
%10z
u
%21.3f
\n
"
,
e
->
step
,
e
->
time
,
e
->
timeStep
,
e
->
updates
,
e
->
g_updates
,
e
->
wallclock_time
);
fflush
(
e
->
file_timesteps
);
}
...
...
@@ -2708,7 +2708,7 @@ void engine_split(struct engine *e, struct partition *initial_partition) {
/* Re-allocate the local parts. */
if
(
e
->
verbose
)
message
(
"Re-allocating parts array from %z
i
to %z
i
."
,
s
->
size_parts
,
message
(
"Re-allocating parts array from %z
u
to %z
u
."
,
s
->
size_parts
,
(
size_t
)(
s
->
nr_parts
*
1
.
2
));
s
->
size_parts
=
s
->
nr_parts
*
1
.
2
;
struct
part
*
parts_new
=
NULL
;
...
...
@@ -2730,7 +2730,7 @@ void engine_split(struct engine *e, struct partition *initial_partition) {
/* Re-allocate the local gparts. */
if
(
e
->
verbose
)
message
(
"Re-allocating gparts array from %z
i
to %z
i
."
,
s
->
size_gparts
,
message
(
"Re-allocating gparts array from %z
u
to %z
u
."
,
s
->
size_gparts
,
(
size_t
)(
s
->
nr_gparts
*
1
.
2
));
s
->
size_gparts
=
s
->
nr_gparts
*
1
.
2
;
struct
gpart
*
gparts_new
=
NULL
;
...
...
src/parallel_io.c
View file @
e7f0fdd9
...
...
@@ -528,27 +528,18 @@ void read_ic_parallel(char* fileName, const struct UnitSystem* internal_units,
int
num_fields
=
0
;
struct
io_props
list
[
100
];
size_t
N
=
0
;
size_t
N
particles
=
0
;
/* Read particle fields into the particle structure */
switch
(
ptype
)
{
case
GAS
:
/* if (!dry_run) */
/* hydro_read_particles(h_grp, N[ptype], N_total[ptype],
* offset[ptype], */
/* *parts); */
/* break; */
N
=
*
Ngas
;
Nparticles
=
*
Ngas
;
hydro_read_particles
(
*
parts
,
list
,
&
num_fields
);
break
;
case
DM
:
/* if (!dry_run) */
/* darkmatter_read_particles(h_grp, N[ptype], N_total[ptype], */
/* offset[ptype], *gparts); */
/* break; */
N
=
Ndm
;
Nparticles
=
Ndm
;
darkmatter_read_particles
(
*
gparts
,
list
,
&
num_fields
);
break
;
...
...
@@ -559,7 +550,7 @@ void read_ic_parallel(char* fileName, const struct UnitSystem* internal_units,
/* Read everything */
if
(
!
dry_run
)
for
(
int
i
=
0
;
i
<
num_fields
;
++
i
)
readArray
(
h_grp
,
list
[
i
],
N
,
N_total
[
ptype
],
offset
[
ptype
],
readArray
(
h_grp
,
list
[
i
],
N
particles
,
N_total
[
ptype
],
offset
[
ptype
],
internal_units
,
ic_units
);
/* Close particle group */
...
...
@@ -793,13 +784,13 @@ void write_output_parallel(struct engine* e, const char* baseName,
int
num_fields
=
0
;
struct
io_props
list
[
100
];
size_t
N
=
0
;
size_t
N
particles
=
0
;
/* Write particle fields from the particle structure */
switch
(
ptype
)
{
case
GAS
:
N
=
Ngas
;
N
particles
=
Ngas
;
hydro_write_particles
(
parts
,
list
,
&
num_fields
);
break
;
...
...
@@ -816,7 +807,7 @@ void write_output_parallel(struct engine* e, const char* baseName,
collect_dm_gparts
(
gparts
,
Ntot
,
dmparts
,
Ndm
);
/* Write DM particles */
N
=
Ndm
;
N
particles
=
Ndm
;
darkmatter_write_particles
(
dmparts
,
list
,
&
num_fields
);
/* Free temporary array */
...
...
@@ -829,9 +820,9 @@ void write_output_parallel(struct engine* e, const char* baseName,
/* Write everything */
for
(
int
i
=
0
;
i
<
num_fields
;
++
i
)
writeArray
(
e
,
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
list
[
i
],
N
,
N_total
[
ptype
],
mpi_rank
,
offset
[
ptype
],
internal_units
,
snapshot_units
);
writeArray
(
e
,
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
list
[
i
],
Nparticles
,
N_total
[
ptype
],
mpi_rank
,
offset
[
ptype
],
internal_units
,
snapshot_units
);
/* Free temporary array */
free
(
dmparts
);
...
...
src/runner.c
View file @
e7f0fdd9
...
...
@@ -609,7 +609,7 @@ static void runner_do_drift(struct cell *c, struct engine *e) {
if
(
!
c
->
split
)
{
/* Loop over all the g-particles in the cell */
const
in
t
nr_gparts
=
c
->
gcount
;
const
size_
t
nr_gparts
=
c
->
gcount
;
for
(
size_t
k
=
0
;
k
<
nr_gparts
;
k
++
)
{
/* Get a handle on the gpart. */
...
...
src/runner_doiact.h
View file @
e7f0fdd9
...
...
@@ -2864,14 +2864,15 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
/* Get the sorting index. */
int
sid
=
0
;
for
(
int
k
=
0
;
k
<
3
;
k
++
)
sid
=
3
*
sid
+
((
cj
->
loc
[
k
]
-
ci
->
loc
[
k
]
+
shift
[
k
]
<
0
)
?
0
:
(
cj
->
loc
[
k
]
-
ci
->
loc
[
k
]
+
shift
[
k
]
>
0
)
?
2
:
1
);
sid
=
sortlistID
[
sid
];
new_
sid
=
3
*
new_sid
+
((
cj
->
loc
[
k
]
-
ci
->
loc
[
k
]
+
shift
[
k
]
<
0
)
?
0
:
(
cj
->
loc
[
k
]
-
ci
->
loc
[
k
]
+
shift
[
k
]
>
0
)
?
2
:
1
);
new_
sid
=
sortlistID
[
new_
sid
];
/* Do any of the cells need to be sorted first? */
if
(
!
(
cj
->
sorted
&
(
1
<<
sid
)))
runner_do_sort
(
r
,
cj
,
(
1
<<
sid
),
1
);
if
(
!
(
cj
->
sorted
&
(
1
<<
new_sid
)))
runner_do_sort
(
r
,
cj
,
(
1
<<
new_sid
),
1
);
/* Compute the interactions. */
DOPAIR_SUBSET
(
r
,
ci
,
parts
,
ind
,
count
,
cj
);
...
...
src/scheduler.c
View file @
e7f0fdd9
...
...
@@ -111,12 +111,12 @@ void scheduler_addunlock(struct scheduler *s, struct task *ta,
static
void
scheduler_splittask
(
struct
task
*
t
,
struct
scheduler
*
s
)
{
/* Static constants. */
const
static
int
pts
[
7
][
8
]
=
{
static
const
int
pts
[
7
][
8
]
=
{
{
-
1
,
12
,
10
,
9
,
4
,
3
,
1
,
0
},
{
-
1
,
-
1
,
11
,
10
,
5
,
4
,
2
,
1
},
{
-
1
,
-
1
,
-
1
,
12
,
7
,
6
,
4
,
3
},
{
-
1
,
-
1
,
-
1
,
-
1
,
8
,
7
,
5
,
4
},
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
12
,
10
,
9
},
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
11
,
10
},
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
12
}};
const
static
float
sid_scale
[
13
]
=
{
0
.
1897
,
0
.
4025
,
0
.
1897
,
0
.
4025
,
0
.
5788
,
static
const
float
sid_scale
[
13
]
=
{
0
.
1897
,
0
.
4025
,
0
.
1897
,
0
.
4025
,
0
.
5788
,
0
.
4025
,
0
.
1897
,
0
.
4025
,
0
.
1897
,
0
.
4025
,
0
.
5788
,
0
.
4025
,
0
.
5788
};
...
...
src/serial_io.c
View file @
e7f0fdd9
...
...
@@ -220,7 +220,7 @@ void prepareArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
/* Set chunk size */
h_err
=
H5Pset_chunk
(
h_prop
,
rank
,
chunk_shape
);
if
(
h_err
<
0
)
{
error
(
"Error while setting chunk size (%ll
d
, %ll
d
) for field '%s'."
,
error
(
"Error while setting chunk size (%ll
u
, %ll
u
) for field '%s'."
,
chunk_shape
[
0
],
chunk_shape
[
1
],
props
.
name
);
}
...
...
@@ -590,26 +590,18 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
int
num_fields
=
0
;
struct
io_props
list
[
100
];
size_t
N
=
0
;
size_t
N
particles
=
0
;
/* Read particle fields into the particle structure */
switch
(
ptype
)
{
case
GAS
:
/* if (!dry_run) */
/* hydro_read_particles(h_grp, N[ptype], N_total[ptype], */
/* offset[ptype], *parts); */
/* break; */
N
=
*
Ngas
;
Nparticles
=
*
Ngas
;
hydro_read_particles
(
*
parts
,
list
,
&
num_fields
);
break
;
case
DM
:
/* if (!dry_run) */
/* darkmatter_read_particles(h_grp, N[ptype], N_total[ptype], */
/* offset[ptype], *gparts); */
/* break; */
N
=
Ndm
;
Nparticles
=
Ndm
;
darkmatter_read_particles
(
*
gparts
,
list
,
&
num_fields
);
break
;
...
...
@@ -621,7 +613,7 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
/* Read everything */
if
(
!
dry_run
)
for
(
int
i
=
0
;
i
<
num_fields
;
++
i
)
readArray
(
h_grp
,
list
[
i
],
N
,
N_total
[
ptype
],
offset
[
ptype
],
readArray
(
h_grp
,
list
[
i
],
N
particles
,
N_total
[
ptype
],
offset
[
ptype
],
internal_units
,
ic_units
);
/* Close particle group */
...
...
@@ -886,13 +878,13 @@ void write_output_serial(struct engine* e, const char* baseName,
int
num_fields
=
0
;
struct
io_props
list
[
100
];
size_t
N
=
0
;
size_t
N
particles
=
0
;
/* Write particle fields from the particle structure */
switch
(
ptype
)
{
case
GAS
:
N
=
Ngas
;
N
particles
=
Ngas
;
hydro_write_particles
(
parts
,
list
,
&
num_fields
);
break
;
...
...
@@ -907,7 +899,7 @@ void write_output_serial(struct engine* e, const char* baseName,
collect_dm_gparts
(
gparts
,
Ntot
,
dmparts
,
Ndm
);
/* Write DM particles */
N
=
Ndm
;
N
particles
=
Ndm
;
darkmatter_write_particles
(
dmparts
,
list
,
&
num_fields
);
break
;
...
...
@@ -918,9 +910,9 @@ void write_output_serial(struct engine* e, const char* baseName,
/* Write everything */
for
(
int
i
=
0
;
i
<
num_fields
;
++
i
)
writeArray
(
e
,
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
list
[
i
],
N
,
N_total
[
ptype
],
mpi_rank
,
offset
[
ptype
],
internal_units
,
snapshot_units
);
writeArray
(
e
,
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
list
[
i
],
Nparticles
,
N_total
[
ptype
],
mpi_rank
,
offset
[
ptype
],
internal_units
,
snapshot_units
);
/* Free temporary array */
free
(
dmparts
);
...
...
src/single_io.c
View file @
e7f0fdd9
...
...
@@ -257,7 +257,7 @@ void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
/* Set chunk size */
h_err
=
H5Pset_chunk
(
h_prop
,
rank
,
chunk_shape
);
if
(
h_err
<
0
)
{
error
(
"Error while setting chunk size (%ll
d
, %ll
d
) for field '%s'."
,
error
(
"Error while setting chunk size (%ll
u
, %ll
u
) for field '%s'."
,
chunk_shape
[
0
],
chunk_shape
[
1
],
props
.
name
);
}
...
...
@@ -471,18 +471,18 @@ void read_ic_single(char* fileName, const struct UnitSystem* internal_units,
int
num_fields
=
0
;
struct
io_props
list
[
100
];
size_t
N
=
0
;
size_t
N
particles
=
0
;
/* Read particle fields into the structure */
switch
(
ptype
)
{
case
GAS
:
N
=
*
Ngas
;
N
particles
=
*
Ngas
;
hydro_read_particles
(
*
parts
,
list
,
&
num_fields
);
break
;
case
DM
:
N
=
Ndm
;
N
particles
=
Ndm
;
darkmatter_read_particles
(
*
gparts
,
list
,
&
num_fields
);
break
;
...
...
@@ -493,7 +493,7 @@ void read_ic_single(char* fileName, const struct UnitSystem* internal_units,
/* Read everything */
if
(
!
dry_run
)
for
(
int
i
=
0
;
i
<
num_fields
;
++
i
)
readArray
(
h_grp
,
list
[
i
],
N
,
internal_units
,
ic_units
);
readArray
(
h_grp
,
list
[
i
],
N
particles
,
internal_units
,
ic_units
);
/* Close particle group */
H5Gclose
(
h_grp
);
...
...
src/space.c
View file @
e7f0fdd9
...
...
@@ -423,7 +423,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
int
*
gind
;
if
((
gind
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
gind_size
))
==
NULL
)
error
(
"Failed to allocate temporary g-particle indices."
);
for
(
in
t
k
=
0
;
k
<
nr_gparts
;
k
++
)
{
for
(
size_
t
k
=
0
;
k
<
nr_gparts
;
k
++
)
{
struct
gpart
*
restrict
gp
=
&
s
->
gparts
[
k
];
for
(
int
j
=
0
;
j
<
3
;
j
++
)
if
(
gp
->
x
[
j
]
<
0
.
0
)
...
...
@@ -481,7 +481,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
#endif
/* Move non-local gparts to the end of the list. */
for
(
in
t
k
=
0
;
k
<
nr_gparts
;)
{
for
(
size_
t
k
=
0
;
k
<
nr_gparts
;)
{
if
(
cells
[
gind
[
k
]].
nodeID
!=
local_nodeID
)
{
cells
[
gind
[
k
]].
gcount
-=
1
;
nr_gparts
-=
1
;
...
...
@@ -590,7 +590,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
}
/* Assign each particle to its cell. */
for
(
in
t
k
=
nr_gparts
;
k
<
s
->
nr_gparts
;
k
++
)
{
for
(
size_
t
k
=
nr_gparts
;
k
<
s
->
nr_gparts
;
k
++
)
{
const
struct
gpart
*
const
p
=
&
s
->
gparts
[
k
];
gind
[
k
]
=
cell_getid
(
cdim
,
p
->
x
[
0
]
*
ih
[
0
],
p
->
x
[
1
]
*
ih
[
1
],
p
->
x
[
2
]
*
ih
[
2
]);
...
...
@@ -1574,13 +1574,13 @@ void space_init(struct space *s, const struct swift_params *params,
/* Check that all the part positions are reasonable, wrap if periodic. */
if
(
periodic
)
{
for
(
in
t
k
=
0
;
k
<
Npart
;
k
++
)
for
(
size_
t
k
=
0
;
k
<
Npart
;
k
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
while
(
parts
[
k
].
x
[
j
]
<
0
)
parts
[
k
].
x
[
j
]
+=
dim
[
j
];
while
(
parts
[
k
].
x
[
j
]
>=
dim
[
j
])
parts
[
k
].
x
[
j
]
-=
dim
[
j
];
}
}
else
{
for
(
in
t
k
=
0
;
k
<
Npart
;
k
++
)
for
(
size_
t
k
=
0
;
k
<
Npart
;
k
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
if
(
parts
[
k
].
x
[
j
]
<
0
||
parts
[
k
].
x
[
j
]
>=
dim
[
j
])
error
(
"Not all particles are within the specified domain."
);
...
...
@@ -1588,13 +1588,13 @@ void space_init(struct space *s, const struct swift_params *params,
/* Same for the gparts */
if
(
periodic
)
{
for
(
in
t
k
=
0
;
k
<
Ngpart
;
k
++
)
for
(
size_
t
k
=
0
;
k
<
Ngpart
;
k
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
while
(
gparts
[
k
].
x
[
j
]
<
0
)
gparts
[
k
].
x
[
j
]
+=
dim
[
j
];
while
(
gparts
[
k
].
x
[
j
]
>=
dim
[
j
])
gparts
[
k
].
x
[
j
]
-=
dim
[
j
];
}
}
else
{
for
(
in
t
k
=
0
;
k
<
Ngpart
;
k
++
)
for
(
size_
t
k
=
0
;
k
<
Ngpart
;
k
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
if
(
gparts
[
k
].
x
[
j
]
<
0
||
gparts
[
k
].
x
[
j
]
>=
dim
[
j
])
error
(
"Not all g-particles are within the specified domain."
);
...
...
src/tools.c
View file @
e7f0fdd9
...
...
@@ -499,7 +499,7 @@ void engine_single_density(double *dim, long long int pid,
hydro_init_part
(
&
p
);
/* Loop over all particle pairs (force). */
for
(
int
k
=
0
;
k
<
N
;
k
++
)
{
for
(
k
=
0
;
k
<
N
;
k
++
)
{
if
(
parts
[
k
].
id
==
p
.
id
)
continue
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
dx
[
i
]
=
p
.
x
[
i
]
-
parts
[
k
].
x
[
i
];
...
...
src/version.c
View file @
e7f0fdd9
...
...
@@ -218,7 +218,7 @@ const char *hdf5_version(void) {
#ifdef HAVE_HDF5
unsigned
int
majnum
,
minnum
,
relnum
;
H5get_libversion
(
&
majnum
,
&
minnum
,
&
relnum
);
sprintf
(
version
,
"%
i
.%
i
.%
i
"
,
majnum
,
minnum
,
relnum
);
sprintf
(
version
,
"%
u
.%
u
.%
u
"
,
majnum
,
minnum
,
relnum
);
#else
sprintf
(
version
,
"Unknown version"
);
#endif
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment