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

associate to an allocatable array fails inside an omp directive

Klein__Ygal
Novice
843 Views

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.

0 Kudos
4 Replies
Barbara_P_Intel
Employee
793 Views

I filed a bug report on this for you, CMPLRIL0-34840.

Interestingly, it compiles and runs OK with ifx. That's your workaround: use ifx. Object files created with ifx are compatible with those created by ifort. You can mix and match.



0 Kudos
Klein__Ygal
Novice
768 Views

Thank you Barabara

 

I can not seem to enter the bug report

 

Can you please give a link to the bug report?

0 Kudos
Barbara_P_Intel
Employee
761 Views

@Klein__Ygal We don't have a mechanism for you to see the actual bug report. I'll post here when a fix is available to you.

 

 

0 Kudos
Barbara_P_Intel
Employee
569 Views

The compiler team researched this and determined another workaround.

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
    associate(a=>static_array, b=>allocatable_array)
      !$omp parallel do
      do i = 1, 5
              write(*, *) "i, a(i)", i, a(i)
              write(*, *) "i, b(i)", i, b(i)
      end do
    !$omp end parallel do
    end associate
end program openmmp_with_associate_to_allocatable

Can you use these workarounds: ifx or move the ASSOCIATE outside the parallel do? 

ifx is the way of the future for Intel Fortran.

 

0 Kudos
Reply