1

I'm trying to compile some old fortran77 programs with gfortran and getting error with allocatable arrays. If I define arrays in f90-style, like:

REAL*8,allocatable::somearray(:)

everything is fine, but in those old programs arrays defined as:

REAL*8  somearray[ALLOCATABLE](:)

which cause gfortran error output:

REAL*8,allocatable::somearray[ALLOCATABLE](:)                        
                             1
Fatal Error: Coarrays disabled at (1), use -fcoarray= to enable

I really wish to avoid rewriting whole programs to f90 style, so, could you please tell me, is there any way to force gfortran to compile it? Thanks a lot.

Fortranner
  • 2,525
  • 2
  • 22
  • 25
  • 4
    Allocatable arrays are a Fortran 90 feature. The syntax in the code you show that causes the error is neither Fortran 77 or Fortran 90. – IanH Apr 16 '14 at 07:42
  • 2
    This is completely non-standard, I would not even call that Fortran. – Vladimir F Героям слава Apr 16 '14 at 07:45
  • gfortran thinks that [] indicates co-arrays, which is f90 or f95 feature. But I don't use co-arrays at all. Is there any way to force gfortran use only f77 syntax? All these programs are using f77 standard and were compiled with unknown compiler. They are all using array definition like I described above. –  Apr 16 '14 at 07:52
  • Yes, search and replace will help, but I really wish to avoid modifying those programs because they still uses on Windows machines with that noname compiler which accepts such strange standard of arrays definition. –  Apr 16 '14 at 08:05
  • 2
    This is NOT Fortran 77. This is not standard Fortran at all! – Vladimir F Героям слава Apr 16 '14 at 08:15
  • which compiler? He-Who-Must-Not-Be-Named? – Peter Petrik Apr 16 '14 at 08:20

3 Answers3

0

For standard checking you can use -std flag

-std=std Specify the standard to which the program is expected to conform, which may be one of f95',f2003', f2008',gnu', or `legacy'.

To "force" gfortran to compile your code, you have to use syntax it recognizes

Peter Petrik
  • 9,701
  • 5
  • 41
  • 65
0

I'd probably go for search and replace. For example,

  sed 's/\(REAL\*8\)[[:blank:]]\+\([^[]\+\)\[ALLOCATABLE\]\(.*\)/\1, allocatable :: \2\3/' <old.source> > <new.source>

where sed is available.

Of course, be careful with sed :).

In any case, as it seems your code was written in some non-standard version of old Fortran, you'll probably need to make changes in any case.

Mali Remorker
  • 1,206
  • 11
  • 20
0

For what it's worth the Intel Fortran compiler (v13.something) compiles the following micro-program without complaint. This executes and writes 10 to the terminal:

  REAL*8  somearray[ALLOCATABLE](:)
  allocate(somearray(10))
  print *, size(somearray)
  end

Given the history of the Intel compiler I suspect that the strange declaration is an extension provided by DEC Fortran, possibly an early implementation of what was later standardised in Fortran 90.

High Performance Mark
  • 77,191
  • 7
  • 105
  • 161
  • Yes, I think that it might be Intel Fortran compiler. Problem was that gfortran doesn't understand its syntax without -std=f95 –  Apr 16 '14 at 08:59