LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Error: Ambiguous interfaces Fortran (https://www.linuxquestions.org/questions/programming-9/error-ambiguous-interfaces-fortran-699959/)

tak.rliu 01-26-2009 10:52 AM

Error: Ambiguous interfaces Fortran
 
I'm wrote a Fortran program to do analysis;

It seems to install fine on my OpenSuse 10.3; but when I try to compile it on my OpenSuse 11.0, it gives me this error after I type "$make"

gfortran -g -I"src/mod" -J"src/mod" -o src/obj/mod_quaternion.o -c src/derivedType/mod_quaternion.f90
src/derivedType/mod_quaternion.f90:455.47:

Imultiplication_q2,Rmultiplication_q2
1
Error: Ambiguous interfaces 'rmultiplication_q2' and 'rmultiplication_q' in intrinsic '*' operator at (1)
make: *** [mod_quaternion.o] Error 1

I know I'm not giving a lot of details here; but could anyone shed some light as to what the problem might be? Especially the part about the ambiguous interfaces.

paulsm4 01-27-2009 11:42 PM

That's the FORTRAN compiler's way of telling you it's confused about how you want to multiply "i * x". It knows "i" is an integer, and it knows "x" is some kind of real ... but it wants you to better specify exactly what kind of "real".

This link might help:
http://www.sesp.cse.clrc.ac.uk/Publi...re/node11.html

tak.rliu 01-28-2009 09:36 AM

Code:

interface operator ( * )
                module procedure Imultiplication_q,Rmultiplication_q,&
                                                    multiplication_q,multiplication_q2,&
                                                    Imultiplication_q2,Rmultiplication_q2
end interface

function Imultiplication_q(i,q1)result(q)

                implicit none
                integer,intent(in)::i
                type(quaternion),intent(in)::q1
                type(quaternion)::q
                q%a=i*(q1%a)
                q%v=i*(q1%v)

        end function Imultiplication_q

        function Imultiplication_q2(q1,i)result(q)

                implicit none
                integer,intent(in)::i
                type(quaternion),intent(in)::q1
                type(quaternion)::q
                q%a=i*(q1%a)
                q%v=i*(q1%v)

        end function Imultiplication_q2


        function Rmultiplication_q(a,q1)result(q)

                implicit none
                real(kind=double),intent(in)::a
                type(quaternion),intent(in)::q1
                type(quaternion)::q
                q%a=a*q1%a
                q%v=a*q1%v

        end function Rmultiplication_q

        function Rmultiplication_q2(a,q1)result(q)

                implicit none
                real(kind=double),intent(in)::a
                type(quaternion),intent(in)::q1
                type(quaternion)::q
                q%a=a*q1%a
                q%v=a*q1%v

        end function Rmultiplication_q2

I'm pretty sure it's declared; kind=double. Is there anything else I should try?

paulsm4 01-28-2009 01:08 PM

Sorry - I didn't realize that *you* were trying to code "explicit interfaces". I thought you were trying to get some legacy F77 (or older) code to compile in a Fortran 90/95 environment.

I don't have any experience with explicit interfaces (new, I believe, in Fortran 90). Here are a couple of links that might help:

http://www.physicsforums.com/showthread.php?t=237380
http://books.google.com/books?id=40U...A468#PPA458,M1

PS:
Maybe the problem would go away if you *didn't* use the explicit interfaces. Or at least didn't attempt to override any operators - but used functions, instead.

Just a thought .. PSM

tak.rliu 01-29-2009 08:27 AM

Haha; thanks anyways, I figured it out.

Explicit Interfaces are the way of the future for Fortran.


All times are GMT -5. The time now is 06:47 AM.