Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

ifort 11.1 undefined reference

dnoack
Beginner
2,720 Views
Hello,

using ifort 9.1 or 10.1 my program compiles without any errors. With ifort 11.1 I get some "undefined reference to `myfunc_' ". That means, that ifort cannot find myfunc, although this function is at the beginning of the same source file and the same module as the later call in a subroutine.

Does anyone know, if the ifort 11.1 contains a bug?

Best regards
dnoack
0 Kudos
1 Solution
mecej4
Honored Contributor III
2,721 Views
Remove ",dpythag" from the end of line-4, because its redeclaration there supersedes the module procedure dpythag and inserts a call to an external routine with the same name. Since there is no such external routine presented to the linker, an undefined reference results.

View solution in original post

0 Kudos
7 Replies
Ron_Green
Moderator
2,721 Views
no bugs that would be as obvious as you claim this is.

Let's see the source file.

ron
0 Kudos
dnoack
Beginner
2,721 Views
I Have generated a short example which doesn't compile wit ifort 11.0, but compile without any errors with ifort 9.1 and 10.1. What is wrong with this example?

module mod_impl
contains
subroutine sub
double precision :: a,b,c,dpythag
a=1.d0
b=2.d0
c=dpythag(a,b)
end subroutine sub
function dpythag(a,b)
double precision :: a,b,dpythag
dpythag=a*dsqrt(1.d0+(b/a)**2.d0)
end function dpythag
end module mod_impl
program myprog
use mod_impl
call sub
end

0 Kudos
mecej4
Honored Contributor III
2,722 Views
Remove ",dpythag" from the end of line-4, because its redeclaration there supersedes the module procedure dpythag and inserts a call to an external routine with the same name. Since there is no such external routine presented to the linker, an undefined reference results.
0 Kudos
dnoack
Beginner
2,721 Views
Thank you, this solve the problem.
But why ifort 9.1 and 10.1 don't complains about this?
0 Kudos
mecej4
Honored Contributor III
2,721 Views
I do not have those versions at hand, but here is the output from Version 7.0:

Intel Fortran Compiler for 32-bit applications, Version 7.0 Build 20021028Z
Copyright (C) 1985-2002 Intel Corporation. All rights reserved.

EPC Fortran-95 Version F95 Intel:200200:131124
Copyright (c) 1993-2000 EPCL. All Rights Reserved.
impl.f90
module MOD_IMPL
module subroutine SUB
module function DPYTHAG
program MYPROG

17 Lines Compiled
Microsoft Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

-out:impl.exe
impl.obj
impl.obj : error LNK2001: unresolved external symbol _DPYTHAG
impl.exe : fatal error LNK1120: 1 unresolved externals

Note that reporting errors with old versions gets you little unless the same errors also beset the current versions.
0 Kudos
TimP
Honored Contributor III
2,721 Views
It was noticed at the time, that those compilers implemented the reference incorrectly, allowing it to be resolved by the module function. We had a discussion about the merits of the case on the forum.
0 Kudos
Steven_L_Intel1
Employee
2,721 Views
I discuss this particular issue here.
0 Kudos
Reply