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
Oleksii Turkot
CrystFEL
Commits
f5eb3478
Commit
f5eb3478
authored
Apr 22, 2010
by
Thomas White
Browse files
render_hkl: Run multiple POV-ray instances in parallel
parent
680991c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/render_hkl.c
View file @
f5eb3478
...
...
@@ -27,13 +27,17 @@
#include
"reflections.h"
#define MAX_PROC (256)
static
void
show_help
(
const
char
*
s
)
{
printf
(
"Syntax: %s [options] <file.hkl>
\n\n
"
,
s
);
printf
(
"Render intensity lists using POVray.
\n
"
"Render intensity lists using POV
-
ray.
\n
"
"
\n
"
" -h, --help Display this help message.
\n
"
" -h, --help Display this help message.
\n
"
" -j <n> Run <n> instances of POV-ray in parallel.
\n
"
"
\n
"
);
}
...
...
@@ -50,8 +54,10 @@ int main(int argc, char *argv[])
double
asx
,
asy
,
asz
;
double
bsx
,
bsy
,
bsz
;
double
csx
,
csy
,
csz
;
pid_t
pid
;
pid_t
pid
s
[
MAX_PROC
]
;
float
max
;
int
nproc
=
1
;
int
i
;
/* Long options */
const
struct
option
longopts
[]
=
{
...
...
@@ -60,7 +66,7 @@ int main(int argc, char *argv[])
};
/* Short options */
while
((
c
=
getopt_long
(
argc
,
argv
,
"h"
,
longopts
,
NULL
))
!=
-
1
)
{
while
((
c
=
getopt_long
(
argc
,
argv
,
"h
j:
"
,
longopts
,
NULL
))
!=
-
1
)
{
switch
(
c
)
{
case
'h'
:
{
...
...
@@ -68,6 +74,11 @@ int main(int argc, char *argv[])
return
0
;
}
case
'j'
:
{
nproc
=
atoi
(
optarg
);
break
;
}
case
0
:
{
break
;
}
...
...
@@ -79,6 +90,11 @@ int main(int argc, char *argv[])
}
if
(
(
nproc
>
MAX_PROC
)
||
(
nproc
<
1
)
)
{
ERROR
(
"Number of processes is invalid.
\n
"
);
return
1
;
}
infile
=
argv
[
optind
];
cell
=
load_cell_from_pdb
(
"molecule.pdb"
);
...
...
@@ -276,21 +292,38 @@ int main(int argc, char *argv[])
fprintf
(
fh
,
"
\n
"
);
fclose
(
fh
);
pid
=
fork
();
if
(
!
(
(
pid
!=
0
)
&&
(
pid
!=
-
1
)
)
)
{
if
(
pid
==
-
1
)
{
fprintf
(
stderr
,
"fork() failed.
\n
"
);
}
else
{
/* Forked successfully, child process */
execlp
(
"povray"
,
""
,
"+W320"
,
"+H240"
,
"+Irender.pov"
,
"+Orender.png"
,
"+KFI0"
,
"+KFF499"
,
"+KI0"
,
"+KF499"
,
// "+SF220", "+EF280",
NULL
);
}
}
else
{
for
(
i
=
0
;
i
<
nproc
;
i
++
)
{
pids
[
i
]
=
fork
();
if
(
!
(
(
pids
[
i
]
!=
0
)
&&
(
pids
[
i
]
!=
-
1
)
)
)
{
if
(
pids
[
i
]
==
-
1
)
{
ERROR
(
"fork() failed.
\n
"
);
}
else
{
char
minf
[
256
];
char
maxf
[
256
];
int
nf
,
xf
,
nsec
;
nsec
=
500
/
nproc
;
nf
=
nsec
*
i
;
xf
=
(
nsec
*
i
+
nsec
)
-
1
;
snprintf
(
minf
,
255
,
"+SF%i"
,
nf
);
snprintf
(
maxf
,
255
,
"+EF%i"
,
xf
);
/* Forked successfully, child process */
execlp
(
"povray"
,
""
,
"+W1024"
,
"+H768"
,
"+Irender.pov"
,
"+Orender.png"
,
"+KFI0"
,
"+KFF499"
,
"+KI0"
,
"+KF499"
,
minf
,
maxf
,
NULL
);
}
}
/* else start the next one */
}
for
(
i
=
0
;
i
<
nproc
;
i
++
)
{
int
r
;
waitpid
(
pid
,
&
r
,
0
);
waitpid
(
pid
s
[
i
]
,
&
r
,
0
);
}
return
0
;
...
...
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