Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ptp-user] Variables values are wrong during debug of fortran "Calculate Pi in MPI"

Dear Greg,
Have you found the time to look into my problem?
Best,
Alexis

Alexis Giauque
Maître de Conférences
Ecole Centrale de Lyon
LMFA - Groupe Turbomachines
36 Avenue Guy de Collongue 69134 Ecully
Tel: 04 72 18 61 44
On 04/13/2017 09:52 AM, Alexis Giauque wrote:
Dear Greg,
Since the program is parallel I am more precisely using mpif90 (below the result of "mpif90 --version")
GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

I also add the source code of the basic PTP parallel test:
! ============================================================================
! Name        : TEST.f90
! Author      : ALex
! Version     :
! Copyright   : Your copyright notice
! Description : Calculate Pi in MPI
! ============================================================================

subroutine calc_pi(rank, num_procs)
    use mpi
    implicit none

    integer, intent(in) :: rank
    integer, intent(in) :: num_procs

    integer          :: i
    integer          :: ierror
    integer          :: num_intervals
    double precision :: h
    double precision :: mypi
    double precision :: pi
    double precision :: sum
    double precision :: x

    ! set number of intervals to calculate
    if (rank == 0) num_intervals = 100000000

    ! tell other tasks how many intervals
    call MPI_Bcast(num_intervals, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierror)

    ! now everyone does their calculation

    h = 1.0d0 / num_intervals
    sum = 0.0d0

    do i = rank + 1, num_intervals, num_procs
        x = h * (i - 0.5d0);
        sum = sum + (4.0d0 / (1.0d0 + x*x))
    end do

    mypi = h * sum

    ! combine everyone's calculations
    call MPI_Reduce(mypi, pi, 1, MPI_DOUBLE_PRECISION, MPI_SUM, 0, &
        MPI_COMM_WORLD, ierror)

    if (rank == 0) print *, "PI is approximately ", pi
end subroutine

program mpi_pi_example
    use mpi
    implicit none

    integer, parameter :: LEN = 100               ! message length

    integer            :: ierror                  ! error code
    integer            :: my_rank                 ! rank of process
    integer            :: num_procs               ! number of processes
    integer            :: source                  ! rank of sender
    integer            :: dest                    ! rank of receiver
    integer            :: tag                     ! tag for messages
    character(len=LEN) :: message                 ! storage for message
    integer            :: status(MPI_STATUS_SIZE) ! return status for receive

    dest = 0
    tag = 0

    ! start up MPI

    call MPI_Init(ierror)

    ! find out process rank
    call MPI_Comm_rank(MPI_COMM_WORLD, my_rank, ierror)

    ! find out number of processes
    call MPI_Comm_size(MPI_COMM_WORLD, num_procs, ierror)


    if (my_rank .ne. 0) then
        ! create message
        write (message, *) "Greetings from process ", my_rank
        call MPI_Send(message, LEN, MPI_CHARACTER, &
                dest, tag, MPI_COMM_WORLD, ierror)
    else
        print *, "Num processes: ", num_procs
        do source = 1, num_procs-1
            call MPI_Recv(message, LEN, MPI_CHARACTER, source, tag, &
                    MPI_COMM_WORLD, status, ierror)
            print *, "Process 0 received ", message
        end do

        ! now return the compliment
        write (message, *) "Hi, how are you?"
    end if

    call MPI_Bcast(message, LEN, MPI_CHARACTER, dest, MPI_COMM_WORLD, ierror)

    if (my_rank .ne. 0) then
        print *, "Process ", my_rank, " received ", message
    end if

    ! calculate PI
    call calc_pi(my_rank, num_procs)

    ! shut down MPI
    call MPI_Finalize(ierror)

    stop
end program


Alexis Giauque
Maître de Conférences
Ecole Centrale de Lyon
LMFA - Groupe Turbomachines
36 Avenue Guy de Collongue 69134 Ecully
Tel: 04 72 18 61 44
On 04/12/2017 04:01 PM, Greg Watson wrote:
Are you using gfortran? Can you send me a sample code?

Thanks,
Greg

On Apr 12, 2017, at 9:32 AM, Alexis Giauque <alexis.giauque@xxxxxxxxxx> wrote:

Hi Greg,
Thanks for answering my call.
Variables are either integer or double precision (such as pi).
Let me know if I can make my case any clearer.
Best,

Alexis Giauque
Maître de Conférences
Ecole Centrale de Lyon
LMFA - Groupe Turbomachines
36 Avenue Guy de Collongue 69134 Ecully
Tel: 04 72 18 61 44
On 04/12/2017 03:17 PM, Greg Watson wrote:
Hi Alexis,

What is the type declaration for the variables?

Regards,
Greg

On Apr 10, 2017, at 10:00 AM, Alexis Giauque <alexis.giauque@xxxxxxxxxx> wrote:

Dear PTP users,
I am having troubles debugging the simple test-case "Calculate Pi in MPI" using 2 procs.
The thing is that (as seen in the attached picture) variables values are completely wrong (tested as ok using the same gdb outside of eclipse).
It seems that it could be that the variables values is interpreted as an address by the debugger (might be ok in C) but I don't know if I can change this behavior in eclipse.
I use Eclipse Neon.3 , PTP with SDM 9.1.2.20170223. GDB is GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Has anyone seen the same kind of thing? Could you help me?
Best regards,
--
Alexis Giauque
Maître de Conférences
Ecole Centrale de Lyon
LMFA - Groupe Turbomachines
36 Avenue Guy de Collongue 69134 Ecully
Tel: 04 72 18 61 44
<bug.png>_______________________________________________
ptp-user mailing list
ptp-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ptp-user



_______________________________________________
ptp-user mailing list
ptp-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ptp-user

_______________________________________________
ptp-user mailing list
ptp-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ptp-user



_______________________________________________
ptp-user mailing list
ptp-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ptp-user



_______________________________________________
ptp-user mailing list
ptp-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ptp-user


Back to the top