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
e02b3299
Commit
e02b3299
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
And done the same for the serial_io case.
parent
35332b91
No related branches found
No related tags found
2 merge requests
!136
Master
,
!126
Support for XMF file descriptors with multiple particle types.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/serial_io.c
+38
-24
38 additions, 24 deletions
src/serial_io.c
src/single_io.c
+1
-1
1 addition, 1 deletion
src/single_io.c
with
39 additions
and
25 deletions
src/serial_io.c
+
38
−
24
View file @
e02b3299
...
...
@@ -172,9 +172,10 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
* Routines writing an output file
*-----------------------------------------------------------------------------*/
void
prepareArray
(
hid_t
grp
,
char
*
fileName
,
FILE
*
xmfFile
,
char
*
name
,
enum
DATA_TYPE
type
,
long
long
N_total
,
int
dim
,
struct
UnitSystem
*
us
,
enum
UnitConversionFactor
convFactor
)
{
void
prepareArray
(
hid_t
grp
,
char
*
fileName
,
FILE
*
xmfFile
,
char
*
partTypeGroupName
,
char
*
name
,
enum
DATA_TYPE
type
,
long
long
N_total
,
int
dim
,
struct
UnitSystem
*
us
,
enum
UnitConversionFactor
convFactor
)
{
hid_t
h_data
=
0
,
h_err
=
0
,
h_space
=
0
,
h_prop
=
0
;
int
rank
=
0
;
hsize_t
shape
[
2
];
...
...
@@ -234,7 +235,7 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile, char* name,
}
/* Write XMF description for this data set */
writeXMFline
(
xmfFile
,
fileName
,
name
,
N_total
,
dim
,
type
);
writeXMFline
(
xmfFile
,
fileName
,
partTypeGroupName
,
name
,
N_total
,
dim
,
type
);
/* Write unit conversion factors for this data set */
conversionString
(
buffer
,
us
,
convFactor
);
...
...
@@ -267,10 +268,11 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile, char* name,
*
* Calls #error() if an error occurs.
*/
void
writeArrayBackEnd
(
hid_t
grp
,
char
*
fileName
,
FILE
*
xmfFile
,
char
*
name
,
enum
DATA_TYPE
type
,
int
N
,
int
dim
,
long
long
N_total
,
int
mpi_rank
,
long
long
offset
,
char
*
part_c
,
size_t
partSize
,
struct
UnitSystem
*
us
,
void
writeArrayBackEnd
(
hid_t
grp
,
char
*
fileName
,
FILE
*
xmfFile
,
char
*
partTypeGroupName
,
char
*
name
,
enum
DATA_TYPE
type
,
int
N
,
int
dim
,
long
long
N_total
,
int
mpi_rank
,
long
long
offset
,
char
*
part_c
,
size_t
partSize
,
struct
UnitSystem
*
us
,
enum
UnitConversionFactor
convFactor
)
{
hid_t
h_data
=
0
,
h_err
=
0
,
h_memspace
=
0
,
h_filespace
=
0
;
...
...
@@ -285,8 +287,8 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
/* Prepare the arrays in the file */
if
(
mpi_rank
==
0
)
prepareArray
(
grp
,
fileName
,
xmfFile
,
name
,
type
,
N_total
,
dim
,
us
,
convFactor
);
prepareArray
(
grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
name
,
type
,
N_total
,
dim
,
us
,
convFactor
);
/* Allocate temporary buffer */
temp
=
malloc
(
N
*
dim
*
sizeOfType
(
type
));
...
...
@@ -370,21 +372,26 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
* @param fileName Unused parameter in non-MPI mode
* @param xmfFile Unused parameter in non-MPI mode
* @param name The name of the array to write.
* @param partTypeGroupName The name of the group containing the particles in
*the HDF5 file.
* @param type The #DATA_TYPE of the array.
* @param N The number of particles to write.
* @param dim The dimension of the data (1 for scalar, 3 for vector)
* @param part A (char*) pointer on the first occurrence of the field of
*interest
*in the parts array
*interest in the parts array
* @param N_total Unused parameter in non-MPI mode
* @param mpi_rank Unused parameter in non-MPI mode
* @param offset Unused parameter in non-MPI mode
* @param field The name (code name) of the field to read from.
* @param us The UnitSystem currently in use
* @param convFactor The UnitConversionFactor for this array
*
*/
#define writeArray(grp, fileName, xmfFile, name, type, N, dim, part, N_total, \
mpi_rank, offset, field, us, convFactor) \
writeArrayBackEnd(grp, fileName, xmfFile, name, type, N, dim, N_total, \
mpi_rank, offset, (char*)(&(part[0]).field), \
#define writeArray(grp, fileName, xmfFile, partTypeGroupName, name, type, N, \
dim, part, N_total, mpi_rank, offset, field, us, \
convFactor) \
writeArrayBackEnd(grp, fileName, xmfFile, partTypeGroupName, name, type, N, \
dim, N_total, mpi_rank, offset, (char*)(&(part[0]).field), \
sizeof(part[0]), us, convFactor)
/* Import the right hydro definition */
...
...
@@ -643,7 +650,7 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
xmfFile
=
prepareXMFfile
();
/* Write the part corresponding to this specific output */
writeXMFheader
(
xmfFile
,
N_total
[
0
],
fileName
,
e
->
time
);
writeXMF
output
header
(
xmfFile
,
fileName
,
e
->
time
);
/* Open file */
/* message("Opening file '%s'.", fileName); */
...
...
@@ -716,6 +723,10 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
/* Don't do anything if no particle of this kind */
if
(
N_total
[
ptype
]
==
0
)
continue
;
/* Add the global information for that particle type to the XMF meta-file
*/
writeXMFgroupheader
(
xmfFile
,
fileName
,
N_total
[
ptype
],
ptype
);
/* Open the particle group in the file */
char
partTypeGroupName
[
PARTICLE_GROUP_BUFFER_SIZE
];
snprintf
(
partTypeGroupName
,
PARTICLE_GROUP_BUFFER_SIZE
,
"/PartType%d"
,
...
...
@@ -728,6 +739,9 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
/* Close particle group */
H5Gclose
(
h_grp
);
/* Close this particle group in the XMF file as well */
writeXMFgroupfooter
(
xmfFile
,
ptype
);
}
/* Close file */
...
...
@@ -763,9 +777,9 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
switch
(
ptype
)
{
case
GAS
:
hydro_write_particles
(
h_grp
,
fileName
,
xmfFile
,
N
[
ptype
]
,
N_total
[
ptype
],
mpi_rank
,
offset
[
ptype
],
parts
,
us
);
hydro_write_particles
(
h_grp
,
fileName
,
partTypeGroupName
,
xmfFile
,
N
[
ptype
],
N_total
[
ptype
],
mpi_rank
,
offset
[
ptype
],
parts
,
us
);
break
;
...
...
@@ -780,9 +794,9 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
collect_dm_gparts
(
gparts
,
Ntot
,
dmparts
,
Ndm
);
/* Write DM particles */
darkmatter_write_particles
(
h_grp
,
fileName
,
xmfFile
,
N
[
ptype
]
,
N_total
[
ptype
],
mpi_rank
,
offset
[
ptype
],
dmparts
,
us
);
darkmatter_write_particles
(
h_grp
,
fileName
,
partTypeGroupName
,
xmfFile
,
N
[
ptype
],
N_total
[
ptype
],
mpi_rank
,
offset
[
ptype
],
dmparts
,
us
);
/* Free temporary array */
free
(
dmparts
);
...
...
@@ -805,7 +819,7 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
}
/* Write footer of LXMF file descriptor */
if
(
mpi_rank
==
0
)
writeXMFfooter
(
xmfFile
);
if
(
mpi_rank
==
0
)
writeXMF
output
footer
(
xmfFile
,
outputCount
,
e
->
time
);
/* message("Done writing particles..."); */
++
outputCount
;
...
...
This diff is collapsed.
Click to expand it.
src/single_io.c
+
1
−
1
View file @
e02b3299
...
...
@@ -575,7 +575,7 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
/* Don't do anything if no particle of this kind */
if
(
numParticles
[
ptype
]
==
0
)
continue
;
/* Add the global information for that particle type */
/* Add the global information for that particle type
to the XMF meta-file
*/
writeXMFgroupheader
(
xmfFile
,
fileName
,
numParticles
[
ptype
],
ptype
);
/* Open the particle group in the file */
...
...
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