I am trying to allocate a field that is part of an abstract data type within an OpenMP parallel region. To do the job I am calling an initialization subroutine defined in the same module. I encounter the following behavior:
- if the variable is declared private then the field appears to be allocated both inside the module and after the call to the initialization subroutine in the main program
- if the variable is declared shared the field is allocated within the module, but IS NOT allocated after the call to the initialization subroutine in the main program
Notice that I cannot reproduce the same behavior if the allocatable array is not part of a structure. A minimal example showing this behavior is given by the two files below:
I am quite a newbie of OpenMP so I was wondering if this is the behavior I should expect. In this case how I can initialize a shared variable of this kind?