Catastrophic compiler error

Catastrophic compiler error

The following code gives a catastrophic compiler error:

      CHARACTER(*) FUNCTION fmt(rr)
      REAL*8 :: rr
      CHARACTER(LEN=LEN(fmt)) :: cc
      WRITE(cc,'(4g13.5)') rr
      IF(cc == '      0.00000') cc = '  0.00000'
      fmt = cc

D:\Devl.OLI\OLIEngines\src\asap>ifort a.for
Intel(R) Visual Fortran Compiler Professional for applications running on IA-32, Version 11.1    Build 20100414 Package ID: w_cprof_
Copyright (C) 1985-2010 Intel Corporation.  All rights reserved.

a.for(4): catastrophic error: **Internal compiler error: internal abort** Please report this error along with the circumstances in w
hich it occurred in a Software Problem Report.  Note: File and line given may not be explicit cause of this error.
      CHARACTER(LEN=LEN(fmt)) :: cc
compilation aborted for a.for (code 3)

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I thought I had seen everything...  I don't think this usage is legal, but in any case an internal compiler error is the wrong response. I will let the developers know - thanks. The issue ID is DPD200244699.

Looking at what the standard allows in a specification expression, fmt is not a dummy argument, COMMON variable nor is it accessed by use or host association. So the only clause that might allow it is:

22 (9) a specification inquiry where each designator or function argument is
23 (a) a restricted expression or
24 (b) a variable whose properties inquired about are not
25 (i) dependent on the upper bound of the last dimension of an assumed-size array,
26 (ii) deferred, or
27 (iii) defined by an expression that is not a restricted expression,

I think LEN(fmt) fails all of these. The length is not "deferred" in the way the standard means it - that would mean LEN=:.

A CHARACTER(*) function is a deprecated feature and is often misunderstood. I recommend avoiding it.

Retired 12/31/2016

Thanks Steve, just need to make one minor fix to the code (I can't edit it for some reason) - remove the "4" from the write statement.

You can remove the whole WRITE statement and still get the error. It has to do with the use of LEN(FMT) when declaring cc.

Retired 12/31/2016

How would you write this code without using a character(*) function?

I am not completely certain what you want to do, but perhaps something like this:

module fmtmod
implicit none
function fmt (rr)
character(:), allocatable :: fmt
real(8), intent(in) :: rr
! Initially allocate result to 13 characters for the write
allocate (character(13) :: fmt)
write (fmt,'(G13.5)') rr
fmt = trim(fmt)
end function fmt
end module fmtmod

You would need to USE FMTMOD to make this accessible - I did this because an explicit interface is required and this is the easiest way.

Retired 12/31/2016

In a future release, the compiler will give a reasonable error message for this case.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today