Intel Visual Fortran 11.1
Version of implementation Intel Visual Fortran of programming language FortranVersion of Intel Visual Fortran.
Examples:
Hello, World! - Fortran (109):
program HelloWorld
print *, 'Hello, World!'
end program HelloWorld
Factorial - Fortran (110):
This example uses iterative factorial definition. Format specifiers I and A are used for printing integers and strings, respectively. Trying to calculate 13! produces an arithmetic overflow error, so last lines of program output look like this:
13! = 1932053504
14! = 1278945280
15! = 2004310016
16! = 2004189184
program Factorial
integer :: f,n
f = 1
n = 0
do
print '(I2, A, I10)', n, "! = ", f
n = n + 1
f = f * n
if (n==17) then
exit
end if
end do
end program Factorial
Fibonacci numbers - Fortran (113):
This example uses iterative definition of Fibonacci numbers. The tricky part is printing the calculated values in one line, without leading or trailing spaces. Format specifier (I3, A, $)
means that first an integer is printed using exactly 3 positions, followed by a string. The final $ suppresses trailing carriage return, used by default, so that everything is printed in one line.
program Fibonacci
integer :: f1,f2,f3,i
i = 1
f1 = 0
f2 = 1
do
f3 = f2 + f1
f1 = f2
f2 = f3
i = i + 1
if (f1<10) then
print '(I1, A, $)', f1, ', '
elseif (f1<100) then
print '(I2, A, $)', f1, ', '
else
print '(I3, A, $)', f1, ', '
end if
if (i==17) then
exit
end if
end do
print *, '...'
end program Fibonacci
Comments
]]>blog comments powered by Disqus
]]>