Re: OpenMP: data scoping and modules



Hello Joaquin,

The short answer to your question: Yes.

However, in general it is recommended to keep the usage of global
variables to a minimum, since the "non-locality" in programming style
is error-prone. In your example, just assume that "sub" is called within
a threaded region. Then, at the very least, you need to put updates
to shared_data into a critical region. Even so, your algorithm may
not work as intended.

Regards


OK, thanks. So in this case, if i took private_data out of module data
and instead kept it only as an argument to func, that would be better
because I'd have fewer globally declared variables, but it would still
be private, because it's declared inside func?

.