MALLOC (The GNU Fortran Compiler) (original) (raw)

The following example demonstrates the use of MALLOC andFREE with Cray pointers.

program test_malloc implicit none integer i real8 x(), z pointer(ptr_x,x)

ptr_x = malloc(20*8) do i = 1, 20 x(i) = sqrt(1.0d0 / i) end do z = 0 do i = 1, 20 z = z + x(i) print *, z end do call free(ptr_x) end program test_malloc