1+3
(2+3)*3
integer :: i
integer :: j
i = 5
j = 6
i
(i+j)*3
You can declare a function and use it in expressions:
integer function fn(a, b)
integer, intent(in) :: a, b
fn = a + b
end function
fn(2, 3)
fn(2, 3)*3
You can redeclare a function and it will shadow the old fn
function. Now fn(2, 3)
returns a different value:
integer function fn(a, b)
integer, intent(in) :: a, b
fn = a - b
end function
fn(2, 3)
You can use loops, if statements or the print
function.
integer :: i
do i = 1, 4
if (i == 3) cycle
print *, "variable i =", i
end do
You can do plotting using Matplotlib underneath:
integer :: i, tmp
do i = 1, 4
tmp = plot(1, i+1, 1)
end do
show()
integer :: i, j, n
n = 5
j = 0
Show Abstract Syntax Tree (AST) after parsing (based on syntax only, no semantics):
%%showast
do i = 1, n
j = j + i
end do
Show LLVM code:
%%showllvm
do i = 1, n
j = j + i
end do
Show assembly code:
%%showasm
do i = 1, n
j = j + i
end do
Load and show an image file:
integer :: i, tmp
do i = 1, 4
tmp = plot(2, 1, i)
end do
savefig(1)
%showimage output1.png
List the current directory:
%ls