Overload problem



I use g95 to compile the code below and met an error:

*Error:Ambiguous interfaces 'print_try4' and 'print_try3' in
generic
interface 'print_try'
at (1)*

How to solve this problem? Thanks in advance!

The following is my code:

PROGRAM main

IMPLICIT NONE

INTEGER,DIMENSION(:),ALLOCATABLE::try1
INTEGER,DIMENSION(:),POINTER::try2
INTEGER::i,j,k


INTERFACE print_try
MODULE PROCEDURE print_try3
MODULE PROCEDURE print_try4
END INTERFACE print_try

ALLOCATE(try1(10))
ALLOCATE(try2(10))
DO i=1,10
try1(i)=1
try2(i)=2
END DO
CALL print_try(try1)

DEALLOCATE(try1)
DEALLOCATE(try2)

CONTAINS
SUBROUTINE print_try3(a)
IMPLICIT NONE
INTEGER,DIMENSION(:),ALLOCATABLE::a
INTEGER::n,i

n=SIZE(a)
DO i=1,n
WRITE(*,*) n,a(i)
END DO
END SUBROUTINE print_try3

SUBROUTINE print_try4(b)
IMPLICIT NONE
INTEGER,DIMENSION(:),POINTER::b
INTEGER::n,i

n=SIZE(b)
DO i=1,n
WRITE(*,*) n,b(i)
END DO
END SUBROUTINE print_try4
END PROGRAM main

.



Relevant Pages

  • Re: generic INTERFACE and name clash
    ... I would define the generic interface name and all of the specifics in one module. ... Unfortunately, the name FOO does not give me the foggiest ideas of what the subroutine does, so I cannot think of a more descriptive subroutine name. ... Module Procedure Foo_I2 ...
    (comp.lang.fortran)
  • Re: compiler switch -c
    ... All methods must be exposed by interface. ... module procedure fruit_summary_ ... end subroutine init_fruit_ ... character, intent, optional:: message ...
    (comp.lang.fortran)
  • Re: generic interface question
    ... MODULE procedure foo1,foo2,foo3 ... SUBROUTINE foo2 ... Is that actually what the compiler says, ... INTERFACE odinit ...
    (comp.lang.fortran)
  • Re: Passing pointers to subroutines in other modules
    ... in one module to a subroutine in another module. ... people talk about needing an interface ... You do need an explicit interface, ... anything like that will tell the compiler that it is not a module procedure. ...
    (comp.lang.fortran)
  • TRANSFER arbitrary data ? (long)
    ... subroutine to minimize a function of n variables, ... end interface ... that to an integer array and back. ... subroutine minimize(Func, x, context) ...
    (comp.lang.fortran)