Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Annonces
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

ifort 11.1 undefined reference

dnoack
Débutant
2 740 Visites
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 Compliments
1 Solution
mecej4
Contributeur émérite III
2 741 Visites
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.

Voir la solution dans l'envoi d'origine

0 Compliments
7 Réponses
Ron_Green
Modérateur
2 741 Visites
no bugs that would be as obvious as you claim this is.

Let's see the source file.

ron
0 Compliments
dnoack
Débutant
2 741 Visites
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 Compliments
mecej4
Contributeur émérite III
2 742 Visites
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 Compliments
dnoack
Débutant
2 741 Visites
Thank you, this solve the problem.
But why ifort 9.1 and 10.1 don't complains about this?
0 Compliments
mecej4
Contributeur émérite III
2 741 Visites
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 Compliments
TimP
Contributeur émérite III
2 741 Visites
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 Compliments
Steven_L_Intel1
Employé
2 741 Visites
I discuss this particular issue here.
0 Compliments
Répondre