Problem compiling FORTRAN code

In summary: If the code was ever written on punch cards, the 1 would have been in column 1, but it is not part of the code.
  • #1
FatLynn
1
0
Hello, I received some very old cold, and I don't even know for which FORTRAN standard it was originally written, only that it has existed since at least 1993. I'm trying to compile it in gfortran, and I get the following error:

'Error: Expected a right parenthesis in expression at (1)'
1 / 1H( ,1H1 ,1HX ,1H, ,1H ,1H ,1HA ,1H ,1H ,1H) /
1

The code is shown below, and the line indicated in the error message is the fourth line of the code shown here. Anyone know why I am getting this issue?

INTEGER F(10),G(14),LUN(5)
DIMENSION MESSG(NMESSG)
DATA F(1),F(2),F(3),F(4),F(5),F(6),F(7),F(8),F(9),F(10)
1 / 1H( ,1H1 ,1HX ,1H, ,1H ,1H ,1HA ,1H ,1H ,1H) /
DATA G(1),G(2),G(3),G(4),G(5),G(6),G(7),G(8),G(9),G(10)
1 / 1H( ,1H1 ,1HX ,1H ,1H ,1H ,1H ,1H ,1H ,1H /
DATA G(11),G(12),G(13),G(14)
1 / 1H ,1H ,1H ,1H) /
DATA LA/1HA/,LCOM/1H,/,LBLANK/1H /
C PREPARE FORMAT FOR WHOLE LINES
C***FIRST EXECUTABLE STATEMENT XERPRT
NCHAR = I1MACH(6)
NFIELD = 72/NCHAR
CALL S88FMT(2,NFIELD,F(5))
CALL S88FMT(2,NCHAR,F(8))
C PREPARE FORMAT FOR LAST, PARTIAL LINE, IF NEEDED
NCHARL = NFIELD*NCHAR
NLINES = NMESSG/NCHARL
NWORD = NLINES*NFIELD
NCHREM = NMESSG - NLINES*NCHARL
IF (NCHREM.LE.0) GO TO 40
DO 10 I=4,13
10 G(I) = LBLANK
NFIELD = NCHREM/NCHAR
IF (NFIELD.LE.0) GO TO 20
C PREPARE WHOLE WORD FIELDS
G(4) = LCOM
CALL S88FMT(2,NFIELD,G(5))
G(7) = LA
CALL S88FMT(2,NCHAR,G(8))
20 CONTINUE
NCHLST = MOD(NCHREM,NCHAR)
IF (NCHLST.LE.0) GO TO 30
C PREPARE PARTIAL WORD FIELD
G(10) = LCOM
G(11) = LA
CALL S88FMT(2,NCHLST,G(12))
30 CONTINUE
40 CONTINUE
C PRINT THE MESSAGE
NWORD1 = NWORD+1
NWORD2 = (NMESSG+NCHAR-1)/NCHAR
CALL XGETUA(LUN,NUNIT)
DO 50 KUNIT = 1,NUNIT
IUNIT = LUN(KUNIT)
IF (IUNIT.EQ.0) IUNIT = I1MACH(4)
IF (NWORD.GT.0) WRITE (IUNIT,F) (MESSG(I),I=1,NWORD)
IF (NCHREM.GT.0) WRITE (IUNIT,G) (MESSG(I),I=NWORD1,NWORD2)
50 CONTINUE
RETURN
END
 
Technology news on Phys.org
  • #2
I don't know Fortran, but from a general knowledge of programming, this seems to be a syntax error:
FatLynn said:
1H( ,1H1 ,1HX
You must have something after the opening bracket and before the first comma.
 
  • #3
I believe that for some old FORTRAN compilers that is not a syntax error.

What you are seeing is called a Hollerith Constant, described here
which consist of a positive integer constant followed by H followed by
the integer constant number of characters, so 1H( is a one byte constant
containing the character (
and that would be followed by the character 1 followed by the character X

Documentation describing GNU FORTRAN support for Hollerith Constants
described here
 
Last edited:
  • Like
Likes FactChecker
  • #4
What happened to the indentation?

Columns 1-5 are for statement number
C in column 1 makes the rest of the line a comment.
Non blank in column 6 means a continuation of the previous line.
Columns 7-71 are for the FORTRAN
Columns 72-80 are for the sequence number.

FatLynn said:
1 / 1H( ,1H1 ,1HX ,1H, ,1H ,1H ,1HA ,1H ,1H ,1H) /

I suspect that leading 1 is not part of the code, it should have been in column 6 to signal that line is a continuation of the previous line.I suspect that leading 1 was meant to be in column 6. It is not part of the code but a signal that the line is a continuation of the previous line.

If someone threw away the leading blanks on all lines they F*ed up the code.
 
  • Like
  • Informative
Likes FactChecker, Klystron and jedishrfu
  • #5
Yes I think @anorlunda nailed it. The program was probably written on punch cards and later saved as a file. Whoever did it, didnt realize the need to keep the columnar format of fortran.
 
  • #6
Also, using a modern or semi-modern compiler, best to explicitly indicate Hollerith characters.
 
  • #7
anorlunda said:
What happened to the indentation?

Bingo. The 1 is almost certainly a continuation character, and used to be in column 6.
 
  • Like
Likes jedishrfu

1. What does "problem compiling FORTRAN code" mean?

Compiling code refers to the process of converting human-readable code into machine-executable instructions. A "problem compiling FORTRAN code" means there were errors or issues encountered during this process.

2. Why does FORTRAN code sometimes have compiling problems?

FORTRAN is a complex programming language with strict syntax rules. Any small error in the code, such as a missing semicolon or incorrect variable declaration, can result in compilation problems.

3. How can I fix a compilation problem in FORTRAN code?

The first step is to carefully review the error messages and identify the specific lines of code where the problem is occurring. Then, refer to the FORTRAN language documentation to understand the correct syntax and make necessary corrections to the code.

4. Are there any tools that can help with debugging FORTRAN compilation problems?

Yes, there are several debugging tools available for FORTRAN code, such as the GNU Debugger and Intel Inspector. These tools can help identify and fix common compilation issues.

5. Can compatibility issues cause problems when compiling FORTRAN code?

Yes, compatibility issues can arise when trying to compile FORTRAN code written for older versions of the language. It is important to ensure that the code is written for the version of FORTRAN being used and to make necessary updates for compatibility.

Similar threads

  • Programming and Computer Science
Replies
14
Views
1K
  • Programming and Computer Science
Replies
22
Views
6K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
1
Views
943
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
22
Views
4K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
16
Views
2K
  • Programming and Computer Science
Replies
6
Views
1K
Back
Top