I can't give you a complete answer, but I think this is less an MPI
question and more of a Fortran question. The question is if you have a
Fortran derived type, one of whose components is a POINTER, what does
the data structure look like in linear memory? I could imagine the
answer is implementation dependent. Anyhow, here is a sample, non-MPI,
Fortran program that illustrates the question: % cat b.f90 type :: small integer, pointer :: array(:) end type small type(small) :: lala integer, pointer :: array(:) n = 20 allocate( lala%array(n) ) allocate( array(n) ) lala%array = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 /) array = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 /) call sub(lala) call sub(lala%array) call sub( array) end subroutine sub(x) integer x(20) write(6,*) x end % f90 b.f90 % a.out 599376 20 4 599372 1 20 -4197508 1 2561 0 33 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 % So, your model of 20 consecutive words does not work if you pass the derived type. It does work if you pass the POINTER component. This is with Oracle (Sun) Studio Fortran. Again, I can imagine the behavior depends on the Fortran compiler. I suspect what's going on is that a POINTER is a complicated data structure that has all sorts of metadata in it, but if you pass a POINTER the compiler knows to pass the thing you're pointing to rather than the metadata itself. Jeremy Roberts wrote: I'm trying to parallelize a Fortran code with rather complicated derived types full of pointer arrays. When I build the MPI type for sending, all the static components are sent, but the pointer arrays are not (and retain initial values). I imagine this has to do with memory addresses when creating the MPI struct, but I have no idea how to fix it. |
- [OMPI users] Fortran MPI Struct with Allocatable Array Jeremy Roberts
- Re: [OMPI users] Fortran MPI Struct with Allocatable A... Eugene Loh