The collective coarray subroutines such as co_sum, co_min, etc. produce incorrect results when result_image is not specified. According to the 2018 Fortran Standard, the results should return on all images in this case. However, it seems the only comes back in image 1. The program below uses the example given in the standard in section 16.9.50 which states:
Example. If the number of images in the current team is two and A is the array [1, 5, 3] on one image and [4,1, 6] on the other image, the value of A after executing the statement CALL CO_SUM(A) is [5, 6, 9] on both images.
The following program shows that this does not happen.
program test implicit none integer :: a(3)
I compiled this using
ifort -V -coarray -coarray-num-images=2 -O0 co_sum_test_2.f90 -o co_sum_test_2 Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.0.166 Build 20191121
... and running it gave these results:
5 6 9 1 4 1 6 2
The result came back in image 1 only when it should have come back in both images.
Thank you for sending us this bug report. I'll get it into our system.
update: ID CMPLRILO-32636
For more complete information about compiler optimizations, see our Optimization Notice.