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.