View previous topic :: View next topic |
Author |
Message |
simon
Joined: 05 Jul 2006 Posts: 299
|
Posted: Sat Mar 23, 2013 4:33 am Post subject: Using VPARAM |
|
|
Below is a trivial program with a simple error (executable statement occurring before a CONTAINS statement) that should prevent compilation.
Code: | MODULE m1
#ifdef A
i=1
#endif
END MODULE m1
|
If I compile using the following command, there is no error, which is appropriate since ifdef A is undefined:
FTN95 <filename>.f95 /CFPP
However, if I try using either of the following commands I get an error message:
FTN95 <filename>.f95 /CFPP /VPARAM A 0
FTN95 <filename>.f95 /CFPP /VPARAM A 1
It makes sense to me that the second command should generate an error, but why does the first one not work? |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Sat Mar 23, 2013 9:52 am Post subject: |
|
|
It would make sense to a C programmer.
The concept is that the parameter is set not that it is set to a particular value.
See ftn95.chm under FTN95 Fortran language extensions->The C-style preprocessor. |
|
Back to top |
|
 |
simon
Joined: 05 Jul 2006 Posts: 299
|
Posted: Sat Mar 23, 2013 1:29 pm Post subject: |
|
|
Thanks for the quick response Paul, especially on the weekend!
So I would need to use the Fortran conditional compilation statements as follows:
Code: | MODULE m1
CIF (A) THEN
i=1
CENDIF
END MODULE m1
|
which does compile as expected with /VPARAM A 1 and /VPARAM A 0.
But these are Fortran extensions, correct? Using the C-format, I can get my code to compile with other compilers. I'm not sure about CIF. If not I am sure I can work around that. |
|
Back to top |
|
 |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Sat Mar 23, 2013 5:27 pm Post subject: |
|
|
Does this do what you want?
Code: |
MODULE m1
#ifdef A
#if A
i=1
#endif
#endif
END MODULE m1
|
These don't give compile errors
FTN95 <filename>.f95 /CFPP
FTN95 <filename>.f95 /CFPP /VPARAM A 0
This gives a compiler error
FTN95 <filename>.f95 /CFPP /VPARAM A 1 _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
 |
|