View previous topic :: View next topic |
Author |
Message |
louis
Joined: 19 Oct 2005 Posts: 9
|
Posted: Mon Mar 06, 2006 11:28 am Post subject: Conditional compilation with C-style preprocessing |
|
|
The FTN95 manual says that C-style preprocessing is available through the /CFPP compiler directive.
However, using FTN95 in the following manner : FTN95 myprog.f /CFPP
raises errors concerning the #ifdef and #include statements which are present in the code of myprog.f
How does one use the C-style preprocessor for Fortran source files ? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Mon Mar 06, 2006 1:35 pm Post subject: Conditional compilation with C-style preprocessing |
|
|
Louis
I seem to recall that the documentation appeared in one version of FTN95 before the feature was enabled. I think you should be OK with either version 4.8 or 4.9. This is from memory. I do not have the version log to hand. I have tried with version 4.9 and it is OK.
The range of features is limited and is described in the help file under "C-Style Conditional Compilation".
Regards
Paul |
|
Back to top |
|
|
Anonymous Guest
|
Posted: Mon Mar 06, 2006 3:14 pm Post subject: Conditional compilation with C-style preprocessing |
|
|
Dear Paul
I am using FTN95 v 4.9.1 (without .NET) and it does not work in the fashion I described. Am I using the correct command line syntax ?
The program code (in fixed format) starts as
program SPDF
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
#include "params.inc"
#include "const.inc"
#ifdef USEMPI
include "mpif.h"
#endif
c
character atom1*8, atom2*8
The compiler objects to all the # statements as invalid.
Regards Louis |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Mar 07, 2006 12:41 am Post subject: Conditional compilation with C-style preprocessing |
|
|
Louis
If you are using /CFPP on the command line then FTN95 should not complain about all of the # statements. Try them one at a time starting with just one #include and an include file that contains no # statements.
As I recall, #define in FTN95 does not work in the same way as C. You must use /VPARAM or /DEFINE on the command line at the same time. I am guessing here but one or two simple trials will verify this.
Regards
Paul |
|
Back to top |
|
|
Anonymous Guest
|
Posted: Tue Mar 07, 2006 1:42 am Post subject: Conditional compilation with C-style preprocessing |
|
|
Paul
On testing I find that FTN95 works with /CFPP if the source code is in free format, but not in the old Fortan fixed format. I guess there is
no way round this? I am trying to use FTN95 compile a large pre-written program in fixed format, which would be too troublesome to modify.
Louis |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Mar 07, 2006 2:39 am Post subject: Conditional compilation with C-style preprocessing |
|
|
Louis
A simple example works OK for me but I had to start the # in column 7.
Regards
Paul |
|
Back to top |
|
|
Andrew
Joined: 09 Sep 2004 Posts: 232 Location: Frankfurt, Germany
|
Posted: Sat Mar 18, 2006 5:57 am Post subject: Conditional compilation with C-style preprocessing |
|
|
It is possible to use #define within source code and also on the command line as a replacement for /VPARAM. |
|
Back to top |
|
|
|