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

OpenMP and scalars

Ted_Rosenbaum
Beginner
607 Views
Hi,
I have been having a problem with openmp where when I declare a scalar firstprivate, the correct value is not passed to all the threads (an arbitrary large number is passed instread), however when I use a one dimensional array everything works fine.
Since I already have a work around, this is not a pressing issue for me, but I'm interested in trying to understand the behavior (since the work around should not be necessary).
I'm guessing it has something to do with the way that fortran treats arrays vs. scalars (maybe passing one by value and one by reference, but I don't know enough to know why that would generate this issue).
I appreciate any insights.

Thanks,

Ted
0 Kudos
2 Replies
TimP
Honored Contributor III
607 Views
It's probably hard to deal with this without an actual example. The firstprivate variable should not have SAVE (explicitly or implicitly). I've found it useful sometimes to avoid firstprivate/lastprivate even at some increase in code verbosity.
0 Kudos
Udit_P_Intel
Employee
607 Views
I agree with Tim. It would be helpful using an actual example. Are you using a REAL or INTEGER datatype, or CHARACTER? I know that CHARACTERs are treated in a special way by the compiler, and that could be an issue.
You could also try to run with -O0 to ensure that there isn't some illegal optimisation that the compiler is attempting. Finally, if the scalar is ALLOCATABLE, that would also add a level of complexity. I hope these points help, but if you gave an example program, then it would help us pinpoint the cause of failure.
Best!
-Udit
0 Kudos
Reply