Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Line Continuation Command

webbj
Beginner
1,047 Views
I have been trying to write a very simple program that requires a continuation command. I know the program works as it comes straight out of a book and similar programs that are known to have compiled with continuation commands dont compile on my compiler. The compiler tells me that it sees the & symbol as a syntax command and expects to see an END OF STATEMENT COMMAND, , etc... Why is this not working and what do I need to do to make it work. The program looks as follows;

PROGRAM Probability
c
IMPLICIT NONE
REAL(8) :: AvgOccor,Prob
INTEGER :: NumProb,I,NumOccur
c
WRITE(*, '(1X,A)', ADVANCE = "NO") &
"How many probabilities do you wish to calculate: "
READ*, NumProb
c
WRITE(*,*) NumProb
c
STOP
END
0 Kudos
4 Replies
TimP
Honored Contributor III
1,047 Views
In your example, it looks as if you may be confusing fixed and free form source. If you want & continuation to work either way, you have to put & beyond col. 72 in the line to be continued, and repeat it in column 6 of the continuation line. No doubt Steve will repeat the recommendation to be certain you are using free form, which you get by default when you name your source file with .f90
0 Kudos
Steven_L_Intel1
Employee
1,047 Views
To fix your code:

1. Name the file with a .f90 file type
2. Replace the c in column 1 with a !

Then it will be valid free-form source.
0 Kudos
webbj
Beginner
1,047 Views
To fix your code:

1. Name the file with a .f90 file type
2. Replace the c in column 1 with a !

Then it will be valid free-form source.

So what is the difference between titling the file as a .f and a .f90 file?

0 Kudos
Steven_L_Intel1
Employee
1,047 Views
The compiler needs to know whether a source is fixed-form or free-form. The standard did not establish a convention for this, so compiler vendors generally settled on .f90 meaning free-form source and .f or .for meaning fixed-form source. Some compilers, not ours, recognize other variants such as .f95, but this is a mistake in my view. It is unfortunate that the use of .f90 implies to many people Fortran 90 in particular. It would have been better to pick something such as .ffr that did not relate to a particular revision of the standard, but back then, Fortran 90 was it.
0 Kudos
Reply