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

Local Data in Pure Subroutines

mattsdad
Beginner
906 Views

Will the local data inFortran's pure subroutines ever "cross wires" due to parallel read-modify-write in different threads?

0 Kudos
7 Replies
Steven_L_Intel1
Employee
906 Views

If you're using /parallel or OpenMP that is coded properly, there should not be a problem. Pure routines really aren't anything special in this regard.

0 Kudos
mattsdad
Beginner
906 Views

Yes, I have an OMP PARALLEL DO loop. The loop index is used to specify a different element of an array. Only that specific element is passed into the pure subroutine. So all the affected data from outside the pure subroutine is preperly segreated by thread.

The real question is - does the locally declared data in the called subroutine need to have OMP directives to prevent interaction between threads?

0 Kudos
Steven_L_Intel1
Employee
906 Views
By default,. all variables are "automatic" (stack allocated) when OpenMP is used. So unless you did something that woild force static allocation (SAVE or initialization), nothing should need to be done.
0 Kudos
mattsdad
Beginner
906 Views
Does the POINTER attribute cause a variable to be STATIC when there is no initialization?
0 Kudos
Steven_L_Intel1
Employee
906 Views
No.
0 Kudos
mattsdad
Beginner
906 Views
Does theTARGET attribute cause a variable to be STATIC when there is no initialization?
0 Kudos
Steven_L_Intel1
Employee
906 Views
No. The only thing that forces static allocation for local variables is the SAVE attribute, either explicit or implicit. The only way you get SAVE implicitly is with initialization.
0 Kudos
Reply