Skip to content

Commit

Permalink
Merge pull request #475 from PrincetonUniversity/issue-472
Browse files Browse the repository at this point in the history
Issue 472 -- Implement templated array reading for multidimensional fortran arrays. Reading ibool, coordinates, partials
  • Loading branch information
lsawade authored Feb 17, 2025
2 parents 426e6f0 + f6190c7 commit cae5636
Show file tree
Hide file tree
Showing 35 changed files with 766 additions and 706 deletions.
26 changes: 15 additions & 11 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,32 @@ about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.
## Expected behavior
A clear and concise description of what you expected to happen.

## Actual (buggy) behavior
A clear and concise description of what is happening instead.

**To Reproduce**
## Screenshots

If applicable, add screenshots to help explain your problem.

## Setup information:

- Installation instructions:
```
Please paste the cmake configuration command here
Please paste the cmake configuration command here
```

**Expected behavior**
A clear and concise description of what you expected to happen.
## Machine information:

**Screenshots**
If applicable, add screenshots to help explain your problem.
[please complete the following information:]

**Machine information (please complete the following information):**
- OS: [e.g. Redhat]
- GPU available: [e.g. Yes (NVIDIA A100)]

**Additional context**
## Additional context

Add any other context about the problem here.
11 changes: 8 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ assignees: ''

---

**Is your feature request related to a problem? Please describe.**
## Is your feature request related to a problem?
A clear and concise description of what the problem is.

**Describe the solution you'd like**
## Describe the solution you'd like

A clear and concise description of what you want to happen.

**Additional context**
## Additional context

Add any other context or screenshots about the feature request here.

If this feature request helps with an existing issue, please link the issue here.
E.g. #<issue number>
6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Description
## Description

Please describe the changes/features in this pull request.

# Issue Number
## Issue Number

If there is an issue created for these changes, link it here

# Checklist
## Checklist

Please make sure to check developer documentation on specfem docs.

Expand Down
65 changes: 42 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(FETCHCONTENT_QUIET TRUE)

if (SPECFEMPP_BINDING_PYTHON)
message("-- Adding -fPIC flag for Python binding.")
message(STATUS "Adding -fPIC flag for Python binding.")
if(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
set(CMAKE_CXX_FLAGS "-fp-model=precise -fPIC")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
message("-- Detected Intel classic compiler which will be deprecated soon.")
message("-- It is recommended you use IntelLLVM compiler.")
message(STATUS "Detected Intel classic compiler which will be deprecated soon.")
message(STATUS "It is recommended you use IntelLLVM compiler.")
set(CMAKE_CXX_FLAGS "-diag-disable=10441 -fp-model=precise -fPIC")
else()
set(CMAKE_CXX_FLAGS "-fPIC")
Expand All @@ -42,24 +42,24 @@ else (SPECFEMPP_BINDING_PYTHON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
set(CMAKE_CXX_FLAGS "-fp-model=precise")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
message("-- Detected Intel classic compiler which will be deprecated soon.")
message("-- It is recommended you use IntelLLVM compiler.")
message(STATUS "Detected Intel classic compiler which will be deprecated soon.")
message(STATUS "It is recommended you use IntelLLVM compiler.")
set(CMAKE_CXX_FLAGS "-diag-disable=10441 -fp-model=precise")
endif()
endif (SPECFEMPP_BINDING_PYTHON)

# Check if MacOS
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(__APPLE__ TRUE)
message("-- macOS detected -- setting __APPLE__ TRUE")
message(STATUS "macOS detected -- setting __APPLE__ TRUE")
else(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(__APPLE__ FALSE)
message("-- macOS not detected -- setting __APPLE__ FALSE")
message(STATUS "macOS not detected -- setting __APPLE__ FALSE")
endif()

if (DEFINED Kokkos_ENABLE_CUDA)
if (Kokkos_ENABLE_CUDA)
# message("Setting CUDA variables")
# message(STATUS "Setting CUDA variables")
set(Kokkos_ENABLE_CUDA_LAMBDA ON CACHE BOOL "Using CUDA Lambda by default")
set(Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE ON CACHE BOOL "Using CUDA Relocatable device by default")
endif()
Expand Down Expand Up @@ -99,7 +99,7 @@ find_package(VTK COMPONENTS


if (NOT VTK_FOUND)
message("VTK not found: ${VTK_NOT_FOUND_MESSAGE}")
message(STATUS "VTK not found: ${VTK_NOT_FOUND_MESSAGE}")
set(VTK_CXX_BUILD OFF)
else ()
message(STATUS " VTK: ${VTK_LIBRARIES}")
Expand Down Expand Up @@ -150,31 +150,31 @@ endif()
find_package(HDF5 COMPONENTS CXX)

if (NOT ${HDF5_FOUND})
message("-- HDF5 not found. Building without HDF5.")
message(STATUS "HDF5 not found. Building without HDF5.")
set(HDF5_CXX_BUILD OFF)
else()
message("HDF5 libs/ and incs/:.")
message(STATUS "HDF5 libs/ and incs/:.")
message(STATUS " LIB: ${HDF5_LIBRARIES}")
message(STATUS " INC: ${HDF5_INCLUDE_DIRS}")
message(STATUS " LIBSO: ${HDF5_CXX_LIBRARIES}")
endif()


if (ENABLE_SIMD)
message("-- Enabling SIMD")
message(STATUS "Enabling SIMD")
add_definitions(-DENABLE_SIMD)
endif()

if (ENABLE_PROFILING)
message("-- Enabling profiling")
message(STATUS "Enabling profiling")
add_definitions(-DENABLE_PROFILING)
endif()

if (ENABLE_DOUBLE_PRECISION)
message("-- Enabling double precision")
message(STATUS "Enabling double precision")
set(TYPE_REAL "double")
else(ENABLE_DOUBLE_PRECISION)
message("-- Enabling single precision")
message(STATUS "Enabling single precision")
set(TYPE_REAL "float")
endif(ENABLE_DOUBLE_PRECISION)

Expand All @@ -188,9 +188,27 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup/constants.hpp.in
include_directories(include)
include_directories(${CMAKE_BINARY_DIR}/include)

# ========== MESHFEM ==============
# Set loglevel to STATUS if build type is debug
if (CMAKE_BUILD_TYPE MATCHES Release)
set(SUBDIR_LOG_LEVEL NOTICE)
else()
set(SUBDIR_LOG_LEVEL STATUS)
endif()

# ========== MESHFEM2D ==============
message(STATUS "Building meshfem2D")
set(_saved_CMAKE_MESSAGE_LOG_LEVEL ${CMAKE_MESSAGE_LOG_LEVEL})
set(CMAKE_MESSAGE_LOG_LEVEL ${SUBDIR_LOG_LEVEL})
add_subdirectory(fortran/meshfem2d)
set(CMAKE_MESSAGE_LOG_LEVEL ${_saved_CMAKE_MESSAGE_LOG_LEVEL})
# =================================

# ========== MESHFEM3D ==============
message(STATUS "Building xmeshfem3D & xgenerate_databases")
set(_saved_CMAKE_MESSAGE_LOG_LEVEL ${CMAKE_MESSAGE_LOG_LEVEL})
set(CMAKE_MESSAGE_LOG_LEVEL ${SUBDIR_LOG_LEVEL})
add_subdirectory(fortran/meshfem3d)
set(CMAKE_MESSAGE_LOG_LEVEL ${_saved_CMAKE_MESSAGE_LOG_LEVEL})
# =================================


Expand Down Expand Up @@ -224,8 +242,8 @@ add_library(
src/IO/mesh/impl/fortran/dim2/read_parameters.cpp
# Fortran 3D part
src/IO/mesh/impl/fortran/dim3/read_parameters.cpp
src/IO/mesh/impl/fortran/dim3/read_mapping.cpp
src/IO/mesh/impl/fortran/dim3/read_coordinates.cpp
src/IO/mesh/impl/fortran/dim3/read_partial_derivatives.cpp
)

if (NOT HDF5_CXX_BUILD)
Expand Down Expand Up @@ -298,9 +316,9 @@ if (MPI_PARALLEL)
specfem_mpi
PUBLIC -DMPI_PARALLEL
)
message("-- Compiling SPECFEM with MPI")
message(STATUS "Compiling SPECFEM with MPI")
else()
message("-- Compiling SPECFEM without MPI")
message(STATUS "Compiling SPECFEM without MPI")
endif(MPI_PARALLEL)

# add_library(
Expand Down Expand Up @@ -330,6 +348,7 @@ add_library(
src/mesh/parameters/parameters.cpp
src/mesh/mapping/mapping.cpp
src/mesh/coordinates/coordinates.cpp
src/mesh/partial_derivatives/partial_derivatives.cpp
src/mesh/mesh.cpp
)

Expand Down Expand Up @@ -681,12 +700,12 @@ target_link_libraries(

# Include tests
if (BUILD_TESTS)
message("-- Including tests.")
message(STATUS "Including tests.")
add_subdirectory(tests/unit-tests)
endif()

if (BUILD_EXAMPLES)
message("-- Including examples.")
message(STATUS "Including examples.")
add_subdirectory(examples)
endif()

Expand All @@ -702,7 +721,7 @@ if (DOXYGEN_FOUND)

# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message("Doxygen build started")
message(STATUS "Doxygen build started")

# Note: do not put "ALL" - this builds docs together with application EVERY TIME!
add_custom_target( docs
Expand All @@ -711,7 +730,7 @@ if (DOXYGEN_FOUND)
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
message(STATUS "Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)

if (SPECFEMPP_USE_SKBUILD AND EXISTS ${SKBUILD_SCRIPTS_DIR})
Expand Down
4 changes: 4 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
cmake_minimum_required(VERSION 3.17.5)

# 2D
add_subdirectory(anisotropic-crystal)
add_subdirectory(homogeneous-medium-flat-topography)
add_subdirectory(fluid-solid-interface)
add_subdirectory(fluid-solid-bathymetry)
add_subdirectory(solid-solid-interface)
add_subdirectory(Tromp_2005)

# 3D
add_subdirectory(dim3/homogeneous_halfspace)
6 changes: 6 additions & 0 deletions examples/dim3/homogeneous_halfspace/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build/
OUTPUT_FILES/
DATA/meshfem3D_files/Mesh_Par_file
DATA/meshfem3D_files/interfaces.txt
Par_File
specfem_config.yaml
12 changes: 12 additions & 0 deletions examples/dim3/homogeneous_halfspace/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

CMAKE_MINIMUM_REQUIRED(VERSION 3.17.5)


configure_file(config/Mesh_Par_file.in ${CMAKE_CURRENT_SOURCE_DIR}/DATA/meshfem3D_files/Mesh_Par_file)
configure_file(config/interfaces.txt.in ${CMAKE_CURRENT_SOURCE_DIR}/DATA/meshfem3D_files/interfaces.txt)
configure_file(config/Par_File.in ${CMAKE_CURRENT_SOURCE_DIR}/Par_File)
configure_file(config/specfem_config.yaml.in ${CMAKE_CURRENT_SOURCE_DIR}/specfem_config.yaml)

# Mkdir
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OUTPUT_FILES/DATABASES_MPI)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OUTPUT_FILES/results)
1 change: 1 addition & 0 deletions examples/dim3/homogeneous_halfspace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ xmeshfem3D -p DATA/meshfem3D_files/Mesh_Par_file
xgenerate_databases -p Par_File
```

## Running the simulation (so far only reading the mesh)
Then we can run specfem with the following command:

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ UTM_PROJECTION_ZONE = 11
SUPPRESS_UTM_PROJECTION = .true.

# file that contains the interfaces of the model / mesh
INTERFACES_FILE = DATA/meshfem3D_files/interfaces.txt
INTERFACES_FILE = @CMAKE_CURRENT_SOURCE_DIR@/DATA/meshfem3D_files/interfaces.txt

# file that contains the cavity
CAVITY_FILE = no_cavity.dat
Expand Down Expand Up @@ -67,7 +67,7 @@ CREATE_VTK_FILES = .true.
SAVE_MESH_AS_CUBIT = .false.

# path to store the databases files
LOCAL_PATH = ./OUTPUT_FILES/DATABASES_MPI
LOCAL_PATH = @CMAKE_CURRENT_SOURCE_DIR@/OUTPUT_FILES/DATABASES_MPI

#-----------------------------------------------------------
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ NGNOD = 8
MODEL = default

# path for external model files (if MODEL = coupled)
COUPLED_MODEL_DIRECTORY = DATA/coupled_model/
COUPLED_MODEL_DIRECTORY = @CMAKE_CURRENT_SOURCE_DIR@/DATA/coupled_model/

# path for external tomographic models files
TOMOGRAPHY_PATH = DATA/tomo_files/
TOMOGRAPHY_PATH = @CMAKE_CURRENT_SOURCE_DIR@/DATA/tomo_files/
# if you are using a SEP model (oil-industry format)
SEP_MODEL_DIRECTORY = DATA/my_SEP_model/
SEP_MODEL_DIRECTORY = @CMAKE_CURRENT_SOURCE_DIR@/DATA/my_SEP_model/

#-----------------------------------------------------------

Expand Down Expand Up @@ -166,7 +166,7 @@ HDUR_MOVIE = 0.0
SAVE_MESH_FILES = .false.

# path to store the local database file on each node
LOCAL_PATH = OUTPUT_FILES/DATABASES_MPI
LOCAL_PATH = @CMAKE_CURRENT_SOURCE_DIR@/OUTPUT_FILES/DATABASES_MPI

# interval at which we output time step info and max of norm of displacement
NTSTEP_BETWEEN_OUTPUT_INFO = 500
Expand Down Expand Up @@ -194,7 +194,7 @@ USE_SOURCES_RECEIVERS_Z = .false.
# its norm is ignored and the norm of the force used is the factor force source times the source time function.
USE_FORCE_POINT_SOURCE = .false.

SOURCE_FILENAME = DATA/CMTSOLUTION
SOURCE_FILENAME = @CMAKE_CURRENT_SOURCE_DIR@/DATA/CMTSOLUTION

# set to true to use a Ricker source time function instead of the source time functions set by default
# to represent a (tilted) FORCESOLUTION force point source or a CMTSOLUTION moment-tensor source.
Expand Down Expand Up @@ -347,7 +347,7 @@ SAVE_MOHO_MESH = .false.
COUPLE_WITH_INJECTION_TECHNIQUE = .false.
INJECTION_TECHNIQUE_TYPE = 3 # 1 = DSM, 2 = AxiSEM, 3 = FK
MESH_A_CHUNK_OF_THE_EARTH = .false.
TRACTION_PATH = DATA/AxiSEM_tractions/3/
TRACTION_PATH = @CMAKE_CURRENT_SOURCE_DIR@/DATA/AxiSEM_tractions/3/
FKMODEL_FILE = FKmodel
RECIPROCITY_AND_KH_INTEGRAL = .false. # does not work yet

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# interface number 1 (topography, top of the mesh)
.true. 2 2 0.0 0.0 1000.0 1000.0
DATA/meshfem3D_files/interface1.txt
@CMAKE_CURRENT_SOURCE_DIR@/DATA/meshfem3D_files/interface1.txt
#
# for each layer, we give the number of spectral elements in the vertical direction
#
Expand Down
Loading

0 comments on commit cae5636

Please sign in to comment.