Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Long strings in data statements

I'd like to initialize a long string in Fortran 77 in a DATA statement, like this:

      DATA Lipsum /
     *'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendi
     *sse tincidunt, velit id hendrerit bibendum, erat nisl dignissim ar
     *cu'/

but the internal policy of the program I'm contributing to does not like it as it prohibits lines with an odd number of quote marks.

I can "fool" the policy checker by using double quotes instead, or using ' as the continuation character (in the first and last line), but I'd like to know if there is some other way to have long strings in DATA statements, where the concatenation operator // does not seem to be allowed.

like image 787
Jellby Avatar asked Mar 17 '26 13:03

Jellby


1 Answers

one approach is to declare an array of short strings and equivalence to your long one:

character*63 cshort(3)/
     *'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspen',
     *'disse tincidunt, velit id hendrerit bibendum, erat nisl digniss',
     *'im arcu'/
character*180 clong
equivalence (cshort,clong)

For this to work you need to count the characters and be sure each line but the last has the exact length of the short string. Note 63 is the max string length that will fit in 72 columns along with the quotes and comma.

like image 119
agentp Avatar answered Mar 20 '26 22:03

agentp