View previous topic :: View next topic |
Author |
Message |
mecej4
Joined: 31 Oct 2006 Posts: 1901
|
Posted: Tue Jan 10, 2023 3:53 pm Post subject: Compiler rejects #include in col-1 of fixed form source file |
|
|
Given a test program source file (fixed form) containing #include directives starting in column-1, FTN95 refuses to compile the file.
Code: |
program fppbug
implicit none
#include "size.inc"
print *,NSIZE
end program |
where the included file contains the single line
Code: |
integer :: NSIZE = 100 |
FTN95 says:
Code: |
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:
Quote: |
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 . |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8232 Location: Salford, UK
|
Posted: Tue Jan 10, 2023 5:57 pm Post subject: |
|
|
OK. Thanks. I will take a look at this. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8232 Location: Salford, UK
|
Posted: Thu Jan 12, 2023 4:31 pm Post subject: |
|
|
This bug has now been fixed for the next release of FTN95 (after v8.95). |
|
Back to top |
|
 |
sigment
Joined: 17 Dec 2007 Posts: 13
|
Posted: Tue Jul 29, 2025 10:44 pm Post subject: |
|
|
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 |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8232 Location: Salford, UK
|
Posted: Wed Jul 30, 2025 7:20 am Post subject: |
|
|
Have you used /cfpp on the FTN95 command line? |
|
Back to top |
|
 |
sigment
Joined: 17 Dec 2007 Posts: 13
|
Posted: Wed Jul 30, 2025 1:01 pm Post subject: |
|
|
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. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8232 Location: Salford, UK
|
Posted: Wed Jul 30, 2025 2:42 pm Post subject: |
|
|
It ought to work. Can you post a simple demo program? |
|
Back to top |
|
 |
sigment
Joined: 17 Dec 2007 Posts: 13
|
Posted: Wed Jul 30, 2025 2:56 pm Post subject: |
|
|
Turns out the problem is NOT related to preprocessor statements in the included file.
Code: |
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:
Code: |
CHARACTER, PARAMETER :: os_sep = '\'
CHARACTER, PARAMETER :: no_sep = '/'
|
[/code] |
|
Back to top |
|
 |
|