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
0700702c
Commit
0700702c
authored
12 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
read from zipped data.
Former-commit-id: 5f9615fdefe34c139f61f88165b7c47711ceba61
parent
5dbc5f55
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
Makefile
+2
-2
2 additions, 2 deletions
Makefile
test.c
+83
-0
83 additions, 0 deletions
test.c
with
85 additions
and
2 deletions
Makefile
+
2
−
2
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
)
...
...
This diff is collapsed.
Click to expand it.
test.c
+
83
−
0
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
}
...
...
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