- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How about ifort modf1.f90 temp.f90 -o ..... ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
just for curiosity, why do you have it has a .txt file instead of directly a .f90 file?

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page