I have a question regarding using MODULE in openMP.
Our program can be simplied by the following example. The parallel region iswithin subroutine SUB1. Variables A & B are from VAR1_ARRAYS modules. To remove the data dependence,we madeA & B as private. However, we found that A & B values are the same from different thread even though they should be different. Clearly A & B values are shared among the threads.
Within subroutine SUB1, variables A & B were not used even though they were marked asPRIVATE at he beginning of the parallel region. I am wondering if private will not work for this kinds of MODULES? Dowe have to pass A & B parameters in CALL SUB2(A,B) and CALL SUB3(A,B) instead ofusing MODULE?Or we have a bug somewhere?
MAIN program
call SUB1
.......
STOP
END
SUBROUTINE SUB1
USE VAR1_ARRAYS, ONLY: A, B
......
!$OMP parallel do private(A,B)
DO I = 1, II
CALL SUB2
CALL SUB3
ENDDO
RETURN
END
SUBROUTINE SUB2
USE VAR1_ARRAYS, ONLY: A, B
...
A=...
B=...
RETURN
END
SUBROUTINE SUB3
USE VAR1_ARRAYS, ONLY: A, B
...
C=A*B
...
RETURN
END
SUBROUTINEMODULES
MODULE VAR1_ARRAYS
REAL A, B
END MODULE
RETURN
END
Link Copied
For more complete information about compiler optimizations, see our Optimization Notice.