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
6ba85fea
Commit
6ba85fea
authored
6 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Fixes to the initialisation of io_properties
parent
2b40f415
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common_io.c
+96
-0
96 additions, 0 deletions
src/common_io.c
src/io_properties.h
+140
-225
140 additions, 225 deletions
src/io_properties.h
with
236 additions
and
225 deletions
src/common_io.c
+
96
−
0
View file @
6ba85fea
...
...
@@ -993,6 +993,26 @@ void io_convert_gpart_f_mapper(void* restrict temp, int N,
props
.
convert_gpart_f
(
e
,
gparts
+
delta
+
i
,
&
temp_f
[
i
*
dim
]);
}
/**
* @brief Mapper function to copy #gpart into a buffer of ints using a
* conversion function.
*/
void
io_convert_gpart_i_mapper
(
void
*
restrict
temp
,
int
N
,
void
*
restrict
extra_data
)
{
const
struct
io_props
props
=
*
((
const
struct
io_props
*
)
extra_data
);
const
struct
gpart
*
restrict
gparts
=
props
.
gparts
;
const
struct
engine
*
e
=
props
.
e
;
const
size_t
dim
=
props
.
dimension
;
/* How far are we with this chunk? */
int
*
restrict
temp_i
=
(
int
*
)
temp
;
const
ptrdiff_t
delta
=
(
temp_i
-
props
.
start_temp_i
)
/
dim
;
for
(
int
i
=
0
;
i
<
N
;
i
++
)
props
.
convert_gpart_i
(
e
,
gparts
+
delta
+
i
,
&
temp_i
[
i
*
dim
]);
}
/**
* @brief Mapper function to copy #gpart into a buffer of doubles using a
* conversion function.
...
...
@@ -1053,6 +1073,26 @@ void io_convert_spart_f_mapper(void* restrict temp, int N,
props
.
convert_spart_f
(
e
,
sparts
+
delta
+
i
,
&
temp_f
[
i
*
dim
]);
}
/**
* @brief Mapper function to copy #spart into a buffer of ints using a
* conversion function.
*/
void
io_convert_spart_i_mapper
(
void
*
restrict
temp
,
int
N
,
void
*
restrict
extra_data
)
{
const
struct
io_props
props
=
*
((
const
struct
io_props
*
)
extra_data
);
const
struct
spart
*
restrict
sparts
=
props
.
sparts
;
const
struct
engine
*
e
=
props
.
e
;
const
size_t
dim
=
props
.
dimension
;
/* How far are we with this chunk? */
int
*
restrict
temp_i
=
(
int
*
)
temp
;
const
ptrdiff_t
delta
=
(
temp_i
-
props
.
start_temp_i
)
/
dim
;
for
(
int
i
=
0
;
i
<
N
;
i
++
)
props
.
convert_spart_i
(
e
,
sparts
+
delta
+
i
,
&
temp_i
[
i
*
dim
]);
}
/**
* @brief Mapper function to copy #spart into a buffer of doubles using a
* conversion function.
...
...
@@ -1113,6 +1153,26 @@ void io_convert_bpart_f_mapper(void* restrict temp, int N,
props
.
convert_bpart_f
(
e
,
bparts
+
delta
+
i
,
&
temp_f
[
i
*
dim
]);
}
/**
* @brief Mapper function to copy #bpart into a buffer of ints using a
* conversion function.
*/
void
io_convert_bpart_i_mapper
(
void
*
restrict
temp
,
int
N
,
void
*
restrict
extra_data
)
{
const
struct
io_props
props
=
*
((
const
struct
io_props
*
)
extra_data
);
const
struct
bpart
*
restrict
bparts
=
props
.
bparts
;
const
struct
engine
*
e
=
props
.
e
;
const
size_t
dim
=
props
.
dimension
;
/* How far are we with this chunk? */
int
*
restrict
temp_i
=
(
int
*
)
temp
;
const
ptrdiff_t
delta
=
(
temp_i
-
props
.
start_temp_i
)
/
dim
;
for
(
int
i
=
0
;
i
<
N
;
i
++
)
props
.
convert_bpart_i
(
e
,
bparts
+
delta
+
i
,
&
temp_i
[
i
*
dim
]);
}
/**
* @brief Mapper function to copy #bpart into a buffer of doubles using a
* conversion function.
...
...
@@ -1246,6 +1306,18 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
io_convert_gpart_f_mapper
,
temp_f
,
N
,
copySize
,
0
,
(
void
*
)
&
props
);
}
else
if
(
props
.
convert_gpart_i
!=
NULL
)
{
/* Prepare some parameters */
int
*
temp_i
=
(
int
*
)
temp
;
props
.
start_temp_i
=
(
int
*
)
temp
;
props
.
e
=
e
;
/* Copy the whole thing into a buffer */
threadpool_map
((
struct
threadpool
*
)
&
e
->
threadpool
,
io_convert_gpart_i_mapper
,
temp_i
,
N
,
copySize
,
0
,
(
void
*
)
&
props
);
}
else
if
(
props
.
convert_gpart_d
!=
NULL
)
{
/* Prepare some parameters */
...
...
@@ -1282,6 +1354,18 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
io_convert_spart_f_mapper
,
temp_f
,
N
,
copySize
,
0
,
(
void
*
)
&
props
);
}
else
if
(
props
.
convert_spart_i
!=
NULL
)
{
/* Prepare some parameters */
int
*
temp_i
=
(
int
*
)
temp
;
props
.
start_temp_i
=
(
int
*
)
temp
;
props
.
e
=
e
;
/* Copy the whole thing into a buffer */
threadpool_map
((
struct
threadpool
*
)
&
e
->
threadpool
,
io_convert_spart_i_mapper
,
temp_i
,
N
,
copySize
,
0
,
(
void
*
)
&
props
);
}
else
if
(
props
.
convert_spart_d
!=
NULL
)
{
/* Prepare some parameters */
...
...
@@ -1318,6 +1402,18 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
io_convert_bpart_f_mapper
,
temp_f
,
N
,
copySize
,
0
,
(
void
*
)
&
props
);
}
else
if
(
props
.
convert_bpart_i
!=
NULL
)
{
/* Prepare some parameters */
int
*
temp_i
=
(
int
*
)
temp
;
props
.
start_temp_i
=
(
int
*
)
temp
;
props
.
e
=
e
;
/* Copy the whole thing into a buffer */
threadpool_map
((
struct
threadpool
*
)
&
e
->
threadpool
,
io_convert_bpart_i_mapper
,
temp_i
,
N
,
copySize
,
0
,
(
void
*
)
&
props
);
}
else
if
(
props
.
convert_bpart_d
!=
NULL
)
{
/* Prepare some parameters */
...
...
This diff is collapsed.
Click to expand it.
src/io_properties.h
+
140
−
225
View file @
6ba85fea
...
...
@@ -51,6 +51,8 @@ typedef void (*conversion_func_part_long_long)(const struct engine*,
const
struct
xpart
*
,
long
long
*
);
typedef
void
(
*
conversion_func_gpart_float
)(
const
struct
engine
*
,
const
struct
gpart
*
,
float
*
);
typedef
void
(
*
conversion_func_gpart_int
)(
const
struct
engine
*
,
const
struct
gpart
*
,
int
*
);
typedef
void
(
*
conversion_func_gpart_double
)(
const
struct
engine
*
,
const
struct
gpart
*
,
double
*
);
typedef
void
(
*
conversion_func_gpart_long_long
)(
const
struct
engine
*
,
...
...
@@ -58,6 +60,8 @@ typedef void (*conversion_func_gpart_long_long)(const struct engine*,
long
long
*
);
typedef
void
(
*
conversion_func_spart_float
)(
const
struct
engine
*
,
const
struct
spart
*
,
float
*
);
typedef
void
(
*
conversion_func_spart_int
)(
const
struct
engine
*
,
const
struct
spart
*
,
int
*
);
typedef
void
(
*
conversion_func_spart_double
)(
const
struct
engine
*
,
const
struct
spart
*
,
double
*
);
typedef
void
(
*
conversion_func_spart_long_long
)(
const
struct
engine
*
,
...
...
@@ -65,6 +69,8 @@ typedef void (*conversion_func_spart_long_long)(const struct engine*,
long
long
*
);
typedef
void
(
*
conversion_func_bpart_float
)(
const
struct
engine
*
,
const
struct
bpart
*
,
float
*
);
typedef
void
(
*
conversion_func_bpart_int
)(
const
struct
engine
*
,
const
struct
bpart
*
,
int
*
);
typedef
void
(
*
conversion_func_bpart_double
)(
const
struct
engine
*
,
const
struct
bpart
*
,
double
*
);
typedef
void
(
*
conversion_func_bpart_long_long
)(
const
struct
engine
*
,
...
...
@@ -125,16 +131,19 @@ struct io_props {
/* Conversion function for gpart */
conversion_func_gpart_float
convert_gpart_f
;
conversion_func_gpart_int
convert_gpart_i
;
conversion_func_gpart_double
convert_gpart_d
;
conversion_func_gpart_long_long
convert_gpart_l
;
/* Conversion function for spart */
conversion_func_spart_float
convert_spart_f
;
conversion_func_spart_int
convert_spart_i
;
conversion_func_spart_double
convert_spart_d
;
conversion_func_spart_long_long
convert_spart_l
;
/* Conversion function for bpart */
conversion_func_bpart_float
convert_bpart_f
;
conversion_func_bpart_int
convert_bpart_i
;
conversion_func_bpart_double
convert_bpart_d
;
conversion_func_bpart_long_long
convert_bpart_l
;
};
...
...
@@ -215,7 +224,10 @@ INLINE static struct io_props io_make_input_field_(
INLINE
static
struct
io_props
io_make_output_field_
(
const
char
name
[
FIELD_BUFFER_SIZE
],
enum
IO_DATA_TYPE
type
,
int
dimension
,
enum
unit_conversion_factor
units
,
char
*
field
,
size_t
partSize
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
...
...
@@ -223,23 +235,7 @@ INLINE static struct io_props io_make_output_field_(
r
.
units
=
units
;
r
.
field
=
field
;
r
.
partSize
=
partSize
;
r
.
parts
=
NULL
;
r
.
gparts
=
NULL
;
r
.
sparts
=
NULL
;
r
.
bparts
=
NULL
;
r
.
conversion
=
0
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
NULL
;
r
.
convert_bpart_f
=
NULL
;
r
.
convert_bpart_d
=
NULL
;
r
.
convert_bpart_l
=
NULL
;
return
r
;
}
...
...
@@ -273,27 +269,18 @@ INLINE static struct io_props io_make_output_field_convert_part_INT(
conversion_func_part_int
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
partSize
;
r
.
parts
=
parts
;
r
.
xparts
=
xparts
;
r
.
sparts
=
NULL
;
r
.
conversion
=
1
;
r
.
convert_part_i
=
functionPtr
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
NULL
;
return
r
;
}
...
...
@@ -319,32 +306,18 @@ INLINE static struct io_props io_make_output_field_convert_part_FLOAT(
conversion_func_part_float
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
partSize
;
r
.
parts
=
parts
;
r
.
xparts
=
xparts
;
r
.
gparts
=
NULL
;
r
.
sparts
=
NULL
;
r
.
bparts
=
NULL
;
r
.
conversion
=
1
;
r
.
convert_part_i
=
NULL
;
r
.
convert_part_f
=
functionPtr
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
NULL
;
r
.
convert_bpart_f
=
NULL
;
r
.
convert_bpart_d
=
NULL
;
r
.
convert_bpart_l
=
NULL
;
return
r
;
}
...
...
@@ -370,32 +343,18 @@ INLINE static struct io_props io_make_output_field_convert_part_DOUBLE(
conversion_func_part_double
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
partSize
;
r
.
parts
=
parts
;
r
.
xparts
=
xparts
;
r
.
gparts
=
NULL
;
r
.
sparts
=
NULL
;
r
.
bparts
=
NULL
;
r
.
conversion
=
1
;
r
.
convert_part_i
=
NULL
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
functionPtr
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
NULL
;
r
.
convert_bpart_f
=
NULL
;
r
.
convert_bpart_d
=
NULL
;
r
.
convert_bpart_l
=
NULL
;
return
r
;
}
...
...
@@ -421,32 +380,18 @@ INLINE static struct io_props io_make_output_field_convert_part_LONGLONG(
conversion_func_part_long_long
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
partSize
;
r
.
parts
=
parts
;
r
.
xparts
=
xparts
;
r
.
gparts
=
NULL
;
r
.
sparts
=
NULL
;
r
.
bparts
=
NULL
;
r
.
conversion
=
1
;
r
.
convert_part_i
=
NULL
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
functionPtr
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
NULL
;
r
.
convert_bpart_f
=
NULL
;
r
.
convert_bpart_d
=
NULL
;
r
.
convert_bpart_l
=
NULL
;
return
r
;
}
...
...
@@ -459,6 +404,40 @@ INLINE static struct io_props io_make_output_field_convert_part_LONGLONG(
io_make_output_field_convert_gpart_##type(name, type, dim, units, \
sizeof(gpart[0]), gpart, convert)
/**
* @brief Construct an #io_props from its parameters
*
* @param name Name of the field to read
* @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset
* @param gpartSize The size in byte of the particle
* @param gparts The particle array
* @param functionPtr The function used to convert a g-particle to a float
*
* Do not call this function directly. Use the macro defined above.
*/
INLINE
static
struct
io_props
io_make_output_field_convert_gpart_INT
(
const
char
name
[
FIELD_BUFFER_SIZE
],
enum
IO_DATA_TYPE
type
,
int
dimension
,
enum
unit_conversion_factor
units
,
size_t
gpartSize
,
const
struct
gpart
*
gparts
,
conversion_func_gpart_int
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
partSize
=
gpartSize
;
r
.
gparts
=
gparts
;
r
.
conversion
=
1
;
r
.
convert_gpart_i
=
functionPtr
;
return
r
;
}
/**
* @brief Construct an #io_props from its parameters
*
...
...
@@ -478,32 +457,17 @@ INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT(
const
struct
gpart
*
gparts
,
conversion_func_gpart_float
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
gpartSize
;
r
.
parts
=
NULL
;
r
.
xparts
=
NULL
;
r
.
gparts
=
gparts
;
r
.
sparts
=
NULL
;
r
.
bparts
=
NULL
;
r
.
conversion
=
1
;
r
.
convert_part_i
=
NULL
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
functionPtr
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
NULL
;
r
.
convert_bpart_f
=
NULL
;
r
.
convert_bpart_d
=
NULL
;
r
.
convert_bpart_l
=
NULL
;
return
r
;
}
...
...
@@ -527,32 +491,17 @@ INLINE static struct io_props io_make_output_field_convert_gpart_DOUBLE(
const
struct
gpart
*
gparts
,
conversion_func_gpart_double
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
gpartSize
;
r
.
parts
=
NULL
;
r
.
xparts
=
NULL
;
r
.
gparts
=
gparts
;
r
.
sparts
=
NULL
;
r
.
bparts
=
NULL
;
r
.
conversion
=
1
;
r
.
convert_part_i
=
NULL
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
functionPtr
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
NULL
;
r
.
convert_bpart_f
=
NULL
;
r
.
convert_bpart_d
=
NULL
;
r
.
convert_bpart_l
=
NULL
;
return
r
;
}
...
...
@@ -576,32 +525,17 @@ INLINE static struct io_props io_make_output_field_convert_gpart_LONGLONG(
const
struct
gpart
*
gparts
,
conversion_func_gpart_long_long
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
gpartSize
;
r
.
parts
=
NULL
;
r
.
xparts
=
NULL
;
r
.
gparts
=
gparts
;
r
.
sparts
=
NULL
;
r
.
bparts
=
NULL
;
r
.
conversion
=
1
;
r
.
convert_part_i
=
NULL
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
functionPtr
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
NULL
;
r
.
convert_bpart_f
=
NULL
;
r
.
convert_bpart_d
=
NULL
;
r
.
convert_bpart_l
=
NULL
;
return
r
;
}
...
...
@@ -614,6 +548,40 @@ INLINE static struct io_props io_make_output_field_convert_gpart_LONGLONG(
io_make_output_field_convert_spart_##type(name, type, dim, units, \
sizeof(spart[0]), spart, convert)
/**
* @brief Construct an #io_props from its parameters
*
* @param name Name of the field to read
* @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset
* @param spartSize The size in byte of the particle
* @param sparts The particle array
* @param functionPtr The function used to convert a g-particle to a float
*
* Do not call this function directly. Use the macro defined above.
*/
INLINE
static
struct
io_props
io_make_output_field_convert_spart_INT
(
const
char
name
[
FIELD_BUFFER_SIZE
],
enum
IO_DATA_TYPE
type
,
int
dimension
,
enum
unit_conversion_factor
units
,
size_t
spartSize
,
const
struct
spart
*
sparts
,
conversion_func_spart_int
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
partSize
=
spartSize
;
r
.
sparts
=
sparts
;
r
.
conversion
=
1
;
r
.
convert_spart_i
=
functionPtr
;
return
r
;
}
/**
* @brief Construct an #io_props from its parameters
*
...
...
@@ -633,32 +601,17 @@ INLINE static struct io_props io_make_output_field_convert_spart_FLOAT(
const
struct
spart
*
sparts
,
conversion_func_spart_float
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
spartSize
;
r
.
parts
=
NULL
;
r
.
xparts
=
NULL
;
r
.
gparts
=
NULL
;
r
.
sparts
=
sparts
;
r
.
bparts
=
NULL
;
r
.
conversion
=
1
;
r
.
convert_part_i
=
NULL
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
functionPtr
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
NULL
;
r
.
convert_bpart_f
=
NULL
;
r
.
convert_bpart_d
=
NULL
;
r
.
convert_bpart_l
=
NULL
;
return
r
;
}
...
...
@@ -682,32 +635,17 @@ INLINE static struct io_props io_make_output_field_convert_spart_DOUBLE(
const
struct
spart
*
sparts
,
conversion_func_spart_double
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
spartSize
;
r
.
parts
=
NULL
;
r
.
xparts
=
NULL
;
r
.
gparts
=
NULL
;
r
.
sparts
=
sparts
;
r
.
bparts
=
NULL
;
r
.
conversion
=
1
;
r
.
convert_part_i
=
NULL
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
functionPtr
;
r
.
convert_spart_l
=
NULL
;
r
.
convert_bpart_f
=
NULL
;
r
.
convert_bpart_d
=
NULL
;
r
.
convert_bpart_l
=
NULL
;
return
r
;
}
...
...
@@ -731,32 +669,17 @@ INLINE static struct io_props io_make_output_field_convert_spart_LONGLONG(
const
struct
spart
*
sparts
,
conversion_func_spart_long_long
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
spartSize
;
r
.
parts
=
NULL
;
r
.
xparts
=
NULL
;
r
.
gparts
=
NULL
;
r
.
sparts
=
sparts
;
r
.
bparts
=
NULL
;
r
.
conversion
=
1
;
r
.
convert_part_i
=
NULL
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
functionPtr
;
r
.
convert_bpart_f
=
NULL
;
r
.
convert_bpart_d
=
NULL
;
r
.
convert_bpart_l
=
NULL
;
return
r
;
}
...
...
@@ -769,6 +692,40 @@ INLINE static struct io_props io_make_output_field_convert_spart_LONGLONG(
io_make_output_field_convert_bpart_##type(name, type, dim, units, \
sizeof(bpart[0]), bpart, convert)
/**
* @brief Construct an #io_props from its parameters
*
* @param name Name of the field to read
* @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset
* @param bpartSize The size in byte of the particle
* @param bparts The particle array
* @param functionPtr The function used to convert a b-particle to a int
*
* Do not call this function directly. Use the macro defined above.
*/
INLINE
static
struct
io_props
io_make_output_field_convert_bpart_INT
(
const
char
name
[
FIELD_BUFFER_SIZE
],
enum
IO_DATA_TYPE
type
,
int
dimension
,
enum
unit_conversion_factor
units
,
size_t
bpartSize
,
const
struct
bpart
*
bparts
,
conversion_func_bpart_int
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
partSize
=
bpartSize
;
r
.
bparts
=
bparts
;
r
.
conversion
=
1
;
r
.
convert_bpart_i
=
functionPtr
;
return
r
;
}
/**
* @brief Construct an #io_props from its parameters
*
...
...
@@ -788,31 +745,17 @@ INLINE static struct io_props io_make_output_field_convert_bpart_FLOAT(
const
struct
bpart
*
bparts
,
conversion_func_bpart_float
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
bpartSize
;
r
.
parts
=
NULL
;
r
.
xparts
=
NULL
;
r
.
gparts
=
NULL
;
r
.
sparts
=
NULL
;
r
.
bparts
=
bparts
;
r
.
conversion
=
1
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
NULL
;
r
.
convert_bpart_f
=
functionPtr
;
r
.
convert_bpart_d
=
NULL
;
r
.
convert_bpart_l
=
NULL
;
return
r
;
}
...
...
@@ -836,31 +779,17 @@ INLINE static struct io_props io_make_output_field_convert_bpart_DOUBLE(
const
struct
bpart
*
bparts
,
conversion_func_bpart_double
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
bpartSize
;
r
.
parts
=
NULL
;
r
.
xparts
=
NULL
;
r
.
gparts
=
NULL
;
r
.
sparts
=
NULL
;
r
.
bparts
=
bparts
;
r
.
conversion
=
1
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
NULL
;
r
.
convert_bpart_f
=
NULL
;
r
.
convert_bpart_d
=
functionPtr
;
r
.
convert_bpart_l
=
NULL
;
return
r
;
}
...
...
@@ -884,30 +813,16 @@ INLINE static struct io_props io_make_output_field_convert_bpart_LONGLONG(
const
struct
bpart
*
bparts
,
conversion_func_bpart_long_long
functionPtr
)
{
struct
io_props
r
;
bzero
(
&
r
,
sizeof
(
struct
io_props
));
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
NULL
;
r
.
partSize
=
bpartSize
;
r
.
parts
=
NULL
;
r
.
xparts
=
NULL
;
r
.
gparts
=
NULL
;
r
.
sparts
=
NULL
;
r
.
bparts
=
bparts
;
r
.
conversion
=
1
;
r
.
convert_part_f
=
NULL
;
r
.
convert_part_d
=
NULL
;
r
.
convert_part_l
=
NULL
;
r
.
convert_gpart_f
=
NULL
;
r
.
convert_gpart_d
=
NULL
;
r
.
convert_gpart_l
=
NULL
;
r
.
convert_spart_f
=
NULL
;
r
.
convert_spart_d
=
NULL
;
r
.
convert_spart_l
=
NULL
;
r
.
convert_bpart_f
=
NULL
;
r
.
convert_bpart_d
=
NULL
;
r
.
convert_bpart_l
=
functionPtr
;
return
r
;
...
...
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