Hello,
I have been playing around with the following example:
PROGRAM test IMPLICIT NONE INTEGER, PARAMETER :: max_str_len = 32 CHARACTER(LEN=max_str_len) :: str INTEGER :: i str = '7' CALL Load(str, i) WRITE(*, *) "i = ", i CONTAINS SUBROUTINE Load(str, val) CHARACTER(LEN = max_str_len), INTENT(IN) :: str CLASS(*), INTENT(INOUT) :: val SELECT TYPE(val) TYPE IS(INTEGER) READ(str, *) val TYPE IS(REAL) READ(str, *) val TYPE IS(CHARACTER(*)) READ(str, *) val END SELECT END SUBROUTINE END PROGRAM
When I try to compile it with
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.1.5.339 Build 20120612
using -O0, the code compiles, nevertheless it produces a segmentation fault. Using -On for n>=1, ifort meets
its demise by stating that "catastrophic error: **Internal compiler error".
However, ifort "Version 13.0.1.117 Build 20121010" seems to produce the expected result "i = 7".
Interestingly, a slighly modified version of the subroutine works even with ifort v 12, namely:
SUBROUTINE Load(str, val) CHARACTER(LEN = max_str_len), INTENT(IN) :: str CLASS(*), INTENT(INOUT) :: val INTEGER :: i REAL :: z CHARACTER(LEN=max_str_len) :: str_temp SELECT TYPE(val) TYPE IS(INTEGER) READ(str, *) i val = i TYPE IS(REAL) READ(str, *) z val = z TYPE IS(CHARACTER(*)) READ(str, *) str_temp val = str_temp END SELECT END SUBROUTINE
Therefore it looks like that the "catastrophic error" is caused by presence of a CLASS(*) variable
in the READ statement. However, within the SELECT TYPE section, this should be a valid
construct, shouldn't it?