<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
p
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:Arial;
        color:navy;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
 /* List Definitions */
 @list l0
        {mso-list-id:1689672426;
        mso-list-type:hybrid;
        mso-list-template-ids:-202464672 -866891874 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Arial;
        mso-fareast-font-family:"Times New Roman";}
@list l0:level2
        {mso-level-tab-stop:1.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level3
        {mso-level-tab-stop:1.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level4
        {mso-level-tab-stop:2.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-tab-stop:2.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-tab-stop:3.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level7
        {mso-level-tab-stop:3.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-tab-stop:4.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-tab-stop:4.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hi Erich,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Frankly the code leading up to that for
loop is a bit scary. &nbsp;I don&#8217;t really know anything about MPI I/O,
but I can get you a few tips on your C++:<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><font
size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'><span style='mso-list:Ignore'>-<font size=1 face="Times New Roman"><span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></font></span></span></font><![endif]><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>Unless
you&#8217;re using a horribly out of date compiler like MSVC 6, you should use
the standard header names &lt;iostream&gt;, &lt;vector&gt;, &lt;ctime&gt;, etc.<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><font
size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'><span style='mso-list:Ignore'>-<font size=1 face="Times New Roman"><span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></font></span></span></font><![endif]><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>If you
are using a horribly out of date compiler like MSVC 6, you should upgrade to
the free MSVC++ 2005 Express Edition.<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><font
size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'><span style='mso-list:Ignore'>-<font size=1 face="Times New Roman"><span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></font></span></span></font><![endif]><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>In this
case it&#8217;s a cosmetic fix, but you should probably pass the
vector&lt;bool&gt; parameter by reference instead of by value.<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><font
size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'><span style='mso-list:Ignore'>-<font size=1 face="Times New Roman"><span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></font></span></span></font><![endif]><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>You seem
to be doing some mind boggling casting in order to determine if
num_elements_per_rank is too big to fit in an int (but only on your last
process?). &nbsp;You might get rid of that voodoo by using size_t (usually at
least an unsigned 4 byte int) for your position indexes instead
(vector&lt;T&gt;::size() returns vector&lt;T&gt;::size_type which usually boils
down to size_t).<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Beyond that, I would need to see some
debug output from your for loop. &nbsp;For example, what indexes are actually
being passed to the I/O calls by each process?&nbsp; Does MPI::File::Read_at()
allocate memory for the &#8220;buf&#8221; variable you pass it? &nbsp;If not,
you haven&#8217;t allocated any memory for it and that would lead to a crash
before you could say &#8220;new char.&#8221;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Good luck,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Matt Chambers<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> <st1:PersonName
w:st="on">owner-<st1:PersonName w:st="on">mpich-discuss@mcs.anl.gov</st1:PersonName></st1:PersonName>
[mailto:<st1:PersonName w:st="on">owner-<st1:PersonName w:st="on">mpich-discuss@mcs.anl.gov</st1:PersonName></st1:PersonName>]
<b><span style='font-weight:bold'>On Behalf Of </span></b>Erich Peterson<br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, April 18, 2007
3:02 AM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName w:st="on">mpich-discuss@mcs.anl.gov</st1:PersonName><br>
<b><span style='font-weight:bold'>Subject:</span></b> [MPICH] Help With I/O</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>Hi all, I'm trying to write this
little routine which is part of my graduate project. What I'm trying to do is
pass a vector of bools in to the QueryData method. In that method I split the
vector up into equal parts among the number of processes, have each process
open a datafile which as 20 byte records (no new lines), read that record from
the file if the&nbsp;vector they are checking has &quot;true&quot; (basically
if vector[0] = true, it means grab the first record of the file), and lastly,
it should output that record into a new file.<br>
&nbsp;<br>
I have been able to determine it is messing up on the for-loop. The error is:<br>
&nbsp;<br>
[Student@cluster1 erich_test_area]$ mpiexec -n 3
/mnt/pvfs2/acxiom/erich_test_area/RecordRetrieval<br>
terminate called after throwing an instance of 'MPI::Exception'<br>
terminate called after throwing an instance of 'MPI::Exception'<br>
terminate called after throwing an instance of 'MPI::Exception'<br>
rank 0 in job 1&nbsp; cluster1_33602&nbsp;&nbsp; caused collective abort of all
ranks<br>
&nbsp; exit status of rank 0: killed by signal 6&nbsp;<br>
<br>
If someone could please tell me or edit the code if they see what is wrong.
Thanks!<br>
&nbsp;<br>
Main.cpp:<br>
<br>
#include &quot;RecordRetrieval.h&quot;<br>
#include &lt;vector.h&gt;<br>
int main()<br>
{<br>
&nbsp;&nbsp; vector&lt;bool&gt; vec;<br>
&nbsp;&nbsp; vec.push_back(true);<br>
&nbsp;&nbsp; vec.push_back(false);<br>
&nbsp;&nbsp; vec.push_back(true);<br>
&nbsp;&nbsp; vec.push_back(false);<br>
&nbsp;&nbsp; vec.push_back(true);<br>
&nbsp;&nbsp; vec.push_back(false);<br>
&nbsp;&nbsp; RecordRetrieval rec;<br>
&nbsp;&nbsp; rec.QueryData(vec, &quot;test.dat&quot;);<br>
&nbsp;&nbsp; return 0;<br>
}<br>
<br>
RecordRetrieval.cpp:<br>
&nbsp;<br>
#include &quot;RecordRetrieval.h&quot;<br>
#include &quot;mpi.h&quot;<br>
#include &quot;time.h&quot;<br>
#include &quot;iostream.h&quot;<br>
void RecordRetrieval::QueryData(vector&lt;bool&gt; unencoded_vector, char *
filename)<br>
{<br>
&nbsp;&nbsp;&nbsp; int num_processes;<br>
&nbsp;&nbsp;&nbsp; int num_vector_elements;<br>
&nbsp;&nbsp;&nbsp; float num_elements_per_rank;<br>
&nbsp;&nbsp;&nbsp; int local_start_position;<br>
&nbsp;&nbsp;&nbsp; int local_end_position;<br>
&nbsp;&nbsp;&nbsp; char * buf;<br>
&nbsp;&nbsp;&nbsp; int my_rank;<br>
&nbsp;&nbsp;&nbsp; MPI::File input_file;<br>
&nbsp;&nbsp;&nbsp; MPI::Status input_file_status;<br>
&nbsp;&nbsp;&nbsp; MPI::File output_file;<br>
&nbsp;&nbsp;&nbsp; MPI::Status output_file_status;<br>
&nbsp;&nbsp;&nbsp; //MPI::Offset filesize;<br>
&nbsp;&nbsp;&nbsp; char output_filename[30];<br>
&nbsp;&nbsp;&nbsp; size_t i;<br>
&nbsp;&nbsp;&nbsp; struct tm tim;<br>
&nbsp;&nbsp;&nbsp; time_t now;<br>
&nbsp;&nbsp;&nbsp; now = time(NULL);<br>
&nbsp;&nbsp;&nbsp; tim = *(localtime(&amp;now));<br>
&nbsp;&nbsp;&nbsp; i = strftime(output_filename, 30,
&quot;%m_%d_%Y_%H_%M_%S&quot;, &amp;tim);<br>
<br>
&nbsp;&nbsp;&nbsp; /* Let the system do what it needs to start up MPI */<br>
&nbsp;&nbsp;&nbsp; MPI::Init();<br>
&nbsp;&nbsp;&nbsp; /* Get my process rank */<br>
&nbsp;&nbsp;&nbsp; my_rank = MPI::COMM_WORLD.Get_rank();<br>
&nbsp;&nbsp;&nbsp; /* Find out how many processes are being used */<br>
&nbsp;&nbsp;&nbsp; num_processes = MPI::COMM_WORLD.Get_size();<br>
&nbsp;&nbsp;&nbsp; num_vector_elements = unencoded_vector.size();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;num_elements_per_rank = num_vector_elements /
num_processes;<br>
&nbsp;&nbsp;&nbsp; local_start_position = my_rank * (int)num_elements_per_rank;<br>
&nbsp;&nbsp;&nbsp; if(my_rank == num_processes - 1)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(num_elements_per_rank *
num_processes == (int)num_elements_per_rank * num_processes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
local_end_position = local_start_position + ((int)num_elements_per_rank - 1);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
local_end_position = (local_start_position + (int)num_elements_per_rank - 1) +<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(((int)num_elements_per_rank * num_processes) - ((int)num_elements_per_rank *
num_processes));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local_end_position =
local_start_position + ((int)num_elements_per_rank - 1);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; input_file = MPI::File::Open(MPI::COMM_WORLD, filename,
MPI::MODE_RDONLY,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
MPI::INFO_NULL);<br>
&nbsp;&nbsp;&nbsp; output_file = MPI::File::Open(MPI::COMM_WORLD,
output_filename, MPI::MODE_CREATE | MPI::MODE_WRONLY, MPI::INFO_NULL);<br>
&nbsp;&nbsp;&nbsp; // filesize = input_file.Get_size();<br>
&nbsp;&nbsp;&nbsp; for(int i = local_start_position; i &lt; local_end_position
+ 1; i++)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(unencoded_vector[i])<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
input_file.Read_at(i * 20, buf, 20, MPI_CHAR, input_file_status);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
output_file.Write_shared(buf, 20, MPI_CHAR, output_file_status);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; cout &lt;&lt; &quot;Error&quot;;<br>
&nbsp;&nbsp;&nbsp; input_file.Close();<br>
&nbsp;&nbsp;&nbsp; output_file.Close();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp; MPI::Finalize();<br>
}<o:p></o:p></span></font></p>

<div class=MsoNormal align=center style='text-align:center'><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>

<hr size=2 width="100%" align=center>

</span></font></div>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>Discover the new Windows Vista <a
href="http://search.msn.com/results.aspx?q=windows+vista&amp;mkt=en-US&amp;form=QBRE"
target="_new">Learn more!</a><o:p></o:p></span></font></p>

</div>

</div>

</body>

</html>