Search code examples
debuggingfortranfortran77formatted

Fortran formatted write function triggers "has exited with code 408 (0x198)" on IF Composer 2013


When following Fortran code is executed on the Intel Fortran Composer 2013 the compiler triggers a breakpoint at write function and retuns code 408:

       character*20  date_char
       character*10  LADATE

       ...
       if (date_char(3:3) .EQ. "") date_char(3:3)="0"
       if (date_char(7:7) .EQ. "") date_char(7:7)="0"
       write(LADATE,"(2A2,A4)")
     S date_char(3:4),date_char(7:8),date_char(9:12)

It is a fixed line-length format and the S represents the line continuation.

The date_char has a value of ' 29 012013 ' and the LADATE ' '

As soon as the write statement is reached the debugger triggers a breakpoint and the Call Stack shows following system functions being called:

for_issue_diagnostics() _for_emit_diagnostics()

Your time is appreciated


Solution

  • The problem was that the LADATE variable was actually a call-by-reference argument (FORTRAN77 default passing convention):

       SUBROUTINE MDATE(LADATE)
    
       character*20  date_char
       character*10  LADATE
       ...
       write(LADATE,"(2A2,A4)")
     S date_char(3:4),date_char(7:8),date_char(9:12)
    
       RETURN
       END
    

    and it was passed as an argument several subroutines above as a just an 8-character string. Simply written, the call would be equivalent to:

       ...
       CHARACTER VAR*20
       ...
       CALL MDATE(VAR(10:17))
       ...
    

    The program started, but after an attempt to access an inaccessible array addresses by the write function the breakpoint was triggered.