• associate to an allocatable array inside an openmp directive using ifor

    From ygalklein@gmail.com@21:1/5 to All on Sun Jul 17 00:48:22 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Neil@21:1/5 to ygal...@gmail.com on Sun Jul 17 10:20:44 2022
    ygal...@gmail.com <ygalklein@gmail.com> wrote:
    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

    It successfully compiles and runs with nagfor, with & without -fopenmp.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ygalklein@gmail.com@21:1/5 to All on Sun Jul 17 06:41:49 2022
    ב-יום ראשון, 17 ביולי 2022 בשעה 16:21:39 UTC+3, pehache כתב/ה:
    Le 17/07/2022 à 09:48, ygal...@gmail.com a écrit :
    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?
    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>

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From pehache@21:1/5 to All on Sun Jul 17 15:21:34 2022
    Le 17/07/2022 à 09:48, ygal...@gmail.com a écrit :
    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?
    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 : <j3nn2hFmqj7U1@mid.individual.net>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From FortranFan@21:1/5 to ygal...@gmail.com on Sun Jul 17 07:38:51 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ygalklein@gmail.com@21:1/5 to All on Sun Jul 17 07:57:42 2022
    ב-יום ראשון, 17 ביולי 2022 בשעה 17:38:53 UTC+3, FortranFan כתב/ה:
    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
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From pehache@21:1/5 to All on Sun Jul 17 23:03:28 2022
    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"


    --
    "...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 : <j3nn2hFmqj7U1@mid.individual.net>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ron Shepard@21:1/5 to pehache on Mon Jul 18 11:45:44 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)