11cmake_minimum_required (VERSION 3.17.5)
22
3- project (SPECFEMPP VERSION 0.1.0)
3+ project (SPECFEMPP VERSION 0.1.0 LANGUAGES CXX Fortran )
44
55set (CMAKE_CXX_STANDARD 17)
66option (HDF5_CXX_BUILD "Build HDF5 C++" ON )
@@ -11,6 +11,8 @@ option(BUILD_EXAMPLES "Examples included" ON)
1111option (ENABLE_SIMD "Enable SIMD" OFF )
1212option (ENABLE_PROFILING "Enable profiling" OFF )
1313option (SPECFEMPP_BINDING_PYTHON "Enable Python binding" OFF )
14+ option (ENABLE_DOUBLE_PRECISION "Enable double precision" OFF )
15+
1416# set(CMAKE_BUILD_TYPE Release)
1517set (CHUNK_SIZE 32)
1618set (NUM_CHUNKS 1)
@@ -26,12 +28,12 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2628set (FETCHCONTENT_QUIET TRUE )
2729
2830if (SPECFEMPP_BINDING_PYTHON)
29- message ("-- Adding -fPIC flag for Python binding." )
31+ message (STATUS " Adding -fPIC flag for Python binding." )
3032 if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" )
3133 set (CMAKE_CXX_FLAGS "-fp-model=precise -fPIC" )
3234 elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" )
33- message ("-- Detected Intel classic compiler which will be deprecated soon." )
34- message ("-- It is recommended you use IntelLLVM compiler." )
35+ message (STATUS " Detected Intel classic compiler which will be deprecated soon." )
36+ message (STATUS " It is recommended you use IntelLLVM compiler." )
3537 set (CMAKE_CXX_FLAGS "-diag-disable=10441 -fp-model=precise -fPIC" )
3638 else ()
3739 set (CMAKE_CXX_FLAGS "-fPIC" )
@@ -40,24 +42,24 @@ else (SPECFEMPP_BINDING_PYTHON)
4042 if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" )
4143 set (CMAKE_CXX_FLAGS "-fp-model=precise" )
4244 elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" )
43- message ("-- Detected Intel classic compiler which will be deprecated soon." )
44- message ("-- It is recommended you use IntelLLVM compiler." )
45+ message (STATUS " Detected Intel classic compiler which will be deprecated soon." )
46+ message (STATUS " It is recommended you use IntelLLVM compiler." )
4547 set (CMAKE_CXX_FLAGS "-diag-disable=10441 -fp-model=precise" )
4648 endif ()
4749endif (SPECFEMPP_BINDING_PYTHON)
4850
4951# Check if MacOS
5052if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
5153 set (__APPLE__ TRUE )
52- message ("-- macOS detected -- setting __APPLE__ TRUE" )
54+ message (STATUS " macOS detected -- setting __APPLE__ TRUE" )
5355else (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
5456 set (__APPLE__ FALSE )
55- message ("-- macOS not detected -- setting __APPLE__ FALSE" )
57+ message (STATUS " macOS not detected -- setting __APPLE__ FALSE" )
5658endif ()
5759
5860if (DEFINED Kokkos_ENABLE_CUDA)
5961 if (Kokkos_ENABLE_CUDA)
60- # message("Setting CUDA variables")
62+ # message(STATUS "Setting CUDA variables")
6163 set (Kokkos_ENABLE_CUDA_LAMBDA ON CACHE BOOL "Using CUDA Lambda by default" )
6264 set (Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE ON CACHE BOOL "Using CUDA Relocatable device by default" )
6365 endif ()
@@ -97,7 +99,7 @@ find_package(VTK COMPONENTS
9799
98100
99101if (NOT VTK_FOUND)
100- message ("VTK not found: ${VTK_NOT_FOUND_MESSAGE} " )
102+ message (STATUS "VTK not found: ${VTK_NOT_FOUND_MESSAGE} " )
101103 set (VTK_CXX_BUILD OFF )
102104else ()
103105 message (STATUS " VTK: ${VTK_LIBRARIES} " )
@@ -148,34 +150,68 @@ endif()
148150find_package (HDF5 COMPONENTS CXX)
149151
150152if (NOT ${HDF5_FOUND} )
151- message ("-- HDF5 not found. Building without HDF5." )
153+ message (STATUS " HDF5 not found. Building without HDF5." )
152154 set (HDF5_CXX_BUILD OFF )
153155else ()
154- message ("HDF5 libs/ and incs/:." )
156+ message (STATUS "HDF5 libs/ and incs/:." )
155157 message (STATUS " LIB: ${HDF5_LIBRARIES} " )
156158 message (STATUS " INC: ${HDF5_INCLUDE_DIRS} " )
157159 message (STATUS " LIBSO: ${HDF5_CXX_LIBRARIES} " )
158160endif ()
159161
160162
161- configure_file (constants.hpp.in constants.hpp)
162-
163- include_directories (include )
164- include_directories (${CMAKE_BINARY_DIR} )
165-
166- add_subdirectory (fortran/meshfem2d)
167- add_subdirectory (fortran/meshfem3d)
168-
169163if (ENABLE_SIMD)
170- message ("-- Enabling SIMD" )
164+ message (STATUS " Enabling SIMD" )
171165 add_definitions (-DENABLE_SIMD)
172166endif ()
173167
174168if (ENABLE_PROFILING)
175- message ("-- Enabling profiling" )
169+ message (STATUS " Enabling profiling" )
176170 add_definitions (-DENABLE_PROFILING)
177171endif ()
178172
173+ if (ENABLE_DOUBLE_PRECISION)
174+ message (STATUS "Enabling double precision" )
175+ set (TYPE_REAL "double" )
176+ else (ENABLE_DOUBLE_PRECISION)
177+ message (STATUS "Enabling single precision" )
178+ set (TYPE_REAL "float" )
179+ endif (ENABLE_DOUBLE_PRECISION)
180+
181+ # Configure the setup headers
182+ configure_file (${CMAKE_CURRENT_SOURCE_DIR} /setup/specfem_setup.hpp.in
183+ ${CMAKE_BINARY_DIR} /include /specfem_setup.hpp)
184+ configure_file (${CMAKE_CURRENT_SOURCE_DIR} /setup/constants.hpp.in
185+ ${CMAKE_BINARY_DIR} /include /constants.hpp)
186+
187+ # Add the include directories so that the generated files can be found
188+ include_directories (include )
189+ include_directories (${CMAKE_BINARY_DIR} /include )
190+
191+ # Set loglevel to STATUS if build type is debug
192+ if (CMAKE_BUILD_TYPE MATCHES Release)
193+ set (SUBDIR_LOG_LEVEL NOTICE)
194+ else ()
195+ set (SUBDIR_LOG_LEVEL STATUS )
196+ endif ()
197+
198+ # ========== MESHFEM2D ==============
199+ message (STATUS "Building meshfem2D" )
200+ set (_saved_CMAKE_MESSAGE_LOG_LEVEL ${CMAKE_MESSAGE_LOG_LEVEL} )
201+ set (CMAKE_MESSAGE_LOG_LEVEL ${SUBDIR_LOG_LEVEL} )
202+ add_subdirectory (fortran/meshfem2d)
203+ set (CMAKE_MESSAGE_LOG_LEVEL ${_saved_CMAKE_MESSAGE_LOG_LEVEL} )
204+ # =================================
205+
206+ # ========== MESHFEM3D ==============
207+ message (STATUS "Building xmeshfem3D & xgenerate_databases" )
208+ set (_saved_CMAKE_MESSAGE_LOG_LEVEL ${CMAKE_MESSAGE_LOG_LEVEL} )
209+ set (CMAKE_MESSAGE_LOG_LEVEL ${SUBDIR_LOG_LEVEL} )
210+ add_subdirectory (fortran/meshfem3d)
211+ set (CMAKE_MESSAGE_LOG_LEVEL ${_saved_CMAKE_MESSAGE_LOG_LEVEL} )
212+ # =================================
213+
214+
179215# Build specfem2d libraries
180216add_library (
181217 quadrature
@@ -196,13 +232,20 @@ add_library(
196232 src/IO/fortranio/fortran_io.cpp
197233 src/IO/sources .cpp
198234 src/IO/receivers.cpp
199- src/IO/mesh.cpp
200- src/IO/mesh/impl/fortran/read_boundaries.cpp
201- src/IO/mesh/impl/fortran/read_elements.cpp
202- src/IO/mesh/impl/fortran/read_material_properties.cpp
203- src/IO/mesh/impl/fortran/read_mesh_database.cpp
204- src/IO/mesh/impl/fortran/read_interfaces.cpp
205- src/IO/mesh/impl/fortran/read_parameters.cpp
235+ # Fortran 2D part
236+ src/IO/mesh/impl/fortran/dim2/mesh.cpp
237+ src/IO/mesh/impl/fortran/dim2/read_boundaries.cpp
238+ src/IO/mesh/impl/fortran/dim2/read_elements.cpp
239+ src/IO/mesh/impl/fortran/dim2/read_material_properties.cpp
240+ src/IO/mesh/impl/fortran/dim2/read_mesh_database.cpp
241+ src/IO/mesh/impl/fortran/dim2/read_interfaces.cpp
242+ src/IO/mesh/impl/fortran/dim2/read_parameters.cpp
243+ # Fortran 3D part
244+ src/IO/mesh/impl/fortran/dim3/mesh.cpp
245+ src/IO/mesh/impl/fortran/dim3/read_parameters.cpp
246+ src/IO/mesh/impl/fortran/dim3/read_coordinates.cpp
247+ src/IO/mesh/impl/fortran/dim3/read_partial_derivatives.cpp
248+ src/IO/mesh/impl/fortran/dim3/utilities.cpp
206249)
207250
208251if (NOT HDF5_CXX_BUILD)
@@ -275,9 +318,9 @@ if (MPI_PARALLEL)
275318 specfem_mpi
276319 PUBLIC -DMPI_PARALLEL
277320 )
278- message ("-- Compiling SPECFEM with MPI" )
321+ message (STATUS " Compiling SPECFEM with MPI" )
279322else ()
280- message ("-- Compiling SPECFEM without MPI" )
323+ message (STATUS " Compiling SPECFEM without MPI" )
281324endif (MPI_PARALLEL)
282325
283326# add_library(
@@ -294,21 +337,36 @@ endif(MPI_PARALLEL)
294337
295338add_library (
296339 mesh
297- src/mesh/boundaries/forcing_boundaries.cpp
298- src/mesh/boundaries/absorbing_boundaries.cpp
299- src/mesh/boundaries/acoustic_free_surface.cpp
300- src/mesh/elements/tangential_elements.cpp
301- src/mesh/elements/axial_elements.cpp
340+ # 2-D
341+ src/mesh/dim2/mesh.cpp
342+ src/mesh/dim2/boundaries/forcing_boundaries.cpp
343+ src/mesh/dim2/boundaries/absorbing_boundaries.cpp
344+ src/mesh/dim2/boundaries/acoustic_free_surface.cpp
345+ src/mesh/dim2/elements/tangential_elements.cpp
346+ src/mesh/dim2/elements/axial_elements.cpp
302347 # src/mesh/mpi_interfaces/mpi_interfaces.cpp
303- src/mesh/materials/materials.cpp
304- src/mesh/coupled_interfaces/interface_container.cpp
305- src/mesh/coupled_interfaces/coupled_interfaces.cpp
306- src/mesh/tags/tags.cpp
307- src/mesh/mesh.cpp
348+ src/mesh/dim2/materials/materials.cpp
349+ src/mesh/dim2/coupled_interfaces/interface_container.cpp
350+ src/mesh/dim2/coupled_interfaces/coupled_interfaces.cpp
351+ src/mesh/dim2/tags/tags.cpp
352+ # 3-D
353+ src/mesh/dim3/mesh.cpp
354+ src/mesh/dim3/boundaries/absorbing_boundary.cpp
355+ src/mesh/dim3/boundaries/free_surface.cpp
356+ src/mesh/dim3/coupled_interfaces/coupled_interfaces.cpp
357+ src/mesh/dim3/element_types/element_types.cpp
358+ src/mesh/dim3/parameters/parameters.cpp
359+ src/mesh/dim3/parameters/parameters.cpp
360+ src/mesh/dim3/mapping/mapping.cpp
361+ src/mesh/dim3/materials/materials.cpp
362+ src/mesh/dim3/coordinates/coordinates.cpp
363+ src/mesh/dim3/partial_derivatives/partial_derivatives.cpp
364+
308365)
309366
310367target_link_libraries (
311368 mesh
369+ enumerations
312370 Kokkos::kokkos
313371 specfem_mpi
314372 # material_class
@@ -614,21 +672,46 @@ add_executable(
614672 src/specfem2d.cpp
615673)
616674
617-
618-
619675target_link_libraries (
620676 specfem2d
621677 execute
622678)
623679
680+ add_executable (
681+ specfem3d
682+ src/specfem3d.cpp
683+ )
684+
685+ target_link_libraries (
686+ specfem3d
687+ specfem_mpi
688+ IO
689+ Kokkos::kokkos
690+ mesh
691+ quadrature
692+ compute
693+ source_class
694+ parameter_reader
695+ receiver_class
696+ writer
697+ periodic_tasks
698+ reader
699+ coupled_interface
700+ kokkos_kernels
701+ solver
702+ ${BOOST_LIBS}
703+ yaml-cpp
704+ )
705+
706+
624707# Include tests
625708if (BUILD_TESTS)
626- message ("-- Including tests." )
709+ message (STATUS " Including tests." )
627710 add_subdirectory (tests/unit-tests)
628711endif ()
629712
630713if (BUILD_EXAMPLES)
631- message ("-- Including examples." )
714+ message (STATUS " Including examples." )
632715 add_subdirectory (examples)
633716endif ()
634717
@@ -644,7 +727,7 @@ if (DOXYGEN_FOUND)
644727
645728 # request to configure the file
646729 configure_file (${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
647- message ("Doxygen build started" )
730+ message (STATUS "Doxygen build started" )
648731
649732 # Note: do not put "ALL" - this builds docs together with application EVERY TIME!
650733 add_custom_target ( docs
@@ -653,7 +736,7 @@ if (DOXYGEN_FOUND)
653736 COMMENT "Generating API documentation with Doxygen"
654737 VERBATIM )
655738else (DOXYGEN_FOUND)
656- message ("Doxygen need to be installed to generate the doxygen documentation" )
739+ message (STATUS "Doxygen need to be installed to generate the doxygen documentation" )
657740endif (DOXYGEN_FOUND)
658741
659742if (SPECFEMPP_USE_SKBUILD AND EXISTS ${SKBUILD_SCRIPTS_DIR} )
0 commit comments