Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

associate to an allocatable array inside an openmp directive using ifort

68 views
Skip to first unread message

ygal...@gmail.com

unread,
Jul 17, 2022, 3:48:26 AM7/17/22
to
Hi,

I am trying to compile and run the following code:

``` fortran
program openmmp_with_associate_to_allocatable
implicit none
integer, allocatable, dimension(:) :: allocatable_array
integer :: static_array(5), i
allocate(allocatable_array(5))
do i = 1, 5
allocatable_array(i) = i
static_array(i) = i
end do
!$omp parallel do
do i = 1, 5
associate(a=>static_array, b=>allocatable_array)
write(*, *) "i, a(i)", i, a(i)
write(*, *) "i, b(i)", i, b(i)
end associate
end do
!$omp end parallel do
end program openmmp_with_associate_to_allocatable
```


Using gfortran 12.1 (with or without -fopenmp) the code compiles and runs succesfully and prints both a and b as asked.

Using itel fortran compiler 2022.2.0: Without using -qopenmp - the code compiles and runs successfully.
When using -qopenmp - the code compiles but crashes when tryihnjg to print b which associates to an allocatable array. a - which is ascociated to a static array is printed successfully.

Does any one know if this code is written with a problem or is there a problem in ifort?

Thanks,
Ygal

Neil

unread,
Jul 17, 2022, 6:20:47 AM7/17/22
to
It successfully compiles and runs with nagfor, with & without -fopenmp.

pehache

unread,
Jul 17, 2022, 9:21:39 AM7/17/22
to
The validity of such code looks unclear
https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-with-associate-define-private/m-p/1180441

--
"...sois ouvert aux idées des autres pour peu qu'elles aillent dans le
même sens que les tiennes.", ST sur fr.bio.medecine
ST passe le mur du çon : <j3nn2h...@mid.individual.net>

ygal...@gmail.com

unread,
Jul 17, 2022, 9:41:51 AM7/17/22
to
ב-יום ראשון, 17 ביולי 2022 בשעה 16:21:39 UTC+3, pehache כתב/ה:
Hi,
Thanks for the replies.
I saw the link in intel forum that you sent.

It is not the same code.
and supposudely not the same problem

Give attention to the fact that there is no problem with the static array...
Thanks anyway.
If anyone knows if this is an intel compiler probelm - would be gald to know

FortranFan

unread,
Jul 17, 2022, 10:38:53 AM7/17/22
to
On Sunday, July 17, 2022 at 9:41:51 AM UTC-4, ygal...@gmail.com wrote:

> ..
> If anyone knows if this is an intel compiler probelm - would be gald to know

@Ygal,

You may want to post your inquiry at the Intel Fortran forum also and the replies there by Intel Support team on your question(s) may prove useful to you:

https://community.intel.com/t5/Intel-Fortran-Compiler/bd-p/fortran-compiler

ygal...@gmail.com

unread,
Jul 17, 2022, 10:57:44 AM7/17/22
to
ב-יום ראשון, 17 ביולי 2022 בשעה 17:38:53 UTC+3, FortranFan כתב/ה:
Thanks Fortran Fan.

POsted

https://community.intel.com/t5/Intel-Fortran-Compiler/associate-to-an-allocatable-array-fails-inside-an-omp-directive/m-p/1400967#M162085

pehache

unread,
Jul 17, 2022, 5:03:34 PM7/17/22
to
Le 17/07/2022 à 15:41, ygal...@gmail.com a écrit :
>
> Hi,
> Thanks for the replies.
> I saw the link in intel forum that you sent.
>
> It is not the same code.
> and supposudely not the same problem

Sure, but some comments tend to show that it is not always easy to know
how ASSOCIATE and OpenMP work together...

"The OpenMP and Fortran standards are not explicit on what happens to an
associate name inside an OpenMP parallel do loop"

Ron Shepard

unread,
Jul 18, 2022, 12:45:48 PM7/18/22
to
On 7/17/22 4:03 PM, pehache wrote:
> Le 17/07/2022 à 15:41, ygal...@gmail.com a écrit :
>>
>> Hi,
>> Thanks for the replies.
>> I saw the link in intel forum that you sent.
>>
>> It is not the same code.
>> and supposudely not the same problem
>
> Sure, but some comments tend to show that it is not always easy to know
> how ASSOCIATE and OpenMP work together...
>
> "The OpenMP and Fortran standards are not explicit on what happens to an
> associate name inside an OpenMP parallel do loop"

Just out of curiosity, what if, instead of an associate name, the same
thing had been accomplished with a call to a contains procedure? Is the
OpenMP behavior defined in that case?

$.02 -Ron Shepard


0 new messages