- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a Fortran project that I normally compile using a hand-made Visual Studio project file, but I'm in the process of reconfiguring my whole build system using CMake so that I can more easily port the same source code between different compilers and platforms.
However, when I try to compile this project, which makes extensive use of OpenMP, I find that I get error messages on every OpenMP tag. Every error message is the same:
error #5082: Syntax error, found INTEGER_CONSTANT '1' when expecting one of: NONE PRIVATE FIRSTPRIVATE SHARED
...and occurs everywhere that I use
!$OMP PARALLEL DO
...and its extensions (such as SIMD, COLLAPSE etc.). I don't see the error where I use other OpenMP parallel constructs, such as SECTIONS.
I've looked at the compiler options in my original Visual Studio project file and in the CMake-generated one, and they look the same as far as I can tell. In particular the /Qopenmp and /standard-semantics flags are selected in both cases.
What might I be doing wrong?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What this sounds like is a preprocessor (or CMAKE) is replacing a keyword with the contents of a macro.
See if you have defined a macro named: NONE, PRIVATE, FIRSTPRIVATE, or SHARED
or DEFAULT
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Jim. I'm sure it's not that, though. There are no macros of that sort defined anywhere in the project.
I should add that the same source code compiles cleanly in gfortran, under both Linux and Windows, when driven from the same CMake file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another data point; it looks like the problem is in the clause "DEFAULT(SHARED)"; that is to say, almost all my !$OMP PARALLEL DO statements have the form
!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(i)
...but if I replace this with
!$OMP PARALLEL DO PRIVATE(i)
...then the errors go away.
Yet this is correct OpenMP syntax, as far as I can tell, and it works in gfortran and in Intel Fortran when I compile it with the hand-generated VS2015 project file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This even more smells like a preprocessor thing. SHARED is a common enough term.
You could try adding "-USHARED" to your Fortran compile-time flags.
--Lorri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, that was indeed the solution; Jim was in fact correct the first time around, and you were too Lorri. Thank you.
In CMake I had designated the library as SHARED to cause it to be compiled as a DLL rather than a static library. Having done this in the wrong place, it had found its way into my preprocessor macros where, even though it was starting me in the face, the context was so different that I failed to twig.
Another example of how, so often in life, you see what you expect to see rather than what's actually there right under your nose...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You mean, you don't smell what's right under your nose ;)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page