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

SPREAD and UNPACK not accepted in constant expressions

Harald
Beginner
649 Views
Hello all, it appears that SPREAD and UNPACK are still not accepted in constant expressions: program ifort_unpack implicit none integer, parameter :: set(5) = (/ 11,12,13,14,15 /) integer, parameter :: sel(2) = (/ 12,14 /) logical, parameter :: mask(size(set)) = & any (spread (set,2,size(sel)) == & spread (sel,1,size(set)), dim=2) integer :: i integer, parameter :: idx(size(set)) = & unpack (vector = (/ (i,i=1,size(set)) /), & mask = mask, & field = 0 ) print *, idx end program ifort_unpack % ifort -V ifort-unpack.f90 Intel(R) Fortran Compiler XE for applications running on IA-32, Version 13.0.1.117 Build 20121010 Copyright (C) 1985-2012 Intel Corporation. All rights reserved. FOR NON-COMMERCIAL USE ONLY Intel(R) Fortran 13.0-2074 ifort-unpack.f90(6): error #6263: This intrinsic function is invalid in constant expressions. [SPREAD] any (spread (set,2,size(sel)) == & ------------^ ifort-unpack.f90(7): error #6263: This intrinsic function is invalid in constant expressions. [SPREAD] spread (sel,1,size(set)), dim=2) ------------^ ifort-unpack.f90(10): error #6263: This intrinsic function is invalid in constant expressions. [UNPACK] unpack (vector = (/ (i,i=1,size(set)) /), & -------^ compilation aborted for ifort-unpack.f90 (code 1) I could not find any corresponding restriction in the F2k3 and F2k8 draft, so I assume that there should be none. (If I remember correctly, it was illegal for SPREAD in F95) Harald
0 Kudos
4 Replies
Steven_L_Intel1
Employee
649 Views
This is a F2003 feature we have not completely implemented yet - transformational intrinsics in constant expressions.
0 Kudos
Harald
Beginner
649 Views

Steve Lionel (Intel) wrote:

This is a F2003 feature we have not completely implemented yet - transformational intrinsics in constant expressions.

I just checked the above code with

Intel(R) Fortran Compiler XE for applications running on IA-32, Version 15.0.0.090 Build 20140723

and still get the above error messages.  Do you envisage when there will be progress?

Harald

 

0 Kudos
Steven_L_Intel1
Employee
649 Views

There are a handful of intrinsics not yet implemented, but we're working to get those done. Do you have an application using these?

0 Kudos
Harald
Beginner
649 Views

I find SPREAD very convenient, but cannot yet use it in constant expressions for portable code.  Since it works with most other Fortran compilers, I tend to forget this.

UNPACK is a little bit exotic, and there are probably few situations where it needs to be evaluated at compile time.

Harald

 

0 Kudos
Reply