Pergunta

Well, I've this problem (the description is long, but I think it is easy to solve) . I've three files:

nrtype.f90, which have some stupid definitions, but it is used by the following files:

module nrtype
    integer, parameter :: I4B = SELECTED_INT_KIND(9)
    integer, parameter :: I2B = SELECTED_INT_KIND(4)
    integer, parameter :: I1B = SELECTED_INT_KIND(2)
    integer, parameter :: SP = KIND(1.0)
    integer, parameter :: DP = KIND(1.0D0)
endmodule nrtype

LUd.f90, which makes part of the work:

module descomposicionLU
    use nrtype

    implicit none

contains

subroutine LUd(A, LU, bk)
    implicit none

    real(DP), intent (in), dimension(:,:)                 :: A
    real(DP), intent (out), dimension(:,:)                :: LU
    integer(I2B), dimension(size(A,1),2)                  :: bk

        <more code that doesn't worth to mention>

endsubroutine LUd

<more code that doesn't worth to mention>

endmodule descomposicionLU

A file called FrontBackSub.f90, which does the other part of the work:

module FrontBack

    use nrtype

    implicit none

contains

function FrontSLU(A,B) result (X)
    implicit none
    real(DP), dimension(:,:), intent (in)       :: A, B
    real(DP), dimension(size(B,1),size(B,2))    :: X

     <more code>

endfunction FrontSLU

endmodule FrontBack

And finallymain.f90, which is something like this:

program main
    use descomposicionLU
    use FrontBack

    implicit none

    integer, parameter                      :: N=3
    real(DP), dimension(N,N)                :: MA, MLU
    integer(I2B), dimension(N,2)            :: Vbk


    MA(1,:)=(/1.0,   7.0,     11.0/)
    MA(2,:)=(/14.0,  24.0,    19.0/)
    MA(3,:)=(/7.0,   8.0,     9.0/)

    call LUd(MA, MLU, Vbk)

endprogram main

But, the issue comes during compilation, with ifort nrtype.f90 FrontBackSub.f90 LUd.f90 FrontBackSub.f90 main.f90 i've got:

/tmp/ifortbW2y7D.o: In function `frontback._':
FrontBackSub.f90:(.text+0x0): multiple definition of `frontback._'
/tmp/ifortVQdBCN.o:FrontBackSub.f90:(.text+0x0): first defined here
/tmp/ifortbW2y7D.o: In function `frontback_mp_frontslu_':
FrontBackSub.f90:(.text+0x10): multiple definition of `frontback_mp_frontslu_'
/tmp/ifortVQdBCN.o:FrontBackSub.f90:(.text+0x10): first defined here
/tmp/ifortbW2y7D.o: In function `frontback_mp_backs_':
FrontBackSub.f90:(.text+0x460): multiple definition of `frontback_mp_backs_'
/tmp/ifortVQdBCN.o:FrontBackSub.f90:(.text+0x460): first defined here

Or, more clear, with gfortran nrtype.f90 FrontBackSub.f90 LUd.f90 FrontBackSub.f90 main.f90:

/tmp/ccpZnjOp.o: In function `__frontback_MOD_backs':
FrontBackSub.f90:(.text+0x0): multiple definition of `__frontback_MOD_backs'
/tmp/ccsr4QjQ.o:FrontBackSub.f90:(.text+0x0): first defined here
/tmp/ccpZnjOp.o: In function `__frontback_MOD_frontslu':
FrontBackSub.f90:(.text+0x582): multiple definition of `__frontback_MOD_frontslu'
/tmp/ccsr4QjQ.o:FrontBackSub.f90:(.text+0x582): first defined here
collect2: error: ld returned 1 exit status

So, it says that the functions (it is plural because when I add new functions the issue expand to them) in FrontBackSub.f90 are defined several times which, clearly, the are not.

Where is the problem that I can't see?

Thanks for your time pals.

Foi útil?

Solução

Why do you have the source FrontBackSub.f90 two times in the compile command? Just don't do that.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top