blob: 8f975c302b4aeb6f5c1187ef7e5049f98fee2aef [file] [log] [blame]
program functioncalling
implicit none
intrinsic flush
print *, 'This is the Fortran program; I am going to call some functions now...'
call sum(1.0,2.0,3.0)
call factorial(3)
print *, 'Done'
call flush; stop
contains
subroutine sum(x,y,z)
implicit none
real :: x
real :: y
real :: z
!x = x+y+z ! gfortran 4.4.0 on Mac OS X 10.5.7 gives "Bus error"
print *, x
end subroutine sum
subroutine factorial(j)
implicit none
integer :: i
integer :: j
real :: p
p=1
i=1
do i=1,j
p=p*i
end do
print *, j, "! = ", p
end subroutine factorial
subroutine sum2(x,y)
implicit none
real :: p
integer :: x, y
p = x+y
end subroutine sum2
end