A Fortran program sits between program name and end program name. Modern code is free-form source in .f90 files: no fixed columns.
Fortran · Lesson 1 · On the house
Hello Fortran
program blocks, print *, comments with !, and compiling with gfortran. Lesson 1 is free — on the house.
Lessons · Fortran · Lesson 1 of 10 · On the house
Hello Fortran
program blocks, print *, comments with !, and compiling with gfortran.

print *, 'hello' writes a line using list-directed format, where * means 'let the compiler choose the layout'. Strings use single or double quotes.
Comments start with ! and run to the end of the line. Fortran is case-insensitive: PRINT and print are the same.
Compile and run with gfortran hello.f90 -o hello && ./hello. Add -Wall -std=f2018 to catch mistakes early.
Long statements continue onto the next line with a trailing &.
hello
! hello.f90
program hello
implicit none
print *, 'hello'
print *, 'two plus three is', &
2 + 3
end program hello
Quiz
Quiz
Quiz
Quiz
Check
Match the still for: Hello Fortran.
Open-book: the answers are on this page. Pass every quiz and check (5) to mark the lesson done. This visit: 0/5.