开发者

insane number of continuation lines in fortran (ifort)

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 开发者_StackOverflow社区I set the limit of the compiler to unlimited, or what alternative strategy can I use to host this array initialization ?


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜