tags:

views:

54

answers:

0

I am trying to receive a variable from multiple processed as part of a DO loop. However, the value of the variable is 0 after the operation if I use a variable to represent the processor number. It works fine if I put the processor number in directly. Oddly enough, the exact same code works fine earlier in the program. Any thoughts on my problem?

  DO s = 1,numproc-1,1
        CALL MPI_RECV( numZERO, 1, MPI_INTEGER, s, 1, MPI_COMM_WORLD, status, ierr )
        WRITE(*,*)'s',s,'numZERO',numZERO
  END DO

gives:

  s   1   numZERO   0
  s   2   numZERO   0 ...

when it is coded:

  CALL MPI_RECV( numZERO, 1, MPI_INTEGER, 1, 1, MPI_COMM_WORLD, status, ierr )
  WRITE(*,*)'1 numZERO',numZERO
  CALL MPI_RECV( numZERO, 1, MPI_INTEGER, 2, 1, MPI_COMM_WORLD, status, ierr )
  WRITE(*,*)'2 numZERO',numZERO

I get

  1 numZERO   1
  2 numZERO   2 ...

s is an integer.