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

ifort can't find references to external calls/types

admin2
Beginner
1,383 Views
I actually posted this in the wrong forum (Visual Fortran for Windows, http://software.intel.com/en-us/forums/showthread.php?t=66489), so I'm reposting here:

I'm trying to compile DL_POLY v3.10 :

http://www.cse.scitech.ac.uk/ccg/software/DL_POLY/

but get this error:

mpif90 -c -ip -O3 comms_module.f90
comms_module.f90(638): error #6404: This name does not have a type, and must have an explicit type. [MPI_WTIME]
tzero = MPI_WTIME()

"mpif90 -echo" returns (i.e. what is mpif90 really running):

+ '[' no = no ']'
+ unset 'allargs[0]'
++ expr 0 + 1
+ argno=1
+ '[' 1 -eq 0 ']'
+ '[' no = yes ']'
+ mpilibs='-lmpichf90 -lmpich'
+ F90FLAGS=
+ LDFLAGS=' '
+ '[' -n '' ']'
+ '[' -z -I ']'
+ F90INCDIRS=-I/sb/apps/mvapich2/Linux2/1.4rc2/x86_64-icc/include
+ moduledir=/sb/apps/mvapich2/Linux2/1.4rc2/x86_64-icc/include
+ modulelib=mpichf90
+ '[' -n '' ']'
+ '[' -n -I ']'
+ F90MODDIRS=-I/sb/apps/mvapich2/Linux2/1.4rc2/x86_64-icc/include
+ F90MODLIBS=-lmpichf90
+ '[' yes = yes ']'
+ '[' -n '' ']'
+ ifort -I/sb/apps/mvapich2/Linux2/1.4rc2/x86_64-icc/include -I/sb/apps/mvapich2/Linux2/1.4rc2/x86_64-icc/include -L/sb/apps/mvapich2/Linux2/1.4rc2/x86_64-icc/lib -lmpichf90 -lmpichf90 -lmpich -lpthread -lrdmacm -libverbs -libumad -lrt
/sb/apps/intel/intel_fc_11/lib/intel64/for_main.o: In function `main':
/export/users/nbtester/efi2linux_nightly/branch-ubs-11_1/20090512_000000/libdev/frtl/src/libfor/for_main.c:(.text+0x38): undefined reference to `MAIN__'
+ rc=1
+ '[' -n '' ']'
+ exit 1

The code compiles fine when mpif90 uses gfortran, i.e. when we use mvapich2 compiled with g++/gcc/gfortran and gfortran to compile DL_POLY. Here's a table I made to show how I compiled the dependencies to show what works and what doesnt:

| mvapich2 | dl_poly | dl_poly finished compiling ? | dl_poly finished linking? |
| gcc/gfortran/g++ | gfortran | yes | yes |
| gcc/gfortran/g++ | ifort | no, error #6404 | N/A |
| ifort/icc | gfortran | yes | no |
| ifort/icc | ifort | no, error #6404 | N/A |

The reason why dl_poly wouldn't link with the icc/ifort compiled mvapich2 and the gfortran compiled dl_poly is understandable because there are references to intel specific calls like __intel_ssee2_strlen and _intel_fast_memcpy that aren't in libgfortran, etc so I ended up getting errors like this during linking:

/gcc/x86_64-redhat-linux/4.1.2/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crtn.o
/sb/apps/mvapich2/Linux2/1.4rc2/x86_64-icc/lib/libmpich.a(file_openf.o): In function `pmpi_file_open_':
/sb/apps/mvapich2/mvapich2-1.4rc2/src/binding/f77/file_openf.c:132: undefined reference to `_intel_fast_memcpy'

For the case where I tried the gcc/g++/gfortran compiled mvapich2 and then tried to use ifort to compile DL_POLY, I also tried ifort versions 8 - 10 but they all returned the same error #6404. There were some mentions of trying "fpp", which I looked up in the ifort man page but I don't really understand how to use to try to get this to compile with ifort.
0 Kudos
19 Replies
TimP
Honored Contributor III
1,383 Views
Now that you've decided to discuss linux rather than Windows, you still need to build mvapich2 (at least the Fortran libraries) with ifort and use the resulting mpif90 or equivalent. The mvapich2 gfortran library .a or .so won't work with ifort, although the gcc libraries should be OK. You must keep your mvapich2 ifort and gfortran support and builds separate. This ought to be explained in the mvapich2 instructions.
0 Kudos
Steven_L_Intel1
Employee
1,383 Views

The issue is simply whether or not the program unit that gets this error contains an INCLUDE of 'mpif.h' where that file, in the INCLUDE path, declares MPI_WTIME. It would appear, for the configuration you are using, that it does not.
0 Kudos
admin2
Beginner
1,383 Views
arg, another double post, ffx seems to just sit (no message in the status bar that data was sent to intel.com) after I click submit post, but it really ends up submitting it. The page doesn't go back to the forum thread until I click submit post again.
0 Kudos
admin2
Beginner
1,383 Views
Quoting - tim18
Now that you've decided to discuss linux rather than Windows, you still need to build mvapich2 (at least the Fortran libraries) with ifort and use the resulting mpif90 or equivalent. The mvapich2 gfortran library .a or .so won't work with ifort, although the gcc libraries should be OK. You must keep your mvapich2 ifort and gfortran support and builds separate. This ought to be explained in the mvapich2 instructions.

That's the setup I'm using but ifort doesn't seem to like the semantics in this application where MPI_WTIME is used but gfortran has no problems with it. We've compiled other applications, e.g. Amber, with ifort/icc using mvapich2 compiled with intel compilers (same environment/same setup as this), i.e. so we know all of this should work.


The issue is simply whether or not the program unit that gets this error contains an INCLUDE of 'mpif.h' where that file, in the INCLUDE path, declares MPI_WTIME. It would appear, for the configuration you are using, that it does not.


Well it does:

% grep mpif comms_module.f90
Include 'mpif.h'

and it is declared as mentioned in my earlier post, showing you it again:

% grep MPI_WTIME /sb/apps/mvapich2/Linux2/1.4rc2/x86_64-icc/include/mpif.h
INTEGER MPI_WTIME_IS_GLOBAL
PARAMETER (MPI_WTIME_IS_GLOBAL=1681915912)
EXTERNAL MPI_WTIME, MPI_WTICK
EXTERNAL PMPI_WTIME, PMPI_WTICK
REAL*8 MPI_WTIME, MPI_WTICK
REAL*8 PMPI_WTIME, PMPI_WTICK

Furthermore, gfortran would not be able to compile this if that include line wasn't in there. Watch what happens when I comment it out:

% grep mpif.h comms_module.f90
! Include 'mpif.h'

Now try to compile with gfortran:

mpif90 -c -ip -O3 comms_module.f90
In file comms_module.f90:27

status(1:MPI_STATUS_SIZE) = 0
1
Error: Symbol 'mpi_status_size' at (1) has no IMPLICIT type
In file comms_module.f90:27

Same thing happens with ifort:

mpif90 -c -ip -O3 comms_module.f90
comms_module.f90(27): error #6562: A data initialization-expr is not valid for this object. [STATUS]
status(1:MPI_STATUS_SIZE) = 0

Now I put it back in:

% grep mpif.h comms_module.f90
Include 'mpif.h'

and ifort only blows up on the usage of MPI_WTIME but understands all the other MPI_ calls and types:

mpif90 -c -ip -O3 comms_module.f90
comms_module.f90(638): error #6404: This name does not have a type, and must have an explicit type. [MPI_WTIME]
tzero = MPI_WTIME()
---------------^

So you see, ifort seems to only be having a problem with the declaration and usage of MPI_WTIME. Again, gfortran understands all of the code in DL_POLY and the declarations in mpif.h but ifort does not. Why?




0 Kudos
Steven_L_Intel1
Employee
1,383 Views
Please attach mpi_comms.f90 to a reply here so we can see the actual source. That there is a single INCLUDE in the file does not mean it is everywhere needed.
0 Kudos
admin2
Beginner
1,383 Views
Please attach mpi_comms.f90 to a reply here so we can see the actual source. That there is a single INCLUDE in the file does not mean it is everywhere needed.

Attached.
0 Kudos
Steven_L_Intel1
Employee
1,383 Views
Thanks. It's what I thought. Subroutine gtime references MPI_WTIME but does not include mpif.h and has IMPLICIT NONE. ifort is correct in reporting an error. I can't explain why gfortran doesn't do the same.
0 Kudos
admin2
Beginner
1,383 Views
Thanks. It's what I thought. Subroutine gtime references MPI_WTIME but does not include mpif.h and has IMPLICIT NONE. ifort is correct in reporting an error. I can't explain why gfortran doesn't do the same.

So exactly what do I do to fix this error? I put:

Include 'mpif.h'

under Implicit None in the gtime subroutine but it didn't make a difference, same error.
0 Kudos
Mike_Rezny
Beginner
1,383 Views

So exactly what do I do to fix this error? I put:

Include 'mpif.h'

under Implicit None in the gtime subroutine but it didn't make a difference, same error.
Hi,
I tried to compile your comms_module.f90, but I will need the source for kinds_f90.
Can you please post this source as well.
0 Kudos
Mike_Rezny
Beginner
1,383 Views

The issue is simply whether or not the program unit that gets this error contains an INCLUDE of 'mpif.h' where that file, in the INCLUDE path, declares MPI_WTIME. It would appear, for the configuration you are using, that it does not.
Hi Steve,
unless I am mistaken including 'mpif.h' after implicit none at the top of the module
will provide the necessary declarations for all the subroutines declared in this module.

Basically, the short version is:

Module comms_module
implicit none
include 'mpif.h'

Contains
Subroutine gtime(time)
implicit none

time = MPI_WTIME()

End Subroutine gtime
End Module comms_module


Now comes the weirdness:
On the original file, as posted
commenting out
!Use kinds_f90
and adding
integer, parameter :: wp = 8

satisfies the declarations.

Without adding the include 'mpif.h' in subroutine gtime, intel MPI and Intel fortran 11.1.046 compiles without error.

I then Unloaded the Intel MPI module and loaded mvapich2/0.9.8-12
This source file still compiles without error.

So, I am not yet convinced it is a Intel Fortran compiler problem.

Is it possible, that the mpif.h file being looked at is not the one being used in the preprocessing step.

I would try compiling with -i and looking at the preprocessed source to see what is being included.
A simple grep is not enough if code is being surrounded by #def that are false at compile time.

regards
Mike

0 Kudos
Steven_L_Intel1
Employee
1,383 Views
You are correct that including mpif.h at the top of the module would define those values for all contained routines. In the code originally provided, the routine where the error occurred was an external routine, not a module procedure.

I did not see any evidence that preprocessing was being used.
0 Kudos
admin2
Beginner
1,383 Views
Quoting - Mike Rezny
Hi,
I tried to compile your comms_module.f90, but I will need the source for kinds_f90.
Can you please post this source as well.

I've attached kinds_f90.f90
0 Kudos
admin2
Beginner
1,383 Views
Quoting - Mike Rezny
Is it possible, that the mpif.h file being looked at is not the one being used in the preprocessing step.


Argh!!! That was it. These guys include :

mpif.h -> SERIAL/mpif.h

in the same directory! I just moved it out of the way for true MPI compilation and everything compiled and linked fine. I guess the difference here was that ifort always looks in the local directory for include files before what's given in -I arguments . Gfortran looks in the -I path first.



0 Kudos
Mike_Rezny
Beginner
1,383 Views

Argh!!! That was it. These guys include :

mpif.h -> SERIAL/mpif.h

in the same directory! I just moved it out of the way for true MPI compilation and everything compiled and linked fine. I guess the difference here was that ifort always looks in the local directory for include files before what's given in -I arguments . Gfortran looks in the -I path first.



Hi,
great, that your problem has been found.

This possibility occured to me last night while I was in the shower but you found it before I got in this morning.

I had a very similar problem on a global climate model that decided to put a 'netcdf.h' fil ein the source directory.
The original users had declared that the code would only work with one particular version of netcdf (the one that matched the included header file.

Since then I always do a "ls -l *.h" in every source directory. (Well when I still remember).

regards
Mike
0 Kudos
james118
Beginner
1,383 Views

Argh!!! That was it. These guys include :

mpif.h -> SERIAL/mpif.h

in the same directory! I just moved it out of the way for true MPI compilation and everything compiled and linked fine. I guess the difference here was that ifort always looks in the local directory for include files before what's given in -I arguments . Gfortran looks in the -I path first.




I'm have a similar problem, albeit when trying to compile in serial (not MPI):

node18:source root$ make intel
make LD="/opt/intel/Compiler/11.1/056/bin/ia32/ifort -o"
LDFLAGS="-fast -fpp"
FC="/opt/intel/Compiler/11.1/056/bin/ia32/ifort -c"
LCFLAGS="-fast -fpp"
EX=DLPOLY.Y BINROOT=../execute master
make[1]: Entering directory `/home/DL_Poly/dl_poly_3.10/source'
DL_POLY_3 compilation in SRL2 mode

'Use mpi_module' must be uncommented in 'comms_module.f90'

/opt/intel/Compiler/11.1/056/bin/ia32/ifort -c comms_module.f90
comms_module.f90(638): error #6404: This name does not have a type, and must have an explicit type. [MPI_WTIME]
tzero = MPI_WTIME()
---------------^
compilation aborted for comms_module.f90 (code 1)
make[1]: *** [comms_module.o] Error 1

I understand that the previous person solved the problem by somehow modifying the mpif.h -> SERIAL/mpif.h link. I tried removing the mpif.h link, but that seemed to make things worse. Can anyone help me?

Thanks for your help.

James

ps, this is the first time that I've ever compiled anything with a self-made makefile.
0 Kudos
Mike_Rezny
Beginner
1,383 Views
Quoting - james118

I'm have a similar problem, albeit when trying to compile in serial (not MPI):

node18:source root$ make intel
make LD="/opt/intel/Compiler/11.1/056/bin/ia32/ifort -o"
LDFLAGS="-fast -fpp"
FC="/opt/intel/Compiler/11.1/056/bin/ia32/ifort -c"
LCFLAGS="-fast -fpp"
EX=DLPOLY.Y BINROOT=../execute master
make[1]: Entering directory `/home/DL_Poly/dl_poly_3.10/source'
DL_POLY_3 compilation in SRL2 mode

'Use mpi_module' must be uncommented in 'comms_module.f90'

/opt/intel/Compiler/11.1/056/bin/ia32/ifort -c comms_module.f90
comms_module.f90(638): error #6404: This name does not have a type, and must have an explicit type. [MPI_WTIME]
tzero = MPI_WTIME()
---------------^
compilation aborted for comms_module.f90 (code 1)
make[1]: *** [comms_module.o] Error 1

I understand that the previous person solved the problem by somehow modifying the mpif.h -> SERIAL/mpif.h link. I tried removing the mpif.h link, but that seemed to make things worse. Can anyone help me?

Thanks for your help.

James

ps, this is the first time that I've ever compiled anything with a self-made makefile.
Hi,

It looks like you are trying to compile using ifort and not mpiifort
using only ifort means the compiler does not know where the MPI include filesor libraries are located.
mpiifort is a wrapper script that calls ifort and adding amongst other things the required include and library paths.

regards
Mike
0 Kudos
james118
Beginner
1,383 Views
Quoting - Mike Rezny
Hi,

It looks like you are trying to compile using ifort and not mpiifort
using only ifort means the compiler does not know where the MPI include filesor libraries are located.
mpiifort is a wrapper script that calls ifort and adding amongst other things the required include and library paths.

regards
Mike

Hello Mike,

Thanks for your reply. I can't find where to obtain the mpiifort script. It didn't come with the intel fortran compiler. I found another forum post saying that it is provided with "Intel MPI" however I can't find where to download that.

Would you be able to point me in the right direction?

Thanks for your help.

James
0 Kudos
Mike_Rezny
Beginner
1,383 Views
Quoting - james118

Hello Mike,

Thanks for your reply. I can't find where to obtain the mpiifort script. It didn't come with the intel fortran compiler. I found another forum post saying that it is provided with "Intel MPI" however I can't find where to download that.

Would you be able to point me in the right direction?

Thanks for your help.

James

It sounds like you have the Intel Fortran compiler installed but you don't have the Intel MPi libraries.
That is an extrapackage. Sorry, but I can't help you much with that. You will have to download it from the Intel site.
You will need one of the cluster Toolkits or maybe just the Intel MPI Library.

Look at:
http://software.intel.com/en-us/articles/code-downloads/

regards
Mike
0 Kudos
TimP
Honored Contributor III
1,383 Views
In Intel MPI, mpiifort is the wrapper which specifically invokes ifort, while mpif90 invokes gfortran. In open source MPI, typically, you must rebuild the MPI against ifort, and then mpif90 or mpif77 will incorporate ifort. You will not be able to link against libraries built with an incompatible Fortran. You would expect useful relevant documentation on the support site for your chosen MPI.
0 Kudos
Reply