From 3343f1a8d5ad5fcb1aa93a87e34447e244a0ffc4 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 10 Jun 2020 16:47:28 -0400 Subject: [PATCH 1/4] Updates to allow GEOS to build without MKL This set of PRs is to allow GEOS to build without MKL. Note that it currently does this by making RRTMGP unusable if MKL is not found. This is not ideal, but it's a first attempt. --- NCEP_sp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NCEP_sp/CMakeLists.txt b/NCEP_sp/CMakeLists.txt index 725d20b..1ca1495 100644 --- a/NCEP_sp/CMakeLists.txt +++ b/NCEP_sp/CMakeLists.txt @@ -18,7 +18,7 @@ set (CMAKE_Fortran_FLAGS_RELEASE "-O2 ${GEOS_Fortran_Release_FPE_Flags} ${EXTEND esma_add_library (${this} SRCS ${srcs} DEPENDENCIES NCEP_w3_${precision}) -target_link_libraries(${this} PUBLIC ${MKL_LIBRARIES}) +target_link_libraries(${this} PUBLIC ${LAPACK_LIBRARIES}) if (precision MATCHES "r4i4") # use default real/int precisions From c6a35d6e5b03cb4cd09875fd50416c1b44326cd1 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Thu, 11 Jun 2020 12:16:27 -0400 Subject: [PATCH 2/4] Ugly hack for zero-diff For unknown reasons, even though, with MKL loaded, MKL_LIBRARIES is the same as LAPACK_LIBRARIES save for a `-lm -ldl`, the answers are non-zero-diff. So, if MKL_FOUND, use MKL_LIBRARIES to maintain zero-diff --- NCEP_sp/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/NCEP_sp/CMakeLists.txt b/NCEP_sp/CMakeLists.txt index 1ca1495..0daa7aa 100644 --- a/NCEP_sp/CMakeLists.txt +++ b/NCEP_sp/CMakeLists.txt @@ -18,7 +18,11 @@ set (CMAKE_Fortran_FLAGS_RELEASE "-O2 ${GEOS_Fortran_Release_FPE_Flags} ${EXTEND esma_add_library (${this} SRCS ${srcs} DEPENDENCIES NCEP_w3_${precision}) -target_link_libraries(${this} PUBLIC ${LAPACK_LIBRARIES}) +if (MKL_FOUND) + target_link_libraries(${this} PUBLIC ${MKL_LIBRARIES}) +else () + target_link_libraries(${this} PUBLIC ${LAPACK_LIBRARIES}) +endif () if (precision MATCHES "r4i4") # use default real/int precisions From be35dacf2910daf47fa560f4488239da86e3f8ca Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Fri, 4 Sep 2020 13:36:33 -0400 Subject: [PATCH 3/4] Use find_package in NCEP_sp --- NCEP_sp/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/NCEP_sp/CMakeLists.txt b/NCEP_sp/CMakeLists.txt index 0daa7aa..20b3a36 100644 --- a/NCEP_sp/CMakeLists.txt +++ b/NCEP_sp/CMakeLists.txt @@ -18,10 +18,16 @@ set (CMAKE_Fortran_FLAGS_RELEASE "-O2 ${GEOS_Fortran_Release_FPE_Flags} ${EXTEND esma_add_library (${this} SRCS ${srcs} DEPENDENCIES NCEP_w3_${precision}) +if (APPLE) + set(MKL_Fortran TRUE) +endif () +find_package(MKL) if (MKL_FOUND) - target_link_libraries(${this} PUBLIC ${MKL_LIBRARIES}) + set(BLA_VENDOR Intel10_64lp_seq) + target_link_libraries(${this} PRIVATE ${MKL_LIBRARIES}) else () - target_link_libraries(${this} PUBLIC ${LAPACK_LIBRARIES}) + find_package(LAPACK REQUIRED) + target_link_libraries(${this} PRIVATE ${LAPACK_LIBRARIES}) endif () if (precision MATCHES "r4i4") From 8b22490ca07aece3d0ea3d0d57193f142fa6ee82 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Fri, 18 Sep 2020 14:05:22 -0400 Subject: [PATCH 4/4] Use same MKL logic in NCEP_gfsio --- NCEP_gfsio/CMakeLists.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/NCEP_gfsio/CMakeLists.txt b/NCEP_gfsio/CMakeLists.txt index 92a5412..b09b7ed 100644 --- a/NCEP_gfsio/CMakeLists.txt +++ b/NCEP_gfsio/CMakeLists.txt @@ -2,7 +2,19 @@ esma_set_this () esma_add_library (${this} SRCS gfsio_module.f90 gfsio_solve_axb.F90 - DEPENDENCIES GMAO_mpeu NCEP_bacio_r4i4 NCEP_w3_r4i4 ${MKL_LIBRARIES} + DEPENDENCIES GMAO_mpeu NCEP_bacio_r4i4 NCEP_w3_r4i4 ) +if (APPLE) + set(MKL_Fortran TRUE) +endif () +find_package(MKL) +if (MKL_FOUND) + set(BLA_VENDOR Intel10_64lp_seq) + target_link_libraries(${this} PRIVATE ${MKL_LIBRARIES}) +else () + find_package(LAPACK REQUIRED) + target_link_libraries(${this} PRIVATE ${LAPACK_LIBRARIES}) +endif () + set (CMAKE_Fortran_FLAGS_RELEASE "-O3 ${BIG_ENDIAN} ${common_Fortran_flags} ${GEOS_Fortran_Release_FPE_Flags} ${ALIGNCOM}")