Silverfrost Forums

Welcome to our forums

Using VPARAM

23 Mar 2013 3:33 #11868

Below is a trivial program with a simple error (executable statement occurring before a CONTAINS statement) that should prevent compilation.

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?

23 Mar 2013 8:52 #11869

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.

23 Mar 2013 12:29 #11872

Thanks for the quick response Paul, especially on the weekend!

So I would need to use the Fortran conditional compilation statements as follows:

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.

23 Mar 2013 4:27 #11873

Does this do what you want?

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

Please login to reply.