integer :: i integer, parameter :: n = 20 integer, dimension(n) :: index = [(i, i = 1, n, 1)] ! list comp
The list comprehension in Fortran can even be nested (because it is essentially a do-loop), according to this Rosetta Code example: https://rosettacode.org/wiki/List_comprehensions#Fortran
The list comprehension in Fortran can even be nested (because it is essentially a do-loop), according to this Rosetta Code example: https://rosettacode.org/wiki/List_comprehensions#Fortran