-
Notifications
You must be signed in to change notification settings - Fork 1
/
modele-control.pyar
7193 lines (6211 loc) · 250 KB
/
modele-control.pyar
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
======================== FILE ./CMakeLists.txt
FILE: ./CMakeLists.txt
# ------------------------------------------------------------------------ #
# modelE cmake setup
# ------------------------------------------------------------------------ #
#
# Usage: cmake -DRUN=<modelE run> /path/to/my/repo [optional arguments]
#
# Required argument:
#
# -DRUN=<modelE run>
# /path/to/my/repo
#
# Optional arguments (when possible a default is assigned):
#
# -DCMAKE_CXX_COMPILER=<c++ compiler> (default is system's compiler)
# -DCMAKE_C_COMPILER=<c compiler> (default is system's)
# -DCMAKE_Fortran_COMPILER=<fortran compiler> (default is system's)
# -DCMAKE_BUILD_TYPE=Debug (or Release)
# -DCOMPILE_WITH_TRAPS=NO (or YES)
# -DCOMPILE_IC=NO (or YES to compile init_cond directory)
# -DCOMPILE_DIAGS=NO (or YES to compile mk_diags directory)
# -DCOMPILE_AUX=NO (or YES to compile aux directory)
# -DMPI=YES (or NO)
# -DRUNSRC=<modelE template> (default is none)
# -DMODEL_DECKS_DIR=/path/to/my/decks (default is none)
#
# NOTE: RUN must be specified with full path.
#
# Examples:
#
# Run cmake in a temporary directory:
#
# 1) cmake -DRUN=/path/my/decks/ef40cc.R /path/to/my/repo
#
# Uses specified e4f40cc.R rundeck using source code in /path/to/my/repo
#
# It is common to create a "build" subdirectory in the source directory ,
# cd to it and run cmake as follows:
#
# 2) cmake -DRUN=e4f0.R -DRUNSRC=E4F40.R ..
#
# Creates e4f0.R rundeck in current directory using the specified template.
#
# If you want to store or share your rundeck, specify where it should be
# created using the MODEL_DECKS_DIR option:
#
# 3) cmake -DMODEL_DECKS_DIR=/path/to/my/decks -DRUN=e4f0.R -DRUNSRC=E4F40.R ..
#
#
# ------------------------------------------------------------------------
cmake_minimum_required (VERSION 3.2)
project (ModelE)
enable_language(Fortran)
# Where to look first for project cmake modules,
# before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake
)
include(PreventInSourceBuild)
include(setup_rpath)
# Process command line options
include(ProcessCommandLineOptions)
#
# Set some CMake defaults
include(DefineCMakeDefaults)
# Set platform settings and check for required compiler versions
include(DefinePlatformDefaults)
# Set compiler flags
#include ("cmake/PISM_CMake_macros.cmake")
#include ("cmake/GLINT2_CMake_macros.cmake")
include (ModelE_CMake_macros)
modele_set_flags()
# Find required packages
#pism_find_prerequisites()
#glint2_find_prerequisites()
modele_find_prerequisites()
# Specify all the subdirectories to build
if (COMPILE_MODEL MATCHES YES)
add_subdirectory(model)
endif()
# Not yet on the master (dev) branch...
# add_subdirectory (pyext)
# Do we want to build aux?
if(COMPILE_AUX MATCHES YES)
add_subdirectory(aux)
endif()
# Do we want to build mk_diags?
if(COMPILE_DIAGS MATCHES YES)
add_subdirectory(model/mk_diags)
endif()
# Do we want to build init_cond?
if(COMPILE_IC MATCHES YES)
add_subdirectory(init_cond)
endif()
# If PFUNIT environment variable is set then WITH_PFUNIT is set to YES
if(WITH_PFUNIT MATCHES YES)
add_subdirectory(tests)
endif()
message(STATUS "********************************************")
message(STATUS "********** PROJECT: ${PROJECT_NAME} **********")
message(STATUS "Architecture: ${ARCHITECTURE}")
message(STATUS "System: ${CMAKE_SYSTEM_NAME}")
message(STATUS "MODELERC: $ENV{MODELERC}")
message(STATUS "COMPILER: ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "RUNSRC: ${RUNSRC}")
message(STATUS "RUN: ${RUN}")
message(STATUS "MPI: ${MPI}")
message(STATUS "WITH_PFUNIT: ${WITH_PFUNIT}")
if (COMPILE_WITH_DEBUG MATCHES YES)
message(STATUS "COMPILE_WITH_DEBUG: ${COMPILE_WITH_DEBUG}")
endif()
if (COMPILE_WITH_TRAPS MATCHES YES)
message(STATUS "COMPILE_WITH_TRAPS: ${COMPILE_WITH_TRAPS}")
endif()
message(STATUS "********************************************")
__EOF__
======================== FILE ./aux/CMakeLists.txt
FILE: ./aux/CMakeLists.txt
# aux
aux_set_dependencies()
include_directories(
${PROJECT_BINARY_DIR}/model
)
# Targets
add_executable(RMS RMS.f)
add_executable(mkdeep.exe mkdeep.f)
add_executable(RDijk2llEM RDijk2llEM.f)
add_executable(inputll2cs inputLL2CS.f regrid.f ncio.f)
target_link_libraries(inputll2cs ${AUX_EXTERNAL_LIBS})
add_executable(ll2cs ll2cs.f regrid.f ncio.f)
target_link_libraries(ll2cs ${AUX_EXTERNAL_LIBS})
add_executable(ncll2cs ncll2cs.f regrid.f ncio.f)
target_link_libraries(ncll2cs ${AUX_EXTERNAL_LIBS})
list(APPEND apps RMS)
list(APPEND apps mkdeep.exe)
foreach(app ${apps})
#message(STATUS " ---> Add executable ${app}")
target_link_libraries(${app} ${AUX_EXTERNAL_LIBS})
endforeach()
__EOF__
======================== FILE ./cmake/DefineCMakeDefaults.cmake
FILE: ./cmake/DefineCMakeDefaults.cmake
# Always include srcdir and builddir in include path
# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in
# about every subdir
# since cmake 2.4.0
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Put the include dirs which are in the source or build tree
# before all other include dirs, so the headers in the sources
# are prefered over the already installed ones
# since cmake 2.4.1
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
# Use colored output
# since cmake 2.4.0
set(CMAKE_COLOR_MAKEFILE ON)
# Set the default build type to release with debug info
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo
CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
)
endif (NOT CMAKE_BUILD_TYPE)
__EOF__
======================== FILE ./cmake/DefinePlatformDefaults.cmake
FILE: ./cmake/DefinePlatformDefaults.cmake
# Set system vars
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
set(LINUX TRUE)
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set (OSX TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(FREEBSD TRUE)
set(BSD TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
set(OPENBSD TRUE)
set(BSD TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
set(NETBSD TRUE)
set(BSD TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
if (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
set(SOLARIS TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
if (CMAKE_SYSTEM_NAME MATCHES "OS2")
set(OS2 TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "OS2")
if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
# require at least ifort 14.0
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14.0)
message("\n ---> IFORT COMPILER VERSION: " ${CMAKE_CXX_COMPILER_VERSION})
message(FATAL_ERROR "---> IFORT version must be at least 14.0!")
endif()
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
# require at least gcc 4.9.1
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.1)
message("\n ---> GNU COMPILER VERSION: " ${CMAKE_CXX_COMPILER_VERSION})
message(FATAL_ERROR "---> GNU version must be at least 4.9.1!")
endif()
else()
message( FATAL_ERROR "Unrecognized compiler. Please use ifort or gfortran" )
endif()
__EOF__
======================== FILE ./cmake/FindBlitz++.cmake
FILE: ./cmake/FindBlitz++.cmake
# - Try to find BLITZ++
# Once done, this will define
#
# BLITZ++_FOUND - system has BLITZ++
# BLITZ++_INCLUDE_DIR - the BLITZ++ include directory
# BLITZ++_LIBRARY - lib to link to use BLITZ++
include(LibFindMacros)
# Use pkg-config to get hints about paths
#libfind_pkg_check_modules(BLITZ++_PKGCONF blitz)
# Include dir
find_path(BLITZ++_INCLUDE_DIR
NAMES blitz/blitz.h
HINTS ${BLITZ++_PKGCONF_INCLUDE_DIRS}
)
# Finally the library itself
find_library(BLITZ++_LIBRARY
NAMES blitz
HINTS ${BLITZ++_PKGCONF_LIBRARY_DIRS}
)
# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
set(BLITZ++_PROCESS_INCLUDE BLITZ++_INCLUDE_DIR )
set(BLITZ++_PROCESS_LIB BLITZ++_LIBRARY)
libfind_process(BLITZ++)
__EOF__
======================== FILE ./cmake/FindCGAL.cmake
FILE: ./cmake/FindCGAL.cmake
# - Try to find Cgal
# Input Variables
# CGAL_ROOT
# Once done this will define
# CGAL_FOUND - System has Cgal
# CGAL_INCLUDE_DIRS - The Cgal include directories
# CGAL_LIBRARIES - The libraries needed to use Cgal
## CGAL_DEFINITIONS - Compiler switches required for using Cgal
find_path(CGAL_ROOT modules/${CGAL_ARCH}/double/galahad_qpt_double.mod
HINTS ${CGAL_ROOT})
message(CGAL_ROOT ${CGAL_ROOT})
find_path(CGAL_INCLUDE_DIR CGAL/basic.h
HINTS ${CGAL_ROOT})
set(CGAL_INCLUDE_DIRS ${CGAL_INCLUDE_DIR})
find_library(CGAL_LIBRARY CGAL
HINTS ${CGAL_ROOT}/lib)
set(CGAL_LIBRARIES ${CGAL_LIBRARY})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set CGAL_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(Cgal DEFAULT_MSG
CGAL_LIBRARIES CGAL_INCLUDE_DIRS)
mark_as_advanced(CGAL_INCLUDE_DIRS CGAL_LIBRARIES )
#
## Find the CGAL includes and client library
## This module defines
## CGAL_INCLUDE_DIR, where to find CGAL.h
## CGAL_LIBRARIES, the libraries needed to use CGAL.
## CGAL_FOUND, If false, do not try to use CGAL.
#
#if(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES)
# set(CGAL_FOUND TRUE)
#
#else(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES)
#
# FIND_PATH(CGAL_INCLUDE_DIR CGAL/basic.h
# /usr/include
# /usr/local/include
# $ENV{ProgramFiles}/CGAL/*/include
# $ENV{SystemDrive}/CGAL/*/include
# )
#
# find_library(CGAL_LIBRARIES NAMES CGAL libCGAL
# PATHS
# /usr/lib
# /usr/local/lib
# /usr/lib/CGAL
# /usr/lib64
# /usr/local/lib64
# /usr/lib64/CGAL
# $ENV{ProgramFiles}/CGAL/*/lib
# $ENV{SystemDrive}/CGAL/*/lib
# )
#
# if(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES)
# set(CGAL_FOUND TRUE)
# message(STATUS "Found CGAL: ${CGAL_INCLUDE_DIR}, ${CGAL_LIBRARIES}")
# INCLUDE_DIRECTORIES(${CGAL_INCLUDE_DIR} $ENV{CGAL_CFG})
# else(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES)
# set(CGAL_FOUND FALSE)
# message(STATUS "CGAL not found.")
# endif(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES)
#
# mark_as_advanced(CGAL_INCLUDE_DIR CGAL_LIBRARIES)
#
#endif(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES)
#
__EOF__
======================== FILE ./cmake/FindFException.cmake
FILE: ./cmake/FindFException.cmake
# Input Variables
# FEXCEPTION_ROOT
# Produces:
# FEXCEPTION_LIBRARY
# FEXCEPTION_INCLUDE_DIR
FIND_PATH(FEXCEPTION_INCLUDE_DIR fexception_c.hpp
HINTS ${FEXCEPTION_ROOT}/include)
FIND_LIBRARY(FEXCEPTION_LIBRARY NAMES fexception
HINTS ${FEXCEPTION_ROOT}/lib)
IF (FEXCEPTION_INCLUDE_DIR AND FEXCEPTION_LIBRARY)
SET(FEXCEPTION_FOUND TRUE)
ENDIF (FEXCEPTION_INCLUDE_DIR AND FEXCEPTION_LIBRARY)
IF (FEXCEPTION_FOUND)
IF (NOT FEXCEPTION_FIND_QUIETLY)
MESSAGE(STATUS "Found FEXCEPTION_LIBRARY: ${FEXCEPTION_LIBRARY}")
ENDIF (NOT FEXCEPTION_FIND_QUIETLY)
ELSE (FEXCEPTION_FOUND)
IF (FEXCEPTION_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find FEXCEPTION")
ENDIF (FEXCEPTION_FIND_REQUIRED)
ENDIF (FEXCEPTION_FOUND)
__EOF__
======================== FILE ./cmake/FindFFTW.cmake
FILE: ./cmake/FindFFTW.cmake
# - Find FFTW
# Find the native FFTW includes and library
#
# FFTW_INCLUDES - where to find fftw3.h
# FFTW_LIBRARIES - List of libraries when using FFTW.
# FFTW_FOUND - True if FFTW found.
if (FFTW_INCLUDES)
# Already in cache, be silent
set (FFTW_FIND_QUIETLY TRUE)
endif (FFTW_INCLUDES)
find_path (FFTW_INCLUDES fftw3.h
HINTS "${FFTW_ROOT}/include" "$ENV{FFTW_ROOT}/include")
string(REGEX REPLACE "/include/?$" "/lib"
FFTW_LIB_HINT ${FFTW_INCLUDES})
find_library (FFTW_LIBRARIES
NAMES fftw3
HINTS ${FFTW_LIB_HINT})
if ((NOT FFTW_LIBRARIES) OR (NOT FFTW_INCLUDES))
message(STATUS "Trying to find FFTW3 using LD_LIBRARY_PATH (we're desperate)...")
file(TO_CMAKE_PATH "$ENV{LD_LIBRARY_PATH}" LD_LIBRARY_PATH)
find_library(FFTW_LIBRARIES
NAMES fftw3
HINTS ${LD_LIBRARY_PATH})
if (FFTW_LIBRARIES)
get_filename_component(FFTW_LIB_DIR ${FFTW_LIBRARIES} PATH)
string(REGEX REPLACE "/lib/?$" "/include"
FFTW_H_HINT ${FFTW_LIB_DIR})
find_path (FFTW_INCLUDES fftw3.h
HINTS ${FFTW_H_HINT}
DOC "Path to fftw3.h")
endif()
endif()
# handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
# all listed variables are TRUE
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (FFTW DEFAULT_MSG FFTW_LIBRARIES FFTW_INCLUDES)
mark_as_advanced (FFTW_LIBRARIES FFTW_INCLUDES)
__EOF__
======================== FILE ./cmake/FindGALAHAD.cmake
FILE: ./cmake/FindGALAHAD.cmake
# - Try to find Galahad
# Input Variables
# GALAHAD_ROOT
# GALAHAD_ARCH
# Once done this will define
# GALAHAD_FOUND - System has Galahad
# GALAHAD_INCLUDE_DIRS - The Galahad include directories
# GALAHAD_LIBRARIES - The libraries needed to use Galahad
## GALAHAD_DEFINITIONS - Compiler switches required for using Galahad
find_path(GALAHAD_ROOT modules/${GALAHAD_ARCH}/double/galahad_qpt_double.mod
HINTS ${GALAHAD_ROOT})
message(GALAHAD_ROOT ${GALAHAD_ROOT})
set(GALAHAD_INCLUDE_DIRS ${GALAHAD_ROOT}/modules/${GALAHAD_ARCH}/double)
set(GALAHAD_LIB ${GALAHAD_ROOT}/objects/${GALAHAD_ARCH}/double)
# -DUSE_GALAHAD @PETSC_CFLAGS@)
set(GALAHAD_COMPONENTS galahad galahad_hsl galahad_pardiso galahad_wsmp galahad_metis galahad_lapack galahad_blas)
set(GALAHAD_LIBRARIES gomp) # Part of GCC
foreach(COMPONENT ${GALAHAD_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
find_library(${UPPERCOMPONENT}_LIBRARY ${COMPONENT}
HINTS ${GALAHAD_LIB})
set(GALAHAD_LIBRARIES ${GALAHAD_LIBRARIES} ${${UPPERCOMPONENT}_LIBRARY})
endforeach()
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set GALAHAD_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(Galahad DEFAULT_MSG
GALAHAD_LIBRARIES GALAHAD_INCLUDE_DIRS)
mark_as_advanced(GALAHAD_INCLUDE_DIRS GALAHAD_LIBRARIES )
__EOF__
======================== FILE ./cmake/FindGMP.cmake
FILE: ./cmake/FindGMP.cmake
# Copyright (c) 2008-2010 Kent State University
# Copyright (c) 2011-2012 Texas A&M University
#
# This file is distributed under the MIT License. See the accompanying file
# LICENSE.txt or http://www.opensource.org/licenses/mit-license.php for terms
# and conditions.
# FIXME: How do I find the version of GMP that I want to use?
# What versions are available?
# NOTE: GMP prefix is understood to be the path to the root of the GMP
# installation library.
set(GMP_PREFIX "" CACHE PATH "The path to the prefix of a GMP installation")
find_path(GMP_INCLUDE_DIR gmp.h
PATHS ${GMP_PREFIX}/include /usr/include /usr/local/include)
find_library(GMP_LIBRARY NAMES gmp
PATHS ${GMP_PREFIX}/lib /usr/lib /usr/local/lib)
if(GMP_INCLUDE_DIR AND GMP_LIBRARY)
get_filename_component(GMP_LIBRARY_DIR ${GMP_LIBRARY} PATH)
set(GMP_FOUND TRUE)
endif()
if(GMP_FOUND)
if(NOT GMP_FIND_QUIETLY)
MESSAGE(STATUS "Found GMP: ${GMP_LIBRARY}")
endif()
elseif(GMP_FOUND)
if(GMP_FIND_REQUIRED)
message(FATAL_ERROR "Could not find GMP")
endif()
endif()
__EOF__
======================== FILE ./cmake/FindGSL.cmake
FILE: ./cmake/FindGSL.cmake
# - Find GSL
# Find the native GSL includes and library
#
# GSL_INCLUDES - where to find gsl/gsl_*.h, etc.
# GSL_LIBRARIES - List of libraries when using GSL.
# GSL_FOUND - True if GSL found.
if (GSL_INCLUDES)
# Already in cache, be silent
set (GSL_FIND_QUIETLY TRUE)
endif (GSL_INCLUDES)
find_path (GSL_INCLUDES gsl/gsl_math.h
HINTS "${GSL_ROOT}/include" "$ENV{GSL_ROOT}/include")
string(REGEX REPLACE "/include/?$" "/lib"
GSL_LIB_HINT ${GSL_INCLUDES})
find_library (GSL_LIB
NAMES gsl
HINTS ${GSL_LIB_HINT})
find_library(GSL_CBLAS_LIB
NAMES gslcblas
HINTS ${GSL_LIB_HINT})
if ((NOT GSL_INCLUDES) OR (NOT GSL_LIB) OR (NOT GSL_CBLAS_LIB))
message(STATUS "Trying to find GSL using 'gsl-config'...")
find_program(GSL_CONFIG "gsl-config")
if (GSL_CONFIG)
execute_process(COMMAND ${GSL_CONFIG} --prefix
OUTPUT_VARIABLE GSL_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE)
find_path(GSL_INCLUDES gsl/gsl_math.h
HINTS "${GSL_PREFIX}/include")
find_library (GSL_LIB NAMES gsl
HINTS "${GSL_PREFIX}/lib")
find_library(GSL_CBLAS_LIB NAMES gslcblas
HINTS "${GSL_PREFIX}/lib")
endif()
endif()
if ((NOT GSL_LIB) OR (NOT GSL_INCLUDES))
message(STATUS "Trying to find GSL using LD_LIBRARY_PATH (we're desperate)...")
file(TO_CMAKE_PATH "$ENV{LD_LIBRARY_PATH}" LD_LIBRARY_PATH)
find_library(GSL_LIB
NAMES gsl
HINTS ${LD_LIBRARY_PATH})
find_library(GSL_CBLAS_LIB
NAMES gslcblas
HINTS ${LD_LIBRARY_PATH})
if (GSL_LIB)
get_filename_component(GSL_LIB_DIR ${GSL_LIB} PATH)
string(REGEX REPLACE "/lib/?$" "/include"
GSL_H_HINT ${GSL_LIB_DIR})
find_path (GSL_INCLUDES gsl/gsl_math.h
HINTS ${GSL_H_HINT}
DOC "Path to gsl/gsl_math.h")
endif()
endif()
if (GSL_LIB AND GSL_CBLAS_LIB)
set (GSL_LIBRARIES "${GSL_LIB}" "${GSL_CBLAS_LIB}")
endif()
# handle the QUIETLY and REQUIRED arguments and set GSL_FOUND to TRUE if
# all listed variables are TRUE
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (GSL DEFAULT_MSG GSL_LIBRARIES GSL_INCLUDES)
mark_as_advanced (GSL_LIB GSL_CBLAS_LIB GSL_INCLUDES)
__EOF__
======================== FILE ./cmake/FindMPI.cmake
FILE: ./cmake/FindMPI.cmake
# - Find a Message Passing Interface (MPI) implementation
# The Message Passing Interface (MPI) is a library used to write
# high-performance distributed-memory parallel applications, and
# is typically deployed on a cluster. MPI is a standard interface
# (defined by the MPI forum) for which many implementations are
# available. All of them have somewhat different include paths,
# libraries to link against, etc., and this module tries to smooth
# out those differences.
#
# === Variables ===
#
# This module will set the following variables per language in your project,
# where <lang> is one of C, CXX, or Fortran:
# MPI_<lang>_FOUND TRUE if FindMPI found MPI flags for <lang>
# MPI_<lang>_COMPILER MPI Compiler wrapper for <lang>
# MPI_<lang>_COMPILE_FLAGS Compilation flags for MPI programs
# MPI_<lang>_INCLUDE_PATH Include path(s) for MPI header
# MPI_<lang>_LINK_FLAGS Linking flags for MPI programs
# MPI_<lang>_LIBRARIES All libraries to link MPI programs against
# Additionally, FindMPI sets the following variables for running MPI
# programs from the command line:
# MPIEXEC Executable for running MPI programs
# MPIEXEC_NUMPROC_FLAG Flag to pass to MPIEXEC before giving
# it the number of processors to run on
# MPIEXEC_PREFLAGS Flags to pass to MPIEXEC directly
# before the executable to run.
# MPIEXEC_POSTFLAGS Flags to pass to MPIEXEC after other flags
# === Usage ===
#
# To use this module, simply call FindMPI from a CMakeLists.txt file, or
# run find_package(MPI), then run CMake. If you are happy with the auto-
# detected configuration for your language, then you're done. If not, you
# have two options:
# 1. Set MPI_<lang>_COMPILER to the MPI wrapper (mpicc, etc.) of your
# choice and reconfigure. FindMPI will attempt to determine all the
# necessary variables using THAT compiler's compile and link flags.
# 2. If this fails, or if your MPI implementation does not come with
# a compiler wrapper, then set both MPI_<lang>_LIBRARIES and
# MPI_<lang>_INCLUDE_PATH. You may also set any other variables
# listed above, but these two are required. This will circumvent
# autodetection entirely.
# When configuration is successful, MPI_<lang>_COMPILER will be set to the
# compiler wrapper for <lang>, if it was found. MPI_<lang>_FOUND and other
# variables above will be set if any MPI implementation was found for <lang>,
# regardless of whether a compiler was found.
#
# When using MPIEXEC to execute MPI applications, you should typically use
# all of the MPIEXEC flags as follows:
# ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} PROCS
# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS
# where PROCS is the number of processors on which to execute the program,
# EXECUTABLE is the MPI program, and ARGS are the arguments to pass to the
# MPI program.
#
# === Backward Compatibility ===
#
# For backward compatibility with older versions of FindMPI, these
# variables are set, but deprecated:
# MPI_FOUND MPI_COMPILER MPI_LIBRARY
# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_EXTRA_LIBRARY
# MPI_LINK_FLAGS MPI_LIBRARIES
# In new projects, please use the MPI_<lang>_XXX equivalents.
#=============================================================================
# Copyright 2001-2011 Kitware, Inc.
# Copyright 2010-2011 Todd Gamblin [email protected]
# Copyright 2001-2009 Dave Partyka
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# include this to handle the QUIETLY and REQUIRED arguments
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/GetPrerequisites.cmake)
#
# This part detects MPI compilers, attempting to wade through the mess of compiler names in
# a sensible way.
#
# The compilers are detected in this order:
#
# 1. Try to find the most generic available MPI compiler, as this is usually set up by
# cluster admins. e.g., if plain old mpicc is available, we'll use it and assume it's
# the right compiler.
#
# 2. If a generic mpicc is NOT found, then we attempt to find one that matches
# CMAKE_<lang>_COMPILER_ID. e.g. if you are using XL compilers, we'll try to find mpixlc
# and company, but not mpiicc. This hopefully prevents toolchain mismatches.
#
# If you want to force a particular MPI compiler other than what we autodetect (e.g. if you
# want to compile regular stuff with GNU and parallel stuff with Intel), you can always set
# your favorite MPI_<lang>_COMPILER explicitly and this stuff will be ignored.
#
# Start out with the generic MPI compiler names, as these are most commonly used.
set(_MPI_C_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r)
set(_MPI_CXX_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++
mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r)
set(_MPI_Fortran_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r
mpif90 mpif90_r mpf90 mpf90_r
mpif77 mpif77_r mpf77 mpf77_r)
# GNU compiler names
set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r)
set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r)
set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r
mpig77 mpig77_r mpg77 mpg77_r)
# Intel MPI compiler names
set(_MPI_Intel_C_COMPILER_NAMES mpiicc)
set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++ mpiiCC)
set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77)
# PGI compiler names
set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc)
set(_MPI_PGI_CXX_COMPILER_NAMES mpipgCC mppgCC)
set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77)
# XLC MPI Compiler names
set(_MPI_XL_C_COMPILER_NAMES mpxlc mpxlc_r mpixlc mpixlc_r)
set(_MPI_XL_CXX_COMPILER_NAMES mpixlcxx mpixlC mpixlc++ mpxlcxx mpxlc++ mpixlc++ mpxlCC
mpixlcxx_r mpixlC_r mpixlc++_r mpxlcxx_r mpxlc++_r mpixlc++_r mpxlCC_r)
set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95_r
mpixlf90 mpixlf90_r mpxlf90 mpxlf90_r
mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r
mpixlf mpixlf_r mpxlf mpxlf_r)
# append vendor-specific compilers to the list if we either don't know the compiler id,
# or if we know it matches the regular compiler.
foreach (lang C CXX Fortran)
foreach (id GNU Intel PGI XL)
if (NOT CMAKE_${lang}_COMPILER_ID OR "${CMAKE_${lang}_COMPILER_ID}" STREQUAL "${id}")
list(APPEND _MPI_${lang}_COMPILER_NAMES ${_MPI_${id}_${lang}_COMPILER_NAMES})
endif()
unset(_MPI_${id}_${lang}_COMPILER_NAMES) # clean up the namespace here
endforeach()
endforeach()
# Names to try for MPI exec
set(_MPI_EXEC_NAMES mpiexec mpirun lamexec srun)
# Grab the path to MPI from the registry if we're on windows.
set(_MPI_PREFIX_PATH)
if(WIN32)
list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/..")
list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]")
list(APPEND _MPI_PREFIX_PATH "$ENV{ProgramW6432}/MPICH2/")
endif()
# Build a list of prefixes to search for MPI.
foreach(SystemPrefixDir ${CMAKE_SYSTEM_PREFIX_PATH})
foreach(MpiPackageDir ${_MPI_PREFIX_PATH})
if(EXISTS ${SystemPrefixDir}/${MpiPackageDir})
list(APPEND _MPI_PREFIX_PATH "${SystemPrefixDir}/${MpiPackageDir}")
endif()
endforeach()
endforeach()
#
# interrogate_mpi_compiler(lang try_libs)
#
# Attempts to extract compiler and linker args from an MPI compiler. The arguments set
# by this function are:
#
# MPI_<lang>_INCLUDE_PATH MPI_<lang>_LINK_FLAGS MPI_<lang>_FOUND
# MPI_<lang>_COMPILE_FLAGS MPI_<lang>_LIBRARIES
#
# MPI_<lang>_COMPILER must be set beforehand to the absolute path to an MPI compiler for
# <lang>. Additionally, MPI_<lang>_INCLUDE_PATH and MPI_<lang>_LIBRARIES may be set
# to skip autodetection.
#
# If try_libs is TRUE, this will also attempt to find plain MPI libraries in the usual
# way. In general, this is not as effective as interrogating the compilers, as it
# ignores language-specific flags and libraries. However, some MPI implementations
# (Windows implementations) do not have compiler wrappers, so this approach must be used.
#
function (interrogate_mpi_compiler lang try_libs)
# MPI_${lang}_NO_INTERROGATE will be set to a compiler name when the *regular* compiler was
# discovered to be the MPI compiler. This happens on machines like the Cray XE6 that use
# modules to set cc, CC, and ftn to the MPI compilers. If the user force-sets another MPI
# compiler, MPI_${lang}_COMPILER won't be equal to MPI_${lang}_NO_INTERROGATE, and we'll
# inspect that compiler anew. This allows users to set new compilers w/o rm'ing cache.
string(COMPARE NOTEQUAL "${MPI_${lang}_NO_INTERROGATE}" "${MPI_${lang}_COMPILER}" interrogate)
# If MPI is set already in the cache, don't bother with interrogating the compiler.
if (interrogate AND ((NOT MPI_${lang}_INCLUDE_PATH) OR (NOT MPI_${lang}_LIBRARIES)))
if (MPI_${lang}_COMPILER)
# Check whether the -showme:compile option works. This indicates that we have either OpenMPI
# or a newer version of LAM-MPI, and implies that -showme:link will also work.
execute_process(
COMMAND ${MPI_${lang}_COMPILER} -showme:compile
OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE MPI_COMPILER_RETURN)
if (MPI_COMPILER_RETURN EQUAL 0)
# If we appear to have -showme:compile, then we should
# also have -showme:link. Try it.
execute_process(
COMMAND ${MPI_${lang}_COMPILER} -showme:link
OUTPUT_VARIABLE MPI_LINK_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE MPI_LINK_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE MPI_COMPILER_RETURN)
if (MPI_COMPILER_RETURN EQUAL 0)
# We probably have -showme:incdirs and -showme:libdirs as well,
# so grab that while we're at it.
execute_process(
COMMAND ${MPI_${lang}_COMPILER} -showme:incdirs
OUTPUT_VARIABLE MPI_INCDIRS OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE MPI_INCDIRS ERROR_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${MPI_${lang}_COMPILER} -showme:libdirs
OUTPUT_VARIABLE MPI_LIBDIRS OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE MPI_LIBDIRS ERROR_STRIP_TRAILING_WHITESPACE)
else()
# reset things here if something went wrong.
set(MPI_COMPILE_CMDLINE)
set(MPI_LINK_CMDLINE)
endif()
endif ()
# Older versions of LAM-MPI have "-showme". Try to find that.
if (NOT MPI_COMPILER_RETURN EQUAL 0)
execute_process(
COMMAND ${MPI_${lang}_COMPILER} -showme
OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE MPI_COMPILER_RETURN)
endif()
# MVAPICH uses -compile-info and -link-info. Try them.
if (NOT MPI_COMPILER_RETURN EQUAL 0)
execute_process(
COMMAND ${MPI_${lang}_COMPILER} -compile-info
OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE MPI_COMPILER_RETURN)
# If we have compile-info, also have link-info.
if (MPI_COMPILER_RETURN EQUAL 0)
execute_process(
COMMAND ${MPI_${lang}_COMPILER} -link-info
OUTPUT_VARIABLE MPI_LINK_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE MPI_LINK_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE MPI_COMPILER_RETURN)
endif()
# make sure we got compile and link. Reset vars if something's wrong.
if (NOT MPI_COMPILER_RETURN EQUAL 0)
set(MPI_COMPILE_CMDLINE)
set(MPI_LINK_CMDLINE)
endif()
endif()
# MPICH just uses "-show". Try it.
if (NOT MPI_COMPILER_RETURN EQUAL 0)
execute_process(
COMMAND ${MPI_${lang}_COMPILER} -show
OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE MPI_COMPILER_RETURN)
endif()
if (MPI_COMPILER_RETURN EQUAL 0)
# We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE
# into MPI_LINK_CMDLINE, if we didn't find the link line.
if (NOT MPI_LINK_CMDLINE)
set(MPI_LINK_CMDLINE ${MPI_COMPILE_CMDLINE})
endif()
else()
message(STATUS "Unable to determine MPI from MPI driver ${MPI_${lang}_COMPILER}")
set(MPI_COMPILE_CMDLINE)
set(MPI_LINK_CMDLINE)
endif()
# Here, we're done with the interrogation part, and we'll try to extract args we care
# about from what we learned from the compiler wrapper scripts.
# If interrogation came back with something, extract our variable from the MPI command line
if (MPI_COMPILE_CMDLINE OR MPI_LINK_CMDLINE)
# Extract compile flags from the compile command line.
string(REGEX MATCHALL "(^| )-[Df]([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}")
set(MPI_COMPILE_FLAGS_WORK)
foreach(FLAG ${MPI_ALL_COMPILE_FLAGS})
if (MPI_COMPILE_FLAGS_WORK)
set(MPI_COMPILE_FLAGS_WORK "${MPI_COMPILE_FLAGS_WORK} ${FLAG}")
else()
set(MPI_COMPILE_FLAGS_WORK ${FLAG})
endif()
endforeach()
# Extract include paths from compile command line
string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}")
foreach(IPATH ${MPI_ALL_INCLUDE_PATHS})
string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH})
string(REGEX REPLACE "//" "/" IPATH ${IPATH})
list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH})
endforeach()
# try using showme:incdirs if extracting didn't work.
if (NOT MPI_INCLUDE_PATH_WORK)
set(MPI_INCLUDE_PATH_WORK ${MPI_INCDIRS})
separate_arguments(MPI_INCLUDE_PATH_WORK)
endif()
# If all else fails, just search for mpi.h in the normal include paths.
if (NOT MPI_INCLUDE_PATH_WORK)
set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
find_path(MPI_HEADER_PATH mpi.h
HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH}
PATH_SUFFIXES include)
set(MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH})
endif()
# Extract linker paths from the link command line
string(REGEX MATCHALL "(^| |-Wl,)-L([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}")
set(MPI_LINK_PATH)
foreach(LPATH ${MPI_ALL_LINK_PATHS})
string(REGEX REPLACE "^(| |-Wl,)-L" "" LPATH ${LPATH})
string(REGEX REPLACE "//" "/" LPATH ${LPATH})
list(APPEND MPI_LINK_PATH ${LPATH})
endforeach()
# try using showme:libdirs if extracting didn't work.
if (NOT MPI_LINK_PATH)
set(MPI_LINK_PATH ${MPI_LIBDIRS})
separate_arguments(MPI_LINK_PATH)
endif()
# Extract linker flags from the link command line
string(REGEX MATCHALL "(^| )-Wl,([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}")
set(MPI_LINK_FLAGS_WORK)
foreach(FLAG ${MPI_ALL_LINK_FLAGS})
if (MPI_LINK_FLAGS_WORK)
set(MPI_LINK_FLAGS_WORK "${MPI_LINK_FLAGS_WORK} ${FLAG}")
else()
set(MPI_LINK_FLAGS_WORK ${FLAG})
endif()
endforeach()
# Extract the set of libraries to link against from the link command
# line
string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}")
# add the compiler implicit directories because some compilers
# such as the intel compiler have libraries that show up
# in the showme list that can only be found in the implicit
# link directories of the compiler.
if (DEFINED CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES)
set(MPI_LINK_PATH
"${MPI_LINK_PATH};${CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES}")
endif ()
# Determine full path names for all of the libraries that one needs
# to link against in an MPI program
foreach(LIB ${MPI_LIBNAMES})
string(REGEX REPLACE "^ ?-l" "" LIB ${LIB})
# MPI_LIB is cached by find_library, but we don't want that. Clear it first.
set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
find_library(MPI_LIB NAMES ${LIB} HINTS ${MPI_LINK_PATH})
if (MPI_LIB)
list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB})
elseif (NOT MPI_FIND_QUIETLY)
message(WARNING "Unable to find MPI library ${LIB}")
endif()
endforeach()
# Sanity check MPI_LIBRARIES to make sure there are enough libraries
list(LENGTH MPI_LIBRARIES_WORK MPI_NUMLIBS)
list(LENGTH MPI_LIBNAMES MPI_NUMLIBS_EXPECTED)
if (NOT MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED)
set(MPI_LIBRARIES_WORK "MPI_${lang}_LIBRARIES-NOTFOUND")
endif()
endif()
elseif(try_libs)
# If we didn't have an MPI compiler script to interrogate, attempt to find everything
# with plain old find functions. This is nasty because MPI implementations have LOTS of
# different library names, so this section isn't going to be very generic. We need to
# make sure it works for MS MPI, though, since there are no compiler wrappers for that.
find_path(MPI_HEADER_PATH mpi.h
HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH}
PATH_SUFFIXES include Inc)
set(MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH})
# Decide between 32-bit and 64-bit libraries for Microsoft's MPI