Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29273 討論

bounds of assumed-rank dummy argument not equal to actual argument

John_D_6
新貢獻者 I
730 檢視
the draft Fortran 2015 standard reads:

An actual argument of any rank may correspond to an assumed-rank dummy argument. 
The rank and shape of the dummy argument are the rank and shape of 
the corresponding actual argument. If the rank is nonzero, the lower and upper 
bounds of the dummy argument are those that would be given by the intrinsic 
functions LBOUND and UBOUND respectively if applied to the actual argument, 
except that when the actual argument is assumed-size, the upper bound of the 
last dimension of the dummy argument is 2 less than the lower bound of
that dimension.

(section 12.5.2.4 on ordinary dummy variables, paragraph 15)

Here is a small test program:

program assumedrank
 implicit none
 real,dimension(:,:,:),allocatable :: bb
 real,dimension(3:9,10:15,16:32) :: c

 allocate(bb(3:9,10:15,16:32))
 print*, 'Actual argument, allocatable, lbound=',lbound(bb)
 call p(bb)
 print*, 'Actual argument, lbound=',lbound(c)
 call p(c)

 contains

 subroutine p(a)
  real,dimension(..) :: a
  print*,'Dummy argument, lbound=',lbound(a)
 
 end subroutine p

end

The Intel 16.0.0 compiler returns the correct lower bounds for an allocatable array as actual argument
(note that there is no allocatable keyword for the dummy argument), but it returns 1 1 1 for the fixed-shape array.
The standard suggests that it should also have the lower bounds of the actual argument in the latter case.

Cheers,

John

(PS: gfortran 5.2.0 returns 1 1 1 as the lower bounds, both for the allocatable and the fixed-shape array.)
0 積分
3 回應
Kevin_D_Intel
員工
730 檢視

Thank you for the post. I submitted this to Development.

(Internal tracking id: DPD200377056)

(Resolution Update on 02/22/2016): This defect is fixed in the Intel® Parallel Studio XE 2016 Update 2 Release (PSXE 2016.2.062/ CnL 2016.2.181 - Linux)

John_D_6
新貢獻者 I
730 檢視

I see that this problem was resolved in Intel Fortran 16.0.2. Many thanks!

Kevin_D_Intel
員工
730 檢視

Thank you for your post. Yes, that is correct. You beat me to the confirmation/verification. As you noted, this is fixed in the recently announced PSXE 2016 Update 2 release (PSXE 2016.2.062/ CnL 2016.2.181 - Linux)

回覆