Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
fa40c14e
Commit
fa40c14e
authored
1 year ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Base implementation of the FOF virtual snapshot. For now, an empty file with a header
parent
eb1819d7
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1812
Upgrade to FOF to treat some types differently
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fof_catalogue_io.c
+40
-3
40 additions, 3 deletions
src/fof_catalogue_io.c
with
40 additions
and
3 deletions
src/fof_catalogue_io.c
+
40
−
3
View file @
fa40c14e
...
...
@@ -35,7 +35,7 @@
void
write_fof_hdf5_header
(
hid_t
h_file
,
const
struct
engine
*
e
,
const
long
long
num_groups_total
,
const
long
long
num_groups_this_file
,
const
struct
fof_props
*
props
)
{
const
struct
fof_props
*
props
,
const
int
virtual
)
{
/* Open header to write simulation properties */
hid_t
h_grp
=
...
...
@@ -117,7 +117,7 @@ void write_fof_hdf5_header(hid_t h_file, const struct engine* e,
io_write_attribute_i
(
h_grp
,
"NumFilesPerSnapshot"
,
e
->
nr_nodes
);
io_write_attribute_i
(
h_grp
,
"ThisFile"
,
e
->
nodeID
);
io_write_attribute_s
(
h_grp
,
"SelectOutput"
,
"Default"
);
io_write_attribute_i
(
h_grp
,
"Virtual"
,
0
);
io_write_attribute_i
(
h_grp
,
"Virtual"
,
virtual
);
const
int
to_write
[
swift_type_count
]
=
{
0
};
io_write_attribute
(
h_grp
,
"CanHaveTypes"
,
INT
,
to_write
,
swift_type_count
);
io_write_attribute_s
(
h_grp
,
"OutputType"
,
"FOF"
);
...
...
@@ -291,6 +291,36 @@ void write_fof_hdf5_array(
H5Sclose
(
h_space
);
}
void
write_fof_virtual_file
(
const
struct
fof_props
*
props
,
const
size_t
num_groups_total
,
const
struct
engine
*
e
)
{
#if H5_VERSION_GE(1, 10, 0)
/* Create the filename */
char
file_name
[
512
];
char
subdir_name
[
265
];
sprintf
(
subdir_name
,
"%s_%04i"
,
props
->
base_name
,
e
->
snapshot_output_count
);
const
char
*
base
=
basename
(
subdir_name
);
sprintf
(
file_name
,
"%s/%s.hdf5"
,
subdir_name
,
base
);
/* Open HDF5 file with the chosen parameters */
hid_t
h_file
=
H5Fcreate
(
file_name
,
H5F_ACC_TRUNC
,
H5P_DEFAULT
,
H5P_DEFAULT
);
if
(
h_file
<
0
)
error
(
"Error while opening file '%s'."
,
file_name
);
/* Start by writing the header */
write_fof_hdf5_header
(
h_file
,
e
,
num_groups_total
,
num_groups_total
,
props
,
/*virtual=*/
1
);
hid_t
h_grp
=
H5Gcreate
(
h_file
,
"/Groups"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
if
(
h_grp
<
0
)
error
(
"Error while creating groups group.
\n
"
);
/* Close everything */
H5Gclose
(
h_grp
);
H5Fclose
(
h_file
);
#endif
}
void
write_fof_hdf5_catalogue
(
const
struct
fof_props
*
props
,
const
size_t
num_groups
,
const
struct
engine
*
e
)
{
...
...
@@ -320,7 +350,8 @@ void write_fof_hdf5_catalogue(const struct fof_props* props,
#endif
/* Start by writing the header */
write_fof_hdf5_header
(
h_file
,
e
,
num_groups_total
,
num_groups_local
,
props
);
write_fof_hdf5_header
(
h_file
,
e
,
num_groups_total
,
num_groups_local
,
props
,
/*virtual=*/
0
);
hid_t
h_grp
=
H5Gcreate
(
h_file
,
"/Groups"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
...
...
@@ -359,6 +390,12 @@ void write_fof_hdf5_catalogue(const struct fof_props* props,
H5Fclose
(
h_file
);
#ifdef WITH_MPI
#if H5_VERSION_GE(1, 10, 0)
/* Write the virtual meta-file */
if
(
e
->
nodeID
==
0
)
write_fof_virtual_file
(
props
,
num_groups_total
,
e
);
#endif
MPI_Barrier
(
MPI_COMM_WORLD
);
#endif
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment