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

Problems with compiling external modules

webbj
Beginner
668 Views
I have written a simple program to open a module with two functions. the main program is supposed to use one of the functions to calculate a temperature conversion. The main program is titled temp.txt of which I transform into a temp.f90 as well as the module mod.txt which is transfomred into a mod.f90 file. I then use the command ifort temp.f90 mod1.f90 -o program to compile them together and create an executable. However, the compiler tells me that it does not recognize the USE Temp_Lib command and tells me to check INCLUDE paths. It also tells me that the term Fah_to_Cel does not have a type and must have an explicit type. I think it tells me this because it is having trouble accessing the module to see that the type is defines. The program and module are listed after this paragraph. What do I need to do to get this program and module to compile together? These are not written on one text file, the program represents one text file, the module represents another.

PROGRAM Temp_Conv
USE Temp_Lib
IMPLICIT NONE
REAL(8) :: Fah_Temp,Cel_Temp
WRITE(*,'(1X,A)',ADVANCE="NO") "Enter Fahrenheit Temperature: "
READ*,Fah_Temp
Cel_Temp=Fah_to_Cel(Fah_Temp)
WRITE(*,10) "The Celsius Temperature is: ",Cel_Temp
10 FORMAT(A27,3X,f10.4)
END PROGRAM Temp_Conv

MODULE Temp_Lib

CONTAINS
FUNCTION Fah_to_Cel(Temp)
REAL(8) :: Fah_to_Cel
REAL(8), INTENT(IN) :: Temp
Fah_to_Cel=(Temp-32)/1.8
END FUNCTION Fah_to_Cel

FUNCTIONCel_to_Fah
REAL(8) :: Cel_to_Fah
REAL(8), INTENT(IN) :: Temp
Cel_to_Fah=1.8*Temp+32
END FUNCTION Cel_to_Fah
END MODULE Temp_Lib


0 Kudos
3 Replies
TimP
Honored Contributor III
668 Views

How about ifort modf1.f90 temp.f90 -o ..... ?
0 Kudos
Steven_L_Intel1
Employee
668 Views
As Tim suggests, the source of the module must be compiled before any USE of that module is seen. You may want to add a -o to name the executable.
0 Kudos
rreis
New Contributor I
668 Views
just for curiosity, why do you have it has a .txt file instead of directly a .f90 file?
0 Kudos
Reply