Problem compiling FORTRAN code

  • Thread starter FatLynn
  • Start date
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
 

Wrichik Basu

Insights Author
Gold Member
2018 Award
1,130
971
I don't know Fortran, but from a general knowledge of programming, this seems to be a syntax error:
1H( ,1H1 ,1HX
You must have something after the opening bracket and before the first comma.
 
1,067
28
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:

anorlunda

Mentor
Insights Author
Gold Member
7,501
4,239
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.

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.
 
10,931
4,442
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.
 

Klystron

Gold Member
490
543
Also, using a modern or semi-modern compiler, best to explicitly indicate Hollerith characters.
 

Vanadium 50

Staff Emeritus
Science Advisor
Education Advisor
23,211
5,537

Want to reply to this thread?

"Problem compiling FORTRAN code" You must log in or register to reply here.

Related Threads for: Problem compiling FORTRAN code

  • Posted
Replies
2
Views
4K
  • Posted
Replies
2
Views
3K
Replies
3
Views
2K
Replies
6
Views
647
  • Posted
Replies
10
Views
3K
Replies
4
Views
10K
Replies
4
Views
6K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top