Hi,
I have a F77 code in which there is a DATA statement like this
DATA TOP/'FRAME ANALYSIS','PLANE STRAIN ANALYSIS','BUCKLING ANALYSIS',
'SHELL ANALYSIS'/
and in the code it is used as
TOP(i)
I think it is good data structure - array of strings. But what could be a modern alternative ? I think “DATA” blocks should be avoided so how do I replace this ?
@Ashok , as shown by the other posts here, the “modern alternative” is clearly named constants and letting the compiler do as much as possible for setting up the constant(s), including the size of the array i.e., use the implied-shape facility from Fortran 2018 revision.
In the case of arrays of named constants, one may see a value in type-declaration within the array constructor on the right, especially with arrays of string literals (CHARACTER type) that can obviate the need to individually pad each array element, see below: