Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29393 Обсуждение

Internal compiler error (C0000005) when compiling simple function in a module

larixpjm
Начинающий
2 128Просмотр.

This simple program compiles:

PROGRAM test_chr
IMPLICIT NONE
WRITE(*,*) int2str0(12,5)

CONTAINS

FUNCTION int2str0(I,Pos)
INTEGER, INTENT(IN) :: I
INTEGER, INTENT(IN) :: Pos
CHARACTER(LEN=Pos) :: int2str0
INTEGER :: j

WRITE(int2str0,'(I<Pos>)',IOSTAT=j) I
IF(j /= 0) THEN
WRITE(*,*) 'Error: Pos parameter too small!'
STOP
END IF
j = INDEX(int2str0,' ',.TRUE.)
int2str0(1:j) = REPEAT('0',j)
END FUNCTION int2str0

END PROGRAM test_chr

However, when I put this function inside a module, e.g.,

 

MODULE util
IMPLICIT NONE
CONTAINS

FUNCTION int2str0(I,Pos)
INTEGER, INTENT(IN) :: I
INTEGER, INTENT(IN) :: Pos
CHARACTER(LEN=Pos) :: int2str0
INTEGER :: j

WRITE(int2str0,'(I<Pos>)',IOSTAT=j) I
IF(j /= 0) THEN
WRITE(*,*) 'Error: Pos parameter too small!'
STOP
END IF
j = INDEX(int2str0,' ',.TRUE.)
int2str0(1:j) = REPEAT('0',j)
END FUNCTION int2str0

END MODULE util

 

the compiler throws the error with the message:

xfortcom: Fatal: There has been an internal compiler error (C0000005).

What is the problem here?

0 баллов
6 Ответы
Ron_Green
Модератор
2 110Просмотр.

We will get a bug report on this.  Reproducer is:

MODULE util
IMPLICIT NONE
CONTAINS

FUNCTION int2str0(I,Pos)
INTEGER, INTENT(IN) :: I
INTEGER, INTENT(IN) :: Pos
CHARACTER(LEN=Pos) :: int2str0
INTEGER :: j

WRITE(int2str0,'(I<Pos>)',IOSTAT=j) I
IF(j /= 0) THEN
WRITE(*,*) 'Error: Pos parameter too small!'
STOP
END IF
j = INDEX(int2str0,' ',.TRUE.)
int2str0(1:j) = REPEAT('0',j)
END FUNCTION int2str0

END MODULE util

Thank you for sending this to us.

 

FortranFan
Почетный участник III
2 072Просмотр.

Thanks Ron for the follow-up to the original post.

 

It may help Intel Support team as well as readers to note the internal compiler error occurs with IFX,  Classic compiler viz. IFORT v2021.7 didn't throw such an error.

 

I checked IFORT out of concern for a senior scientist colleague (a hobbyist legacy FORTRAN 77 style coder who writes some code for some individual tasks at work) who has a similar functions to convert numeric types to strings and uses IFORT as part of Intel oneAPI. 

larixpjm
Начинающий
1 693Просмотр.

I think I have found a temporary solution for this problem - I added a local variable and used it in the format clause.

FUNCTION int2str0(I,Pos)
INTEGER, INTENT(IN) :: I
INTEGER, INTENT(IN) :: Pos
CHARACTER(LEN=Pos) :: int2str0
INTEGER :: j, p
p = Pos
WRITE(int2str0,'(I<p>)',IOSTAT=j) I
IF(j /= 0) THEN
WRITE(*,*) 'Error: Pos parameter too small!'
STOP
END IF
j = INDEX(int2str0,' ',.TRUE.)
int2str0(1:j) = REPEAT('0',j)
END FUNCTION int2str0

 

Xiaoping_D_Intel
Сотрудник
2 077Просмотр.

The error has been reproduced and escalated with a bug report. I will let you know when there is an update on it.


larixpjm
Начинающий
1 881Просмотр.

I still have the same error when compiled with the newest compiler version oneAPI 2023.0...

Devorah_H_Intel
Модератор
1 439Просмотр.

The fix will be in 2024.0 Intel Fortran Compiler.

Ответить