Created
September 9, 2011 06:32
-
-
Save certik/1205621 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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