program hello
implicit none
integer n,s
subroutine fcount(n,s)
s=0
do i=1,n
s=s+1./i
end do
end
call fcount(50,s1)
call fcount(100,s2)
call fcount(150,s3)
call fcount(200,s4)
s=s1+s2+s3+s4
print *, "s=", s
end program
program hello
implicit none
real :: ss,s(4)
call fcount(50,s(1))
call fcount(100,s(2))
call fcount(150,s(3))
call fcount(200,s(4))
ss=sum(s)
print *, "s=", ss
contains
subroutine fcount(n,s)
integer :: n , i
real :: s
s=0
do i=1,n
s=s+1./i
end do
end subroutine fcount
end program hello
program hello
implicit none
write(*,*) "s=", sum(fcount([50,100,150,200]))
contains
Elemental Real Function fcount(n) result( s )
integer , intent(IN) :: n
integer :: i
s=sum(1./[(i,i=1,n)])
End Function fcount
End program hello