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

Problem with -Idir

flyglede
Beginner
394 Views
HPC->pwd

/home/micro/compphys/y/mod



HPC->cat mod.f90

module datad

real:: x

endmodule datad



HPC->ifort -c mod.f90



HPC->ls

datad.mod mod.f90 mod.o



HPC->cd ../

HPC->ls

main.f90 mod



HPC->cat main.f90

PROGRAM MAIN

use datad

implicit none

x=1.0

print*,x

end PROGRAM MAIN



HPC->ifort main.f90 -I/home/micro/compphys/y/mod

/tmp/ifortCCs17A.o(.text+0x52): In function `MAIN__':

: undefined reference to `datad_mp_x_'



HPC->ifort -V

Intel Fortran Itanium Compiler for Itanium-based applications

Version 9.0 Build 20050624 Package ID: l_fc_c_9.0.024



But the PGI fortran compiler can do.

Can you help me? Thanks.

Message Edited by flyglede on 11-30-2005 03:52 PM

0 Kudos
3 Replies
Steven_L_Intel1
Employee
394 Views
You have to include on the command that does the link the .o file(s) from the separate module compilations.
0 Kudos
flyglede
Beginner
394 Views
Thank you, but I don't see such limitation from intel fortran online help:

---------------------------------------------------------------------------------------------------

1. From: /opt/intel/fc/9.0/doc/main_for/mergedProjects/copts_for/fortran_options/option_i_ucase_f.htm

I: Specifies a directory to add to the include path.

Description

This option specifies a directory to add to the include path, which is searched for module files referenced in USE statements and include files referenced in INCLUDE statements.

---------------------------------------------------------------------------------------------------

2. From: /opt/intel/fc/9.0/doc/main_for/mergedProjects/bldaps_for/fced_mod.htm

---------------------------------------------------------------------------------------------------

Working with Multi-Directory Module Files



For an example of managing modules when the .mod files could be produced in different directories, assume that the program mod_def.f90 resides in directory /usr/yourdir/test/t, and this program contains a module defined as follows:



file: mod_def.f90

module definedmod

.

.

.

end module



The compiler command:



ifort -c mod_def.f90



produces two files: mod_def.o and definedmod.mod in directory /usr/yourdir/test/t.



If you need to use the above .mod file in another directory, for example, in directory /usr/yourdir/test/t2, where the program usemod uses the definedmod.mod file, do the following:



file: use_mod_def.f90

program usemod

use definedmod

.

.

.

end program



To compile the above program, use this command:



ifort -c use_mod_def.f90 -I/usr/yourdir/test/t



where the -Idir option provides the compiler with the path to search and locate the definedmod.mod file.

---------------------------------------------------------------------------------------------------





But if I use the codes from
/opt/intel/fc/9.0/doc/main_for/mergedProjects/bldaps_for/ug1l_mod_prog.htm

it works! The difference is no variables out of interface.

---------------------------------------------------------------------------------------------------

HPC->pwd

/home/micro/compphys/in

HPC->ls

array_calc.f90

HPC->ifort -c array_calc.f90

HPC->ls

array_calc.f90 array_calc.o array_calculator.mod

HPC->cd ..

HPC->ls

calc_aver.f90 in main.f90

HPC->ifort main.f90 calc_aver.f90 -I/home/micro/compphys/in/

HPC->ls

a.out calc_aver.f90 in main.f90

---------------------------------------------------------------------------------------------------

Message Edited by flyglede on 12-06-2005 11:47 AM

0 Kudos
flyglede
Beginner
394 Views
Thank you very much!

But I don't see such limitation from intel fortran online help:
---------------------------------------------------------------------------------------------------
1. From: /opt/intel/fc/9.0/doc/main_for/mergedProjects/copts_for/fortran_options/option_i_ucase_f.htm
I: Specifies a directory to add to the include path.
Description
This option specifies a directory to add to the include path, which is searched for module files referenced in USE statements and include files referenced in INCLUDE statements.
---------------------------------------------------------------------------------------------------
2. From: /opt/intel/fc/9.0/doc/main_for/mergedProjects/bldaps_for/fced_mod.htm
---------------------------------------------------------------------------------------------------
Working with Multi-Directory Module Files

For an example of managing modules when the .mod files could be produced in different directories, assume that the program mod_def.f90 resides in directory /usr/yourdir/test/t, and this program contains a module defined as follows:

file: mod_def.f90
module definedmod
.
.
.
end module

The compiler command:

ifort -c mod_def.f90

produces two files: mod_def.o and definedmod.mod in directory /usr/yourdir/test/t.

If you need to use the above .mod file in another directory, for example, in directory /usr/yourdir/test/t2, where the program usemod uses the definedmod.mod file, do the following:

file: use_mod_def.f90
program usemod
use definedmod
.
.
.
end program

To compile the above program, use this command:

ifort -c use_mod_def.f90 -I/usr/yourdir/test/t

where the -Idir option provides the compiler with the path to search and locate the definedmod.mod file.
---------------------------------------------------------------------------------------------------


But if I use the codes from /opt/intel/fc/9.0/doc/main_for/mergedProjects/bldaps_for/ug1l_mod_prog.htm
it works! The difference is no variables out of interface.
---------------------------------------------------------------------------------------------------
HPC->pwd
/home/micro/compphys/in
HPC->ls
array_calc.f90
HPC->ifort -c array_calc.f90
HPC->ls
array_calc.f90 array_calc.o array_calculator.mod
HPC->cd ..
HPC->ls
calc_aver.f90 in main.f90
HPC->ifort main.f90 calc_aver.f90 -I/home/micro/compphys/in/
HPC->ls
a.out calc_aver.f90 in main.f90
0 Kudos
Reply