MiuraB
MiuraB

Reputation: 31

Why does a DO CONCURRENT statement gives a strange result?

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?

Upvotes: 3

Views: 285

Answers (0)

Related Questions