- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey,
I am trying to compile the following code in Visual Fortran (compiler version 11.0.066):
program simple
include 'mpif.h'
integer numtasks, rank, ierr, rc
call MPI_INIT(ierr)
if (ierr .ne. MPI_SUCCESS) then
print *,'Error starting MPI program. Terminating.'
call MPI_ABORT(MPI_COMM_WORLD, rc, ierr)
end if
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, numtasks, ierr)
print *, 'Number of tasks=',numtasks,' My rank=',rank
! ****** do some work ******
call MPI_FINALIZE(ierr)
end
I get the error: Error 1 fatal error LNK1107: invalid or corrupt file: cannot read at 0x416B C:\Program Files\Intel\MPI\3.2.1.009\ia32\include\mpif.h 1
As mentioned in another thread I have added "additional libraries" under linker options: C:\Program Files\Intel\MPI\3.2.1.009\ia32\include plus mpif.h under Input-> additional dependencies.
Do I need to change the compiler to mpif90.bat? If so, how is this done in Visual Studio.
Thank you very much,
Benjamin
I am trying to compile the following code in Visual Fortran (compiler version 11.0.066):
program simple
include 'mpif.h'
integer numtasks, rank, ierr, rc
call MPI_INIT(ierr)
if (ierr .ne. MPI_SUCCESS) then
print *,'Error starting MPI program. Terminating.'
call MPI_ABORT(MPI_COMM_WORLD, rc, ierr)
end if
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, numtasks, ierr)
print *, 'Number of tasks=',numtasks,' My rank=',rank
! ****** do some work ******
call MPI_FINALIZE(ierr)
end
I get the error: Error 1 fatal error LNK1107: invalid or corrupt file: cannot read at 0x416B C:\Program Files\Intel\MPI\3.2.1.009\ia32\include\mpif.h 1
As mentioned in another thread I have added "additional libraries" under linker options: C:\Program Files\Intel\MPI\3.2.1.009\ia32\include plus mpif.h under Input-> additional dependencies.
Do I need to change the compiler to mpif90.bat? If so, how is this done in Visual Studio.
Thank you very much,
Benjamin
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do not put the .h file under "Additional Dependencies" in the linker property - that is the cause of the error. The folder containing that file should go under "Additional INCLUDE Directories" in the Fortran properties.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
Do not put the .h file under "Additional Dependencies" in the linker property - that is the cause of the error. The folder containing that file should go under "Additional INCLUDE Directories" in the Fortran properties.
Error 3 error LNK2019: unresolved external symbol _MPI_COMM_RANK referenced in function _MAIN__ main.obj
(All other MPI commands cannot be found either)
I have included the path C:Program FilesIntelMPI3.2.1.009ia32include as additional compiler and linker paths but still receive this error. Both files, mpif.h and mpi.h (this one has the mpi commands i need) are in the path.
Any ideas what is going wrong here?
Thanks ,
Benjamin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is not sufficient to list the library folder - you will need to add the name of the library. You can put this under "Additional Dependencies" in the Linker property page. I do not know, offhand, what the right library name is to use. Read the Intel MPI documentation to see which libraries are to be used. There may be more than one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
It is not sufficient to list the library folder - you will need to add the name of the library. You can put this under "Additional Dependencies" in the Linker property page. I do not know, offhand, what the right library name is to use. Read the Intel MPI documentation to see which libraries are to be used. There may be more than one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - tim18
The mpiifort script could be used (in place of ifort) in the ifort command line window to find out which MPI libraries are linked. With the additional option -# these details are displayed.
Now to allow for multiple threads it is necessary to start the executable with mpiexec.exe instead of ifort.exe. Luckily I found a C++ tutorial for integrating MPI into Visual Studio (http://supercomputingblog.com/mpi/getting-started-with-mpi-using-visual-studio-2008-express/). To make it short, adding C:Program FilesIntelMPI3.2.1.009ia32binmpiexec.exe as command in debugging under properties and -n 2 $(TargetPath) under command arguments enables the use of two cores. Works perfectly!
The last thing remaining is to enable the debugger. I could not find information on this in the reference manual (except for I_MPI_DEBUG). Does anyone know if there is a way to get debugging to work for MPI code within Visual Studio?
Thanks,
Benjamin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have read all above and still have a question:
HOW TO LINK mpif.h to the iFORTRAN (11)project in VISUAL STUDIO 2008, because no fluent answer was given.
Please, who have successfully made it, describe the procedure step-by-step.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You don't link against header files. You add their folder to the include path, and set the fpp preprocessing option. The MPI compiler wrappers, such as mpif90, mpiifort,... take care of this, as well as linking the corresponding libraries, for you, when you use command line.

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