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

problem with Array bounds check with CHARACTER *

Gary_Quinn_At_Teessi
621 Views
Hi.

I'm trying to debug an old FORTRAN program with the help of -CB to check array bounds, and have come across an error which doen't make any sense to me. Below is a simplified version of the problem.

The program fails with
"forrtl: severe (408): fort: (18): Dummy character variable 'OPTION' has length 136 which is greater then actual variable length 80"

I don't understand why it should fail when passing a smaller *(80) array into a larger *(136) array - but passing a *(136) into a *(80) is ok ?

Am I doing something silly ?

Thanks in anticipation,
Gary.


PROGRAM CHARTEST

C ifort -g -CB chartest.F

CHARACTER *(80) INP

INP = "TEST"
CALL BCD84(INP)
END


SUBROUTINE BCD84(OPTION)

CHARACTER*(136) OPTION

PRINT *,"OPTION = '",OPTION,"'"
RETURN

END

0 Kudos
1 Solution
Steven_L_Intel1
Employee
621 Views

Actually, it is not ok to pass a (80) array to a (136) array, but the compiler does not have the ability to report the error.

The code you have would access characters past the end of INP and is not legal Fortran. What you should do is declare OPTION to be CHARACTER(*) so that it takes on the length of the argument.

View solution in original post

0 Kudos
2 Replies
Steven_L_Intel1
Employee
622 Views

Actually, it is not ok to pass a (80) array to a (136) array, but the compiler does not have the ability to report the error.

The code you have would access characters past the end of INP and is not legal Fortran. What you should do is declare OPTION to be CHARACTER(*) so that it takes on the length of the argument.
0 Kudos
Gary_Quinn_At_Teessi
621 Views

What you should do is declare OPTION to be CHARACTER(*) so that it takes on the length of the argument.


Many Thanks Steve, that fixed it :-)

Gary.

0 Kudos
Reply