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
694ba18b
Commit
694ba18b
authored
May 27, 2019
by
Matthieu Schaller
Browse files
Correctly clean the engine after a FOF stand-alone run.
parent
cd03b7b3
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/main.c
View file @
694ba18b
...
...
@@ -1088,7 +1088,7 @@ int main(int argc, char *argv[]) {
#endif
if
(
myrank
==
0
)
message
(
"Time integration ready to start. End of dry-run."
);
engine_clean
(
&
e
);
engine_clean
(
&
e
,
/*fof=*/
0
);
free
(
params
);
return
0
;
}
...
...
@@ -1325,7 +1325,7 @@ int main(int argc, char *argv[]) {
if
(
with_cosmology
)
cosmology_clean
(
e
.
cosmology
);
if
(
with_self_gravity
)
pm_mesh_clean
(
e
.
mesh
);
if
(
with_cooling
||
with_temperature
)
cooling_clean
(
&
cooling_func
);
engine_clean
(
&
e
);
engine_clean
(
&
e
,
/*fof=*/
0
);
free
(
params
);
/* Say goodbye. */
...
...
examples/main_fof.c
View file @
694ba18b
...
...
@@ -90,7 +90,6 @@ int main(int argc, char *argv[]) {
struct
pm_mesh
mesh
;
struct
gpart
*
gparts
=
NULL
;
struct
gravity_props
gravity_properties
;
struct
hydro_props
hydro_properties
;
struct
fof_props
fof_properties
;
struct
part
*
parts
=
NULL
;
struct
phys_const
prog_const
;
...
...
@@ -99,6 +98,10 @@ int main(int argc, char *argv[]) {
struct
bpart
*
bparts
=
NULL
;
struct
unit_system
us
;
int
with_stars
=
0
;
int
with_black_holes
=
0
;
int
with_hydro
=
0
;
int
nr_nodes
=
1
,
myrank
=
0
;
#ifdef WITH_MPI
...
...
@@ -158,6 +161,11 @@ int main(int argc, char *argv[]) {
OPT_HELP
(),
OPT_GROUP
(
" Simulation options:
\n
"
),
OPT_BOOLEAN
(
's'
,
"hydro"
,
&
with_hydro
,
"Run with hydrodynamics."
,
NULL
,
0
,
0
),
OPT_BOOLEAN
(
'S'
,
"stars"
,
&
with_stars
,
"Run with stars."
,
NULL
,
0
,
0
),
OPT_BOOLEAN
(
'B'
,
"black-holes"
,
&
with_black_holes
,
"Run with black holes."
,
NULL
,
0
,
0
),
OPT_GROUP
(
" Control options:
\n
"
),
OPT_BOOLEAN
(
'a'
,
"pin"
,
&
with_aff
,
...
...
@@ -373,9 +381,6 @@ int main(int argc, char *argv[]) {
}
#endif
/* Common variables for restart and IC sections. */
int
flag_entropy_ICs
=
0
;
/* Initialize unit system and constants */
units_init_from_params
(
&
us
,
params
,
"InternalUnitSystem"
);
phys_const_init
(
&
us
,
params
,
&
prog_const
);
...
...
@@ -408,9 +413,6 @@ int main(int argc, char *argv[]) {
gravity_props_init
(
&
gravity_properties
,
params
,
&
cosmo
,
/*with_cosmology=*/
1
,
periodic
);
/* Initialise the hydro scheme */
hydro_props_init
(
&
hydro_properties
,
&
prog_const
,
&
us
,
params
);
/* Initialise the FOF properties */
bzero
(
&
fof_properties
,
sizeof
(
struct
fof_props
));
if
(
with_fof
)
fof_init
(
&
fof_properties
,
params
,
&
prog_const
,
&
us
);
...
...
@@ -424,6 +426,7 @@ int main(int argc, char *argv[]) {
fflush
(
stdout
);
/* Get ready to read particles of all kinds */
int
flag_entropy_ICs
=
0
;
size_t
Ngas
=
0
,
Ngpart
=
0
,
Nspart
=
0
,
Nbpart
=
0
;
double
dim
[
3
]
=
{
0
.,
0
.,
0
.};
if
(
myrank
==
0
)
clocks_gettime
(
&
tic
);
...
...
@@ -432,23 +435,21 @@ int main(int argc, char *argv[]) {
#if defined(HAVE_PARALLEL_HDF5)
read_ic_parallel
(
ICfileName
,
&
us
,
dim
,
&
parts
,
&
gparts
,
&
sparts
,
&
bparts
,
&
Ngas
,
&
Ngpart
,
&
Nspart
,
&
Nbpart
,
&
flag_entropy_ICs
,
/*
with_hydro
=*/
1
,
/*with_grav=*/
1
,
/*with_stars=*/
1
,
/*with_black_holes=*/
1
,
cleanup_h
,
cleanup_sqrt_a
,
cosmo
.
h
,
cosmo
.
a
,
myrank
,
nr_node
s
,
MPI_COMM_WORLD
,
MPI_INFO_NULL
,
nr_threads
,
/*dry_run=*/
0
);
with_hydro
,
/*with_grav=*/
1
,
with_stars
,
with_black_holes
,
cleanup_h
,
cleanup_sqrt_a
,
cosmo
.
h
,
cosmo
.
a
,
myrank
,
nr_nodes
,
MPI_COMM_WORLD
,
MPI_INFO_NULL
,
nr_thread
s
,
/*dry_run=*/
0
);
#else
read_ic_serial
(
ICfileName
,
&
us
,
dim
,
&
parts
,
&
gparts
,
&
sparts
,
&
bparts
,
&
Ngas
,
&
Ngpart
,
&
Nspart
,
&
Nbpart
,
&
flag_entropy_ICs
,
/*with_hydro=*/
1
,
/*with_grav=*/
1
,
/*with_stars=*/
1
,
/*with_black_holes=*/
1
,
cleanup_h
,
&
Ngpart
,
&
Nspart
,
&
Nbpart
,
&
flag_entropy_ICs
,
with_hydro
,
/*with_grav=*/
1
,
with_stars
,
with_black_holes
,
cleanup_h
,
cleanup_sqrt_a
,
cosmo
.
h
,
cosmo
.
a
,
myrank
,
nr_nodes
,
MPI_COMM_WORLD
,
MPI_INFO_NULL
,
nr_threads
,
/*dry_run=*/
0
);
#endif
#else
read_ic_single
(
ICfileName
,
&
us
,
dim
,
&
parts
,
&
gparts
,
&
sparts
,
&
bparts
,
&
Ngas
,
&
Ngpart
,
&
Nspart
,
&
Nbpart
,
&
flag_entropy_ICs
,
/*with_hydro=*/
1
,
/*with_grav=*/
1
,
/*with_stars=*/
1
,
/*with_black_holes=*/
1
,
cleanup_h
,
&
Ngpart
,
&
Nspart
,
&
Nbpart
,
&
flag_entropy_ICs
,
with_hydro
,
/*with_grav=*/
1
,
with_stars
,
with_black_holes
,
cleanup_h
,
cleanup_sqrt_a
,
cosmo
.
h
,
cosmo
.
a
,
nr_threads
,
/*dry_run=*/
0
);
#endif
#endif
...
...
@@ -548,7 +549,8 @@ int main(int argc, char *argv[]) {
if
(
myrank
==
0
)
clocks_gettime
(
&
tic
);
engine_init
(
&
e
,
&
s
,
params
,
N_total
[
0
],
N_total
[
1
],
N_total
[
2
],
N_total
[
3
],
engine_policies
,
talking
,
&
reparttype
,
&
us
,
&
prog_const
,
&
cosmo
,
&
hydro_properties
,
/*entropy_floor=*/
NULL
,
&
gravity_properties
,
/*hydro_properties=*/
NULL
,
/*entropy_floor=*/
NULL
,
&
gravity_properties
,
/*stars_properties=*/
NULL
,
/*black_holes_properties=*/
NULL
,
/*feedback_properties=*/
NULL
,
&
mesh
,
/*potential=*/
NULL
,
/*cooling_func=*/
NULL
,
...
...
@@ -660,7 +662,7 @@ int main(int argc, char *argv[]) {
/* Clean everything */
cosmology_clean
(
&
cosmo
);
pm_mesh_clean
(
&
mesh
);
engine_clean
(
&
e
);
engine_clean
(
&
e
,
/*fof=*/
1
);
free
(
params
);
/* Say goodbye. */
...
...
src/engine.c
View file @
694ba18b
...
...
@@ -5263,8 +5263,8 @@ void engine_config(int restart, int fof, struct engine *e,
#endif
}
/* Open some files */
if
(
e
->
nodeID
==
0
)
{
/* Open some
global
files */
if
(
!
fof
&&
e
->
nodeID
==
0
)
{
/* When restarting append to these files. */
const
char
*
mode
;
...
...
@@ -5310,11 +5310,10 @@ void engine_config(int restart, int fof, struct engine *e,
"+/- %.4f
\n
# Eta: %f
\n
# Config: %s
\n
# CFLAGS: %s
\n
"
,
hostname
(),
git_branch
(),
git_revision
(),
compiler_name
(),
compiler_version
(),
e
->
nr_threads
,
e
->
nr_nodes
,
SPH_IMPLEMENTATION
,
kernel_name
,
e
->
hydro_properties
?
e
->
hydro_properties
->
target_neighbours
:
0
.
f
,
e
->
hydro_properties
?
e
->
hydro_properties
->
delta_neighbours
:
0
.
f
,
e
->
hydro_properties
?
e
->
hydro_properties
->
eta_neighbours
:
0
.
f
,
configuration_options
(),
compilation_cflags
());
kernel_name
,
e
->
hydro_properties
->
target_neighbours
,
e
->
hydro_properties
->
delta_neighbours
,
e
->
hydro_properties
->
eta_neighbours
,
configuration_options
(),
compilation_cflags
());
fprintf
(
e
->
file_timesteps
,
...
...
@@ -5580,8 +5579,11 @@ void engine_config(int restart, int fof, struct engine *e,
fof_create_mpi_types
();
#endif
/* Initialise the collection group. */
collectgroup_init
();
if
(
!
fof
)
{
/* Initialise the collection group. */
collectgroup_init
();
}
/* Initialize the threadpool. */
threadpool_init
(
&
e
->
threadpool
,
e
->
nr_threads
);
...
...
@@ -6170,8 +6172,11 @@ void engine_recompute_displacement_constraint(struct engine *e) {
/**
* @brief Frees up the memory allocated for this #engine
*
* @param e The #engine to clean.
* @param fof Was this a stand-alone FOF run?
*/
void
engine_clean
(
struct
engine
*
e
)
{
void
engine_clean
(
struct
engine
*
e
,
const
int
fof
)
{
/* Start by telling the runners to stop. */
e
->
step_props
=
engine_step_prop_done
;
swift_barrier_wait
(
&
e
->
run_barrier
);
...
...
@@ -6204,7 +6209,7 @@ void engine_clean(struct engine *e) {
threadpool_clean
(
&
e
->
threadpool
);
/* Close files */
if
(
e
->
nodeID
==
0
)
{
if
(
!
fof
&&
e
->
nodeID
==
0
)
{
fclose
(
e
->
file_timesteps
);
fclose
(
e
->
file_stats
);
...
...
src/engine.h
View file @
694ba18b
...
...
@@ -533,7 +533,7 @@ void engine_print_policy(struct engine *e);
int
engine_is_done
(
struct
engine
*
e
);
void
engine_pin
(
void
);
void
engine_unpin
(
void
);
void
engine_clean
(
struct
engine
*
e
);
void
engine_clean
(
struct
engine
*
e
,
const
int
fof
);
int
engine_estimate_nr_tasks
(
const
struct
engine
*
e
);
void
engine_print_task_counts
(
const
struct
engine
*
e
);
void
engine_fof
(
struct
engine
*
e
,
const
int
dump_results
,
...
...
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