Multi-line comments in an included file trigger "invalid character in name" compiler error. !file1.F95 program file1 include 'file2.F95' stop end program !file2.F95 /* blah */
Cf. multiple topic PR 35707. The problem is that include 'file2.F95' is not processed through CPP. I'm not sure whether it should and when it should (file extension .F/F90/F95/F03/F08/FPP/FOR/fpp, always, or never). One possibility is to use: #include "file2.F95" in this case CPP includes the file before it hands it to the Fortran part of the compiler.
I guess that would only work with GCC but if we can get OpenMP working, that might be good enough. Thank you ^_^.
(In reply to comment #1) > Cf. multiple topic PR 35707. > > The problem is that > include 'file2.F95' > is not processed through CPP. I'm not sure whether it should and when it should > (file extension .F/F90/F95/F03/F08/FPP/FOR/fpp, always, or never). > The standard simply says the text in file2.F95 is included at the location of the include line. It does not and suppose the standard will never discuss whether file2.F95 should be pre-processed before inclusion. This looks like pilot error in that Fortran's INCLUDE does not mean the same thing as C's #include.
(In reply to comment #3) > (In reply to comment #1) > > Cf. multiple topic PR 35707. > > > > The problem is that > > include 'file2.F95' > > is not processed through CPP. I'm not sure whether it should and when it should > > (file extension .F/F90/F95/F03/F08/FPP/FOR/fpp, always, or never). > > > > The standard simply says the text in file2.F95 is included > at the location of the include line. It does not and suppose > the standard will never discuss whether file2.F95 should be > pre-processed before inclusion. > > This looks like pilot error in that Fortran's INCLUDE does not > mean the same thing as C's #include. > Does the Fortran standard mention preprocessing at all? That works in g95, but we are beginning to move away from that. Is a copy of the standard freely available? I would like for this to work with as many different compilers and systems as possible.
(In reply to comment #4 > Does the Fortran standard mention preprocessing at all? No. Section 1.1 (the very 1st section) states 1.1 Scope ISO/IEC 1539 is a multipart International Standard; the parts are published separately. This publication, ISO/IEC 1539-1, which is the first part, specifies the form and establishes the interpretation of programs expressed in the base Fortran language. The purpose of this part of ISO/IEC 1539 is to promote portability, reliability, maintainability, and efficient execution of .... The third part, ISO/IEC 1539-3, defines a standard conditional compilation facility for Fortran. A processor conforming to part 1 need not conform to ISO/IEC 1539-2 or ISO/IEC 1539-3; however, conformance to either assumes conformance to this part. > Is a copy of the standard freely available? The Standard is not free. You, however, can find drafts of the various standards that are provided so people can provide feedback to J3. See the gfortran wiki for pointers to drafts.
(In reply to comment #5) ok. Thank you very much for your help ^_^.
> Does the Fortran standard mention preprocessing at all? Yes, part 3 of the Fortran standard is about preprocessing ("Conditional Compilation", "CoCo"), however, to my knowledge hardly anyone uses it and no compiler implements it. (There exists a Fortran program which can be used as coco preprocessor, see link below.) The de-facto standard for preprocessing is CPP (C Pre Processor) sometimes also called FPP. However, this is only standardized for C and not for Fortran, which causes issues as not every compiler acts the same. Issues: 1. Are newer CPP features supported? 2. Are Fortran "INCLUDE"d files also preprocessed? gfortran/netlib's fpp/NAG f95/openf95/sunf95: (1) no,(2) no g95: no/yes ifort: yes/no, (There are plans to support (1) in gfortran, see PR 28662.) > Is a copy of the standard freely available? Yes and no. The latest drafts before the standard went to ISO are available for free, which are said to be the same except for layout. See links at http://gcc.gnu.org/wiki/GFortranStandards > I would like for this to work with as many different compilers and > systems as possible. Then I really suggest to use #include "...", which should work with any compiler which does CPP preprocessing.
IMO, not pre-processing INCLUDEd files (as opposed to #include'd ones) is a feature, not a bug. Maybe we should make a final decision on this, i.e. if bug or feature, and state/document it, once and for all?
Subject: Bug 37032 Author: dfranke Date: Mon Aug 18 20:46:08 2008 New Revision: 139215 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139215 Log: 2008-08-18 Daniel Franke <franke.daniel@gmail.com> PR fortran/37032 * gfortran.texi: Document decision on include file handling in preprocessed files. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/gfortran.texi
Closing as WONTFIX. Reference: http://gcc.gnu.org/ml/fortran/2008-08/msg00071.html (and following). (Updated) Documentation about gfortran's behaviour with preprocessing can be found in sections 1.3 and 2.3 of the manual (http://gcc.gnu.org/onlinedocs/gfortran/).