Reputation: 31
xic = ac * x**2.D0 * ( (1.D0 / 3.D0) * (1.D0 - x) *
(1.D0 + 10.D0 * x + x** 2.D0) + 2.D0 * x *
(1.D0 - x) * Log(x) )
I was compiling the above code with fortran and got one error
Expected a right parenthesis in expression at (1)
what should i do?
Upvotes: 3
Views: 16050
Reputation: 18118
You are missing line continuation characters. They differ slightly for free and fixed form Fortran. For free form, you need to use &
at the end of the line:
xic = ac * x**2.D0 * ( (1.D0 / 3.D0) * (1.D0 - x) * &
(1.D0 + 10.D0 * x + x** 2.D0) &
+ 2.D0 * x * (1.D0 - x) * Log(x) )
For fixed-format this can be done by e.g. &
at the sixth column of the following line:
xic = ac * x**2.D0 * ( (1.D0 / 3.D0) * (1.D0 - x) *
& (1.D0 + 10.D0 * x + x** 2.D0)
& + 2.D0 * x * (1.D0 - x) * Log(x) )
Alternatively, you can extend the maximum allowed characters by using (gfortran
) -ffree-line-length-0
or -ffixed-line-length-0
.
Upvotes: 7
Reputation: 1490
Check the following methods to cut a long line in Fortran : http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/chap01/continue.html
Upvotes: 2