This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ALLOCATABLE actual argument and the need for an explicit interface.


I stumbled across a subroutine (here rendered as the main program) in the vast sea of procedures of our newest weather forecasting model that's essentially like this:

      REAL, ALLOCATABLE :: A(:)
      INTERFACE
         SUBROUTINE SUB(C,M)
         REAL    :: C(:)
         INTEGER :: M
         END SUBROUTINE SUB
      END INTERFACE
      READ*,N
      ALLOCATE(A(N))
      CALL SUB(A,N)
      DEALLOCATE(A)
      END
      SUBROUTINE SUB(B,I)
      REAL :: B(:)
      PRINT*,I,SIZE(B)
      END

but then without the explicit INTERFACE definition of subroutine SUB.

Without the INTERFACE definition, I get a bogus value for SIZE(B) in the penultimate line of the code (probably more is wrong, too, if you assign to B ;-).

I tried to find the list of specifics that make explicit INTERFACE definitions necessary before calling a subroutine in the Fortran 2003 Standard, but couldn't find it.

Does anyone have a quick pointer ?

Thanks,

--
Toon Moene - e-mail: toon@moene.org - phone: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
At home: http://moene.org/~toon/
Progress of GNU Fortran: http://gcc.gnu.org/gcc-4.5/changes.html


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]