Skip to content

Commit

Permalink
Update build scripts (#106)
Browse files Browse the repository at this point in the history
* update build scripts

* update packaging

* add fortran to project by default

* add fortran compiler to python image

* move fortran mod files to include dir

* separate shared fortran utility module

* fix fortran wrapper build for optional MICM and TUVX inclusion

* update integration builds

* make MICM and TUV-x not dependent on CXX interface

* add more output to fortran packaging script

* only build micm with c++ interface

* update buidl scripts

* specify TUV-x install include paths

* disable TUV-x for some tests

* include fortran compiler in docs build

* update tag for TUV-x

* don't build with TUV-x for doc gen
  • Loading branch information
mattldawson authored May 15, 2024
1 parent 3256dac commit 7d7c380
Show file tree
Hide file tree
Showing 26 changed files with 553 additions and 112 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/fetch_content_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: FetchContentIntegration

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ jobs:
build-and-deploy:
name: Build and deploy to gh-pages
runs-on: ubuntu-latest
strategy:
matrix:
gcc-version: [13]
env:
FC: gfortran-${{ matrix.gcc-version }}
steps:
- uses: actions/checkout@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Run Cmake
run: |
PYTHON_PATH=$(which python)
cmake -S . -B build -D CMAKE_CXX_FLAGS=-Wl,-ld_classic -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D MUSICA_ENABLE_PYTHON_LIBRARY=ON -D Python3_EXECUTABLE=$PYTHON_PATH
cmake -S . -B build -D CMAKE_CXX_FLAGS=-Wl,-ld_classic -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D MUSICA_ENABLE_TUVX=OFF -D MUSICA_ENABLE_PYTHON_LIBRARY=ON -D Python3_EXECUTABLE=$PYTHON_PATH
- name: Build
run: cmake --build build --verbose --parallel 10
Expand All @@ -60,7 +60,7 @@ jobs:
run: brew install netcdf netcdf-fortran

- name: Run Cmake
run: cmake -S . -B build -D CMAKE_CXX_FLAGS=-Wl,-ld_classic -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D MUSICA_BUILD_FORTRAN_INTERFACE=ON
run: cmake -S . -B build -D CMAKE_CXX_FLAGS=-Wl,-ld_classic -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D MUSICA_ENABLE_TUVX=OFF -D MUSICA_BUILD_FORTRAN_INTERFACE=ON

- name: Build
run: cmake --build build --verbose --parallel 10
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- run: pip install -r python/requirements.txt

- name: Run Cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D MUSICA_ENABLE_PYTHON_LIBRARY=ON
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D MUSICA_ENABLE_TUVX=OFF -D MUSICA_ENABLE_PYTHON_LIBRARY=ON

- name: Build
run: cmake --build build --verbose --parallel 10
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- run: pip install -r python/requirements.txt

- name: Run Cmake
run: cmake -S . -B build -G "MinGW Makefiles" -D MUSICA_ENABLE_PYTHON_LIBRARY=ON
run: cmake -S . -B build -G "MinGW Makefiles" -D MUSICA_ENABLE_TUVX=OFF -D MUSICA_ENABLE_PYTHON_LIBRARY=ON

- name: Build
run: cmake --build build --parallel
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
- run: pip install -r python/requirements.txt

- name: Run CMake
run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -D MUSICA_ENABLE_PYTHON_LIBRARY=ON
run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -D MUSICA_ENABLE_TUVX=OFF -D MUSICA_ENABLE_PYTHON_LIBRARY=ON

- name: Build
run: cmake --build build --config ${{ matrix.build_type }} --parallel
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
- run: pip install -r python/requirements.txt

- name: Run CMake
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -D MUSICA_ENABLE_PYTHON_LIBRARY=ON
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -D MUSICA_ENABLE_TUVX=OFF -D MUSICA_ENABLE_PYTHON_LIBRARY=ON

- name: Build
run: cmake --build build --config ${{ matrix.build_type }} --parallel
Expand All @@ -111,7 +111,7 @@ jobs:
- run: pip install -r python/requirements.txt

- name: Run CMake
run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -DCMAKE_C_COMPILER="C:/Program Files/LLVM/bin/clang.exe" -G"MinGW Makefiles" -D MUSICA_ENABLE_PYTHON_LIBRARY=ON
run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -DCMAKE_C_COMPILER="C:/Program Files/LLVM/bin/clang.exe" -G"MinGW Makefiles" -D MUSICA_ENABLE_TUVX=OFF -D MUSICA_ENABLE_PYTHON_LIBRARY=ON

- name: Build
run: cmake --build build --parallel
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
- run: pip install -r python/requirements.txt

- name: Run CMake
run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -T ClangCL -D MUSICA_ENABLE_PYTHON_LIBRARY=ON
run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -T ClangCL -D MUSICA_ENABLE_TUVX=OFF -D MUSICA_ENABLE_PYTHON_LIBRARY=ON

- name: Build
run: cmake --build build --config Debug --parallel
Expand Down
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ option(MUSICA_ENABLE_MPI "Enable MPI parallel support" OFF)
option(MUSICA_ENABLE_OPENMP "Enable OpemMP support" OFF)
option(MUSICA_ENABLE_MEMCHECK "Enable memory checking" OFF)
option(MUSICA_BUILD_DOCS "Build the documentation" OFF)

cmake_dependent_option(
MUSICA_ENABLE_TUVX "Builds TUV-x, a photolysis calculator library" ON "MUSICA_BUILD_FORTRAN_INTERFACE" OFF)

cmake_dependent_option(
MUSICA_ENABLE_MICM "Adds MICM, a model independent chemical mechanism solver" ON "MUSICA_BUILD_C_CXX_INTERFACE" OFF)
option(MUSICA_ENABLE_MICM "Enable MICM" ON)
option(MUSICA_ENABLE_TUVX "Enable TUV-x" ON)

cmake_dependent_option(
MUSICA_ENABLE_PYTHON_LIBRARY "Adds pybind11, a lightweight header-only library that exposes C++ types in Python and vice versa" OFF "MUSICA_BUILD_C_CXX_INTERFACE" OFF)
Expand Down
8 changes: 5 additions & 3 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ endif()
################################################################################
# MICM

if (MUSICA_ENABLE_MICM)
if (MUSICA_ENABLE_MICM AND MUSICA_BUILD_C_CXX_INTERFACE)
FetchContent_Declare(micm
GIT_REPOSITORY https://github.com/NCAR/micm.git
GIT_TAG 2a5cd4e11a6973974f3c584dfa9841d70e0a42d5
Expand All @@ -41,13 +41,15 @@ endif()
################################################################################
# TUV-x

if (MUSICA_ENABLE_TUVX)
if (MUSICA_ENABLE_TUVX AND MUSICA_BUILD_C_CXX_INTERFACE)
set(TUVX_ENABLE_TESTS OFF CACHE BOOL "" FORCE)
set(TUVX_MOD_DIR ${MUSICA_MOD_DIR} CACHE STRING "" FORCE)
set(TUVX_INSTALL_MOD_DIR ${MUSICA_INSTALL_INCLUDE_DIR} CACHE STRING "" FORCE)
set(TUVX_INSTALL_INCLUDE_DIR ${MUSICA_INSTALL_INCLUDE_DIR} CACHE STRING "" FORCE)

FetchContent_Declare(tuvx
GIT_REPOSITORY https://github.com/NCAR/tuv-x.git
GIT_TAG main
GIT_TAG 6ff27992da1485392329208b736d2ec1522dafa3
)

FetchContent_MakeAvailable(tuvx)
Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ RUN dnf -y update \
&& dnf -y install \
cmake \
gcc-c++ \
gfortran \
gdb \
git \
lapack-devel \
lcov \
make \
netcdf-fortran-devel \
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.docs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ RUN echo "The suffix is '$SWITCHER_SUFFIX'"
RUN mkdir /build \
&& cd /build \
&& cmake -D MUSICA_BUILD_DOCS=ON \
-D MUSICA_ENABLE_TUVX=OFF \
/musica \
&& make docs

Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile.fortran-gcc.integration
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ RUN cd musica \
-D CMAKE_BUILD_TYPE=Release \
-D MUSICA_ENABLE_TESTS=ON \
-D MUSICA_ENABLE_MICM=ON \
-D MUSICA_ENABLE_TUVX=OFF \
&& cd build \
&& make install

Expand All @@ -49,6 +50,8 @@ RUN cd musica/fortran/test/fetch_content_integration \
&& cmake .. \
-D CMAKE_BUILD_TYPE=Release \
-D MUSICA_GIT_TAG=${MUSICA_GIT_TAG} \
-D MUSICA_ENABLE_MICM=ON \
-D MUSICA_ENABLE_TUVX=OFF \
&& make

WORKDIR musica/fortran/test/fetch_content_integration/build
16 changes: 7 additions & 9 deletions docker/Dockerfile.fortran-intel
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ RUN apt update \
zlib1g-dev \
&& apt clean

# Build netcdf-fortran
ENV CXX=icpx
ENV CC=icx
ENV FC=ifx
# Set environment variables to install MUSICA using gcc
ENV CXX=g++
ENV CC=gcc
ENV FC=gfortran
ENV FFLAGS="-I/usr/include/"

# Build netcdf-fortran
RUN git clone https://github.com/Unidata/netcdf-fortran.git \
&& cd netcdf-fortran \
&& git checkout v4.6.0 \
Expand All @@ -35,10 +37,6 @@ RUN git clone https://github.com/Unidata/netcdf-fortran.git \
&& make -j 8 \
&& make install

# Set environment variables to install MUSICA using gcc
ENV FC=gfortran
ENV FFLAGS="-I/usr/include/"

# Copy the musica code
COPY . musica

Expand All @@ -47,7 +45,6 @@ RUN cd musica \
&& cmake -S . \
-B build \
-D MUSICA_ENABLE_TESTS=ON \
-D MUSICA_ENABLE_TUVX=OFF \
-D CMAKE_BUILD_TYPE=Release \
&& cd build \
&& make install
Expand All @@ -61,6 +58,7 @@ RUN cd musica/fortran/test/fetch_content_integration \
&& mkdir build && cd build \
&& cmake .. \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_EXE_LINKER_FLAGS="-Wl,--copy-dt-needed-entries" \
-D MUSICA_GIT_TAG=${MUSICA_GIT_TAG} \
&& make

Expand Down
17 changes: 8 additions & 9 deletions docker/Dockerfile.fortran-nvhpc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN apt update \
gcc \
gfortran \
git \
liblapack-dev \
lcov \
libcurl4-openssl-dev \
libhdf5-dev \
Expand All @@ -27,11 +28,13 @@ RUN apt update \
zlib1g-dev \
&& apt clean

# Build netcdf-fortran
ENV CXX=nvc++
ENV CC=nvc
ENV FC=nvfortran
# Set environment variables to install MUSICA using gcc
ENV CXX=g++
ENV CC=gcc
ENV FC=gfortran
ENV FFLAGS="-I/usr/include/"

# Build netcdf-fortran
RUN git clone https://github.com/Unidata/netcdf-fortran.git \
&& cd netcdf-fortran \
&& git checkout v4.6.0 \
Expand All @@ -40,10 +43,6 @@ RUN git clone https://github.com/Unidata/netcdf-fortran.git \
&& make -j 8 \
&& make install

# Set environment variables to install MUSICA using gcc
ENV FC=gfortran
ENV FFLAGS="-I/usr/include/"

# Copy the musica code
COPY . musica

Expand All @@ -52,7 +51,6 @@ RUN cd musica \
&& cmake -S . \
-B build \
-D MUSICA_ENABLE_TESTS=ON \
-D MUSICA_ENABLE_TUVX=OFF \
-D CMAKE_BUILD_TYPE=Release \
&& cd build \
&& make install
Expand All @@ -66,6 +64,7 @@ RUN cd musica/fortran/test/fetch_content_integration \
&& mkdir build && cd build \
&& cmake .. \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_EXE_LINKER_FLAGS="-Wl,--copy-dt-needed-entries" \
-D MUSICA_GIT_TAG=${MUSICA_GIT_TAG} \
&& make

Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile.memcheck
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ RUN dnf -y update \
&& dnf -y install \
cmake \
gcc-c++ \
gfortran \
gdb \
git \
lapack-devel \
lcov \
make \
netcdf-fortran-devel \
Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile.mpi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ WORKDIR /home/test_user
RUN sudo dnf -y install \
cmake \
gcc-c++ \
gfortran \
git \
lapack-devel \
lcov \
make \
netcdf-fortran-devel \
Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile.mpi_openmp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ WORKDIR /home/test_user
RUN sudo dnf -y install \
cmake \
gcc-c++ \
gfortran \
git \
lapack-devel \
lcov \
make \
netcdf-fortran-devel \
Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile.openmp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ WORKDIR /home/test_user
RUN sudo dnf -y install \
cmake \
gcc-c++ \
gfortran \
git \
lapack-devel \
lcov \
make \
netcdf-fortran-devel \
Expand Down
4 changes: 4 additions & 0 deletions docker/Dockerfile.python
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ RUN dnf -y update \
&& dnf -y install \
cmake \
gcc-c++ \
gcc-fortran \
git \
lapack-devel \
make \
netcdf-fortran-devel \
python-devel \
pip \
&& dnf clean all
Expand All @@ -22,6 +25,7 @@ RUN cd musica \
-B build \
-D CMAKE_BUILD_TYPE=Release \
-D MUSICA_ENABLE_PYTHON_LIBRARY=ON \
-D MUSICA_ENABLE_TUVX=OFF \
&& cd build \
&& make install -j 8

Expand Down
20 changes: 18 additions & 2 deletions fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ project(
)

message (STATUS "CMake build configuration for ${PROJECT_NAME} (${CMAKE_BUILD_TYPE}) ${PROJECT_VERSION}")
message (STATUS " MICM: ${MUSICA_ENABLE_MICM}")
message (STATUS " TUV-x: ${MUSICA_ENABLE_TUVX}")
message (STATUS " Tests: ${MUSICA_ENABLE_TESTS}")
message (STATUS " Install: ${MUSICA_ENABLE_INSTALL}")
message (STATUS " C/C++ Interface: ${MUSICA_BUILD_C_CXX_INTERFACE}")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

Expand Down Expand Up @@ -41,9 +46,20 @@ target_link_libraries(musica-fortran

target_sources(musica-fortran
PRIVATE
micm.F90
tuvx.F90
util.F90
)
if (MUSICA_ENABLE_MICM)
target_sources(musica-fortran
PRIVATE
micm.F90
)
endif()
if (MUSICA_ENABLE_TUVX)
target_sources(musica-fortran
PRIVATE
tuvx.F90
)
endif()

# Add flags for gfortran
if(${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
Expand Down
Loading

0 comments on commit 7d7c380

Please sign in to comment.