Skip to content
GitLab
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
0700702c
Commit
0700702c
authored
Aug 29, 2012
by
Pedro Gonnet
Browse files
read from zipped data.
Former-commit-id: 5f9615fdefe34c139f61f88165b7c47711ceba61
parent
5dbc5f55
Changes
2
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
0700702c
...
...
@@ -22,10 +22,10 @@
CC
=
gcc
FC
=
gfortran
OPTS
=
-DTIMER
-DCOUNTER
-DCPU_TPS
=
2.67e9
OPTS
=
-DTIMER
-DCOUNTER
-DCPU_TPS
=
2.67e9
-DHAVE_ZLIB
CFLAGS
=
-O3
-g
-std
=
gnu99
-Wall
-Werror
-march
=
native
-mtune
=
native
-ffast-math
-fomit-frame-pointer
-malign-double
-fstrict-aliasing
-fopenmp
# CFLAGS=-O0 -g -std=gnu99 -Wall -Werror -fopenmp
LDFLAGS
=
-lm
-lpthread
-fopenmp
LDFLAGS
=
-lm
-lpthread
-fopenmp
-lz
FFLAGS
=
$(CFLAGS)
...
...
test.c
View file @
0700702c
...
...
@@ -27,6 +27,11 @@
#include
<math.h>
#include
<omp.h>
/* Conditional headers. */
#ifdef HAVE_ZLIB
#include
<zlib.h>
#endif
/* Local headers. */
#define INLINE
#include
"cycle.h"
...
...
@@ -178,6 +183,28 @@ void map_dump ( struct part *p , struct cell *c , void *data ) {
void
read_coords
(
char
*
fname
,
struct
part
*
parts
,
int
N
)
{
#ifdef HAVE_ZLIB
gzFile
*
fd
;
char
buff
[
1024
];
int
k
;
/* Open the given file. */
if
(
(
fd
=
gzopen
(
fname
,
"r"
)
)
==
NULL
)
error
(
"Failed to open coordinate file"
);
/* Read the coordinates into the part positions. */
for
(
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gzgets
(
fd
,
buff
,
1024
)
==
NULL
)
error
(
"Error reading coordinate file."
);
if
(
sscanf
(
buff
,
"%lf %lf %lf"
,
&
parts
[
k
].
x
[
0
]
,
&
parts
[
k
].
x
[
1
]
,
&
parts
[
k
].
x
[
2
]
)
!=
3
)
{
printf
(
"read_coords: failed to parse %ith entry.
\n
"
,
k
);
error
(
"Error parsing coordinate file."
);
}
}
/* Wrap it up. */
gzclose
(
fd
);
#else
FILE
*
fd
;
int
k
;
...
...
@@ -192,6 +219,10 @@ void read_coords ( char *fname , struct part *parts , int N ) {
error
(
"Error reading coordinate file."
);
}
}
/* Wrap it up. */
fclose
(
fd
);
#endif
}
...
...
@@ -206,6 +237,28 @@ void read_coords ( char *fname , struct part *parts , int N ) {
void
read_cutoffs
(
char
*
fname
,
struct
part
*
parts
,
int
N
)
{
#ifdef HAVE_ZLIB
gzFile
*
fd
;
char
buff
[
1024
];
int
k
;
/* Open the given file. */
if
(
(
fd
=
gzopen
(
fname
,
"r"
)
)
==
NULL
)
error
(
"Failed to open cutoff file"
);
/* Read the coordinates into the part positions. */
for
(
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gzgets
(
fd
,
buff
,
1024
)
==
NULL
)
error
(
"Error reading cutoff file."
);
if
(
sscanf
(
buff
,
"%ef"
,
&
parts
[
k
].
r
)
!=
1
)
{
printf
(
"read_cutoffs: failed to parse %ith entry.
\n
"
,
k
);
error
(
"Error parsing cutoff file."
);
}
}
/* Wrap it up. */
gzclose
(
fd
);
#else
FILE
*
fd
;
int
k
;
...
...
@@ -220,6 +273,10 @@ void read_cutoffs ( char *fname , struct part *parts , int N ) {
error
(
"Error reading cutoff file."
);
}
}
/* Wrap it up. */
fclose
(
fd
);
#endif
}
...
...
@@ -234,6 +291,28 @@ void read_cutoffs ( char *fname , struct part *parts , int N ) {
void
read_id
(
char
*
fname
,
struct
part
*
parts
,
int
N
)
{
#ifdef HAVE_ZLIB
gzFile
*
fd
;
char
buff
[
1024
];
int
k
;
/* Open the given file. */
if
(
(
fd
=
gzopen
(
fname
,
"r"
)
)
==
NULL
)
error
(
"Failed to open id file"
);
/* Read the coordinates into the part positions. */
for
(
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gzgets
(
fd
,
buff
,
1024
)
==
NULL
)
error
(
"Error reading id file."
);
if
(
sscanf
(
buff
,
"%i"
,
&
parts
[
k
].
id
)
!=
1
)
{
printf
(
"read_id: failed to parse %ith entry.
\n
"
,
k
);
error
(
"Error parsing id file."
);
}
}
/* Wrap it up. */
gzclose
(
fd
);
#else
FILE
*
fd
;
int
k
;
...
...
@@ -249,6 +328,10 @@ void read_id ( char *fname , struct part *parts , int N ) {
}
}
/* Wrap it up. */
fclose
(
fd
);
#endif
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment