HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to FortranVariablesOperatorsConditions (if)Loops (do)ArraysFunctions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables
🔢 Numbers & Math
🔁 Condition & Loop
📋 Array
🧩 Functions & Subroutines
Fortran›Introduction to Fortran

Introduction to Fortran

First step into Fortran, the ancestor of scientific computing: program structure and printing with print.

Simple enough for a 5-year-old to understand

Structure of a Fortran program

Every program starts with "program name" and ends with "end program name". print *, is used to print to the screen.

Your first program
1
program hello
Program entry point.
DefinitionProgram entry point.
2
print *, "Hello!"
Prints to the screen (adds a leading space).
Output / InputPrints to the screen (adds a leading space).
3
end program hello
End of program.
DefinitionEnd of program.
DefinitionOutput / Input
💡 Hint: print * is fast but adds a space at the beginning of the output; write(*,'(A)') is used for full control.

🎯 Exercise & Practice

Test what you've learned — answer, write code, check instantly. (1 left)

1.Print exactly Hello World to the screen.

🎯 Expected output: Hello World

Loading editor…

About this topic

Fortran was born at IBM in 1957 and is the oldest high-level programming language still in use. Its name is an abbreviation of the English phrase meaning "formula translator"; its purpose was to allow engineers to write mathematical formulas directly.

The language has undergone several major revisions since then. The 1990 release introduced free-form writing, modules, and dynamic arrays; subsequent releases added object-oriented features and parallel computing support. Today, saying "Fortran" refers to the modern versions.

Fortran remains unmatched in numerical computation. A significant portion of weather forecasting models, fluid dynamics, structural analysis, and climate simulations are written in Fortran; compilers optimize array operations with decades of accumulated expertise.

What you will learn

  • Program structure
  • The difference between free and fixed format
  • Printing to the screen
  • The importance of the implicit none directive
  • Compilation and execution steps

Who is this for?

  • Engineers who do numerical computation
  • Those maintaining scientific code
  • Those entering high-performance computing

When to use?

In scientific software that requires intensive numerical calculation, large array operations, and matrix calculations, Fortran is still one of the fastest and most mature options.

It is not preferred for general-purpose application, web, or interface development; the language and ecosystem are not designed for these areas.

Common mistakes

Wrong

program merhaba
  print *, 'Hello'
end

Program termination is not missing but ambiguous; in modern Fortran, the end line is expected to repeat the program keyword and name. This format makes it readable which block is closing in large sources and catches compiler mismatches.

Correct

program merhaba
  print *, 'Hello'
end program merhaba

Wrong

program merhaba
  print *, "Hello"
  x = 5
  print *, x
end program merhaba

Variable is not declared but the code compiles: Fortran's implicit typing rule treats names starting with letters between i and n as integers and others as real numbers. This causes typos to silently create new variables and is the language's most dangerous legacy.

Correct

program merhaba
  implicit none
  integer :: x
  print *, "Hello"
  x = 5
  print *, x
end program merhaba

Wrong

program merhaba
  implicit none
  print *, 'Since this line is too long, in the old fixed format everything after the seventy-second column is truncated and silently lost by the compiler'
end program merhaba

If the file extension indicates fixed format, there is a line limit and the overflowing part is discarded. For modern free format, the file extension must be ninety and later; otherwise, you compile wrong code without getting an error.

Correct

! file name: should be merhaba.f90
program merhaba
  implicit none
  print *, 'Long lines are not a problem in free format, &
            &they can be split with a continuation sign'
end program merhaba

Frequently asked questions

What is the difference between free format and fixed format?

Fixed format is a punch card legacy: the first six columns carry special meaning and lines are truncated at seventy-two characters. Free format removes these constraints. Files with an extension of ninety and later are accepted as free format.

Is Fortran case-sensitive?

No. Keywords and variable names are independent of letter case. Older code was written entirely in uppercase; lowercase is preferred in modern code and improves readability.

Which compiler should I use?

A free and common option is the Fortran compiler in the GNU compiler family. Commercial options produce faster code on some hardware. For learning, a free compiler is more than enough.

Summary

Fortran is still strong in numerical computing.

Modern code is written in free format.

implicit none must be used in every program.

Implicit typing leads to silent bugs.

The language is not case-sensitive.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code