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

Module issues

Elsayed_A_
Beginner
580 Views

Hello,

The attached file contains some functions and subroutines. The program works fine without putting the functions and subroutines in the module. However, when I use the module I got the following error.

1>testprog.f90
1>Linking...
1>testprog.obj : error LNK2019: unresolved external symbol _FUNC1 referenced in function _XXX_mp_ROCKPROP
1>testprog.obj : error LNK2019: unresolved external symbol _FUNC2 referenced in function _XXX_mp_ROCKPROP
1>Debug\testprog.exe : fatal error LNK1120: 2 unresolved externals

 

Could you please, the source of this issue?

Regards548408

0 Kudos
3 Replies
mecej4
Honored Contributor III
580 Views

If you wish to call subroutines and use functions that are inside a module, you have to include a USE statement for the module in your calle\ing program unit. If you do not do so, the caller will issue references to external names such as FUNC1, but the OBJ file produced from the module will have decorated names which will not match. Similarly, if you have a USE xxx statement, you should not declare FUNC1 and FUNC2 as external. 

0 Kudos
andrew_4619
Honored Contributor III
580 Views

As alluded to in #2, the line "REAL(KIND=8),external :: FUNC1,FUNC2" is the problem and should be removed. In this case they are in the same module so can be automatically seen by ROCKPROP​. Declaring as external is telling the compiler to look elsewhere. 

0 Kudos
Elsayed_A_
Beginner
580 Views

I have removed the external declaration for FUNC1, FUNC2, AND FUNC. Now it is working fine. 

Thanks for your enlightened replies. 

0 Kudos
Reply