Fortran Fixed Form Line Continuation

1.7k Views Asked by At

I'm always using free form .f90 to write Fortran code, but now I have to use some fixed form .f code. As far as I know, a line continuation in the fixed format can be achieved by putting an arbitrary nonblank, nonzero symbol in column 6. So this first block should work

      x =
     &    1

and this second block would fail

      x = &
     &    1

I have the above conclusion proved by a simple demo code, both compiling with a Makefile and comping with Cmake. If using the first way, everything is good; if the second, compiler will report an error saying it can't understand the "&" after the equal sign.

Now what makes me puzzled is that I have a huge Fortran code in fixed form(.f) by someone else. What's used in this huge code for line continuation is like the second way(which seems not working to me). But the Makefile of that code managed to overcome this issue somehow. That code and Makefile is so large and complicated that I can't manage.

So my question is: How can I let the compiler go through the second way? What magic did the huge Fortran code do? Thanks for any hints.

Update:

I tried to use -ffree-form as suggested, but still get the same error. Here is the demo .f file and Makefile.

main.f

      PROGRAM main


      IMPLICIT NONE
        REAL        ::  x
        REAL        ::  y

        x =  &
     &      1
        WRITE(*,*) x

      END PROGRAM main

Makefile:

FC = gfortran
FCFLAGS = -ffree-form

SRCS = main.f
SOBJ = $(SRCS:.f=.o)
EXEC = $(SRCS:.f=)

all: $(EXEC)

%.o: %.f
    $(FC) $(FCFLAGS) -c $<
0

There are 0 best solutions below