CheckMPIF2008StandardCompiles.cmake 2.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
#                          Futility Development Group                          !
#                             All rights reserved.                             !
#                                                                              !
# Futility is a jointly-maintained, open-source project between the University !
# of Michigan and Oak Ridge National Laboratory.  The copyright and license    !
# can be found in LICENSE.txt in the head directory of this repository.        !
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!

FUNCTION(CHECK_MPI_F2008_STANDARD_COMPILES )
    SET(CHECK_TEST_SOURCE
    "
      PROGRAM main
        INCLUDE 'mpif.h'
        WRITE(*,*) 'HELLO WORLD'
      ENDPROGRAM
    "
    )

    IF(TPL_ENABLE_MPI AND NOT DEFINED MPI_F2008_STANDARD_COMPLIANT)
        IF("3.1.3" VERSION_GREATER CMAKE_VERSION)
            MESSAGE(STATUS "Skipping check if MPI is F2008 standard compliant")
            GLOBAL_SET(MPI_F2008_STANDARD_COMPLIANT TRUE)
        ELSE()
            #CMake module "CHECK_Fortran_SOURCE_COMPILERS" is only available in
            #version 3.1.3 and later
            INCLUDE(CheckFortranSourceCompiles)

            #Determine appropriate flag for compiler test
            IF(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" OR
              (MSVC_IDE AND "${CMAKE_Fortran_COMPILER}" STREQUAL "ifort"))
              IF("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
                SET(FSTDFLAG "/std:f08")
              ELSE()
                SET(FSTDFLAG "-std f08")
              ENDIF()
            ELSEIF(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
              SET(FSTDFLAG "-std=f2008")
#            ELSEIF(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI")
#              SET(FSTDFLAG "-Mstandard")
#            ELSEIF(CMAKE_Fortran_COMPILER_ID STREQUAL "Cray")
#              SET(FSTDFLAG "-e n")
#            ELSEIF(CMAKE_Fortran_COMPILER_ID STREQUAL "IBM")
#
#            ELSEIF(CMAKE_Fortran_COMPILER_ID STREQUAL "Pathscale")
#
            ENDIF()
            SET(OLD_CRF ${CMAKE_REQUIRED_FLAGS})
            SET(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} ${FSTDFLAG})

            CHECK_Fortran_SOURCE_COMPILES(${CHECK_TEST_SOURCE}
                MPI_F2008_STANDARD_COMPILES)
            IF(MPI_F2008_STANDARD_COMPILES)
                GLOBAL_SET(MPI_F2008_STANDARD_COMPLIANT TRUE)
            ELSE()
                GLOBAL_SET(MPI_F2008_STANDARD_COMPLIANT FALSE)
            ENDIF()

            SET(CMAKE_REQUIRED_FLAGS ${OLD_CRF})
        ENDIF()
    ELSE()
        IF(TPL_ENABLE_MPI)
            MESSAGE(STATUS
                "MPI F2008 standard compliance already set as: "
                ${MPI_F2008_STANDARD_COMPLIANT}
            )
        ELSE()
            GLOBAL_SET(MPI_F2008_STANDARD_COMPLIANT TRUE)
        ENDIF()
    ENDIF()
ENDFUNCTION()