From: bio_amateur on
My question is if I use an ALLOCATABLE array as the buffer
(unallocated). Should it be allocated before that or the MPI routines
(RECV, BCAST...) will automatically allocate and fill the received
data to it.

Thanks,
Tuan
From: glen herrmannsfeldt on
bio_amateur <hoangtrongminhtuan(a)gmail.com> wrote:

> My question is if I use an ALLOCATABLE array as the buffer
> (unallocated). Should it be allocated before that or the MPI routines
> (RECV, BCAST...) will automatically allocate and fill the received
> data to it.

Much of MPI is in C, so unlikely to allocate Fortran allocatables.

If you use Fortran wrapper routines, it is possible that they
might do that, but I would be surprised. Then again, you can
write your own wrapper routines, use C interoperability and
Fortran 2003 allocate on assignment (or just check to see what
is already allocated) and allocate as needed.

-- glen
From: Ian Bush on

Aha! An easy one!

On 27 May, 03:55, bio_amateur <hoangtrongminht...(a)gmail.com> wrote:
> My question is if I use an ALLOCATABLE array as the buffer
> (unallocated). Should it be allocated before that

Yes. MPI won't allocate it for you. In fact it can't, the latest
binding is only f90.

> or the MPI routines
> (RECV, BCAST...) will automatically allocate and fill the received
> data to it.
>

No.

Ian
From: bio_amateur on
On May 27, 2:44 am, Ian Bush
<ianbush.throwaway.acco...(a)googlemail.com> wrote:
> Aha! An easy one!
>
> On 27 May, 03:55, bio_amateur <hoangtrongminht...(a)gmail.com> wrote:
>
> > My question is if I use an ALLOCATABLE array as the buffer
> > (unallocated). Should it be allocated before that
>
> Yes. MPI  won't allocate it for you. In fact it can't, the latest
> binding is only f90.
>
> > or the MPI routines
> > (RECV, BCAST...) will automatically allocate and fill the received
> > data to it.
>
> No.
>
> Ian

Thanks, Ian and Glen.
From: Craig Powers on
Ian Bush wrote:
> Aha! An easy one!
>
> On 27 May, 03:55, bio_amateur <hoangtrongminht...(a)gmail.com> wrote:
>> My question is if I use an ALLOCATABLE array as the buffer
>> (unallocated). Should it be allocated before that
>
> Yes. MPI won't allocate it for you. In fact it can't, the latest
> binding is only f90.

Notwithstanding that f90 didn't allow allocatable arguments, I don't
think it would even work in a bleeding edge fortran binding without
separate and differently-named routines for allocatable and
non-allocatable buffers. As I recall, generic interfaces can only
distinguish by TKR, so arguments differing only by the presence or
absence of the allocatable attribute would not be distinguishable.