Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29281 Discussions

Intel Fortran 11.1 not recognizing line continuation characters

schneb
Beginner
5,117 Views

I was given a bunch of Fortran code that compiles in windows using Wendy Fortran compiler and told to compile it for Linux.

Some of the files seem to compile just fine, but the Intel compiler seems to choke on some of the line continuations.

As a disclamer: I don't speak fortran so my understanding of what is going wrong could be off.

I use the following command to compile:

ifort -c -extend-source 132 -vms DRAW.FOR

The first errors Iget are:

DRAW.FOR(57): error #5078: Unrecognized token '&' skipped

1003 FORMAT(25H0OPTIONS NOW IN EFFECT...//5X,12HEXT,INT,TYPE 3I3/5X,&

-------------------------------------------------------------------------------------------------------------^

DRAW.FOR(57): error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: < ) ...

1003 FORMAT(25H0OPTIONS NOW IN EFFECT...//5X,12HEXT,INT,TYPE 3I3/5X,&

--------------------------------------------------------------------------------------------------------------^

DRAW.FOR(59): error #5276: Unbalanced parentheses

*X,NOEJ/5X,2L3,12L5/5X,'FRG BRD',/,5X,2L3)

-----------------------------------------------------------------^

DRAW.FOR(58): error #5082: Syntax error, found '&' when expecting one of: ;

& 68HHID,CENT,CART,PERS,SUBS,XSEC,EXPL,AXES,DOTS,LABL,MSKI,MSKD,IMP

------^



The lines of code that this correspond to are as follows (the columns may not line up properly in the pasted text, but they are correct in the code file):

1003 FORMAT(25H0OPTIONS NOW IN EFFECT...//5X,12HEXT,INT,TYPE 3I3/5X,&

& 68HHID,CENT,CART,PERS,SUBS,XSEC,EXPL,AXES,DOTS,LABL,MSKI,MSKD,IMP

*X,NOEJ/5X,2L3,12L5/5X,'FRG BRD',/,5X,2L3)


Is there a compiler flag that I'm missing to tell it to recognize the continuation characters? Any other suggestions as to how to make it work?

Thanks, Bryan

0 Kudos
13 Replies
mecej4
Honored Contributor III
5,117 Views
Most Fortran compilers accept file suffixes of .f and .for as signifying (F77 style) fixed format source input. The rules of fixed format source do not allow using the '&' character at end-of-line as signifying continuation. Instead, the continuation character must be in column-6, prior to the continuation text.

If you want, you can try to see if the file compiles using free-format rules, by using the compiler switch -free.

If that does not work, you have to fix your source code and ensure that it adheres to one of the two standard-specified source formats, rather than a mix of the two.
0 Kudos
TimP
Honored Contributor III
5,117 Views
& as a continuation mark at the end of the line is over-ridden by the options you have selected.

-free option in place of extend-source may work better. -free is implied default for .f90 source file names.

It's strange to use f90 source code format with syntax which was obsoleted in F77, so I'm concerned you may need luck and persistence, including checking documentation.
0 Kudos
schneb
Beginner
5,117 Views
OK, I've taken out the & and placed an * in column 6 on the next line to indicate continuation (as this seems to be the character chosen by whoever wrote the code). The compiler seemed to like this ok, but it doesn't like the * on the next line.

1003 FORMAT(25H0OPTIONS NOW IN EFFECT...//5X,12HEXT,INT,TYPE 3I3/5X,
* 68HHID,CENT,CART,PERS,SUBS,XSEC,EXPL,AXES,DOTS,LABL,MSKI,MSKD,IMP
*X,NOEJ/5X,2L3,12L5/5X,'FRG BRD',/,5X,2L3)

gives the errors:

DRAW.FOR(59): error #6186: This character is not valid in a format list.
*X,NOEJ/5X,2L3,12L5/5X,'FRG BRD',/,5X,2L3)
------^
DRAW.FOR(59): error #7421: A constant or general expression must appear in a format list in this context. [X,NOEJ/]
*X,NOEJ/5X,2L3,12L5/5X,'FRG BRD',/,5X,2L3)
------^
DRAW.FOR(59): error #6186: This character is not valid in a format list.
*X,NOEJ/5X,2L3,12L5/5X,'FRG BRD',/,5X,2L3)
------^

Does it not like the fact that the line was broken inside the 68H descriptor block?


0 Kudos
TimP
Honored Contributor III
5,117 Views
There is no way a 68H string could have been valid under any versions of Fortran standard. It's anybody's guess whether your old compiler expected the string to wrap to the next line when it reached column 73 (if you dropped the extended line length option), unless you know that it depended on extended source line length.
Also, there was no standard which strictly supported both f66 Hollerith and apostrophe quoted strings in the same format, although there aren't so many reasonable variations in intepreting that. If you intend to make this work reliably, you may have to clean it up to correspond with F77.
If you do have a separate item X in a format list, that was an extension used by some compilers as a synonym for 1X, which F90 compilers are obliged to have a means to flag as non-standard (a common means being to reject it).
0 Kudos
schneb
Beginner
5,117 Views
The code was compiled with the extend-source 132 option under the windows compiler.

I believe that the X in the line was supposed to be a part of the previous word before the end of the line was reached, makeingthe wordIMPX.

I get a similar error if I change the lines to:

1003 FORMAT(25H0OPTIONS NOW IN EFFECT...//5X,12HEXT,INT,TYPE 3I3/5X,
* 68HHID,CENT,CART,PERS,SUBS,XSEC,EXPL,AXES,DOTS,LABL,MSKI,MSKD,
*IMPX,NOEJ/5X,2L3,12L5/5X,'FRG BRD',/,5X,2L3)

results in the following:

DRAW.FOR(59): error #6186: This character is not valid in a format list.
*IMPX,NOEJ/5X,2L3,12L5/5X,'FRG BRD',/,5X,2L3)
------^
DRAW.FOR(59): error #7421: A constant or general expression must appear in a format list in this context. [IMPX,NOEJ/]
*IMPX,NOEJ/5X,2L3,12L5/5X,'FRG BRD',/,5X,2L3)
------^
DRAW.FOR(59): error #6186: This character is not valid in a format list.
*IMPX,NOEJ/5X,2L3,12L5/5X,'FRG BRD',/,5X,2L3)
------^
DRAW.FOR(59): error #6186: This character is not valid in a format list.
*IMPX,NOEJ/5X,2L3,12L5/5X,'FRG BRD',/,5X,2L3)
------^
0 Kudos
mecej4
Honored Contributor III
5,117 Views
Yes, Hollerith strings can cross line boundaries. However, if your source line with a to-be-continued Hollerith string ends before column 72, trailing blanks may be added to make up the shortfall. Therefore, the part 'MSKD,IMPX' could become 'MSKDbbb,IMPX', where 'b' stands for a blank, and the subsequent format specs get interpreted incorrectly.

See the compiler options -nopad-source and -pad-source. If -nopad-source is in effect, the presence of trailing blanks in your source lines can cause errors.

A better long-term solution is to use one of the many utilities available to convert the Hollerith strings to quote-delimited strings.
0 Kudos
jimdempseyatthecove
Honored Contributor III
5,117 Views
The problem here is your program is not written on punched cards. In fixed form, lines are truncated after column 72 and padded to column 72 when text continues on next line (column 6 of next line not blank, can be * but often is 1, 2, 3, 4, ..., in the event you dropped your card deck).

The following may or may not be formatted correctly

1 2 3 4 5 6 7

123456789012345678901234567890123456789012345678901234567890123456789012

1003 FORMAT(25H0OPTIONS NOW IN EFFECT...//5X,12HEXT,INT,TYPE 3I3/5X,

1 2 3 4 5 6 7

123456789012345678901234567890123456789012345678901234567890123456789012

* 68HHID,CENT,CART,PERS,SUBS,XSEC,EXPL,AXES,DOTS,LABL,MSKI,MSKD,

12345678901234567890123456789012345678901234567890123456789012

(1st 62 chars of 68)

*IMPX,NOEJ/5X,2L3,12L5/5X,'FRG BRD',/,5X,2L3)

345678^^^

(last 6) |-- OEJ is additional text


*** copy the above and paste into a text editor using fixed font (Courier)

Note, the OEJ follows the text of the 68Hconstant
0 Kudos
jimdempseyatthecove
Honored Contributor III
5,117 Views
Would it be too hard for the forum Styles dropdown to permit a selection of Fixed width font???

Jim
0 Kudos
Steven_L_Intel1
Employee
5,117 Views
Use the code insertion tool (yellow pencil) and select Fortran Fixed Form or even Plain Text.
0 Kudos
jimdempseyatthecove
Honored Contributor III
5,117 Views
Let's try

[fxfortran]        1         2         3         4         5         6         7
123456789012345678901234567890123456789012345678901234567890123456789012
1003 FORMAT(25H0OPTIONS NOW IN EFFECT...//5X,12HEXT,INT,TYPE 3I3/5X,
         1         2         3         4         5         6         7
123456789012345678901234567890123456789012345678901234567890123456789012
     * 68HHID,CENT,CART,PERS,SUBS,XSEC,EXPL,AXES,DOTS,LABL,MSKI,MSKD,
          12345678901234567890123456789012345678901234567890123456789012
          (1st 62 chars of 68)
     *IMPX,NOEJ/5X,2L3,12L5/5X,'FRG  BRD',/,5X,2L3)
      345678^^^
    (last 6) |-- OEJ is additional text
 
That works
The code I copied from the original poster had FORMAT comminng on on column 6.
I left that were it was, as well as the original lead-in spaces. These may or may not
be what was in the original souce
Thanks for the tip

Jim[/fxfortran]
0 Kudos
schneb
Beginner
5,117 Views
[fxfortran]         1         1         1         1         1         1         1
123456789012345678901234567890123456789012345678901234567890123456789012
 1003 FORMAT(25H0OPTIONS NOW IN EFFECT...//5X,12HEXT,INT,TYPE 3I3/5X,
     * 68HHID,CENT,CART,PERS,SUBS,XSEC,EXPL,AXES,DOTS,LABL,MSKI,MSKD,IMP
          12345678901234567890123456789012345678901234567890123456789012
     *X,NOEJ/5X,2L3,12L5/5X,'FRG  BRD',/,5X,2L3)
      345678
[/fxfortran]

Neat trick with the insert code tool. I didn't know about it either, which is why my FORMAT didn't line up in the right place. Above is the original code with everything lined up as it should be, and numbers thrown in to verify the correct columns.

My original problem still exists, the compiler doesn't like it when I break a line inside a Hollerith string and continue it on the next line.
0 Kudos
jimdempseyatthecove
Honored Contributor III
5,117 Views
The viewer is still bugger'd up
Don't see your column 1 or '1' got dropped from line 2

When I did a reply to this post, momentarily I could see the 1 on the 1234... line 2, (prior to doing the listing format change).

----

I suppose your current fix would be to change the 68H to 62H, then on the following line

* 6HX,NOEJ/5x,....

Jim Dempsey
0 Kudos
Steven_L_Intel1
Employee
5,117 Views
There are so many variables when someone pastes code as text into the forum - I can't be sure what the compiler is seeing. I've been unable to reproduce the problem with correctly formed source. Please attach a file (see instructions in my signature below) that causes a problem and I'll be glad to look at it.

An important point to remember is that the standard assumes all fixed-form source lines are exactly 72 characters long. What compilers do with shorter lines is implementation-dependent. By default, Intel Fortran stops at the end of the source line, but if you add the -pad-source option, lines are padded to 72 (or 80 or 132 if you've extended the source line length.) For continued lines, the statement picks up in column 7 or after the continuation indicator in tab source form.
0 Kudos
Reply