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

Assumed Rank Character Variable Fails in Select Rank Statement

CarlB
Beginner
2,555 Views

 

Hello everyone,

 

This function compiles with all data types using gfortran. ifort, however, fails if I try to define a behaviour for rank(0). Higher ranks do work, including rank default.

Minimal example:

subroutine sub(c)
character(*), intent(in) :: c(..)

select rank(c)
rank(0)
   print*, 0
end select
end subroutine sub

 Result:

$ ifort -c ./src/lib.f90 -warn all -check all -error-limit 1 -O0 -g -assume byterecl -traceback -module build/ifort_5C58216731706F11/testingrange -Ibuild/ifort_5C58216731706F11/testingrange  -o build/ifort_5C58216731706F11/testingrange/src_lib.f90.o
./src/lib.f90(10): error #5529: CHARACTER variable 'C' has no length argument in routines with C or STDCALL attribute
select rank(c)
------------^

 Compiler provided by my company:

ifort (IFORT) 19.1.2.254 20200623

 

Is this a bug or a feature? At least the error message isn't that clear.

I assume it has something to do with the additional len parameter of the character type. But I'm curious because it does compile and work with gfortran.

 

Best,
Carl

0 Kudos
1 Solution
Barbara_P_Intel
Employee
2,497 Views

I got the same wrong error message with the current compiler release, 2021.3.0. I filed a bug report, CMPLRIL0-34096, on your behalf. I'll keep you posted on its progress to a fix.



View solution in original post

0 Kudos
8 Replies
Steve_Lionel
Honored Contributor III
2,532 Views

Bug.

0 Kudos
Barbara_P_Intel
Employee
2,498 Views

I got the same wrong error message with the current compiler release, 2021.3.0. I filed a bug report, CMPLRIL0-34096, on your behalf. I'll keep you posted on its progress to a fix.



0 Kudos
CarlB
Beginner
2,449 Views

Thank you for clarifying and for the bug report!

0 Kudos
Devorah_H_Intel
Moderator
2,239 Views

The fix will be available in the next oneAPI release. 

0 Kudos
MarkBuehner
Beginner
1,122 Views

I'm having the same error with inteloneapi-2022.1.2. Is it fixed in a later version? If so, which one?

Thanks!

0 Kudos
Steve_Lionel
Honored Contributor III
1,106 Views

The example compiles successfully in the current ifx version (2025.1.0)

0 Kudos
MarkBuehner
Beginner
976 Views

Thanks so much!

0 Kudos
ethanmusk89
Beginner
803 Views

You're spot on — the issue arises due to how ifort handles character arguments with assumed-rank and missing length metadata, especially for rank(0). Unlike gfortran, ifort expects a length parameter even if the rank is zero, and that’s why the compiler throws that error. It’s not exactly a bug, but more of a strict interpretation of Fortran standards in Intel’s implementation.

I ran into a similar issue while testing assumed-rank character handling across compilers and shared a few insights and workarounds here :executordelta.com — might be useful if you're aiming for cross-compiler compatibility.

0 Kudos
Reply