Skip to content

Instantly share code, notes, and snippets.

@certik
Created September 9, 2011 06:32
Show Gist options
  • Select an option

  • Save certik/1205621 to your computer and use it in GitHub Desktop.

Select an option

Save certik/1205621 to your computer and use it in GitHub Desktop.
program array
implicit none
integer, allocatable :: a(:)
call bill2(100000000, a);
print *, bill(a)
contains
subroutine bill2(n, a)
integer, intent(in) :: n
integer, intent(out), allocatable :: a(:)
integer :: i
allocate(a(n))
do i = 1, size(a)
a(i) = i - 1
end do
end subroutine
integer(8) function bill(a) result(s)
integer, intent(in) :: a(:)
integer :: i
s = 0
do i = 1, size(a)
s = s + a(i)
end do
end function
end program
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment