Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28794 Discussions

Visual Fortran and C preprocessor cpp

johnrohner
Beginner
1,642 Views
Migrating Fortran source code from HPUX to the PC my source code uses cpp syntax for "#include" statements as well as "#if", "#ifdef", "#ifndef", etc. In addition to DVF v6.0, I have Microsoft Visual Studio 6.0 w/ Visual C++ 6.0 installed on my PC. Question: is there a way to invoke the C preprocessor, cpp, to expand source code prior to compulation using DVF?
0 Kudos
12 Replies
Steven_L_Intel1
Employee
1,642 Views
Yes. In Developer Studio, select Project..Settings..Fortran..Preprocessor..Enable FPP. From the command line, use /fpp. This is a Fortran-friendly version of cpp. Note that macro expansion is disabled by default - you can enable it with /fpp:"/m"

Steve
0 Kudos
brentpaul
Beginner
1,642 Views
I just posted a similar problem to the message board. However, in the Compaq Visual Fortran version 6.6c there is no way to change the FPP to /fpp:"/m". How do you change it on that version? Thanks!
Brent
0 Kudos
Steven_L_Intel1
Employee
1,642 Views
You have to type in /fpp:"/m" in the Project Options box.
0 Kudos
brentpaul
Beginner
1,642 Views
Ok, this is probably a basic thing, but I can't locate the "Projects Option Box". Where is that?
0 Kudos
Steven_L_Intel1
Employee
1,642 Views
Project..Settings..Fortran. Each of the settings pages has a text box Project Options where the equivalent command line options are displayed. You can edit this as needed.
0 Kudos
brentpaul
Beginner
1,642 Views
Thanks. I found that. But it still doesn't work. I'm probably asking the wrong question. Here is what I have:
const.h (This is a file with my #defines)
const1.h
const2.h
A lot of .f90 files
How can I compile my code so that it automatically recognizes and substitutes my macros that are defined in the const.h, const1.h, or const2.h?
I do this now with a C preprocessor that I use before my fortran compiler. Thank you.
Brent
0 Kudos
Steven_L_Intel1
Employee
1,642 Views
Are you using INCLUDE to reference these .h files or #include? You must use #include otherwise the preprocessor won't see them.
0 Kudos
brentpaul
Beginner
1,642 Views
Yes, I am using #include. Here are some snippets from the code:
turb.f90:
#include "const.h" (first line of code)
.
.
.
dtur = DISS_L*l + DISS_M * m (this is where I wanted a replacement from const.h)
const.h:
#define DISS_L 13.45454
#define DISS_M 14.3452
0 Kudos
Steven_L_Intel1
Employee
1,642 Views
And you have /fpp:"/m" under Project Options for the project? It should work. If you need further help, write CVF support at vf-support@hp.com.
0 Kudos
brentpaul
Beginner
1,642 Views
Ok, thank you for your help though!!!
Brent
0 Kudos
tedz
Beginner
1,642 Views
I am having the same problem. I have added /fpp:"/m" to my project settings. I have changed my include "file.h"to #include "file.h" and I still get the compilation error:
Warning: Bad # preprocessor line
#define doit 952
running cvf6.6a
0 Kudos
tedz
Beginner
1,642 Views
Disregard my last post. Something was corrupted and effecting one file. I restarted everything from scratch and itseems to be working now.
Thanks for info.
Ted Z.
0 Kudos
Reply