Question

apparently, a limit exists in the number of allowed continuation lines in Fortran compilers. I have a temporary pathological case (made for quick testing purposes) where I am required to initialize a huge array without opening files or do any trickery, just slap data in as literals. The array is quite large (360000 entries).

How can I set the limit of the compiler to unlimited, or what alternative strategy can I use to host this array initialization ?

Was it helpful?

Solution

I don't know about any compiler settings for unlimited continuation lines, but I would suggest these alternatives:

  • assign each value on a single line
  • put the values in a file and read it :)
  • call a C function to fill your fortran array

OTHER TIPS

You could assign them in batches using implicit DO loops, up to the continuation limit imposed by your compiler:

REAL :: xarray(360000)

DATA (xarray(i) i=1,100) /1.0, 2.0, 3.0, 4.0, 5.0, 6.0, &
    7.0, 8.0, &
...
    98.0, 99.0, 100.0 /

 DATA (xarray(i) i=101,200) /101.0, 102.0, 103.0, 104.0, 105.0, 106.0, &
    107.0, 108.0, &
...
    198.0, 199.0, 200.0 /

I've seen this in a lot of scientific Fortran code.

Write some code to create your source files with data from a text file. Split the assignments by row or something to help avoid create one huge statement to initialize the array in one fell swoop. Remember code that generates code can be quite flexible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top