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

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

larixpjm
Beginner
1,504 Views

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 Kudos
6 Replies
Ron_Green
Moderator
1,486 Views

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
Honored Contributor III
1,448 Views

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. 

0 Kudos
larixpjm
Beginner
1,069 Views

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

 

0 Kudos
Xiaoping_D_Intel
Employee
1,453 Views

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


0 Kudos
larixpjm
Beginner
1,257 Views

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

0 Kudos
Devorah_H_Intel
Moderator
815 Views

The fix will be in 2024.0 Intel Fortran Compiler.

0 Kudos
Reply