Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F64330373
io4.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, May 26, 04:06
Size
1 KB
Mime Type
text/x-python
Expires
Tue, May 28, 04:06 (2 d)
Engine
blob
Format
Raw Data
Handle
17885156
Attached To
rPNBODY pNbody
io4.py
View Options
#!/usr/bin/env python
from
mpi4py
import
MPI
from
numpy
import
*
import
time
from
optparse
import
OptionParser
def
parse_options
():
usage
=
"usage: %prog [options] file"
parser
=
OptionParser
(
usage
=
usage
)
parser
.
add_option
(
"-o"
,
"--outputfile"
,
action
=
"store"
,
type
=
"string"
,
dest
=
"outputfile"
,
default
=
"pytest-io4.dat"
,
help
=
"output file name"
)
parser
.
add_option
(
"--DataSize"
,
action
=
"store"
,
type
=
"int"
,
dest
=
"DataSize"
,
default
=
10
,
help
=
"Data size in Mb"
)
(
options
,
args
)
=
parser
.
parse_args
()
files
=
args
return
files
,
options
files
,
opt
=
parse_options
()
comm
=
MPI
.
COMM_WORLD
ThisTask
=
comm
.
Get_rank
()
NTask
=
comm
.
Get_size
()
Procnm
=
MPI
.
Get_processor_name
()
Rank
=
ThisTask
print
"ThisTaks=
%d
"
%
ThisTask
# set data
DataSize
=
1024
*
1024
*
opt
.
DataSize
# 10 Mega
Nnumbers
=
int
(
DataSize
/
8
)
random
.
seed
(
ThisTask
)
data
=
random
.
random
(
Nnumbers
)
nbytes
=
data
.
nbytes
if
ThisTask
==
0
:
t1
=
time
.
time
()
filename
=
opt
.
outputfile
myfile
=
MPI
.
File
.
Open
(
comm
,
filename
,
amode
=
MPI
.
MODE_CREATE
+
MPI
.
MODE_RDWR
)
myfile
.
Set_view
(
data
.
nbytes
*
Rank
)
myfile
.
Write
(
data
.
tostring
())
myfile
.
Close
()
if
ThisTask
==
0
:
t2
=
time
.
time
()
print
"elapsed time : "
,
t2
-
t1
# check
'''
if ThisTask==0:
f = open(filename)
data = fromstring(f.read(nbytes*NTask),int32)
print data
'''
Event Timeline
Log In to Comment