- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Is there an environment variable (like __GFORTRAN__ for gfortran) that can be used to as a flag to the preprocessor so that it will preprocess part of the file when it is a fortran file and skip that part when it is a C or C++ file? It would be valuable if it worked the same for Windows.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
gfortran needs that because it uses cpp for preprocessing Fortran code. Intel Fortran has its own Fortran-specific preprocessor, fpp, which doesn't need such a thing. Can you describe a scenario where such a thing would be useful?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I do not understand part of #1: do you really imply that a single source file would contain C/C++ code and Fortran code? What is it that distinguishes the part that you want skipped/not skipped from the rest of the source file?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We have an include file that has several defines in it that are useful for both fortran and C preprocessing. Unfortunately, another include was added to it that is fortran specific, and was bracketed with the if __GFORTRAN__ so it did not get used in the C++ code. This worked OK on Linux, where the primary compiler used was gfortran, but blows up on Windows, where Intel is the primary compiler, and prevents using Intel on Linux. I recognize this was not the best way this should have been done, but after the fact, it will be much easier to fix the if than to go through and modify all the all the other routines that are involved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, I see. Perhaps __INTEL_COMPILER could be used for this, though this would also be set if you used Intel C++. Or you could add a -DFORTRAN or some such to your ifort build options.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you must use gFortran specific preprocessing you can direct output of gfortran -E to a file which Ifort can compile, or you could define the macro symbol for fpp. If using gfortran to preprocess on windows, input and output must be in separate folders.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, thanks everyone. What we have gone to, which seems to work is setting the if test as below.
#if defined(__GFORTRAN__) || (defined(__INTEL_COMPILER) && !(defined(__ICC)||defined(__ICL))) || defined(_G95__)
I'm not sure why G95 got added in, as I don't think it will compile everything, but it doesn't seem to hurt.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page