[mpich-discuss] MPI_allgather

koppole at aim.com koppole at aim.com
Mon Apr 14 09:03:07 CDT 2008


Hello there,

I have a question/problem regarding mpi_allgather.



When I try to call mpi_allgather, the computations from the 0 (rank =0) 
are filled properly while from all other process, I just get something 
but the numbers are not correct.

Could any one help me ?



For your information, here is part of my FORTRAN CODE. I try to compute 
the dihedral angle on all my nodes in the commreplica communicator. 
Please follow my FORTRAN code below:



FYI:  I have numtasks = 3 with mytaskid going from 0,1,2

-------------------------------------------------------------------------
-------------------------------------------------------------------------
-----------------------------------

!! I allocate the required memory for the dihedral arrays phi_arr and 
phi_prt, which is a 2-D array of length dihe_num

       allocate(phi_arr(3,dihe_num), stat = alloc_failed)

        if (alloc_failed .ne. 0) call setup_alloc_error



        allocate(phi_prt(3,dihe_num), stat = alloc_failed)

        if (alloc_failed .ne. 0) call setup_alloc_error



!! Here I compute the dihedral on all my nodes ; mytaskid = rank of my 
process and numtasks = no. of processors in this communicator

          do i=(1+mytaskid), dihe_num, numtasks



                    one(1:3,1) = atm_crd(1:3,dihe_arr(1,i))

                    two(1:3,1) = atm_crd(1:3,dihe_arr(2,i))

                  three(1:3,1) = atm_crd(1:3,dihe_arr(3,i))

                   four(1:3,1) = atm_crd(1:3,dihe_arr(4,i))



!! phipsi is a subroutine which compute the dihedral angle on the given 
processor from the coordinates of the 4 atoms, which returns phid as 
the dihedral angle

                  call phipsi(phid,one,two,three,four)

                      phi_prt(1,i) = phid



!! here I compute the cos and sin of the returned dihedral angle.

                      phi_prt(2,i) = dcos(phid)

                      phi_prt(3,i) = dsin(phid)



!! "j" keeps track of the number of angles filled.

                 j = j +1

          end do



      call mpi_allgather(phi_prt,3*j,mpi_double_precision, &

                                   phi_arr,3*j,mpi_double_precision, &

                                   commreplica,err_code_mpi)



      if (mytaskid .eq. 0) then

         do i=1,dihe_num

          write(mdout,'(i3,3(1x,f7.3))') i, phi_arr(1:3,i)

         end do

      end if

-------------------------------------------------------------------------
-------------------------------------------------------------------------
-----------------------------------

when I do this: I just get the data from i=1,4,6,7 are correct, all 
other indices is wrong :(. Am i doing something wrong ?



Can anyone help ?

Thanks a lot,

Cheers,

Sampath.



Sampath Koppole,

The Computational Molecular Biophysics Group,                           


Interdisciplinary Center for Scientific Computing (IWR),

368, Im Neuenheimer Feld,

Heidelberg. D-69120.

Germany.

Office   : +49-6221-54-8803

Home     : +49-6221-7293083

Mobile   : +49-173-660-5660

Email    : sampath.koppole at iwr.uni-heidelberg.de

Web Home : http://www.sampath.koppole.com






More information about the mpich-discuss mailing list