! This file: http://ftp.aset.psu.edu/pub/ger/fortran/hdk/farray4.f90 ! ! Illustrates allocating an array in a subprogram and ! using it in the calling (main) program. ! Compiled and run using: Lahey LF95, Salford FTN95, Intel/Compaq CVF ! AIX XLF90. ! subroutine suball(x,n) integer n integer, dimension(:), pointer :: x n=10 allocate(x(1:n)) end subroutine suball program testmem integer :: n, i integer, dimension(:), pointer :: x interface subroutine suball(y,n) integer, dimension(:), pointer :: y integer :: n end subroutine end interface call suball(x, n) x = (/(i,i=1,n)/) print *,"X=",(x(i), i=1,n) deallocate (x) end program testmem