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

**URL:** <https://discourse.cmake.org/t/problem-enabling-64-bit-fortran-compilation-on-windows-using-intel-oneapi-with-cmake-on-windows/4541>\
**Category:** Code\
**Created:** [November 24, 2021, 6:48am UTC](https://discourse.cmake.org/t/problem-enabling-64-bit-fortran-compilation-on-windows-using-intel-oneapi-with-cmake-on-windows/4541 "2021-11-24T06:48:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vishwa\_C](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/8797f3/32.png) [@Vishwa\_C](https://discourse.cmake.org/u/Vishwa_C)\
**Post date:** [November 24, 2021, 6:48am UTC](https://discourse.cmake.org/t/problem-enabling-64-bit-fortran-compilation-on-windows-using-intel-oneapi-with-cmake-on-windows/4541/1 "2021-11-24T06:48:50Z")

</div>

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.

```auto
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](https://discourse.cmake.org/uploads/short-url/y40b17zJ9vvrPxlkaRhjz5BnFVZ.txt) (4.28 KB)

[build\_doesnt\_work.txt](https://discourse.cmake.org/uploads/short-url/yIVmND5WLu7b9e4JLy9XuvmwUUX.txt) (7.86 KB)

[CMakeLists.txt](https://discourse.cmake.org/uploads/short-url/94I4ZlTmaEOSwE9mudOYCKMtvgr.txt) (1.6 KB)

[test.f90](https://discourse.cmake.org/uploads/short-url/9ykIfOA17FB0i8Mn3fW1vuj6TL2.f90) (2.35 KB)

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [November 24, 2021, 1:58pm UTC](https://discourse.cmake.org/t/problem-enabling-64-bit-fortran-compilation-on-windows-using-intel-oneapi-with-cmake-on-windows/4541/2 "2021-11-24T13:58:44Z")

</div>

Cc: @chuckatkins
