Skip to content

Commit

Permalink
Merge pull request #350 from PrincetonUniversity/issue-309-meshfem3d
Browse files Browse the repository at this point in the history
Issue 309 meshfem3d
  • Loading branch information
lsawade authored Dec 31, 2024
2 parents 8c5acab + 4a6776b commit 7b1cb78
Show file tree
Hide file tree
Showing 199 changed files with 84,521 additions and 12 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ set(NUM_CHUNKS 1)
set(NUM_THREADS 160)
set(NUM_VECTOR_LANES 1)

# Set binary output directories.
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/archive)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)


if (SPECFEMPP_ENABLE_PYTHON)
message("-- Adding -fPIC flag for Python binding.")
if(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
Expand Down Expand Up @@ -121,7 +127,8 @@ configure_file(constants.hpp.in constants.hpp)
include_directories(include)
include_directories(${CMAKE_BINARY_DIR})

add_subdirectory(meshfem2d)
add_subdirectory(fortran/meshfem2d)
add_subdirectory(fortran/meshfem3d)

if (ENABLE_SIMD)
message("-- Enabling SIMD")
Expand Down
4 changes: 2 additions & 2 deletions docs/cookbooks/example_01.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ If the above command returns a path to the ``specfem2d`` executable, then the bu

.. code:: bash
export PATH=$PATH:<PATH TO SPECFEM++ BUILD DIRECTORY>
export PATH=$PATH:<PATH TO SPECFEM++ BUILD DIRECTORY/bin>
.. note::

Make sure to replace ``<PATH TO SPECFEM++ BUILD DIRECTORY>`` with the actual path to the SPECFEM++ build directory on your system.
Make sure to replace ``<PATH TO SPECFEM++ BUILD DIRECTORY/bin>`` with the actual path to the SPECFEM++ build directory on your system.

Now let's create the necessary directories to store the input files and output artifacts.

Expand Down
4 changes: 2 additions & 2 deletions docs/cookbooks/example_02.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ If the above command returns a path to the ``specfem2d`` executable, then the bu

.. code:: bash
export PATH=$PATH:<PATH TO SPECFEM++ BUILD DIRECTORY>
export PATH=$PATH:<PATH TO SPECFEM++ BUILD DIRECTORY/bin>
.. note::

Make sure to replace ``<PATH TO SPECFEM++ BUILD DIRECTORY>`` with the actual path to the SPECFEM++ build directory on your system.
Make sure to replace ``<PATH TO SPECFEM++ BUILD DIRECTORY/bin>`` with the actual path to the SPECFEM++ build directory on your system.

Now let's create the necessary directories to store the input files and output artifacts.

Expand Down
4 changes: 2 additions & 2 deletions docs/cookbooks/example_03.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ If the above command returns a path to the ``specfem2d`` executable, then the bu

.. code:: bash
export PATH=$PATH:<PATH TO SPECFEM++ BUILD DIRECTORY>
export PATH=$PATH:<PATH TO SPECFEM++ BUILD DIRECTORY/bin>
.. note::

Make sure to replace ``<PATH TO SPECFEM++ BUILD DIRECTORY>`` with the actual path to the SPECFEM++ build directory on your system.
Make sure to replace ``<PATH TO SPECFEM++ BUILD DIRECTORY/bin>`` with the actual path to the SPECFEM++ build directory on your system.

Now let's create the necessary directories to store the input files and output artifacts.

Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Finally, once compiled you could run SPECFEM++ from inside the build directory,

.. code-block:: bash
export PATH=${PATH}:<location to build directory>
export PATH=${PATH}:<location to SPECFEM++ build directory/bin>
Testing Installation
=====================
Expand Down
4 changes: 2 additions & 2 deletions examples/fluid-solid-interface/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ rule run_solver:
runtime=10,
shell:
"""
module purge
module load boost/1.73.0
# module purge
# module load boost/1.73.0
mkdir -p OUTPUT_FILES/results
echo "Hostname: $(hostname)" > output.log
{SPECFEM_BIN} -p {input.config} >> output.log
Expand Down
4 changes: 2 additions & 2 deletions meshfem2d/CMakeLists.txt → fortran/meshfem2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ set( MESHFEM_OBJECTS

add_custom_command(
OUTPUT meshfem2D
COMMAND ${CMAKE_Fortran_COMPILER} ${FCFLAGS_f90} -o ${CMAKE_BINARY_DIR}/xmeshfem2D ${MESHFEM_OBJECTS} ${MESHFEM_SHARED_OBJECTS}
COMMAND ${CMAKE_Fortran_COMPILER} ${FCFLAGS_f90} -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/xmeshfem2D ${MESHFEM_OBJECTS} ${MESHFEM_SHARED_OBJECTS}
DEPENDS ${MESHFEM_OBJECTS} ${MESHFEM_SHARED_OBJECTS}
)

Expand All @@ -242,6 +242,6 @@ add_custom_target(meshfem2D_exec ALL
)

add_custom_target(xadj_seismogram ALL
COMMAND ${CMAKE_Fortran_COMPILER} ${FCFLAGS_f90} -o ${CMAKE_BINARY_DIR}/xadj_seismogram ${CMAKE_CURRENT_SOURCE_DIR}/adj_seismogram.f90
COMMAND ${CMAKE_Fortran_COMPILER} ${FCFLAGS_f90} -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/xadj_seismogram ${CMAKE_CURRENT_SOURCE_DIR}/adj_seismogram.f90
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/adj_seismogram.f90
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions fortran/meshfem3d/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*build*
25 changes: 25 additions & 0 deletions fortran/meshfem3d/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Minimum CMake version required
cmake_minimum_required(VERSION 3.10)

# Project name and language
project(MESHFEM3D LANGUAGES Fortran C)

# Set the Fortran standard to 95
set(CMAKE_Fortran_STANDARD 95)
set(CMAKE_Fortran_STANDARD_REQUIRED ON)

set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/fortran/meshfem3d/modules)
include_directories("${CMAKE_BINARY_DIR}/fortran/meshfem3d/modules")

set(ADIOS "OFF" CACHE BOOL "Use ADIOS for I/O")

if (ADIOS)
message(STATUS "ADIOS enabled for Meshfem3D Compilation")
else(ADIOS)
message(STATUS "ADIOS disabled for Meshfem3D Compilation")
endif(ADIOS)

add_subdirectory(setup)
add_subdirectory(shared)
add_subdirectory(meshfem3D)
add_subdirectory(generate_databases)
121 changes: 121 additions & 0 deletions fortran/meshfem3d/generate_databases/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Minimum CMake version required
cmake_minimum_required(VERSION 3.10)

# Project name and language
project(MESHFEM3D_MESHFEM3D LANGUAGES Fortran C)

# Set the Fortran standard to 95
set(CMAKE_Fortran_STANDARD 95)
set(CMAKE_Fortran_STANDARD_REQUIRED ON)

set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/fortran/meshfem3d/modules)
include_directories("${CMAKE_BINARY_DIR}/fortran/meshfem3d/modules")

set(MESHFEM3D_GENERATE_DATABASES_MODULE
calc_jacobian.f90
create_mass_matrices.f90
create_regions_mesh.f90
fault_generate_databases.f90
finalize_databases.f90
generate_databases_par.F90
generate_databases.f90
get_absorbing_boundary.F90
get_coupling_surfaces.f90
get_model.F90
get_MPI.f90
get_perm_color.f90
lts_generate_databases.F90
memory_eval.f90
model_1d_cascadia.f90
model_1d_prem.f90
model_1d_socal.f90
model_aniso.f90
model_coupled.f90
model_default.f90
model_external_values.F90
model_ipati.f90
model_gll.f90
model_salton_trough.f90
model_tomography.f90
parse_sep.c
pml_set_local_dampingcoeff.f90
read_parameters.f90
read_partition_files.f90
save_arrays_solver.F90
setup_color_perm.f90
setup_mesh_adjacency.f90
setup_mesh.f90
wavefield_discontinuity_generate_databases.f90
)

set(MESHFEM3D_GEN_DB_HDF5_MODULE
read_partition_files_hdf5.F90
save_arrays_solver_hdf5.F90
)

if (ADIOS)
message(STATUS "ADIOS enabled")
list(APPEND MESHFEM3D_GENERATE_DATABASES_MODULE
model_gll_adios.F90
model_ipati_adios.F90
read_partition_files_adios.F90
save_arrays_solver_adios.F90
save_moho_adios.F90
)
endif(ADIOS)

# Add MPI dependency
if (MPI_PARALLEL)
list(APPEND MESHFEM3D_GENERATE_DATABASES_MODULE model_sep)
else(MPI_PARALLEL)
list(APPEND MESHFEM3D_GENERATE_DATABASES_MODULE model_sep_nompi)
endif(MPI_PARALLEL)

# Create parameter library module
add_library(meshfem3D_generate_databases_module generate_databases_par.F90)
add_library(meshfem3D::generate_databases_module ALIAS meshfem3D_generate_databases_module)
target_link_libraries(meshfem3D_generate_databases_module PRIVATE meshfem3D::constants meshfem3D::shared_module meshfem3D::shared)

# Create HDF5 module
message(STATUS "Creating HDF5 module using: ${MESHFEM3D_GEN_DB_HDF5_MODULE}")
add_library(meshfem3D_generate_databases_hdf5_module
${MESHFEM3D_GEN_DB_HDF5_MODULE}
)
add_library(meshfem3D::generate_databases_hdf5_module ALIAS meshfem3D_generate_databases_hdf5_module)
target_link_libraries(meshfem3D_generate_databases_hdf5_module PRIVATE
meshfem3D::shared_hdf5_module
meshfem3D::shared_module
meshfem3D::generate_databases_module
)

# Compile library
add_library(meshfem3D_generate_databases
${MESHFEM3D_GENERATE_DATABASES_MODULE}
)

add_library(meshfem3D::generate_databases ALIAS meshfem3D_generate_databases)
target_link_libraries(meshfem3D_generate_databases PRIVATE
meshfem3D::generate_databases_module
meshfem3D::generate_databases_hdf5_module
meshfem3D::shared_module
meshfem3D::constants
meshfem3D::version
meshfem3D::shared_hdf5_module
meshfem3D::config
)

# Create executable
add_executable(xgenerate_databases generate_databases.f90)
target_link_libraries(xgenerate_databases PRIVATE
meshfem3D::generate_databases_module
meshfem3D::generate_databases_hdf5_module
meshfem3D::shared
meshfem3D::shared_module
meshfem3D::mesh_hdf5_module
meshfem3D::shared_hdf5_module
meshfem3D::shared_adios_module
meshfem3D::adios_methods_stubs
meshfem3D::param_reader
meshfem3D::version
meshfem3D::generate_databases
)
55 changes: 55 additions & 0 deletions fortran/meshfem3d/generate_databases/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#=====================================================================
#
# S p e c f e m 3 D
# -----------------
#
# Main historical authors: Dimitri Komatitsch and Jeroen Tromp
# CNRS, France
# and Princeton University, USA
# (there are currently many more authors!)
# (c) October 2017
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#=====================================================================

DIR = generate_databases

# The rest of this file is generic
#######################################

####
#### targets
####

default:
$(MAKE) -C ../.. $(DIR)

all:
$(MAKE) -C ../.. all

clean:
$(MAKE) -C ../.. CLEAN=$(DIR) clean

cleanall:
$(MAKE) -C ../.. clean

backup:
mkdir -p bak
cp *f90 *h Makefile bak

bak: backup

.PHONY: default all clean cleanall backup bak
Loading

0 comments on commit 7b1cb78

Please sign in to comment.