LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: poknam (poknam_at_[hidden])
Date: 2003-09-18 10:34:02


Thank you very much!! It works now.
Now I want to follow the logic of the program and write my own one. Here's
the code:

        program main
        include 'mpif.h'
        parameter (BUFSIZE = 2048)
        integer ierr, rank
        integer tag, status(MPI_STATUS_SIZE)
        integer size
        real message(BUFSIZE)
        real BUFFER(2048)
        call MPI_INIT(ierr)
        call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)

        tag = 0
        if (rank == 0) then
                print *, 'Hello world! I am proc ', rank,
        1 ', sending to proc 1..'
                size = BUFSIZE * 4 + MPI_BSEND_OVERHEAD
                call MPI_BUFFER_ATTACH(BUFFER, size, ierr)
                call MPI_BSEND(message, BUFSIZE, MPI_REAL,
        1 1, tag, MPI_COMM_WORLD, ierr)
                call MPI_BUFFER_DETACH(BUFFER, size, ierr)
        else if (rank == 1) then
                call SLEEP(3)
                print *, 'Hello world! I am proc ', rank,
        1 ', just wake up!!'
                call MPI_RECV(message, BUFSIZE, MPI_REAL,
        1 0, tag, MPI_COMM_WORLD, status, ierr)
                print *, 'Hello world! Received 1 message ',
        1 'proc 1!!'
        endif
        print *, 'Proc ', rank, ' finished!!'
        call MPI_FINALIZE(ierr)
        end

Runtime error occur, I've tried changing the value of "size" or the
dimension of "BUFFER", but the result is the same. Here's the output:

Hello world! I am proc 0, sending to proc 1..
MPI_Bsend: unclassified: No buffer space available (rank 0, MPI_COMM_WORLD)
Rank (0, MPI_COMM_WORLD): Call stack within LAM: Rank (0, MPI_COMM_WORLD):
- MPI_Bsend() Rank (0, MPI_COMM_WORLD): - main()

Can anyone tell me why?? Million thanks.

P.N. Lai

-----Original Message-----
From: lam-bounces_at_[hidden] [mailto:lam-bounces_at_[hidden]] On Behalf Of
Nick Nevin
Sent: Thursday, September 18, 2003 8:19 PM
To: General LAM/MPI mailing list
Subject: Re: LAM: SIGSEGV in MPI_Buffer_detach

On Thu, Sep 18, 2003 at 06:40:29PM +0800, poknam wrote:
> This is a very simple program downloaded from web,
>
> But there's runtime error in MPI_BUFFER_DETACH,
>
> I've tried other fortran programs using MPI_BUFFER_DETACH, still a
> similar error occurs.
>
> But the error ONLY occur in Fortran, C has no problem.
>
> Also, I've tried comment the line with MPI_BUFFER_DETACH, then it runs
> smoothly
>
> Below is the code:
>
>
[snip]
>
> call MPI_BUFFER_DETACH(buffer,528,ierr)

You need to pass a variable not a constant as the second argument. For
example

        call MPI_BUFFER_DETACH(buffer,k,ierr)

-nick
_______________________________________________
This list is archived at http://www.lam-mpi.org/MailArchives/lam/