Problem enabling 64 bit Fortran compilation on Windows using Intel OneAPI with Cmake on Windows

Hi,

I am trying to enable 64 bit integer size for a sample hello world kind of Fortran test code, in an MPI setup.
OS: Windows 10
Compiler used: Intel OneAPI 2021.3.0
MPI: Intel MPI
using a CmakeLists file to compile the test with necessary Fortran 64 bit “-i8” option and find_package(MPI). I manually defined MPI_C_LIBRARIES variable to point to mpi libraries in the right order: libmpi_ilp64.lib;impi.lib and MPI_Fortran_Compiler points to mpiifort

I use a test of determining the size of MPI_INTEGER using an API MPI_Type_size( ) to check if 64 bit environment is enabled for Fortran/MPI setup.

call MPI_Type_size(MPI_INTEGER, sz, ierrsiz)
print *, 'sizeof(MPI_INTEGER) ', sz

Correct size of 8 bytes (64 bit) is displayed if the manual definition of MPI libraries is done, otherwise I observe 4 bytes (32 bit).

So to summarise, I was able to observe 2 weird behaviors using CMake build system:

  1. “find_package(MPI COMPONENTS C Fortran REQUIRED)” does not automatically find the required Intel MPI’s ILP64 library. By default, only impi.lib is populated under MPI_C_LIBRARIES. For MPI ILP64 (i.e., 8 byte printing of MPI_INTEGER), the libraries need to be linked in correct order as follows: libmpi_ilp64.lib;impi.lib. This, I achieve by manually forcing the variable “MPI_C_LIBRARIES” as used in CMakeLists.txt. Why cant find_package() command do the necessary work?

  2. The line in CMakeLists.txt < add_definitions("-DInt=__int64" “-DUInt=unsigned __int64” “-i8” “-i8”) >, has “-i8” twice and is used intentionally. For some unknown reason, if I remove the duplicate “i8” and have a single mention, size of MPI_INTEGER drops to 0 (zero) from 8

Attaching the CmakeLists.txt, sample fortran source and build logs.

Kindly help me resolve these issues I observe in CMake build system.

Thanks in advance.

Regards,
Vishwa

build_works.txt (4.28 KB)

build_doesnt_work.txt (7.86 KB)

CMakeLists.txt (1.6 KB)

test.f90 (2.35 KB)

Cc: @chuckatkins