Pergunta

I am trying to compile an old Fortran IV code using the gcc fortran compiler (gfortran 4.8.1 -4). I run the compiler as: gfortran nrlxrf_a.for -std=legacy. These are the error messages:

C:\MinGW\bin>gfortran nrlxrf_a.for -std=legacy

NRLXRF_a.for:5525.72:

  IF ( NFILL.EQ. 0)
                                                                    1

Error: Cannot assign to a named constant at (1)

I have checked the line, and there are no spaces after the end of the statement.

NRLXRF_a.for:5531.7:

 1 ( HFILL( I), I= 1, NFILL), ( H( IU, I), I= I1, I2)
   1

Error: Cannot assign to a named constant at (1)

Any suggestions would be greatly appreciated. Thomas

This is the code section where HFILL and NFILL are used. Is this a matter of selecting the correct option for the compiler or a syntax error?

C:DOC IS THE DATUM NUMERIC?  IF SO, GO TO 44; ELSE GO TO 50.
       NFILL= 0
       HTEST= H( IU, I1)
      IF ( HTEST.NE. HSIGN( 1)) GO TO 41
      GO TO 45
C:-------
 41   IF ( HTEST.NE. HSIGN( 2)) GO TO 42
 45    NFILL= 1
       HTEST= H( IU, I1+ 1)
 42   DO 43 J= 1, 11
      IF ( HTEST.EQ. HDIG( J)) GO TO 44
   43 CONTINUE
       NFILL= 0
      GO TO 50
C:-------
C:DOC DATUM IS NUMERIC.  CALCULATE NO. OF BLANKS TO RIGHT-JUSTIFY.
 44    NFILL= NC- NII
      IF ( I2P.NE. I2) WRITE( KW, 111) ( H( IU, J), J= I1, I2P)
      IF ( I2P.NE. I2) WRITE( KW, 112) ( H( IU, J), J= I1, I2)
C:DOC WRITE ANY FILL BLANKS AND DATUM TO SCRATCH FILE.
 50   CONTINUE
      IF ( NFILL.EQ. 0) WRITE( KS, 102) ( H( IU, I), I= I1, I2)
      IF ( NFILL.EQ. 0)                                             line 5525
C:     1 ENCODE( NC, 102, HIN( 4* NR- 3)) ( H( IU, I), I= I1, I2)
      IF ( NFILL.NE. 0) WRITE( KS, 102)
     1 ( HFILL( I), I= 1, NFILL), ( H( IU, I), I= I1, I2)
      IF ( NFILL.NE. 0)
C:     1 ENCODE( NC, 102, HIN( 4* NR- 3))
     1 ( HFILL( I), I= 1, NFILL), ( H( IU, I), I= I1, I2)           line 5531
       I1= I3+ 1
Foi útil?

Solução

If one assumes that the code is based on that from http://www.nist.gov/mml/csd/inorganic/xrf.cfm then the problem is that gfortran is not a Fortran IV compiler and it doesn't support extensions that other compilers did.

From that source the full "line" (taking into account continuation is) for the first error:

      IF ( NFILL.EQ. 0)
     1 ENCODE( NC, 102, HIN( 4* NR- 3)) ( H( IU, I), I= I1, I2)

According to the gfortran documentation ENCODE is not supported.

I guess that in the code you've presented you (or someone) has attempted to remove the troublesome lines. But incorrectly: lines have been removed, but not whole statements, which can consist of many lines.

Ignoring the fact that removing the encoding fundamentally changes the meaning of the code, you'll need to remove the whole statements where the ENCODEs appear. Remove all subsequent continuation lines and the first preceding non-continuation line. Lines 5525, 5529 and 5520 in these cases.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top