Skip to content
GitLab
Menu
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
bbb5dfb8
Commit
bbb5dfb8
authored
Aug 01, 2016
by
Matthieu Schaller
Browse files
Merge branch 'master' into gravity_infrastructure
parents
87947e64
6ed86e0a
Changes
20
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
bbb5dfb8
...
...
@@ -451,8 +451,8 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM(
AC_MSG_RESULT($rtc_ok)
# Add warning flags by default, if these can be used. Option =error adds
# -Werror to GCC and Intel. Note do this last as compiler tests may
become
# errors, if that's an issue don't use CFLAGS for these, use an AC_SUBST().
# -Werror to GCC
, clang
and Intel. Note do this last as compiler tests may
#
become
errors, if that's an issue don't use CFLAGS for these, use an AC_SUBST().
AC_ARG_ENABLE([compiler-warnings],
[AS_HELP_STRING([--enable-compiler-warnings],
[Enable compile time warning flags, if compiler is known @<:@error/no/yes)@:>@]
...
...
@@ -460,12 +460,23 @@ AC_ARG_ENABLE([compiler-warnings],
[enable_warn="$enableval"],
[enable_warn="error"]
)
if test "$enable_warn" != "no"; then
AX_CFLAGS_WARN_ALL
# AX_CFLAGS_WARN_ALL does not give good warning flags for the Intel compiler
# We will do this by hand instead
case "$ax_cv_c_compiler_vendor" in
gnu | clang)
CFLAGS="$CFLAGS -Wall"
;;
intel )
CFLAGS="$CFLAGS -w2"
;;
esac
# Add a "choke on warning" flag if it exists
if test "$enable_warn" = "error"; then
case "$ax_cv_c_compiler_vendor" in
intel | gnu )
intel | gnu
| clang
)
CFLAGS="$CFLAGS -Werror"
;;
esac
...
...
examples/main.c
View file @
bbb5dfb8
...
...
@@ -611,6 +611,10 @@ int main(int argc, char *argv[]) {
error
(
"call to MPI_Finalize failed with error %i."
,
res
);
#endif
/* Clean everything */
engine_clean
(
&
e
);
free
(
params
);
/* Say goodbye. */
if
(
myrank
==
0
)
message
(
"done. Bye."
);
...
...
src/cell.c
View file @
bbb5dfb8
...
...
@@ -709,6 +709,7 @@ void cell_clean_links(struct cell *c, void *data) {
}
/**
<<<<<<< HEAD
* @brief Checks whether the cells are direct neighbours ot not. Both cells have
* to be of the same size
*
...
...
@@ -791,4 +792,15 @@ void cell_check_multipole(struct cell *c, void *data) {
error
(
"Multipole I_yz are different (%12.15e vs. %12.15e)"
,
ma
.
I_yz
,
mb
.
I_yz
);
}
=======
*
@
brief
Frees
up
the
memory
allocated
for
this
#
cell
*/
void
cell_clean
(
struct
cell
*
c
)
{
free
(
c
->
sort
);
/* Recurse */
for
(
int
k
=
0
;
k
<
8
;
k
++
)
if
(
c
->
progeny
[
k
])
cell_clean
(
c
->
progeny
[
k
]);
>>>>>>>
master
}
src/cell.h
View file @
bbb5dfb8
...
...
@@ -200,5 +200,6 @@ void cell_clean_links(struct cell *c, void *data);
int
cell_are_neighbours
(
const
struct
cell
*
restrict
ci
,
const
struct
cell
*
restrict
cj
);
void
cell_check_multipole
(
struct
cell
*
c
,
void
*
data
);
void
cell_clean
(
struct
cell
*
c
);
#endif
/* SWIFT_CELL_H */
src/engine.c
View file @
bbb5dfb8
...
...
@@ -3019,20 +3019,22 @@ void engine_init(struct engine *e, struct space *s,
if
(
verbose
&&
with_aff
)
message
(
"Affinity at entry: %s"
,
buf
);
int
*
cpuid
=
malloc
(
nr_affinity_cores
*
sizeof
(
int
))
;
int
*
cpuid
=
NULL
;
cpu_set_t
cpuset
;
int
skip
=
0
;
for
(
int
k
=
0
;
k
<
nr_affinity_cores
;
k
++
)
{
int
c
;
for
(
c
=
skip
;
c
<
CPU_SETSIZE
&&
!
CPU_ISSET
(
c
,
entry_affinity
);
++
c
)
;
cpuid
[
k
]
=
c
;
skip
=
c
+
1
;
}
if
(
with_aff
)
{
cpuid
=
malloc
(
nr_affinity_cores
*
sizeof
(
int
));
int
skip
=
0
;
for
(
int
k
=
0
;
k
<
nr_affinity_cores
;
k
++
)
{
int
c
;
for
(
c
=
skip
;
c
<
CPU_SETSIZE
&&
!
CPU_ISSET
(
c
,
entry_affinity
);
++
c
)
;
cpuid
[
k
]
=
c
;
skip
=
c
+
1
;
}
#if defined(HAVE_LIBNUMA) && defined(_GNU_SOURCE)
if
((
policy
&
engine_policy_cputight
)
!=
engine_policy_cputight
)
{
...
...
@@ -3331,8 +3333,8 @@ void engine_init(struct engine *e, struct space *s,
#if defined(HAVE_SETAFFINITY)
if
(
with_aff
)
{
free
(
cpuid
);
free
(
buf
);
}
free
(
buf
);
#endif
/* Wait for the runner threads to be in place. */
...
...
@@ -3396,3 +3398,14 @@ void engine_compute_next_snapshot_time(struct engine *e) {
message
(
"Next output time set to t=%e."
,
next_snapshot_time
);
}
}
/**
* @brief Frees up the memory allocated for this #engine
*/
void
engine_clean
(
struct
engine
*
e
)
{
free
(
e
->
snapshotUnits
);
free
(
e
->
links
);
scheduler_clean
(
&
e
->
sched
);
space_clean
(
e
->
s
);
}
src/engine.h
View file @
bbb5dfb8
...
...
@@ -239,5 +239,6 @@ void engine_print_policy(struct engine *e);
int
engine_is_done
(
struct
engine
*
e
);
void
engine_pin
();
void
engine_unpin
();
void
engine_clean
(
struct
engine
*
e
);
#endif
/* SWIFT_ENGINE_H */
src/io_properties.h
View file @
bbb5dfb8
...
...
@@ -27,7 +27,7 @@
* @brief The two sorts of data present in the GADGET IC files: compulsory to
* start a run or optional.
*/
enum
DATA_IMPORTANCE
{
COMPULSORY
=
1
,
OPTIONAL
=
0
};
enum
DATA_IMPORTANCE
{
COMPULSORY
=
1
,
OPTIONAL
=
0
,
UNUSED
=
-
1
};
/**
* @brief The properties of a given dataset for i/o
...
...
@@ -134,7 +134,7 @@ struct io_props io_make_output_field_(char name[FIELD_BUFFER_SIZE],
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
0
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
field
;
r
.
partSize
=
partSize
;
...
...
@@ -178,7 +178,7 @@ struct io_props io_make_output_field_convert_part_(
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
0
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
field
;
r
.
partSize
=
partSize
;
...
...
@@ -222,7 +222,7 @@ struct io_props io_make_output_field_convert_gpart_(
strcpy
(
r
.
name
,
name
);
r
.
type
=
type
;
r
.
dimension
=
dimension
;
r
.
importance
=
0
;
r
.
importance
=
UNUSED
;
r
.
units
=
units
;
r
.
field
=
field
;
r
.
partSize
=
partSize
;
...
...
src/parallel_io.c
View file @
bbb5dfb8
...
...
@@ -767,7 +767,8 @@ void write_output_parallel(struct engine* e, const char* baseName,
/* Add the global information for that particle type to
* the XMF meta-file */
if
(
mpi_rank
==
0
)
writeXMFgroupheader
(
xmfFile
,
fileName
,
N_total
[
ptype
],
ptype
);
writeXMFgroupheader
(
xmfFile
,
fileName
,
N_total
[
ptype
],
(
enum
PARTICLE_TYPE
)
ptype
);
/* Open the particle group in the file */
char
partTypeGroupName
[
PARTICLE_GROUP_BUFFER_SIZE
];
...
...
@@ -828,7 +829,7 @@ void write_output_parallel(struct engine* e, const char* baseName,
H5Gclose
(
h_grp
);
/* Close this particle group in the XMF file as well */
if
(
mpi_rank
==
0
)
writeXMFgroupfooter
(
xmfFile
,
ptype
);
if
(
mpi_rank
==
0
)
writeXMFgroupfooter
(
xmfFile
,
(
enum
PARTICLE_TYPE
)
ptype
);
}
/* Write LXMF file descriptor */
...
...
src/queue.c
View file @
bbb5dfb8
...
...
@@ -296,3 +296,9 @@ struct task *queue_gettask(struct queue *q, const struct task *prev,
/* Take the money and run. */
return
res
;
}
void
queue_clean
(
struct
queue
*
q
)
{
free
(
q
->
tid
);
free
(
q
->
tid_incoming
);
}
src/queue.h
View file @
bbb5dfb8
...
...
@@ -64,5 +64,6 @@ struct task *queue_gettask(struct queue *q, const struct task *prev,
int
blocking
);
void
queue_init
(
struct
queue
*
q
,
struct
task
*
tasks
);
void
queue_insert
(
struct
queue
*
q
,
struct
task
*
t
);
void
queue_clean
(
struct
queue
*
q
);
#endif
/* SWIFT_QUEUE_H */
src/runner.c
View file @
bbb5dfb8
...
...
@@ -414,10 +414,6 @@ void runner_do_init(struct runner *r, struct cell *c, int timer) {
/* Get ready for a density calculation */
gravity_init_gpart
(
gp
);
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
message
(
"id=%lld a=[%f %f %f]
\n
"
,
gp
->
id_or_neg_offset
,
gp
->
a_grav
[
0
],
gp
->
a_grav
[
1
],
gp
->
a_grav
[
2
]);
}
}
}
...
...
@@ -456,9 +452,9 @@ void runner_do_ghost(struct runner *r, struct cell *c) {
}
/* Init the IDs that have to be updated. */
int
*
pid
;
if
((
pid
=
(
int
*
)
alloc
a
(
sizeof
(
int
)
*
count
))
==
NULL
)
error
(
"Ca
ll to
alloca
faile
d."
);
int
*
pid
=
NULL
;
if
((
pid
=
m
alloc
(
sizeof
(
int
)
*
count
))
==
NULL
)
error
(
"Ca
n't
alloca
te memory for pi
d."
);
for
(
int
k
=
0
;
k
<
count
;
k
++
)
pid
[
k
]
=
k
;
/* While there are particles that need to be updated... */
...
...
@@ -581,6 +577,9 @@ void runner_do_ghost(struct runner *r, struct cell *c) {
if
(
count
)
message
(
"Smoothing length failed to converge on %i particles."
,
count
);
/* Be clean */
free
(
pid
);
TIMER_TOC
(
timer_do_ghost
);
}
...
...
src/runner_doiact.h
View file @
bbb5dfb8
...
...
@@ -950,8 +950,8 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
sortdt_i
=
sort_i
;
countdt_i
=
count_i
;
}
else
if
(
ci
->
ti_end_min
<=
ti_current
)
{
if
(
(
sortdt_i
=
(
struct
entry
*
)
alloca
(
sizeof
(
struct
entry
)
*
count_i
))
==
NULL
)
if
(
posix_memalign
((
void
*
)
&
sortdt_i
,
VEC_SIZE
*
sizeof
(
float
),
sizeof
(
struct
entry
)
*
count_i
)
!=
0
)
error
(
"Failed to allocate dt sortlists."
);
for
(
int
k
=
0
;
k
<
count_i
;
k
++
)
if
(
parts_i
[
sort_i
[
k
].
i
].
ti_end
<=
ti_current
)
{
...
...
@@ -963,8 +963,8 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
sortdt_j
=
sort_j
;
countdt_j
=
count_j
;
}
else
if
(
cj
->
ti_end_min
<=
ti_current
)
{
if
(
(
sortdt_j
=
(
struct
entry
*
)
alloca
(
sizeof
(
struct
entry
)
*
count_j
))
==
NULL
)
if
(
posix_memalign
((
void
*
)
&
sortdt_j
,
VEC_SIZE
*
sizeof
(
float
),
sizeof
(
struct
entry
)
*
count_j
)
!=
0
)
error
(
"Failed to allocate dt sortlists."
);
for
(
int
k
=
0
;
k
<
count_j
;
k
++
)
if
(
parts_j
[
sort_j
[
k
].
i
].
ti_end
<=
ti_current
)
{
...
...
@@ -1270,6 +1270,11 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
IACT
(
r2q2
[
k
],
&
dxq2
[
3
*
k
],
hiq2
[
k
],
hjq2
[
k
],
piq2
[
k
],
pjq2
[
k
]);
#endif
if
(
ci
->
ti_end_max
>
ti_current
&&
ci
->
ti_end_min
<=
ti_current
)
free
(
sortdt_i
);
if
(
cj
->
ti_end_max
>
ti_current
&&
cj
->
ti_end_min
<=
ti_current
)
free
(
sortdt_j
);
TIMER_TOC
(
TIMER_DOPAIR
);
}
...
...
@@ -1309,7 +1314,8 @@ void DOSELF1(struct runner *r, struct cell *restrict c) {
/* Set up indt. */
int
*
indt
=
NULL
;
int
countdt
=
0
,
firstdt
=
0
;
if
((
indt
=
(
int
*
)
alloca
(
sizeof
(
int
)
*
count
))
==
NULL
)
if
(
posix_memalign
((
void
*
)
&
indt
,
VEC_SIZE
*
sizeof
(
int
),
count
*
sizeof
(
int
))
!=
0
)
error
(
"Failed to allocate indt."
);
for
(
int
k
=
0
;
k
<
count
;
k
++
)
if
(
parts
[
k
].
ti_end
<=
ti_current
)
{
...
...
@@ -1499,6 +1505,8 @@ void DOSELF1(struct runner *r, struct cell *restrict c) {
IACT
(
r2q2
[
k
],
&
dxq2
[
3
*
k
],
hiq2
[
k
],
hjq2
[
k
],
piq2
[
k
],
pjq2
[
k
]);
#endif
free
(
indt
);
TIMER_TOC
(
TIMER_DOSELF
);
}
...
...
@@ -1538,7 +1546,8 @@ void DOSELF2(struct runner *r, struct cell *restrict c) {
/* Set up indt. */
int
*
indt
=
NULL
;
int
countdt
=
0
,
firstdt
=
0
;
if
((
indt
=
(
int
*
)
alloca
(
sizeof
(
int
)
*
count
))
==
NULL
)
if
(
posix_memalign
((
void
*
)
&
indt
,
VEC_SIZE
*
sizeof
(
int
),
count
*
sizeof
(
int
))
!=
0
)
error
(
"Failed to allocate indt."
);
for
(
int
k
=
0
;
k
<
count
;
k
++
)
if
(
parts
[
k
].
ti_end
<=
ti_current
)
{
...
...
@@ -1701,6 +1710,8 @@ void DOSELF2(struct runner *r, struct cell *restrict c) {
IACT
(
r2q2
[
k
],
&
dxq2
[
3
*
k
],
hiq2
[
k
],
hjq2
[
k
],
piq2
[
k
],
pjq2
[
k
]);
#endif
free
(
indt
);
TIMER_TOC
(
TIMER_DOSELF
);
}
...
...
src/scheduler.c
View file @
bbb5dfb8
...
...
@@ -498,8 +498,8 @@ void scheduler_splittasks(struct scheduler *s) {
/* Create the sort for ci. */
// lock_lock( &ci->lock );
if
(
ci
->
sorts
==
NULL
)
ci
->
sorts
=
scheduler_addtask
(
s
,
task_type_sort
,
0
,
1
<<
sid
,
0
,
ci
,
NULL
,
0
);
ci
->
sorts
=
scheduler_addtask
(
s
,
task_type_sort
,
task_subtype_none
,
1
<<
sid
,
0
,
ci
,
NULL
,
0
);
else
ci
->
sorts
->
flags
|=
(
1
<<
sid
);
// lock_unlock_blind( &ci->lock );
...
...
@@ -508,8 +508,8 @@ void scheduler_splittasks(struct scheduler *s) {
/* Create the sort for cj. */
// lock_lock( &cj->lock );
if
(
cj
->
sorts
==
NULL
)
cj
->
sorts
=
scheduler_addtask
(
s
,
task_type_sort
,
0
,
1
<<
sid
,
0
,
cj
,
NULL
,
0
);
cj
->
sorts
=
scheduler_addtask
(
s
,
task_type_sort
,
task_subtype_none
,
1
<<
sid
,
0
,
cj
,
NULL
,
0
);
else
cj
->
sorts
->
flags
|=
(
1
<<
sid
);
// lock_unlock_blind( &cj->lock );
...
...
@@ -545,9 +545,9 @@ void scheduler_splittasks(struct scheduler *s) {
* @param tight
*/
struct
task
*
scheduler_addtask
(
struct
scheduler
*
s
,
int
type
,
int
sub
type
,
int
flags
,
int
wait
,
struct
cell
*
ci
,
struct
cell
*
cj
,
int
tight
)
{
struct
task
*
scheduler_addtask
(
struct
scheduler
*
s
,
enum
task_types
type
,
enum
task_subtypes
subtype
,
int
flags
,
int
wait
,
struct
cell
*
ci
,
struct
cell
*
cj
,
int
tight
)
{
/* Get the next free task. */
const
int
ind
=
atomic_inc
(
&
s
->
tasks_next
);
...
...
@@ -1309,3 +1309,16 @@ void scheduler_do_rewait(struct task *t_begin, struct task *t_end,
}
}
}
/**
* @brief Frees up the memory allocated for this #scheduler
*/
void
scheduler_clean
(
struct
scheduler
*
s
)
{
free
(
s
->
tasks
);
free
(
s
->
tasks_ind
);
free
(
s
->
unlocks
);
free
(
s
->
unlock_ind
);
for
(
int
i
=
0
;
i
<
s
->
nr_queues
;
++
i
)
queue_clean
(
&
s
->
queues
[
i
]);
free
(
s
->
queues
);
}
src/scheduler.h
View file @
bbb5dfb8
...
...
@@ -112,9 +112,9 @@ void scheduler_start(struct scheduler *s, unsigned int mask,
void
scheduler_reset
(
struct
scheduler
*
s
,
int
nr_tasks
);
void
scheduler_ranktasks
(
struct
scheduler
*
s
);
void
scheduler_reweight
(
struct
scheduler
*
s
);
struct
task
*
scheduler_addtask
(
struct
scheduler
*
s
,
int
type
,
int
sub
type
,
int
flags
,
int
wait
,
struct
cell
*
ci
,
struct
cell
*
cj
,
int
tight
);
struct
task
*
scheduler_addtask
(
struct
scheduler
*
s
,
enum
task_types
type
,
enum
task_subtypes
subtype
,
int
flags
,
int
wait
,
struct
cell
*
ci
,
struct
cell
*
cj
,
int
tight
);
void
scheduler_splittasks
(
struct
scheduler
*
s
);
struct
task
*
scheduler_done
(
struct
scheduler
*
s
,
struct
task
*
t
);
struct
task
*
scheduler_unlock
(
struct
scheduler
*
s
,
struct
task
*
t
);
...
...
@@ -124,5 +124,6 @@ void scheduler_dump_queue(struct scheduler *s);
void
scheduler_print_tasks
(
const
struct
scheduler
*
s
,
const
char
*
fileName
);
void
scheduler_do_rewait
(
struct
task
*
t_begin
,
struct
task
*
t_end
,
unsigned
int
mask
,
unsigned
int
submask
);
void
scheduler_clean
(
struct
scheduler
*
s
);
#endif
/* SWIFT_SCHEDULER_H */
src/serial_io.c
View file @
bbb5dfb8
...
...
@@ -859,7 +859,8 @@ void write_output_serial(struct engine* e, const char* baseName,
/* Add the global information for that particle type to the XMF
* meta-file */
if
(
mpi_rank
==
0
)
writeXMFgroupheader
(
xmfFile
,
fileName
,
N_total
[
ptype
],
ptype
);
writeXMFgroupheader
(
xmfFile
,
fileName
,
N_total
[
ptype
],
(
enum
PARTICLE_TYPE
)
ptype
);
/* Open the particle group in the file */
char
partTypeGroupName
[
PARTICLE_GROUP_BUFFER_SIZE
];
...
...
@@ -915,7 +916,8 @@ void write_output_serial(struct engine* e, const char* baseName,
H5Gclose
(
h_grp
);
/* Close this particle group in the XMF file as well */
if
(
mpi_rank
==
0
)
writeXMFgroupfooter
(
xmfFile
,
ptype
);
if
(
mpi_rank
==
0
)
writeXMFgroupfooter
(
xmfFile
,
(
enum
PARTICLE_TYPE
)
ptype
);
}
/* Close file */
...
...
src/single_io.c
View file @
bbb5dfb8
...
...
@@ -669,7 +669,8 @@ void write_output_single(struct engine* e, const char* baseName,
if
(
numParticles
[
ptype
]
==
0
)
continue
;
/* Add the global information for that particle type to the XMF meta-file */
writeXMFgroupheader
(
xmfFile
,
fileName
,
numParticles
[
ptype
],
ptype
);
writeXMFgroupheader
(
xmfFile
,
fileName
,
numParticles
[
ptype
],
(
enum
PARTICLE_TYPE
)
ptype
);
/* Open the particle group in the file */
char
partTypeGroupName
[
PARTICLE_GROUP_BUFFER_SIZE
];
...
...
@@ -724,7 +725,7 @@ void write_output_single(struct engine* e, const char* baseName,
H5Gclose
(
h_grp
);
/* Close this particle group in the XMF file as well */
writeXMFgroupfooter
(
xmfFile
,
ptype
);
writeXMFgroupfooter
(
xmfFile
,
(
enum
PARTICLE_TYPE
)
ptype
);
}
/* Write LXMF file descriptor */
...
...
src/space.c
View file @
bbb5dfb8
...
...
@@ -1566,3 +1566,15 @@ void space_link_cleanup(struct space *s) {
/* Recursively apply the cell link cleaning routine */
space_map_cells_pre
(
s
,
1
,
cell_clean_links
,
NULL
);
}
/**
* @brief Frees up the memory allocated for this #space
*/
void
space_clean
(
struct
space
*
s
)
{
for
(
int
i
=
0
;
i
<
s
->
nr_cells
;
++
i
)
cell_clean
(
&
s
->
cells
[
i
]);
free
(
s
->
cells
);
free
(
s
->
parts
);
free
(
s
->
xparts
);
free
(
s
->
gparts
);
}
src/space.h
View file @
bbb5dfb8
...
...
@@ -163,5 +163,6 @@ void space_do_split(struct space *s, struct cell *c);
void
space_do_parts_sort
();
void
space_do_gparts_sort
();
void
space_link_cleanup
(
struct
space
*
s
);
void
space_clean
(
struct
space
*
s
);
#endif
/* SWIFT_SPACE_H */
src/units.c
View file @
bbb5dfb8
...
...
@@ -385,11 +385,11 @@ void units_cgs_conversion_string(char* buffer, const struct UnitSystem* us,
double
units_general_cgs_conversion_factor
(
const
struct
UnitSystem
*
us
,
const
float
baseUnitsExponants
[
5
])
{
double
factor
=
1
.;
int
i
;
for
(
i
=
0
;
i
<
5
;
++
i
)
for
(
int
i
=
0
;
i
<
5
;
++
i
)
if
(
baseUnitsExponants
[
i
]
!=
0
)
factor
*=
pow
(
units_get_base_unit
(
us
,
i
),
baseUnitsExponants
[
i
]);
factor
*=
pow
(
units_get_base_unit
(
us
,
(
enum
BaseUnits
)
i
),
baseUnitsExponants
[
i
]);
return
factor
;
}
...
...
@@ -440,13 +440,12 @@ void units_general_cgs_conversion_string(char* buffer,
const
struct
UnitSystem
*
us
,
const
float
baseUnitsExponants
[
5
])
{
char
temp
[
14
];
double
a_exp
=
units_general_a_factor
(
us
,
baseUnitsExponants
);
double
h_exp
=
units_general_h_factor
(
us
,
baseUnitsExponants
);
int
i
;
const
double
a_exp
=
units_general_a_factor
(
us
,
baseUnitsExponants
);
const
double
h_exp
=
units_general_h_factor
(
us
,
baseUnitsExponants
);
/* Check whether we are unitless or not */
char
isAllNonZero
=
1
;
for
(
i
=
0
;
i
<
5
;
++
i
)
for
(
int
i
=
0
;
i
<
5
;
++
i
)
if
(
baseUnitsExponants
[
i
]
!=
0
.)
isAllNonZero
=
0
;
if
(
isAllNonZero
)
{
...
...
@@ -476,17 +475,20 @@ void units_general_cgs_conversion_string(char* buffer,
strncat
(
buffer
,
temp
,
12
);
/* Add conversion units */
for
(
i
=
0
;
i
<
5
;
++
i
)
for
(
int
i
=
0
;
i
<
5
;
++
i
)
if
(
baseUnitsExponants
[
i
]
!=
0
)
{
if
(
baseUnitsExponants
[
i
]
==
0
.)
sprintf
(
temp
,
" "
);
else
if
(
baseUnitsExponants
[
i
]
==
1
.)
sprintf
(
temp
,
"%s "
,
units_get_base_unit_internal_symbol
(
i
));
sprintf
(
temp
,
"%s "
,
units_get_base_unit_internal_symbol
((
enum
BaseUnits
)
i
));
else
if
(
remainder
(
baseUnitsExponants
[
i
],
1
.)
==
0
)
sprintf
(
temp
,
"%s^%d "
,
units_get_base_unit_internal_symbol
(
i
),
sprintf
(
temp
,
"%s^%d "
,
units_get_base_unit_internal_symbol
((
enum
BaseUnits
)
i
),
(
int
)
baseUnitsExponants
[
i
]);
else
sprintf
(
temp
,
"%s^%7.4f "
,
units_get_base_unit_internal_symbol
(
i
),
sprintf
(
temp
,
"%s^%7.4f "
,
units_get_base_unit_internal_symbol
((
enum
BaseUnits
)
i
),
baseUnitsExponants
[
i
]);
strncat
(
buffer
,
temp
,
12
);
}
...
...
@@ -494,17 +496,19 @@ void units_general_cgs_conversion_string(char* buffer,
/* Add CGS units */
strncat
(
buffer
,
" [ "
,
3
);
for
(
i
=
0
;
i
<
5
;
++
i
)
{
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
if
(
baseUnitsExponants
[
i
]
!=
0
)
{
if
(
baseUnitsExponants
[
i
]
==
0
.)
continue
;
else
if
(
baseUnitsExponants
[
i
]
==
1
.)
sprintf
(
temp
,
"%s "
,
units_get_base_unit_cgs_symbol
(
i
));
sprintf
(
temp
,
"%s "
,
units_get_base_unit_cgs_symbol
(
(
enum
BaseUnits
)
i
));
else
if
(
remainder
(
baseUnitsExponants
[
i
],
1
.)
==
0
)
sprintf
(
temp
,
"%s^%d "
,
units_get_base_unit_cgs_symbol
(
i
),
sprintf
(
temp
,
"%s^%d "
,
units_get_base_unit_cgs_symbol
((
enum
BaseUnits
)
i
),
(
int
)
baseUnitsExponants
[
i
]);
else
sprintf
(
temp
,
"%s^%7.4f "
,
units_get_base_unit_cgs_symbol
(
i
),
sprintf
(
temp
,
"%s^%7.4f "
,
units_get_base_unit_cgs_symbol
((
enum
BaseUnits
)
i
),
baseUnitsExponants
[
i
]);
strncat
(
buffer
,
temp
,
12
);
}
...
...
tests/test27cells.c
View file @
bbb5dfb8
...
...
@@ -253,7 +253,7 @@ int main(int argc, char *argv[]) {
double
perturbation
=
0
.;
char
outputFileNameExtension
[
200
]
=
""
;
char
outputFileName
[
200
]
=
""
;
int
vel
=
velocity_zero
;
enum
velocity_types
vel
=
velocity_zero
;
/* Initialize CPU frequency, this also starts time. */
unsigned
long
long
cpufreq
=
0
;
...
...
@@ -290,7 +290,7 @@ int main(int argc, char *argv[]) {
strcpy
(
outputFileNameExtension
,
optarg
);
break
;
case
'v'
:
sscanf
(
optarg
,
"%d"
,
&
vel
);
sscanf
(
optarg
,
"%d"
,
(
int
*
)
&
vel
);
break
;
case
'?'
:
error
(
"Unknown option."
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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