I have a large array of integer parameters (6024 triplets, for a total of ~9000 elements in a 3x6024 array) to place in a module as data for other functions. The parameter is defined:
Integer, Parameter :: nj = 6024
Integer, Parameter :: abc(1:3,1:nj) = &
& RESHAPE( (/ a1 , b1 , c1, & !j = 1
& a2 , b2 , c2, & !j = 2
!... like 6000 more lines ...
& aj , bj , cj /), & !j = nj
& SHAPE=(/3,nj/),ORDER=(/2,1/) )
Where aj
,bj
, and cj
are arbitrary integer constants.
I prefer this formatting (using continuation lines to keep the triplets together) for readability, but for a long array it introduces too many continuation lines to be in compliance with standard Fortran (Fortran 2003 and newer allow up to 255 continuation lines). These parameters are not predictably distributed, so an implied loop for definition is not an option.
I could put more triplets on a line, but 4-byte integers take up 12 characters each (10 digits, sign, comma), with the continuation &
that leaves room for 10 integers on a standard-compliant free-form line (132 characters). In 255 continuation lines, this establishes a practical limit of ~2550 elements (of this type) that can be listed for the array parameter definition.
Is there a way to do this parameter definition in Fortran 2008 standard-compliant code? Can a parameter array be defined in segments? e.g.
Integer, Parameter :: nj = 6024
Integer, Parameter :: abc(1:3,1:nj)
Integer, Parameter :: abc(:,1) = (/ a1 , b1 , c1 /) !j = 1
Integer, Parameter :: abc(:,2) = (/ a2 , b2 , c2 /) !j = 2
!... like 6000 more lines ...
Integer, Parameter :: abc(:,nj) = (/ aj , bj , cj /) !j = nj