Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29390 ディスカッション

unable to assign value correctly

Zuodong_Y_
初心者
1,776件の閲覧回数

Here is the code to reproduce the problem

program main
	implicit none
	integer :: to(1:2),from(1,2),i
	from(1,:)=[1,2]
	i=1
	to(i:2)=mod((from(1,1:2)),4)
	write(*,*)"from:",from
	write(*,*)"to:",to
end program

compiled with Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.4.196 Build 20170411

the variable "to" should be equal to "from" but it doesn't. Seems only the first element of "to" is assigned.

0 件の賞賛
1 解決策
Ron_Green
モデレーター
1,748件の閲覧回数

This bug is fixed in PSXE 2020 Update2.


元の投稿で解決策を見る

4 返答(返信)
andrew_4619
名誉コントリビューター III
1,776件の閲覧回数
MOD would create an array with the same rank and shape as its arg. 
I made a test using and intermediate array (maybe the compiler creates a temp ) 
but that code (shown below) works.  I suspect either your code is 
nonconforming (but no error is given) or there is a compiler bug. 
Not sure which.


        implicit none
        integer :: to(1:2), from(1,2), i, to2(1,2)
        from(1,:)=[1,2]
        i=1
        to2(i,1:2) = mod(from(1,1:2),4)
        to(i:2) = to2(i,1:2)

 

Steve_Lionel
名誉コントリビューター III
1,776件の閲覧回数

Interesting. The key is the use of i in to(i:2). If that is replaced by to(1:2), it works. This is a compiler bug, still broken in 19.1. Please report it to Intel using the Online Service Center.

Ron_Green
モデレーター
1,776件の閲覧回数

I opened a bug report.  ID is CMPLRIL0-32400

 

Ron_Green
モデレーター
1,749件の閲覧回数

This bug is fixed in PSXE 2020 Update2.


返信