<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi all<div>I have a problem with mpi_type_vector, I want to divide a cubic matrix between for example two processes for solving my problem I have to send boundary plane's information from one process to other I did it before by point_point_communication but I know it's not good because of my huge matrix so I want to use derived data type.</div><div>I want to create a vector I know that in c++ matrix is row major but I have problem with mpi_type_vector().I write arguments with respect to tutorial <a href="http://www.mcs.anl.gov/research/projects/mpi/www/www3/MPI_Type_vector.html">http://www.mcs.anl.gov/research/projects/mpi/www/www3/MPI_Type_vector.html</a></div><div>but I get segmentation fault error .my code is :</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(120, 72, 47); ">#include <span style="color: #d12c26"><mpi.h></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(209, 44, 38); "><span style="color: #78482f">#include </span><iostream></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(187, 45, 157); ">using<span style="color: #000000"> </span>namespace<span style="color: #000000"> std;</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">int</span> main(<span style="color: #bb2d9d">int</span> argc,<span style="color: #bb2d9d">char</span> ** argv)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">int</span> <span style="color: #bb2d9d">const</span> IE=<font class="Apple-style-span" color="#2c2ecf">100</font>,JE=<font class="Apple-style-span" color="#2c2ecf">25</font>,KE=<font class="Apple-style-span" color="#2c2ecf">100;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">int</span> size,rank;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">MPI_Status status;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">MPI_Init(&argc,&argv);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">MPI_Comm_size(MPI_COMM_WORLD,&size);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">MPI_Comm_rank(MPI_COMM_WORLD,&rank);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">MPI_Datatype sub;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(0, 132, 37); ">MPI_Type_vector(KE,IE,IE+(JE-1)*IE,MPI_DOUBLE,&sub);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">MPI_Type_commit(&sub);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">if</span> (rank==<span style="color: #2c2ecf">0</span>){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(187, 45, 157); ">double<span style="color: #000000">*** a=</span>new<span style="color: #000000"> </span>double<span style="color: #000000">**[IE];</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> i=<span style="color: #2c2ecf">0</span>;i<IE;i++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">a[i]=<span style="color: #bb2d9d">new</span> <span style="color: #bb2d9d">double</span> *[JE];</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> j=<span style="color: #2c2ecf">0</span>;j<JE;j++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">a[i][j]=<span style="color: #bb2d9d">new</span> <span style="color: #bb2d9d">double</span> [KE];</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> i=<span style="color: #2c2ecf">0</span>;i<IE;i++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> j=<span style="color: #2c2ecf">0</span>;j<JE;j++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> k=<span style="color: #2c2ecf">0</span>;k<KE;k++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">a[i][j][k]=<span style="color: #2c2ecf">2</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}}}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> i=<span style="color: #2c2ecf">0</span>;i<IE;i++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> j=<span style="color: #2c2ecf">0</span>;j<JE;j++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">a[i][j][<span style="color: #2c2ecf">0</span>]=<span style="color: #2c2ecf">2</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">MPI_Send(&a[<span style="color: #2c2ecf">0</span>][0][0],<span style="color: #2c2ecf">1</span>,sub,<span style="color: #2c2ecf">1</span>,<span style="color: #2c2ecf">52</span>,MPI_COMM_WORLD);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">if</span> (rank==<span style="color: #2c2ecf">1</span>){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(187, 45, 157); ">double<span style="color: #000000">*** b=</span>new<span style="color: #000000"> </span>double<span style="color: #000000">**[IE];</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> i=<span style="color: #2c2ecf">0</span>;i<IE;i++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">b[i]=<span style="color: #bb2d9d">new</span> <span style="color: #bb2d9d">double</span> *[JE];</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> j=<span style="color: #2c2ecf">0</span>;j<JE;j++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">b[i][j]=<span style="color: #bb2d9d">new</span> <span style="color: #bb2d9d">double</span> [KE];</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> i=<span style="color: #2c2ecf">0</span>;i<IE;i++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> j=<span style="color: #2c2ecf">0</span>;j<JE;j++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> k=<span style="color: #2c2ecf">0</span>;k<KE;k++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">b[i][j][k]=<span style="color: #2c2ecf">0</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}}}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">MPI_Recv(&b[<span style="color: #2c2ecf">0</span>][0][0][0],<span style="color: #2c2ecf">1</span>,sub,<span style="color: #2c2ecf">0</span>,<span style="color: #2c2ecf">52</span>,MPI_COMM_WORLD,&status);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> i=<span style="color: #2c2ecf">0</span>;i<IE;i++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> j=<span style="color: #2c2ecf">0</span>;j<JE;j++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">for</span>(<span style="color: #bb2d9d">int</span> k=<span style="color: #2c2ecf">0</span>;k<KE;k++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #bb2d9d">if</span>(b[i][j][k]><span style="color: #2c2ecf">0</span>){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">cout<<<span style="color: #d12c26">"b["</span><<i<<<span style="color: #d12c26">"]["</span><<j<<<span style="color: #d12c26">"]["</span><<k<<<span style="color: #d12c26">"]="</span><<b[i][j][k]<<endl;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}}}}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">MPI_Finalize();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}</div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">I just want to send plane y=0 from process 0 to process 1.can everybody help me?</div></body></html>