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

OpenMP and module: how copy a whole module in each thread


Good morning.

I am trying to parallelize my code through OpenMP.
This code is chock full of variables contained in modules shared with each other via the USE command.
Reading on the forum, I realized that I should use the Threadprivate command and put the variable name in round brackets.
However, this system is impractical, because there are a lot of variables.
Is there a way to use a copy of the whole module in each thread, without having to specify one variable at a time?
Each thread does not need to exchange the module variables with another (also because it would not be parallelizable), but each thread needs all the variables inside the modules

0 Kudos
1 Reply
Honored Contributor III

Place those variables in a user defined type, then instantiate a single variable of that type attributed with threadprivate. For example, you could name the variable "tls" and prefix the references to those variables with "tls%", e.g. tls%ABC

Jim Dempsey

0 Kudos