Blame test/mpi/f90/ext/allocmemf90.f90
|
Packit Service |
c5cf8c |
! This file created from f77/ext/allocmemf.f with f77tof90
|
|
Packit Service |
c5cf8c |
! -*- Mode: Fortran; -*-
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! (C) 2004 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
! See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
program main
|
|
Packit Service |
c5cf8c |
use mpi
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! This program makes use of a common (but not universal; g77 doesn't
|
|
Packit Service |
c5cf8c |
! have it) extension: the "Cray" pointer. This allows MPI_Alloc_mem
|
|
Packit Service |
c5cf8c |
! to allocate memory and return it to Fortran, where it can be used.
|
|
Packit Service |
c5cf8c |
! As this is not standard Fortran, this test is not run by default.
|
|
Packit Service |
c5cf8c |
! To run it, build (with a suitable compiler) and run with
|
|
Packit Service |
c5cf8c |
! mpiexec -n 1 ./allocmemf
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
real a
|
|
Packit Service |
c5cf8c |
pointer (p,a(100,100))
|
|
Packit Service |
c5cf8c |
integer (kind=MPI_ADDRESS_KIND) asize
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
integer ierr, sizeofreal, errs
|
|
Packit Service |
c5cf8c |
integer i,j
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
errs = 0
|
|
Packit Service |
c5cf8c |
call mtest_init(ierr)
|
|
Packit Service |
c5cf8c |
call mpi_type_size( MPI_REAL, sizeofreal, ierr )
|
|
Packit Service |
c5cf8c |
! Make sure we pass in an integer of the correct type
|
|
Packit Service |
c5cf8c |
asize = sizeofreal * 100 * 100
|
|
Packit Service |
c5cf8c |
call mpi_alloc_mem( asize,MPI_INFO_NULL,p,ierr )
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
do i=1,100
|
|
Packit Service |
c5cf8c |
do j=1,100
|
|
Packit Service |
c5cf8c |
a(i,j) = -1
|
|
Packit Service |
c5cf8c |
enddo
|
|
Packit Service |
c5cf8c |
enddo
|
|
Packit Service |
c5cf8c |
a(3,5) = 10.0
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
call mpi_free_mem( a, ierr )
|
|
Packit Service |
c5cf8c |
call mtest_finalize(errs)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
end
|