Skip to content

Commit f74b1e6

Browse files
committed
Merge branch 'housekeeping_2026-02-06' into 'development'
enable compilation on arm64 mac See merge request damask/DAMASK!1172
2 parents 9ec899e + 5558943 commit f74b1e6

File tree

8 files changed

+135
-37
lines changed

8 files changed

+135
-37
lines changed
Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Grid and Mesh Solver
22
on: [push]
33

44
env:
5-
PETSC_VERSION: '3.24.2'
5+
PETSC_VERSION: '3.24.4'
66
HOMEBREW_NO_ANALYTICS: 'ON' # Make Homebrew installation a little quicker
77
HOMEBREW_NO_AUTO_UPDATE: 'ON'
88
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 'ON'
@@ -25,12 +25,13 @@ jobs:
2525

2626
steps:
2727

28-
- uses: actions/checkout@v4
28+
- name: DAMASK - Checkout
29+
uses: actions/checkout@v4
2930

3031
- name: GCC - Install
3132
run: |
3233
sudo apt-get update
33-
sudo apt-get install liblapack-dev
34+
sudo apt-get install liblapack-dev libbz2-dev libfyaml-dev
3435
sudo apt-get install -y gcc-${GCC_V} gfortran-${GCC_V} g++-${GCC_V}
3536
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
3637
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
@@ -66,8 +67,10 @@ jobs:
6667
- name: PETSc - Installation
6768
run: |
6869
cd petsc-${PETSC_VERSION}
69-
./configure --with-fc=gfortran --with-cc=gcc --with-cxx=g++ \
70-
--download-openmpi --download-fftw --download-hdf5 --with-hdf5-fortran-bindings=1 --download-zlib \
70+
sed -i 's/self.getCompiler().lower()/self.getCompiler()/g' config/BuildSystem/config/packages/boost.py # https://gitlab.com/petsc/petsc/-/merge_requests/9012
71+
./configure \
72+
--with-fc=gfortran --with-cc=gcc --with-cxx=g++ \
73+
--download-openmpi --download-fftw --download-hdf5 --with-hdf5-fortran-bindings=1 --download-zlib --download-boost \
7174
--with-mpi-f90module-visibility=1
7275
make all
7376
@@ -91,7 +94,9 @@ jobs:
9194
fail-fast: false
9295

9396
steps:
94-
- uses: actions/checkout@v4
97+
98+
- name: DAMASK - Checkout
99+
uses: actions/checkout@v4
95100

96101
- name: Intel - Install
97102
run: |
@@ -104,7 +109,7 @@ jobs:
104109
| sudo tee /etc/apt/sources.list.d/oneAPI.list
105110
sudo apt-get update
106111
sudo apt-get install \
107-
intel-basekit intel-hpckit
112+
intel-basekit intel-hpckit libbz2-dev libfyaml-dev
108113
source /opt/intel/oneapi/setvars.sh
109114
printenv >> $GITHUB_ENV
110115
@@ -138,11 +143,9 @@ jobs:
138143
run: |
139144
cd petsc-${PETSC_VERSION}
140145
./configure \
141-
--with-fc=mpiifx \
142-
--with-cc=mpiicx \
143-
--with-cxx=mpiicpx \
146+
--with-fc=mpiifx --with-cc=mpiicx --with-cxx=mpiicpx \
144147
--with-x=0 \
145-
--download-fftw --download-hdf5 --with-hdf5-fortran-bindings=1 --download-zlib
148+
--download-fftw --download-hdf5 --with-hdf5-fortran-bindings=1 --download-zlib --download-boost
146149
make all
147150
148151
- name: DAMASK - Compile
@@ -155,3 +158,63 @@ jobs:
155158
run: |
156159
./bin/DAMASK_grid -l tensionX.yaml -g 20grains16x16x16.vti -m material.yaml -w examples/grid
157160
./bin/DAMASK_mesh -l tensionZ_3g.yaml -g cube_3grains.msh -m material.yaml -w examples/mesh
161+
162+
163+
macos_homebrew:
164+
165+
runs-on: macos-26
166+
167+
steps:
168+
169+
- name: DAMASK - Checkout
170+
uses: actions/checkout@v4
171+
172+
- name: GCC - Install
173+
uses: gerlero/brew-install@v1
174+
with:
175+
packages: gcc open-mpi bzip2 libfyaml
176+
177+
- name: PETSc - Cache download
178+
id: petsc-download
179+
uses: actions/cache@v4
180+
with:
181+
path: download
182+
key: petsc-${{ env.PETSC_VERSION }}.tar.gz
183+
184+
- name: PETSc - Download
185+
if: steps.petsc-download.outputs.cache-hit != 'true'
186+
run: |
187+
wget -q https://web.cels.anl.gov/projects/petsc/download/release-snapshots/petsc-${PETSC_VERSION}.tar.gz -P download
188+
189+
- name: PETSc - Prepare
190+
run: |
191+
tar -xf download/petsc-${PETSC_VERSION}.tar.gz -C .
192+
export PETSC_DIR=${PWD}/petsc-${PETSC_VERSION}
193+
export PETSC_ARCH=macos${GCC_V}
194+
printenv >> $GITHUB_ENV
195+
196+
- name: PETSc - Cache Installation
197+
id: petsc-install
198+
uses: actions/cache@v4
199+
with:
200+
path: petsc-${{ env.PETSC_VERSION }}
201+
key: petsc-${{ env.PETSC_VERSION }}-macos-${{ hashFiles('**/petscversion.h') }}
202+
203+
- name: PETSc - Installation
204+
run: |
205+
ln -s /opt/homebrew/bin/gfortran-15 /opt/homebrew/bin/gfortran
206+
cd petsc-${PETSC_VERSION}
207+
./configure --with-fc=mpifort --with-cc=mpicc --with-cxx=mpic++ \
208+
--download-fftw --download-hdf5 --with-hdf5-fortran-bindings=1 --download-zlib --download-boost
209+
make all
210+
211+
- name: DAMASK - Compile
212+
run: |
213+
cmake -B build -DGRID=ON -DMESH=ON -DCMAKE_INSTALL_PREFIX=${PWD} -DBUILDCMD_POST="--include-directory-after=$(gfortran -print-file-name=include)"
214+
cmake --build build --parallel
215+
cmake --install build
216+
217+
- name: DAMASK - Run
218+
run: |
219+
./bin/DAMASK_grid -l tensionX.yaml -g 20grains16x16x16.vti -m material.yaml -w examples/grid
220+
./bin/DAMASK_mesh -l tensionZ_3g.yaml -g cube_3grains.msh -m material.yaml -w examples/mesh

CMakeLists.txt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.18.0)
33
set(CMAKE_CXX_STANDARD 23)
44
set(CMAKE_C_STANDARD 17)
55
include(FindPkgConfig REQUIRED)
6+
include(CheckCXXSymbolExists REQUIRED)
67

78
if(DEFINED ENV{PETSC_DIR})
89
message("PETSC_DIR:\n$ENV{PETSC_DIR}\n")
@@ -41,16 +42,12 @@ project(DAMASK
4142
HOMEPAGE_URL https://damask-multiphysics.org
4243
LANGUAGES Fortran C CXX VERSION "${DAMASK_VERSION_CMAKE}")
4344

44-
if(NOT ${CMAKE_Fortran_COMPILER_ID} STREQUAL "LLVMFlang")
45-
if(NOT ${CMAKE_C_COMPILER_ID} STREQUAL ${CMAKE_Fortran_COMPILER_ID})
46-
message(FATAL_ERROR "C compiler (${CMAKE_C_COMPILER_ID}) does not match Fortran compiler (${CMAKE_Fortran_COMPILER_ID})")
47-
endif()
48-
if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL ${CMAKE_Fortran_COMPILER_ID})
49-
message(FATAL_ERROR "C++ compiler (${CMAKE_CXX_COMPILER_ID}) does not match Fortran compiler (${CMAKE_Fortran_COMPILER_ID})")
50-
endif()
51-
endif()
52-
5345
set(CMAKE_Fortran_PREPROCESS "ON")
46+
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
47+
set(CMAKE_MACOSX_RPATH TRUE)
48+
set(CMAKE_SKIP_BUILD_RPATH TRUE)
49+
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
50+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
5451

5552
pkg_check_modules(fYAML libfyaml)
5653
set(Boost_DEBUG ON)
@@ -185,9 +182,10 @@ if(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
185182
endif()
186183

187184
set(CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}} ${PETSC_INCLUDES} ${BUILDCMD_POST}")
185+
set(CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}} ${PETSC_INCLUDES} ${BUILDCMD_POST}")
188186
set(CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}} ${PETSC_INCLUDES} ${BUILDCMD_POST}")
189187

190-
set(CMAKE_Fortran_LINK_EXECUTABLE "${CMAKE_Fortran_LINK_EXECUTABLE} <LINK_FLAGS> <FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -L${PETSC_LIBRARY_DIRS} -lpetsc ${PETSC_EXTERNAL_LIB}")
188+
set(CMAKE_Fortran_LINK_EXECUTABLE "${CMAKE_Fortran_LINK_EXECUTABLE} <LINK_FLAGS> <FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
191189
if(${GRID})
192190
set(CMAKE_Fortran_LINK_EXECUTABLE "${CMAKE_Fortran_LINK_EXECUTABLE} -lz")
193191
endif()
@@ -202,8 +200,6 @@ if(fYAML_FOUND STREQUAL "1")
202200
set(CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}} -I${fYAML_INCLUDE_DIR}")
203201
endif()
204202

205-
# Link with Fortran compiler requires to add C++ standard library
206-
set(CMAKE_Fortran_LINK_EXECUTABLE "${CMAKE_Fortran_LINK_EXECUTABLE} -lstdc++ ${BUILDCMD_POST}")
207203

208204
message("Fortran Compiler Flags:\n${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}}\n")
209205
message("C Compiler Flags:\n${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}\n")

python/tests/test_grid_filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_coord0(np_rng):
3333
def test_grid_DNA(np_rng,mode,atol):
3434
"""Ensure that cellsSizeOrigin_coordinates0_xx is the inverse of coordinates0_xx."""
3535
cells = np_rng.integers(8,32,(3))
36-
size = np_rng.random(3)
36+
size = np_rng.random(3) + atol*100.
3737
origin = np_rng.random(3)
3838
coord0 = eval(f'grid_filters.coordinates0_{mode}(cells,size,origin)') # noqa
3939
coord0 += (np_rng.random(coord0.shape)-0.5) * atol # add noise

src/CLI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <filesystem>
3535
#include <stdexcept>
3636
#include <utility>
37-
#include "petscversion.h"
37+
#include <petscversion.h>
3838

3939
namespace fs = std::filesystem;
4040

src/CLI.f90

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ subroutine CLI_init()
9090
#elif PETSC_VERSION_MINOR==24
9191
#define PETSC_DOI '10.2172/2998643'
9292
#endif
93-
#if !(defined(BOOST))
93+
#if (defined(BOOST) && !defined(OLD_STYLE_C_TO_FORTRAN_STRING))
94+
type(C_PTR) :: CLI_ = C_NULL_PTR
95+
type(tCLIArgs) :: cliArgs
96+
integer(C_INT) :: stat
97+
#else
9498
character(len=:), allocatable :: &
9599
commandLine, & !< command line call as string
96100
flag, & !< individual flag
@@ -106,11 +110,6 @@ subroutine CLI_init()
106110
#ifdef PETSC_DOI
107111
character(len=*), parameter :: PETSc_DOI = PETSC_DOI
108112
#endif
109-
#if (defined(BOOST) && !defined(OLD_STYLE_C_TO_FORTRAN_STRING))
110-
type(C_PTR) :: CLI_ = C_NULL_PTR
111-
type(tCLIArgs) :: cliArgs
112-
integer(C_INT) :: stat
113-
#endif
114113

115114
print'(/,1x,a)', '<<<+- CLI init -+>>>'
116115

src/CMakeLists.txt

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
# SPDX-License-Identifier: AGPL-3.0-or-later
2+
function(fs_case_sensitive base_path out_var)
3+
set(_test_dir "${base_path}/neveruse")
4+
file(MAKE_DIRECTORY "${_test_dir}")
5+
file(WRITE "${_test_dir}/never.use" "test\n")
6+
file(WRITE "${_test_dir}/NEVER.USE" "test\n")
7+
8+
# Count distinct directory entries
9+
file(GLOB _case_test_files "${_test_dir}/*")
10+
list(LENGTH _case_test_files _case_test_count)
11+
12+
# If both names coexist as separate entries -> case-sensitive
13+
set(_is_case_sensitive FALSE)
14+
if(_case_test_count GREATER 1)
15+
set(_is_case_sensitive TRUE)
16+
endif()
17+
18+
file(REMOVE_RECURSE "${_test_dir}")
19+
set(${out_var} ${_is_case_sensitive} PARENT_SCOPE)
20+
endfunction()
21+
222
foreach(VARIANT GRID MESH TEST)
323
if(${VARIANT})
424
string(TOLOWER "${VARIANT}" VARIANT_LOWER)
@@ -29,12 +49,32 @@ foreach(VARIANT GRID MESH TEST)
2949
add_compile_definitions(BOOST)
3050
endif()
3151
target_link_libraries(${executable_name} PRIVATE damask_c_${VARIANT_LOWER})
52+
target_link_directories(${executable_name} PRIVATE ${PETSC_LIBRARY_DIRS})
53+
target_link_libraries(${executable_name} PRIVATE
54+
${PETSC_LIBRARIES}
55+
${PETSC_EXTERNAL_LIB}
56+
)
57+
58+
# Link with Fortran compiler requires to add C++ standard library
59+
check_cxx_symbol_exists(__GLIBCXX__ "iostream" IS_GNU)
60+
check_cxx_symbol_exists(_LIBCPP_VERSION "iostream" IS_LLVM)
61+
if(${IS_GNU})
62+
target_link_libraries(${executable_name} PRIVATE stdc++)
63+
elseif(${IS_LLVM})
64+
target_link_libraries(${executable_name} PRIVATE c++)
65+
else()
66+
message(FATAL_ERROR "Could not determine C++ standard library")
67+
endif()
68+
3269
install(TARGETS ${executable_name} RUNTIME DESTINATION bin)
33-
INSTALL(CODE "execute_process( \
34-
COMMAND ${CMAKE_COMMAND} -E create_symlink \
35-
${executable_name} \
36-
${CMAKE_INSTALL_PREFIX}/bin/damask_${VARIANT_LOWER} \
37-
)")
70+
fs_case_sensitive(${CMAKE_INSTALL_PREFIX}/bin fs_is_case_sensitive)
71+
if(fs_is_case_sensitive)
72+
INSTALL(CODE "execute_process( \
73+
COMMAND ${CMAKE_COMMAND} -E create_symlink \
74+
${executable_name} \
75+
${CMAKE_INSTALL_PREFIX}/bin/damask_${VARIANT_LOWER} \
76+
)")
77+
endif()
3878
else()
3979
add_library(${executable_name} OBJECT ${damask_fortran} ${damask_c})
4080
exec_program(mktemp OUTPUT_VARIABLE nothing)

src/C_routines.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <string.h>
66
#include <pwd.h>
77
#include <limits.h>
8-
#include "ISO_Fortran_binding.h"
8+
#include <ISO_Fortran_binding.h>
99
#include <stdbool.h>
1010

1111
#ifdef GRID

0 commit comments

Comments
 (0)