In [7]:
program hello
implicit none
print*, "Hello, World!"
end program
The following, not so much:
In [8]:
subroutine foo
print*, "Hello, World"
end subroutine
You can use functions:
In [25]:
program maths
implicit none
integer :: x
x = 7
write(*, '(a,i4)') "x =", x
write(*, '(a,i4)') "x^2 =", square(x)
contains
integer function square(number)
integer, intent(in) :: number
square = number * number
end function
end program
You can even use modules! They just have to be in the same cell as the program...
In [26]:
module funcs
implicit none
contains
integer function square(number)
integer, intent(in) :: number
square = number * number
end function
end module funcs
program maths
use funcs
implicit none
integer :: x
x = 7
write(*, '(a,i4)') "x =", x
write(*, '(a,i4)') "x^2 =", square(x)
end program
In [ ]: