Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Missed optimization on SHAPE intrinsic

styc
Beginner
523 Views

Compile the following program with ifort 13.1.0.146. You would expect the compiler not to create a temporary copy of x(:,:,:,1,2) in subroutine f. But it does. Using UBOUND seems to be a viable workaround.

[fortran]

program test

    double precision, allocatable :: x(:, :, :, :, :)

    double precision y(200, 200, 200, 2, 2)

    integer n1, n2, n3, n4, n5

    read *, n1, n2, n3, n4, n5

    allocate(x(n1, n2, n3, n4, n5))

    call f(x)

    call f(y)

    contains

    subroutine f(x)

        double precision x(:, :, :, :, :)

        print *, shape(x(:, :, :, 1, 2))

    end subroutine

end program[/fortran]

0 Kudos
2 Replies
Steven_L_Intel1
Employee
523 Views

Thanks - I agree that this is a missed opportunity, I have escalated it to the developers as issue DPD200242784.

0 Kudos
Anonymous66
Valued Contributor I
523 Views

A fix has been found for this issue. We are currently planning to include in the next major release which is currently scheduled for later this year.

Annalee

0 Kudos
Reply