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

Compiler Error

Michael8
Beginner
955 Views

Hello:

I am getting a compiler error, and was able to narrow it down to a test case.  The error is: The shapes of the array expressions do not conform.

I am using the 14.0.3.202 version of the compiler.  When I switch back to version 12.0.5.221, it compiles just fine.

Here is the sample code:

module TestMod


   implicit none
   private

   character (len = 100), dimension(5) :: charArr

contains

!******************************************************************************

   character (len = 100) function GetCharArr()
      dimension :: GetCharArr(5)
      GetCharArr = charArr
   end function GetCharArr

!******************************************************************************

end module TestMod

Can anyone explain to me why I'm getting this error message, or, if it is possibly a compiler issue?

Thanks.
Michael

0 Kudos
6 Replies
Steven_L_Intel1
Employee
955 Views

It's a compiler bug. If you do it this way instead, it works:

function GetCharArr()
      character(len=100),dimension(5) :: GetCharArr

I prefer this version as it keeps all the declaration in one place. For some reason the use of LEN= throws it off here. I will report this to the developers and will let you know of any progress. Thanks. Issue ID is DPD200362719.

0 Kudos
Michael8
Beginner
955 Views

Thank you for the quick reply, and for the workaround.

I'll look forward to hearing about progress,

Thanks.
Michael

0 Kudos
FortranFan
Honored Contributor III
955 Views

Steve Lionel (Intel) wrote:

It's a compiler bug. If you do it this way instead, it works:

function GetCharArr()
      character(len=100),dimension(5) :: GetCharArr

I prefer this version as it keeps all the declaration in one place. For some reason the use of LEN= throws it off here. I will report this to the developers and will let you know of any progress. Thanks. Issue ID is DPD200362719.

Michael,

In addition to Steve's suggestion, the following is also an option which provides both flexibility with respect to defining the function result as well as making it more readable:

   FUNCTION GetCharArr() RESULT(RetArr)
      
      !.. Function result
      CHARACTER(LEN = 100) :: RetArr(5)
      
      RetArr = charArr
      
   END FUNCTION GetCharArr

Also, consider adding the PURE attribute to FUNCTION subprograms as the compiler can help flag if the function has "side effects" beyond returning what it is supposed to.

0 Kudos
Steven_L_Intel1
Employee
955 Views

I expect this bug to be fixed in Update 2.

0 Kudos
Michael8
Beginner
955 Views

Thanks.  Just curious about the expected release date for Update 2?

Michael

0 Kudos
Steven_L_Intel1
Employee
955 Views

Looks like early February.

0 Kudos
Reply