PURE function in INTERFACE block not resolved as being a function

Mark Hesselink mhesseli@caltech.edu
Fri Jun 3 02:04:00 GMT 2005


Dear developers,

First of all, thanks for your quick response on my previous email. The 
patch suggested by Tobi indeed solves my problem.

As mentioned in the subject, a PURE function that is part of an 
INTERFACE block is not resolved as being a function. Gfortran gives the 
following warning for the code attached at the end of this email:

module_procedure-1.f90: In function 'show':
module_procedure-1.f90:30: warning: unused variable 'test'

I am using GNU Fortran 95 (GCC 4.1.0 20050602 (experimental)) on Darwin 
7.9.0.

Thanks,

Mark

---

MODULE procedures
    PUBLIC               :: test

    PRIVATE              :: test1,test2

    INTERFACE test
       MODULE PROCEDURE test1,test2
    END INTERFACE test
CONTAINS
    PURE FUNCTION test1 (x) RESULT(r)
       REAL(KIND(0.0d0)), INTENT(IN) :: x
       REAL(KIND(0.0d0))             :: r

       r=x+1.0d0
    END FUNCTION test1

    PURE FUNCTION test2 (x) RESULT(r)
       REAL(KIND(0.0d0)), DIMENSION(:), INTENT(IN)  :: x
       REAL(KIND(0.0d0)), DIMENSION(SIZE(x))        :: r

       FORALL (i=1:SIZE(x))
          r(i)=x(i)+1.0d0
       END FORALL
    END FUNCTION test2
END MODULE procedures

MODULE actions
    USE procedures
CONTAINS
    SUBROUTINE show (x)
       REAL(KIND(0.0d0)), DIMENSION(:)        :: x
       REAL(KIND(0.0d0)), DIMENSION(SIZE(x))  :: d

       d=test (x)
       WRITE (*,'(F8.6)') d
    END SUBROUTINE show
END MODULE actions

PROGRAM module_procedure_1
    USE actions

    REAL(KIND(0.0d0)), DIMENSION(2)  :: x

    x=(/ 1.0d0,0.0d0 /)

    CALL show (x)

END PROGRAM module_procedure_1




More information about the Fortran mailing list