Silverfrost Forums

Welcome to our forums

Compiler rejects #include in col-1 of fixed form source file

10 Jan 2023 2:53 #29808

Given a test program source file (fixed form) containing #include directives starting in column-1, FTN95 refuses to compile the file.

      program fppbug
      implicit none
#include 'size.inc'
      print *,NSIZE
      end program

where the included file contains the single line

      integer :: NSIZE = 100

FTN95 says:

ftn95 /CFPP fppbug.f
[FTN95/Win32 Ver. 8.92.0 Copyright (c) Silverfrost Ltd 1993-2022]
ERROR S:\LANG\ftn95\fppbug.F 3:  Invalid characters in label field of FIXED format source
ERROR S:\LANG\ftn95\fppbug.F 3:  Statement not recognised
ERROR S:\LANG\ftn95\fppbug.F 4:  NSIZE must appear in a type declaration because IMPLICIT NONE has been used
    3 ERRORS  [<FPPBUG> FTN95 v8.92.0]
*** Compilation failed

The usual convention for C processor directives in fixed form (Fortran 77) source is that the directives start in column-1. For example, see the Sun/Oracle page https://docs.oracle.com/cd/E19205-01/820-4180/man1/fpp.1.html , where it says:

ERROR S:\LANG\ftn95\fppbug.F 3:  Invalid characters in label field of FIXED format source
ERROR S:\LANG\ftn95\fppbug.F 3:  Statement not recognised
ERROR S:\LANG\ftn95\fppbug.F 4:  NSIZE must appear in a type declaration because IMPLICIT NONE has been used
    3 ERRORS  [<FPPBUG> FTN95 v8.92.0]
*** Compilation failed

The usual convention for C processor directives in fixed form (Fortran 77) source is that the directives start in column-1. For example, see the Sun/Oracle page https://docs.oracle.com/cd/E19205-01/820-4180/man1/fpp.1.html , where it says: [quote:b723e267c5]All fpp directives start with the hash symbol (#) as the first character on a line.

I think that it is only the output of the preprocessor that should be required to conform to Fortran-77 rules regarding columns 1-6 and 72-80, not the directives themselves.

Note: The example code is silly, but the issue exists with older Fortran 77 packages such as MINUIT from CERN. See, for example, lines 12 to 15 in the file https://github.com/ramos/minuit/blob/master/minuit.F .

10 Jan 2023 4:57 #29810

OK. Thanks. I will take a look at this.

12 Jan 2023 3:31 #29820

This bug has now been fixed for the next release of FTN95 (after v8.95).

29 Jul 2025 9:44 #32247

I find that

#include 'myfile'

is not accepted in .f90 free form source with FTN95 9.10 with the latest newDLLs139.zip updates. I get:

*** Error 699: Invalid character '#' at start of line *** Error 32: Statement not recognised

30 Jul 2025 6:20 #32248

Have you used /cfpp on the FTN95 command line?

30 Jul 2025 12:01 #32249

Yes, I am using /CFPP. From reading other messages I think the problem may be that the included file has #ifdef preprocessor lines. That is a surprising limitation.

30 Jul 2025 1:42 #32250

It ought to work. Can you post a simple demo program?

30 Jul 2025 1:56 #32251

Turns out the problem is NOT related to preprocessor statements in the included file.

program pre
! Demo for FTN95 preprocessor #include issue
! ftn95 /CFPP pre.f90 /LINK
#include 'platform.fh'
print *, os_sep, no_sep
end program

platform.fh:

      CHARACTER, PARAMETER :: os_sep = ''
      CHARACTER, PARAMETER :: no_sep = '/'

[/code]

5 Aug 2025 2:45 #32255

I can see that there is a fault here and I will investigate.

6 Aug 2025 9:15 #32256

This has now been fixed for the next release of FTN95.

Please login to reply.