for better or worse, a single data statement does not need used to declare the values. You can use multiple data statements to fill portions.
The standard does require you not specify a value more than once, although extensions often allow this, I would strongly recommend following the rules as it is not portable and also requires the data to be filled in a particular order, and nothing in the standard says the data statements have to be used in the order declared.
The fact data statements are not required to fill their target can be considered a feature or a flaw. It is possible to accidently only partially fill the target when intending to fill it; leaving uninitialized values, but data statements are very versatile. You can easily fill in row-column order, use repeat modifiers, and so on.
program stuff
integer,parameter :: rp=kind(1.0d0)
integer,parameter :: n=3, m=8
character(len=*),parameter :: dt='(2(g0))'
type item
character(len=20) :: desc
real(kind=rp) :: value
end type item
! if values are easily computed this syntax might work
type(item) :: db2(m)=[(item('item1',i*1.0_rp),i=1,m)]
type(item) :: db(m)
! use multiple data statements
data(db(i), i = 1, n)/&
item('item1', 1.0_rp), &
item('item1', 2.0_rp), &
item('item1', 3.0_rp)/
data(db(i), i = n+1, m)/&
item('item1', 4.0_rp), &
item('item1', 5.0_rp), &
item('item1', 6.0_rp), &
item('item1', 7.0_rp), &
item('item1', 8.0_rp)/
write(*,dt)db
write(*,dt)
write(*,dt)db2
end program stuff
item1 1.0000000000000000
item1 2.0000000000000000
item1 3.0000000000000000
item1 4.0000000000000000
item1 5.0000000000000000
item1 6.0000000000000000
item1 7.0000000000000000
item1 8.0000000000000000
item1 1.0000000000000000
item1 2.0000000000000000
item1 3.0000000000000000
item1 4.0000000000000000
item1 5.0000000000000000
item1 6.0000000000000000
item1 7.0000000000000000
item1 8.0000000000000000
and in anyone that supports f2003 …
Fortran 2023 contains several extensions to Fortran 2018; these are listed below.
• Source form:
The maximum length of a line in free form source has been increased. The maximum length of a statement
has been increased. The limit on the number of continuation lines has been removed.
So you can make the lines really long and put a lot more values on a line, and the limit on the number of continuation lines should be gone; although I think the number of characters in the line would cause a limit to be imposed at some point anyway.
But if the data can be declared by an expression in an implied loop a declaration like used for DB2 above can be very compact, and if the data repeats a repeat count in a DATA statement is even more succinct, and for constants array syntax (ie. R=0 where R is any size array works) is particularly simple.