Thx a lot. I will be more careful with declaration of the MPI variables.

Pawel J.

W dniu 2016-01-22 o 16:06, Nick Papior pisze:
The status field should be

integer :: stat(MPI_STATUS_SIZE)

Perhaps n is located stackwise just after the stat variable, which then overwrites it.

2016-01-22 15:37 GMT+01:00 Paweł Jarzębski <pj...@ippt.pan.pl <mailto:pj...@ippt.pan.pl>>:

    Hi,

    I wrote this code:

          program hello
           implicit none

           include 'mpif.h'
           integer :: rank, dest, source, tag, ierr, stat
           integer :: n
           integer :: taskinfo, ptr

           call MPI_INIT(ierr)
           call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)

           if(rank.eq.0) then
            write(*,*) 'Hello'

            n = 20
            dest = 1
            tag = 1
            taskinfo = n
            call MPI_SEND(taskinfo, 1, MPI_INTEGER, dest, tag,
         1       MPI_COMM_WORLD, ierr)

            tag = tag + 1
            call MPI_SEND(ptr, 1, MPI_INTEGER, dest, tag,
         1       MPI_COMM_WORLD, ierr)

           else
            source = 0
            tag = 1

    !        n = 1
            call MPI_RECV(taskinfo, 1, MPI_INTEGER, source, tag,
         1       MPI_COMM_WORLD, stat, ierr)

            n = taskinfo

            tag = tag + 1

            write(*,*) 'n1 ', n
            write(*,*) 'taskinfo1 ', taskinfo
            call MPI_RECV(ptr, 1, MPI_INTEGER, source, tag,
         1       MPI_COMM_WORLD, stat, ierr)
            write(*,*) 'n2 ', n
            write(*,*) 'taskinfo2 ', taskinfo
           endif

           call MPI_FINALIZE(ierr)
          end


    I supposed that it should produce this:
     Hello
     n1           20
     taskinfo1           20
     n2            20
     taskinfo2           20

    But in fact it produces this:
     Hello
     n1           20
     taskinfo1           20
     n2            2
     taskinfo2           20

    It's strange to me that variable "n" is changed after call to MPI
    subroutine, but I dont even put it in calls to MPI.
    If I comment line 13 with " write(*,*) 'Hello' " everything is ok.
    If I uncomment line 30 with "n = 1", everything is ok as well.

    Could anybody explain me what is happening?

    I tested it on:
      1) intel fortran compiler 14.0 and openmpi 1.6.5
      1) intel fortran compiler 13.1.3 and openmpi 1.8.4

    Best regards,
    Pawel J.




    _______________________________________________
    users mailing list
    us...@open-mpi.org <mailto:us...@open-mpi.org>
    Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users
    Link to this post:
    http://www.open-mpi.org/community/lists/users/2016/01/28334.php




--
Kind regards Nick


_______________________________________________
users mailing list
us...@open-mpi.org
Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users
Link to this post: 
http://www.open-mpi.org/community/lists/users/2016/01/28336.php

Reply via email to