3

Let us compile the following Fortran program:

program main
    implicit none
    integer::j
    complex::y(2)
    real::x(2)

    x(1)=1.0
    x(2)=2.0

    do j=1,2
        y(j)=FF(x(j))
    enddo

    write(6,*)
    write(6,*) y,"by DO"

    forall (integer::i=1:2)
        y(i)=FF(x(i))
    end forall

    write(6,*)
    write(6,*) y,"by FORALL"

    do concurrent (integer::i=1:2)
        y(i)=FF(x(i))
    enddo

    write(6,*)
    write(6,*) y,"by DO CONCURRENT"
    write(6,*)

    contains
    complex pure function FF(xx)
        real,intent(in)::xx
        FF=cmplx(xx)
    end function
end program

by ifort (ver. 19.0.4.243) with no options. Then, we get the result:

$ ./a.out

 (1.000000,0.0000000E+00) (2.000000,0.0000000E+00) by DO

 (1.000000,0.0000000E+00) (2.000000,0.0000000E+00) by FORALL

 (2.000000,0.0000000E+00) (2.000000,0.0000000E+00) by DO CONCURRENT

The first and second results are as expected. Why does not DO CONCURRENT gives the same result?

MiuraB
  • 31
  • 2
  • 1
    You can report bugs in the Intel compiler to Intel (using your support contact or the forums). – francescalus Aug 21 '20 at 10:53
  • I tested with gfortran 7.5 and your code works properly. I would try disabling optimization during compilation with option -O0 to see if this is an optimization issue. – Emilio Aug 21 '20 at 12:09
  • 1
    It seems to work when compiled with `/Qopenmp` or `/Qparallel` –  Aug 21 '20 at 14:20
  • I have just tried it out and I can confirm that this behaviour exists in intel compiler `ifort (IFORT) 19.1.2.254 20200623` and `ifort (IFORT) 19.0.4.243 20190416` (I have not tested any other version). It does not appear, as @Jean-ClaudeArbaut states, the `-parallel` option is given. However, just the `-qopenmp` seems to still have the bug. – chw21 Aug 22 '20 at 02:45
  • @chw21 That's odd. With `ifort 19.1.2.254 build 20200623` for `Windows`, it works with any of the options. It also works if y is not complex but real. There is definitely a bug, and it depends on subtle factors. As an aside, I looked up the Intel forum, and there are several questions related to problems with `do concurrent` in recent versions. –  Aug 22 '20 at 05:02
  • Well, I ran it on Linux. But it seems to me that that's a bug, and it's up to Intel to figure out what's going on. – chw21 Aug 22 '20 at 05:29
  • This compiler behavior is a bug? – MiuraB Aug 22 '20 at 16:04

0 Answers0