error #6897

error #6897

Just upgraded to Composer XE 2011 and code that compiled in IVF 9 through 11 but not fails with the error message:

error #6897: An interface-block in a subprogram must not contain an interface-body for a procedure defined by that subprogram.

I cannot find any help on this error. The source file only contains a single interface block with several interface definitions and the compiler error is thrown for only some of the routine definitions.

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

Later versions of the compiler do more thorough checking of code.  Interfaces may become available through USE statements, so their presence is easy to overlook.

Please present example code that can be used to display the error message. Here is an example that produces an error message with the 13.1 compiler but not with the 11.1 compiler.

subroutine sub(a,b)
implicit none
integer, intent(in) :: a
integer, intent(out) :: b
interface
  subroutine sub(c,d)
  integer, intent(in) :: c,d
  end subroutine sub
end interface

b=f(a)
return

contains

integer function f(d)
integer, intent(in) :: d


f=d*d

return
end function f

end subroutine sub

 

See the psuedo-code below trying to explain the project:

program test
     use ifport
     use <MyLib1>
     use <MyLib2>
     include <stuff>
     include _interfaces.f90
     call sub0(parameters)
     call sub1(parameters)
end program test

in the source file _interfaces.f90:

interface
     subroutine sub0(parameters)
          include <stuff>  ! same as in main, global parameters
          <I/O variable declarations>
     end subroutine sub0
     subroutine sub1(parameters)
          use ifport, only: ...
          use <MyLib1>
          include <stuff>   ! same as in main, global parameters
          <I/O variable declarations>
     end subroutine sub1
end interface

This is a much larger project and I trying to demonstrate the code structure.

Best Reply

The Fortran language does not allow "interface to self" - you can't INCLUDE a file that declares the interface to a procedure you are also defining. There's not enough in your pseudocode to know which the problem is. For example, if <stuff> included an interface for sub0, that would be an error.

The usefulness of "interface to self" has been discussed extensively by the standards committee, but it never gained enough support to add and I think some issues were raised that blocked further work (I don't remember the details.)

Steve

<stuff> would only contain data type info, constants, etc to quickly propagate code changes. No routines or interfaces would be defined in the <stuff> source file.

Then please show us a complete source file that demonstrates the error.

Steve

Resolved; the issue was essentially an 'interface-to-self' caused by including a file that defined the routine interface to the routine source file itself. It is a trivial error once you understand what the message is telling you.

Login to leave a comment.