“Hello, world!”
Here is the “Hello, world!” example of Fortran.
program main
implicit none
print *, 'Hello, World!'
end program main
-
Every Fortran program executes from
program `name`toend program `name`, where`name`is the name of the Fortran program. “Names” (such as variable names, procedure names and module names) in Fortran must be formed by letters, digits and underscore, and must start with a letter (which means__main__is not a valid “name”). -
implicit nonebans the confusing “I-N implicit declaration rule” of Fortran. It is a good habit to addimplicit nonein every Fortran program, even if nothing is declared in the program. -
printmakes an output to “file with unit *”, which is usually the screen.*,means that the output is in “format *”, which will be automatically determined by the processor with some restrictions of Fortran standard.