Hi,
section 4.11
http://www.mpi-forum.org/docs/mpi-20-html/node54.htm
describes how memory allocation can be done in a Fortran program:
REAL A
POINTER (P, A(100,100)) ! no memory is allocated
CALL MPI_ALLOC_MEM(4*100*100, MPI_INFO_NULL, P, IERR)
! memory is allocated
...
A(3,5) = 2.71;
...
CALL MPI_FREE_MEM(A, IERR) ! memory is freed
However, this uses non-standard Cray pointers. I am wondering how this
can be coded using the standard iso_c_binding module - I do not have
much experience using that module, but apparently it provides C
pointers:
use, intrinsic :: iso_c_binding, only: c_float, c_ptr, c_f_pointer
real (c_float), pointer :: a(:,:)
type (c_ptr) :: p
call MPI_Alloc_mem(4*100*100, MPI_INFO_NULL, p, ierr)
call c_f_pointer(p, a, (/100, 100/))
...
a(3,5) = 2.71
...
call MPI_Free_mem(a, ierr)
Is that going to work? Or is there a different way of recoding the
example?
Thanks in advance!
Cheers,
Martin
--
Martin Siegert
Head, Research Computing
WestGrid/ComputeCanada Site Lead
IT Services phone: 778 782-4691
Simon Fraser University fax: 778 782-4242
Burnaby, British Columbia email: siegert_at_[hidden]
Canada V5A 1S6
|