- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Gary Quinn At Teesside
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.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page