<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7036.0">
<TITLE>RE: [mpich-discuss] Problem sometimes when running on winxp on &gt;=2 processes and MPE_IBCAST</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>&nbsp;Hi,<BR>
&nbsp; Can you try running the example program, cpi.exe (MPICH2\examples), provided with MPICH2 with 2/4/8 procs?<BR>
<BR>
# Please let us know the details on how you are running your MPI job (mpiexec command, job script etc and its details.)<BR>
# Pls provide us the details of the machine you are running your MPI job (proc, num of cores etc)<BR>
# Do you get the same error when running non-MPI programs (Try &quot;mpiexec -n 8 hostname&quot; on your system)?<BR>
<BR>
&nbsp;I would also recommend uninstalling/re-installing MPICH2 on your system and trying out the tests above.<BR>
<BR>
Regards,<BR>
Jayesh<BR>
<BR>
-----Original Message-----<BR>
From: Ben Tay [<A HREF="mailto:zonexo@gmail.com">mailto:zonexo@gmail.com</A>]<BR>
Sent: Sunday, May 11, 2008 9:16 AM<BR>
To: Jayesh Krishna<BR>
Subject: Re: [mpich-discuss] Problem sometimes when running on winxp on &gt;=2 processes and MPE_IBCAST<BR>
<BR>
Hi,<BR>
<BR>
I forgot that I modify the original template. Sorry about that. Anyway, I tested again using the fpi example. On 4 processes, sometimes it work, sometimes it doesn't and gives the error msg:<BR>
<BR>
[01:3384].....ERROR:result command received but the wait_list is empty.<BR>
[01:3384]...ERROR:unable to handle the command: &quot;cmd=result src=1 dest=1<BR>
tag=5 c<BR>
md_tag=1 cmd_orig=dbput ctx_key=1 result=DBS_SUCCESS &quot;<BR>
[01:3384]..ERROR:sock_op_close returned while unknown context is in<BR>
state: SMPD_<BR>
IDLE<BR>
<BR>
On 8 processes:<BR>
<BR>
[01:1252].....ERROR:result command received but the wait_list is empty.<BR>
[01:1252]...ERROR:unable to handle the command: &quot;cmd=result src=1 dest=1<BR>
tag=9 c<BR>
md_tag=1 cmd_orig=dbput ctx_key=3 result=DBS_SUCCESS &quot;<BR>
[01:3576].....ERROR:result command received but the wait_list is empty.<BR>
[01:3576]...ERROR:unable to handle the command: &quot;cmd=result src=1 dest=1<BR>
tag=11<BR>
cmd_tag=1 cmd_orig=dbput ctx_key=1 result=DBS_SUCCESS &quot;<BR>
[01:1252]..ERROR:sock_op_close returned while unknown context is in<BR>
state: SMPD_<BR>
IDLE<BR>
[01:3576]..ERROR:sock_op_close returned while unknown context is in<BR>
state: SMPD_<BR>
IDLE<BR>
<BR>
There seems to be sometime wrong with my MPICH2.<BR>
<BR>
Thank you.<BR>
<BR>
Regards.<BR>
<BR>
Jayesh Krishna wrote:<BR>
&gt;<BR>
&gt;&nbsp; Hi,<BR>
&gt;&nbsp;&nbsp; I did not see the exact example source code in RS 6000 MPI<BR>
&gt; programming guide (The closest example was a template code which<BR>
&gt; slightly differs from the one that you sent us).<BR>
&gt;&nbsp;&nbsp; After removing the MPI_Barrier() from for loop (keeping the<BR>
&gt; MPI_Bcast() still in for loop) I do not get any errors when running<BR>
&gt; your program for 0&lt; n &lt;=4 procs. Send us your code and the logic of<BR>
&gt; the code for further analysis.<BR>
&gt;&nbsp;&nbsp; Meanwhile the block distribution code (para_range -- to find the<BR>
&gt; range for block distribution) that you use in your source code is not<BR>
&gt; valid if you have less work to do than the number of procs (i.e., no<BR>
&gt; need for distribution --- You are using the array, jjsta, indices 3 to<BR>
&gt; 6 in your job = which is 4 elements to work with =&gt; the distribution<BR>
&gt; range finder code will fail if you run your code with &gt; 4 procs).<BR>
&gt;<BR>
&gt; Regards,<BR>
&gt; Jayesh<BR>
&gt; -----Original Message-----<BR>
&gt; From: owner-mpich-discuss@mcs.anl.gov<BR>
&gt; [<A HREF="mailto:owner-mpich-discuss@mcs.anl.gov">mailto:owner-mpich-discuss@mcs.anl.gov</A>] On Behalf Of Ben Tay<BR>
&gt; Sent: Wednesday, May 07, 2008 7:45 PM<BR>
&gt; To: mpich-discuss@mcs.anl.gov<BR>
&gt; Subject: Re: [mpich-discuss] Problem sometimes when running on winxp<BR>
&gt; on &gt;=2 processes and MPE_IBCAST<BR>
&gt;<BR>
&gt; Hi,<BR>
&gt;<BR>
&gt; I've removed the MPI_Barrier. The bound checking is also enabled.<BR>
&gt; However the same error still happens, randomly when processes =2 and<BR>
&gt; always when processes =4. I did not encounter this error when I run it<BR>
&gt; in my school's servers.<BR>
&gt;<BR>
&gt; I also just compile using MPICH. Interestingly, there is no problem at<BR>
&gt; all. So I guess this problem is due to MPICH2.<BR>
&gt;<BR>
&gt; Thank you very much.<BR>
&gt;<BR>
&gt; Jayesh Krishna wrote:<BR>
&gt; &gt;<BR>
&gt; &gt;&nbsp; Hi,<BR>
&gt; &gt;&nbsp;&nbsp; Please find my observations below,<BR>
&gt; &gt;<BR>
&gt; &gt; 1) As Anthony pointed out you don't have to call MPI_Barrier() in a<BR>
&gt; &gt; loop for all processes (see usage of MPI collectives).<BR>
&gt; &gt; 2) When running the program with more than 4 procs, some array<BR>
&gt; &gt; accesses are out of bounds (Try re-compiling your program with Run<BR>
&gt; &gt; time checking for &quot;Array and String bounds&quot; --&gt; If you are using VS<BR>
&gt; &gt; check out &quot;Configuration Properties&quot; --&gt; Fortran --&gt; Runtime --&gt; *<BR>
&gt; &gt; for setting the runtime checking)<BR>
&gt; &gt;<BR>
&gt; &gt; Regards,<BR>
&gt; &gt; Jayesh<BR>
&gt; &gt;<BR>
&gt; &gt; -----Original Message-----<BR>
&gt; &gt; From: owner-mpich-discuss@mcs.anl.gov<BR>
&gt; &gt; [<A HREF="mailto:owner-mpich-discuss@mcs.anl.gov">mailto:owner-mpich-discuss@mcs.anl.gov</A>] On Behalf Of Anthony Chan<BR>
&gt; &gt; Sent: Wednesday, May 07, 2008 11:13 AM<BR>
&gt; &gt; To: mpich-discuss@mcs.anl.gov<BR>
&gt; &gt; Subject: Re: [mpich-discuss] Problem sometimes when running on winxp<BR>
&gt; &gt; on &gt;=2 processes and MPE_IBCAST<BR>
&gt; &gt;<BR>
&gt; &gt;<BR>
&gt; &gt; May not be related to the error that you saw.&nbsp; You shouldn't call<BR>
&gt; &gt; MPI_Barrier and MPI_Bcast with a do loop over processes.<BR>
&gt; &gt;<BR>
&gt; &gt; A.Chan<BR>
&gt; &gt; ----- &quot;Ben Tay&quot; &lt;zonexo@gmail.com&gt; wrote:<BR>
&gt; &gt;<BR>
&gt; &gt; &gt; Hi Rajeev,<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; I've attached the code. Thank you very much.<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; Regards.<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; Rajeev Thakur wrote:<BR>
&gt; &gt; &gt; &gt; Can you send us the code?<BR>
&gt; &gt; &gt; &gt;<BR>
&gt; &gt; &gt; &gt; MPE_IBCAST is not a part of the MPI standard. There is no<BR>
&gt; &gt; &gt; &gt; equivalent<BR>
&gt; &gt; &gt; for it<BR>
&gt; &gt; &gt; &gt; in MPICH2. You could spawn a thread that calls MPI_Bcast though<BR>
&gt; &gt; &gt; (after<BR>
&gt; &gt; &gt; &gt; following all the caveats of MPI and threads as defined in the<BR>
&gt; &gt; &gt; standard).<BR>
&gt; &gt; &gt; &gt;<BR>
&gt; &gt; &gt; &gt; Rajeev<BR>
&gt; &gt; &gt; &gt;<BR>
&gt; &gt; &gt; &gt;<BR>
&gt; &gt; &gt; &gt;&gt; -----Original Message-----<BR>
&gt; &gt; &gt; &gt;&gt; From: owner-mpich-discuss@mcs.anl.gov<BR>
&gt; &gt; &gt; &gt;&gt; [<A HREF="mailto:owner-mpich-discuss@mcs.anl.gov">mailto:owner-mpich-discuss@mcs.anl.gov</A>] On Behalf Of Ben Tay<BR>
&gt; &gt; &gt; &gt;&gt; Sent: Wednesday, May 07, 2008 10:25 AM<BR>
&gt; &gt; &gt; &gt;&gt; To: mpich-discuss@mcs.anl.gov<BR>
&gt; &gt; &gt; &gt;&gt; Subject: [mpich-discuss] Problem sometimes when running on<BR>
&gt; &gt; &gt; &gt;&gt; winxp on<BR>
&gt; &gt; &gt; &gt;&gt; &gt;=2 processes and MPE_IBCAST<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt; Hi,<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt; I tried to run a mpi code which is copied from an example by<BR>
&gt; &gt; &gt; &gt;&gt; the RS 6000 book. It is supposed to broadcast and synchronize<BR>
&gt; &gt; &gt; &gt;&gt; all<BR>
&gt; values.<BR>
&gt; &gt; &gt; &gt;&gt; When I ran it on my school's linux servers, there is no problem.<BR>
&gt; &gt; &gt; &gt;&gt; However, if I run it on my own winxp, on &gt;=2 processes,<BR>
&gt; &gt; &gt; &gt;&gt; sometimes it work, other times I get the error:<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt; [01:3216].....ERROR:result command received but the wait_list<BR>
&gt; &gt; &gt; &gt;&gt; is empty.<BR>
&gt; &gt; &gt; &gt;&gt; [01:3216]...ERROR:unable to handle the command: &quot;cmd=result<BR>
&gt; &gt; &gt; &gt;&gt; src=1 dest=1<BR>
&gt; &gt; &gt; &gt;&gt; tag=7 c<BR>
&gt; &gt; &gt; &gt;&gt; md_tag=3 cmd_orig=dbget ctx_key=1 value=&quot;port=1518<BR>
&gt; &gt; &gt; &gt;&gt; description=gotchama-16e5ed i<BR>
&gt; &gt; &gt; &gt;&gt; fname=192.168.1.105 &quot; result=DBS_SUCCESS &quot;<BR>
&gt; &gt; &gt; &gt;&gt; [01:3216].ERROR:error closing the unknown context socket:<BR>
&gt; &gt; &gt; &gt;&gt; generic socket failure , error stack:<BR>
&gt; &gt; &gt; &gt;&gt; MPIDU_Sock_wait(2603): The I/O operation has been aborted<BR>
&gt; &gt; &gt; &gt;&gt; because of either a th read exit or an application request.<BR>
&gt; &gt; &gt; &gt;&gt; (errno 995) [01:3216]..ERROR:sock_op_close returned while<BR>
&gt; &gt; &gt; &gt;&gt; unknown context is in<BR>
&gt; &gt; &gt; &gt;&gt; state: SMPD_<BR>
&gt; &gt; &gt; &gt;&gt; IDLE<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt; Or<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt; [01:3308].....ERROR:result command received but the wait_list<BR>
&gt; &gt; &gt; &gt;&gt; is empty.<BR>
&gt; &gt; &gt; &gt;&gt; [01:3308]...ERROR:unable to handle the command: &quot;cmd=result<BR>
&gt; &gt; &gt; &gt;&gt; src=1 dest=1<BR>
&gt; &gt; &gt; &gt;&gt; tag=15<BR>
&gt; &gt; &gt; &gt;&gt; cmd_tag=5 cmd_orig=barrier ctx_key=0 result=DBS_SUCCESS &quot;<BR>
&gt; &gt; &gt; &gt;&gt; [01:3308]..ERROR:sock_op_close returned while unknown context<BR>
&gt; &gt; &gt; &gt;&gt; is<BR>
&gt; &gt; &gt; in<BR>
&gt; &gt; &gt; &gt;&gt; state: SMPD_<BR>
&gt; &gt; &gt; &gt;&gt; IDLE<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt; There is no problem if I run on 1 process. If it's &gt;=4, then<BR>
&gt; &gt; &gt; &gt;&gt; the error happens all the time. Moreover, it's a rather simple<BR>
&gt; &gt; &gt; &gt;&gt; code and so there shouldn't be anything wrong with it.<BR>
&gt; &gt; &gt; &gt;&gt; Why is this so?<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt; Btw, the RS 6000 book also mention a routine called MPE_IBCAST,<BR>
&gt; &gt; &gt; &gt;&gt; which is a non-blocking version of MPI_BCAST. Is there a<BR>
&gt; &gt; &gt; &gt;&gt; similar routine in MPICH2?<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt; Thank you very much<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt; Regards.<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt;<BR>
&gt; &gt; &gt; &gt;&gt;&nbsp;&nbsp;<BR>
&gt; &gt; &gt; &gt;<BR>
&gt; &gt; &gt; &gt;<BR>
&gt; &gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; program mpi_test2<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; !&nbsp;&nbsp;&nbsp;&nbsp; test to show updating for i,j double loop (partial continuous<BR>
&gt; &gt; data)<BR>
&gt; &gt; &gt; for specific req data only<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; !&nbsp;&nbsp;&nbsp;&nbsp; ie update u(2:6,2:6) values instead of all u values, also for<BR>
&gt; &gt; struct<BR>
&gt; &gt; &gt; data<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; !&nbsp;&nbsp;&nbsp;&nbsp; FVM use<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; implicit none<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; include &quot;mpif.h&quot;&nbsp;&nbsp;&nbsp;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; integer, parameter :: size_x=8,size_y=8<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; integer :: i,j,k,ierr,rank,nprocs,u(size_x,size_y)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; integer :: jsta,jend,jsta2,jend1,inext,iprev,isend1,irecv1,isend2<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; integer :: irecv2,is,ie,js,je<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; integer, allocatable :: jjsta(:), jjlen(:),jjreq(:),u_tmp(:,:)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; INTEGER istatus(MPI_STATUS_SIZE)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; call MPI_Init(ierr)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; call MPI_Comm_rank(MPI_COMM_WORLD,rank,ierr)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; call MPI_Comm_size(MPI_COMM_WORLD,nprocs,ierr)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; allocate (jjsta(0:nprocs-1),jjlen(0:nprocs-1),jjreq(0:nprocs-1))<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; is=3; ie=6;&nbsp;&nbsp; js=3;&nbsp;&nbsp; je=6<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; allocate (u_tmp(is:ie,js:je))<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; do k = 0, nprocs - 1<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call para_range(js,je, nprocs, k, jsta, jend)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jjsta(k) = jsta<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jjlen(k) = (ie-is+1) * (jend - jsta + 1)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; end do<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; call para_range(js, je, nprocs, rank , jsta, jend)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; do j=jsta,jend<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do i=is,ie<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; u(i,j)=(j-1)*size_x+i<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end do<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; end do<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; do j=jsta,jend<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do i=is,ie<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; u_tmp(i,j)=u(i,j)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end do<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; end do<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; do k=0,nprocs-1<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call MPI_Barrier(MPI_COMM_WORLD,ierr)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (k==rank) then<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print *, rank<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write (*,'(8i5)') u<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end if<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; end do<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; do k = 0, nprocs - 1<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call MPI_BCAST(u_tmp(is,jjsta(k)), jjlen(k), MPI_Integer,k,<BR>
&gt; &gt; &gt; MPI_COMM_WORLD, ierr)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; end do<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; deallocate (jjsta, jjlen, jjreq)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; u(is:ie,js:je)=u_tmp(is:ie,js:je)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; do k=0,nprocs-1<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call MPI_Barrier(MPI_COMM_WORLD,ierr)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (k==rank) then<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print *, rank<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write (*,'(8i5)') u<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end if<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; end do<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; call MPI_Finalize(ierr)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; contains<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; subroutine para_range(n1, n2, nprocs, irank, ista, iend)<BR>
&gt; &gt; &gt; !&nbsp;&nbsp;&nbsp;&nbsp; block distribution<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; integer n1 !The lowest value of the iteration variable (IN)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; integer n2 !The highest value of the iteration variable (IN)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; integer nprocs !The number of processes (IN)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; integer irank !The rank for which you want to know the range of<BR>
&gt; &gt; &gt; iterations(IN)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; integer ista !The lowest value of the iteration variable that<BR>
&gt; &gt; &gt; process irank executes (OUT)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; integer iend !The highest value of the iteration variable that<BR>
&gt; &gt; &gt; process irank executes (OUT)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; integer iwork1,iwork2<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; iwork1 = (n2 - n1 + 1) / nprocs<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; iwork2 = mod(n2 - n1 + 1, nprocs)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; ista = irank * iwork1 + n1 + min(irank, iwork2)<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; iend = ista + iwork1 - 1<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; if (iwork2 &gt; irank) iend = iend + 1<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; end subroutine para_range<BR>
&gt; &gt; &gt;<BR>
&gt; &gt; &gt; end program mpi_test2<BR>
&gt; &gt;<BR>
&gt; &gt;<BR>
&gt;<BR>
&gt;<BR>
</FONT>
</P>

</BODY>
</HTML>