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

SIZE intrinsic function does not work on scalars

Arjen_Markus
Honored Contributor I
364 Views

I have noticed that the SIZE intrinsic function does not work on scalar - it does work on assumed-rank arguments that are actually scalars, whereas the Fortran 2018 standard allows this.

Here is a sample program to demonstrate it.

! chkrank.f90 --
!     Check an idea regarding ranks and scalars ...
!
program chkrank
    implicit none

    integer :: x

    call printsize( x )

    !
    ! This is not allowed ... take it out and the program runs fine
    !
    write(*,*) size(x)

contains
subroutine printsize( y )
    integer :: y(..)

    write(*,*) size(y)
end subroutine printsize
end program chkrank

 

0 Kudos
4 Replies
Arjen_Markus
Honored Contributor I
360 Views

Hm, I just got a message that this conclusion is NOT actually valid. So, perhaps my post should throw up the question whether this is allowed or not. It does seem like an unnecessary restriction, but I may be too hasty in concluding that.

0 Kudos
Steve_Lionel
Honored Contributor III
348 Views

"ARRAY shall be assumed-rank or an array."

FortranFan
Honored Contributor II
324 Views

@Arjen_Markus ,

Your post is rather confusing, the comment in the code snippet is the opposite to your statement with "whereas the Fortran 2018 standard allows this" in the post.  So it's all fuzzy as to what is the point here, particularly in the context of Intel Fortran.

As you appear to have realized later, the current Fortran 2018 standard is clear on this, as pointed out by @Steve_Lionel : the argument to the SIZE intrinsic "shall be assumed-rank or an array" and Intel Fortran compiler detects and reports nonconformance.  So perhaps you agree there is nothing further to discuss on this forum?  You can follow-up elsewhere if you propose any changes for Fortran 202Y or later revisions?

0 Kudos
Arjen_Markus
Honored Contributor I
287 Views

Indeed, the matter is quite clear. I stumbled upon this matter as part of a larger conversation regarding some of the new features in Fortran 2023 and we thought that somehow Intel Fortran was incorrect (gfortran version 10.2.0 issues the same complaint, but that is a relatively old version). Therefore the question we discussed transcends the current standard and has nothing specific to do with the compiler.

0 Kudos
Reply