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
40df9f1d
Commit
40df9f1d
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Make sure the right particle size is used
parent
ed3f2c46
No related branches found
No related tags found
2 merge requests
!136
Master
,
!121
Gpart mpi io
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common_io.c
+2
-1
2 additions, 1 deletion
src/common_io.c
src/single_io.c
+21
-15
21 additions, 15 deletions
src/single_io.c
with
23 additions
and
16 deletions
src/common_io.c
+
2
−
1
View file @
40df9f1d
...
@@ -489,7 +489,8 @@ void prepare_dm_gparts(struct gpart* gparts, size_t Ndm) {
...
@@ -489,7 +489,8 @@ void prepare_dm_gparts(struct gpart* gparts, size_t Ndm) {
for
(
size_t
i
=
0
;
i
<
Ndm
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
Ndm
;
++
i
)
{
/* 0 or negative ids are not allowed */
/* 0 or negative ids are not allowed */
if
(
gparts
[
i
].
id
<=
0
)
error
(
"0 or negative ID for DM particle"
);
if
(
gparts
[
i
].
id
<=
0
)
error
(
"0 or negative ID for DM particle %zd: ID=%lld"
,
i
,
gparts
[
i
].
id
);
gparts
[
i
].
id
=
-
gparts
[
i
].
id
;
gparts
[
i
].
id
=
-
gparts
[
i
].
id
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/single_io.c
+
21
−
15
View file @
40df9f1d
...
@@ -63,14 +63,14 @@
...
@@ -63,14 +63,14 @@
* Calls #error() if an error occurs.
* Calls #error() if an error occurs.
*/
*/
void
readArrayBackEnd
(
hid_t
grp
,
char
*
name
,
enum
DATA_TYPE
type
,
int
N
,
void
readArrayBackEnd
(
hid_t
grp
,
char
*
name
,
enum
DATA_TYPE
type
,
int
N
,
int
dim
,
char
*
part_c
,
enum
DATA_IMPORTANCE
importance
)
{
int
dim
,
char
*
part_c
,
size_t
partSize
,
enum
DATA_IMPORTANCE
importance
)
{
hid_t
h_data
=
0
,
h_err
=
0
,
h_type
=
0
;
hid_t
h_data
=
0
,
h_err
=
0
,
h_type
=
0
;
htri_t
exist
=
0
;
htri_t
exist
=
0
;
void
*
temp
;
void
*
temp
;
int
i
=
0
;
int
i
=
0
;
const
size_t
typeSize
=
sizeOfType
(
type
);
const
size_t
typeSize
=
sizeOfType
(
type
);
const
size_t
copySize
=
typeSize
*
dim
;
const
size_t
copySize
=
typeSize
*
dim
;
const
size_t
partSize
=
sizeof
(
struct
part
);
char
*
temp_c
=
0
;
char
*
temp_c
=
0
;
/* Check whether the dataspace exists or not */
/* Check whether the dataspace exists or not */
...
@@ -155,14 +155,13 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
...
@@ -155,14 +155,13 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
*/
*/
void
writeArrayBackEnd
(
hid_t
grp
,
char
*
fileName
,
FILE
*
xmfFile
,
char
*
name
,
void
writeArrayBackEnd
(
hid_t
grp
,
char
*
fileName
,
FILE
*
xmfFile
,
char
*
name
,
enum
DATA_TYPE
type
,
int
N
,
int
dim
,
char
*
part_c
,
enum
DATA_TYPE
type
,
int
N
,
int
dim
,
char
*
part_c
,
struct
UnitSystem
*
us
,
size_t
partSize
,
struct
UnitSystem
*
us
,
enum
UnitConversionFactor
convFactor
)
{
enum
UnitConversionFactor
convFactor
)
{
hid_t
h_data
=
0
,
h_err
=
0
,
h_space
=
0
,
h_prop
=
0
;
hid_t
h_data
=
0
,
h_err
=
0
,
h_space
=
0
,
h_prop
=
0
;
void
*
temp
=
0
;
void
*
temp
=
0
;
int
i
=
0
,
rank
=
0
;
int
i
=
0
,
rank
=
0
;
const
size_t
typeSize
=
sizeOfType
(
type
);
const
size_t
typeSize
=
sizeOfType
(
type
);
const
size_t
copySize
=
typeSize
*
dim
;
const
size_t
copySize
=
typeSize
*
dim
;
const
size_t
partSize
=
sizeof
(
struct
part
);
char
*
temp_c
=
0
;
char
*
temp_c
=
0
;
hsize_t
shape
[
2
];
hsize_t
shape
[
2
];
hsize_t
chunk_shape
[
2
];
hsize_t
chunk_shape
[
2
];
...
@@ -273,7 +272,7 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
...
@@ -273,7 +272,7 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
#define readArray(grp, name, type, N, dim, part, N_total, offset, field, \
#define readArray(grp, name, type, N, dim, part, N_total, offset, field, \
importance) \
importance) \
readArrayBackEnd(grp, name, type, N, dim, (char*)(&(part[0]).field), \
readArrayBackEnd(grp, name, type, N, dim, (char*)(&(part[0]).field), \
importance)
sizeof(part[0]),
importance)
/**
/**
* @brief A helper macro to call the readArrayBackEnd function more easily.
* @brief A helper macro to call the readArrayBackEnd function more easily.
...
@@ -298,7 +297,7 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
...
@@ -298,7 +297,7 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
#define writeArray(grp, fileName, xmfFile, name, type, N, dim, part, N_total, \
#define writeArray(grp, fileName, xmfFile, name, type, N, dim, part, N_total, \
mpi_rank, offset, field, us, convFactor) \
mpi_rank, offset, field, us, convFactor) \
writeArrayBackEnd(grp, fileName, xmfFile, name, type, N, dim, \
writeArrayBackEnd(grp, fileName, xmfFile, name, type, N, dim, \
(char*)(&(part[0]).field), us, convFactor)
(char*)(&(part[0]).field),
sizeof(part[0]),
us, convFactor)
/* Import the right hydro definition */
/* Import the right hydro definition */
#include
"hydro_io.h"
#include
"hydro_io.h"
...
@@ -398,8 +397,8 @@ void read_ic_single(char* fileName, double dim[3], struct part** parts,
...
@@ -398,8 +397,8 @@ void read_ic_single(char* fileName, double dim[3], struct part** parts,
/* message("Allocated %8.2f MB for particles.", *N * sizeof(struct part) /
/* message("Allocated %8.2f MB for particles.", *N * sizeof(struct part) /
* (1024.*1024.)); */
* (1024.*1024.)); */
message
(
"BoxSize = %lf"
,
dim
[
0
]);
/*
message("BoxSize = %lf", dim[0]);
*/
message
(
"NumPart = [%zd, %zd] Total = %zd"
,
*
Ngas
,
Ndm
,
*
Ngparts
);
/*
message("NumPart = [%zd, %zd] Total = %zd", *Ngas, Ndm, *Ngparts);
*/
/* Loop over all particle types */
/* Loop over all particle types */
for
(
int
ptype
=
0
;
ptype
<
NUM_PARTICLE_TYPES
;
ptype
++
)
{
for
(
int
ptype
=
0
;
ptype
<
NUM_PARTICLE_TYPES
;
ptype
++
)
{
...
@@ -477,9 +476,8 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
...
@@ -477,9 +476,8 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
/* Number of particles of each type */
/* Number of particles of each type */
const
size_t
Ndm
=
Ntot
-
Ngas
;
const
size_t
Ndm
=
Ntot
-
Ngas
;
int
numParticles
[
NUM_PARTICLE_TYPES
]
=
/* Gadget-2 convention here */
{
Ngas
,
Ndm
,
0
};
/* Could use size_t instead */
long
long
N_total
[
NUM_PARTICLE_TYPES
]
=
{
Ngas
,
Ndm
,
0
};
int
numParticlesHighWord
[
NUM_PARTICLE_TYPES
]
=
{
0
};
/* File name */
/* File name */
char
fileName
[
FILENAME_BUFFER_SIZE
];
char
fileName
[
FILENAME_BUFFER_SIZE
];
...
@@ -521,19 +519,27 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
...
@@ -521,19 +519,27 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
/* Print the relevant information and print status */
/* Print the relevant information and print status */
writeAttribute
(
h_grp
,
"BoxSize"
,
DOUBLE
,
e
->
s
->
dim
,
3
);
writeAttribute
(
h_grp
,
"BoxSize"
,
DOUBLE
,
e
->
s
->
dim
,
3
);
writeAttribute
(
h_grp
,
"NumPart_ThisFile"
,
UINT
,
numParticles
,
NUM_PARTICLE_TYPES
);
double
dblTime
=
e
->
time
;
double
dblTime
=
e
->
time
;
writeAttribute
(
h_grp
,
"Time"
,
DOUBLE
,
&
dblTime
,
1
);
writeAttribute
(
h_grp
,
"Time"
,
DOUBLE
,
&
dblTime
,
1
);
/* GADGET-2 legacy values */
/* GADGET-2 legacy values */
/* Number of particles of each type */
unsigned
int
numParticles
[
NUM_PARTICLE_TYPES
]
=
{
0
};
unsigned
int
numParticlesHighWord
[
NUM_PARTICLE_TYPES
]
=
{
0
};
for
(
int
ptype
=
0
;
ptype
<
NUM_PARTICLE_TYPES
;
++
ptype
)
{
numParticles
[
ptype
]
=
(
unsigned
int
)
N_total
[
ptype
];
numParticlesHighWord
[
ptype
]
=
(
unsigned
int
)
(
N_total
[
ptype
]
>>
32
);
}
writeAttribute
(
h_grp
,
"NumPart_ThisFile"
,
LONGLONG
,
N_total
,
NUM_PARTICLE_TYPES
);
writeAttribute
(
h_grp
,
"NumPart_Total"
,
UINT
,
numParticles
,
writeAttribute
(
h_grp
,
"NumPart_Total"
,
UINT
,
numParticles
,
NUM_PARTICLE_TYPES
);
NUM_PARTICLE_TYPES
);
writeAttribute
(
h_grp
,
"NumPart_Total_HighWord"
,
UINT
,
numParticlesHighWord
,
writeAttribute
(
h_grp
,
"NumPart_Total_HighWord"
,
UINT
,
numParticlesHighWord
,
NUM_PARTICLE_TYPES
);
NUM_PARTICLE_TYPES
);
double
MassTable
[
NUM_PARTICLE_TYPES
]
=
{
0
.,
0
.,
0
.,
0
.,
0
.,
0
.
};
double
MassTable
[
NUM_PARTICLE_TYPES
]
=
{
0
};
writeAttribute
(
h_grp
,
"MassTable"
,
DOUBLE
,
MassTable
,
NUM_PARTICLE_TYPES
);
writeAttribute
(
h_grp
,
"MassTable"
,
DOUBLE
,
MassTable
,
NUM_PARTICLE_TYPES
);
writeAttribute
(
h_grp
,
"Flag_Entropy_ICs"
,
UINT
,
numParticlesHighWord
,
unsigned
int
flagEntropy
[
NUM_PARTICLE_TYPES
]
=
{
0
};
writeAttribute
(
h_grp
,
"Flag_Entropy_ICs"
,
UINT
,
flagEntropy
,
NUM_PARTICLE_TYPES
);
NUM_PARTICLE_TYPES
);
writeAttribute
(
h_grp
,
"NumFilesPerSnapshot"
,
INT
,
&
numFiles
,
1
);
writeAttribute
(
h_grp
,
"NumFilesPerSnapshot"
,
INT
,
&
numFiles
,
1
);
...
...
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