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

How to include header file in command line

CO_Traut
Beginner
1,112 Views
Hi, there

I have three files, a.inc, b.f90, and c.f90. Now I want to compile the three files via command line on Mac. How to include the header file a.inc? which command should I use.

Thanks much.
0 Kudos
4 Replies
Kevin_D_Intel
Employee
1,112 Views

If a.inc is included using an INCLUDE statement then no additional command line options are needed if all three files reside in the same directory since the compiler defaults to searching the "current working directory". If they do not reside in the same directory then use the -I (capital "I") option to specify additional include search directories.

If a.inc is included using a #include statement, then you must add the -fpp option and any appropriate include paths using -I if the files do not reside in the same directory.
0 Kudos
CO_Traut
Beginner
1,112 Views

If a.inc is included using an INCLUDE statement then no additional command line options are needed if all three files reside in the same directory since the compiler defaults to searching the "current working directory". If they do not reside in the same directory then use the -I (capital "I") option to specify additional include search directories.

If a.inc is included using a #include statement, then you must add the -fpp option and any appropriate include paths using -I if the files do not reside in the same directory.
Hi, Kevin

Thanks much. Here is the command line I used:
ifort MPALE_SVD.INC MPALE_SVD_SHELL.f90 MPALE_SVD_SUB.f90 -L$MKLROOT -L$LIBRARY_PATH -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread

Error information is:
MPALE_SVD.INC(51): error #6406: Conflicting attributes or multiple declaration of name. [C11]
PARAMETER (C11 = 2465.0D8)
-----------------^
MPALE_SVD.INC(52): error #6406: Conflicting attributes or multiple declaration of name. [C12]
PARAMETER (C12 = 1473.0D8)
-----------------^
MPALE_SVD.INC(53): error #6406: Conflicting attributes or multiple declaration of name. [C44]
PARAMETER (C44 = 1247.0D8)
-----------------^
MPALE_SVD.INC(54): error #6406: Conflicting attributes or multiple declaration of name. [HARDMODUL]
PARAMETER (HARDMODUL =5.34D8)
-----------------^
MPALE_SVD.INC(55): error #6406: Conflicting attributes or multiple declaration of name. [SYMFLAG]
PARAMETER (SYMFLAG = 1)
-----------------^
MPALE_SVD.INC(56): error #6406: Conflicting attributes or multiple declaration of name. [EPFLAG]
PARAMETER (EPFLAG = 1)
-----------------^
MPALE_SVD.INC(57): error #6406: Conflicting attributes or multiple declaration of name. [CRSS]
PARAMETER (CRSS = 60.D6)
-----------------^
MPALE_SVD.INC(58): error #6406: Conflicting attributes or multiple declaration of name. [TAUS]
PARAMETER (TAUS = 122.0D6)
-----------------^
MPALE_SVD.INC(60): error #6406: Conflicting attributes or multiple declaration of name. [EPI]
PARAMETER (EPI = 100.)
-----------------^


If I am right, the .inc file is already used, but there is something wrong with my parameter definition?

Part of my environment .sh file is:
#!/bin/sh

export MKLROOT="/opt/intel/Compiler/11.1/058/Frameworks/mkl"

if [ -z "${INCLUDE}" ]
then
export INCLUDE="${MKLROOT}/Headers"
else
export INCLUDE="${MKLROOT}/Headers:$INCLUDE"
fi


best,

0 Kudos
Kevin_D_Intel
Employee
1,112 Views

When including a file via INCLUDE or #include,you do not specify it on the ifort command line.

The errors seem to suggest MPALE_SVD.INC was already includedby one of the other .f90 files being compiled but hard to tell without seeing the full context of the errors.

Try removing MPALE_SVD.INC from the ifort command line.
0 Kudos
CO_Traut
Beginner
1,112 Views

When including a file via INCLUDE or #include,you do not specify it on the ifort command line.

The errors seem to suggest MPALE_SVD.INC was already includedby one of the other .f90 files being compiled but hard to tell without seeing the full context of the errors.

Try removing MPALE_SVD.INC from the ifort command line.
You are right, Kevin.

Thanks for your help.
0 Kudos
Reply