- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The error has been reproduced and escalated with a bug report. I will let you know when there is an update on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I still have the same error when compiled with the newest compiler version oneAPI 2023.0...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The fix will be in 2024.0 Intel Fortran Compiler.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page