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
Array
🧩 Functions & Subroutines
Fortran›REFERENCE›Array
📋

Array

Arrays (1-indexed) and whole-array operations.

CommandDescription
ArrayFixed-size, 1-indexed array.

Array

Try it yourself →

Fixed-size, 1-indexed array.

Syntax

integer :: a(n)

Description

Fortran arrays are 1-indexed BY DEFAULT! Assigned with a = [1,2,3]. Whole arrays can be processed in a single step.

Example

program h
  integer :: a(3)
  a = [5, 10, 15]
  print *, a(2)
  print *, sum(a)
end program h

Expected output

10
30

When to use?

Numerical data, matrix calculations.

Common mistakes

  • ⚠️ The first element is a(1) (not 0). Fortran counts from 1 due to scientific tradition.
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