Skip to content

Commit

Permalink
Merge pull request #37 from NCAR/main
Browse files Browse the repository at this point in the history
MUSICA v0.4.0
  • Loading branch information
K20shores authored Sep 25, 2023
2 parents 0caf2e8 + 70fd6bd commit 8d70c57
Show file tree
Hide file tree
Showing 50 changed files with 484 additions and 475 deletions.
12 changes: 6 additions & 6 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# add things to copy
!CMakeLists.txt
!Dockerfile
!Dockerfile.ccpp
!Dockerfile.mpi
!Dockerfile.mpi_openmp
!Dockerfile.openmp
!ccpp
!cmake
!musica
!musica-fortran
!docs
!include
!cmake
!lib
!packaging
!src
!test
!test
!.gitmodules
!.git
16 changes: 15 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,18 @@ jobs:
- name: build Docker image
run: docker build -t musica-mpi-openmp -f Dockerfile.mpi_openmp .
- name: run tests in container
run: docker run --name test-container -t musica-mpi-openmp bash -c 'make test'
run: docker run --name test-container -t musica-mpi-openmp bash -c 'make test'
build_test_connections_musica-fortran:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- name: delete unnessary tools to free up space
run: rm -rf /opt/hostedtoolcache

- uses: actions/checkout@v2
with:
submodules: recursive
- name: build Docker image
run: docker build -t musica-fortran -f Dockerfile.fortran .
- name: run tests in container
run: docker run --name test-container -t musica-fortran bash -c 'make test'
195 changes: 35 additions & 160 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,53 +1,55 @@
################################################################################
# Preamble

cmake_minimum_required(VERSION 3.21)
set(CMAKE_USER_MAKE_RULES_OVERRIDE "cmake/SetDefaults.cmake")

project(
musica
VERSION 0.3.0
VERSION 0.4.0
LANGUAGES Fortran CXX C
)

set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_LIST_DIR}/cmake")
set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_MODULE_PATH}/SetDefaults.cmake")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
################################################################################
include(CMakeDependentOption)

message ( STATUS "CMake build configuration for musica(${CMAKE_BUILD_TYPE}) ${PROJECT_VERSION}" )
# Library options to build
option(USE_MUSICA "Use MUSICA" ON)
message(STATUS "Building MUSICA sources into a library : ${USE_MUSICA}")

include(musica_util)
checkout_submodules()
option(USE_MUSICA_FORTRAN "Use MUSICA Fortran interface" OFF)
message(STATUS "Building MUSICA-Fortran sources into a library : ${USE_MUSICA_FORTRAN}")

################################################################################
# Projet wide setup options
include(CMakeDependentOption)
cmake_dependent_option(
ENABLE_TESTS "Builds tests that ensures each enabled MUSICA component can be used" ON "USE_MUSICA" OFF)
message(STATUS "Build tests for MUSICA : ${ENABLE_TESTS}")

option( ENABLE_TESTS "Builds tests that ensures each enabled MUSICA component can be used" OFF )
cmake_dependent_option(
ENABLE_TUVX "Builds TUV-x, a photolysis calculator library" ON "USE_MUSICA" OFF)
message(STATUS "Build TUV-x : ${ENABLE_TUVX}")

option( ENABLE_TUVX "Builds TUV-x, a photolysis calculator library" ON )
option( ENABLE_MICM "Adds MICM, a model independent chemical mechanism solver" ON )
cmake_dependent_option(
ENABLE_MICM "Adds MICM, a model independent chemical mechanism solver" ON "USE_MUSICA" OFF)
message(STATUS "Build MICM : ${ENABLE_MICM}")

option( ENABLE_CCPP "Builds the CCPP library" OFF )
cmake_dependent_option(
ENABLE_MPI "Enable MPI parallel support" OFF "USE_MUSICA" OFF)
message(STATUS "Enable MPI parallel support : ${ENABLE_MPI}")

option( ENABLE_MPI "Enable MPI parallel support" OFF)
option( ENABLE_OPENMP "Enable OpemMP support" OFF )
cmake_dependent_option(
ENABLE_OPENMP "Enable OpemMP support" OFF "USE_MUSICA" OFF)
message(STATUS "Enable OpemMP support : ${ENABLE_OPENMP}")

option( CREATE_ENVIRONMENT_MODULE "Creates an Lmod environment module file that can be installed on the same machine this library is installed to." OFF )
cmake_dependent_option(
CREATE_ENVIRONMENT_MODULE "Creates an Lmod environment module file that can be installed on the same machine this library is installed to." OFF "USE_MUSICA" OFF)
message(STATUS "Creates an Lmod environment module : ${CREATE_ENVIRONMENT_MODULE}")

if(CREATE_ENVIRONMENT_MODULE)
set(INSTALL_MODULE_FILE_PATH "" CACHE STRING "This is the path of the modulefiles location that the Lmod files should be installed to.")
endif()

# Set up include and lib directories
set( MUSICA_MOD_DIR "${PROJECT_BINARY_DIR}/include" )
set( MUSICA_LIB_DIR "${PROJECT_BINARY_DIR}/libs" )

include(GNUInstallDirs)
set(INSTALL_PREFIX "musica-${PROJECT_VERSION}")
set(INSTALL_MOD_DIR "${INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
Expand Down Expand Up @@ -78,146 +80,19 @@ elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI")
endif()

################################################################################
# Dependencies

include(cmake/dependencies.cmake)

##############################################################################
# MUSICA targets

####################
# MUSICA
add_library(musica STATIC)
add_library(musica::musica ALIAS musica)

set_target_properties(musica PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${MUSICA_LIB_DIR}
Fortran_MODULE_DIRECTORY ${MUSICA_MOD_DIR}
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)

target_link_libraries(musica
PUBLIC
PkgConfig::netcdff
${JSON_LIB}
)

target_include_directories(musica
PUBLIC
$<BUILD_INTERFACE:${MUSICA_MOD_DIR}>
$<INSTALL_INTERFACE:${INSTALL_MOD_DIR}>
)

target_include_directories(musica
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${INSTALL_MOD_DIR}>
)

add_subdirectory(src)

####################
# MUSICA-core
add_library(musicacore_object)
add_library(musica::musicacore ALIAS musicacore_object)
add_subdirectory(lib/musica-core/src)

set_target_properties(musicacore_object PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${MUSICA_LIB_DIR}
Fortran_MODULE_DIRECTORY ${MUSICA_MOD_DIR}
)

target_include_directories(musicacore_object
PUBLIC
$<BUILD_INTERFACE:${MUSICA_MOD_DIR}>
$<INSTALL_INTERFACE:${INSTALL_MOD_DIR}>
)

target_link_libraries(musicacore_object
PUBLIC
PkgConfig::netcdff
)

# add the sources to musica
target_sources(musica
PRIVATE
$<TARGET_OBJECTS:musicacore_object>
)

####################
# TUV-x
if (ENABLE_TUVX)
add_definitions(-DMUSICA_USE_TUVX)

set(TUVX_MOD_DIR ${MUSICA_MOD_DIR})
set(TUVX_LIB_DIR ${MUSICA_LIB_DIR})
add_subdirectory(lib/tuv-x/src)

set_target_properties(tuvx_object PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${MUSICA_LIB_DIR}
Fortran_MODULE_DIRECTORY ${MUSICA_MOD_DIR}
)

target_include_directories(tuvx_object
PUBLIC
$<BUILD_INTERFACE:${MUSICA_MOD_DIR}>
$<INSTALL_INTERFACE:${INSTALL_MOD_DIR}>
)

target_link_libraries(tuvx_object
PUBLIC
musicacore_object
)

# add the sources to musica
target_sources(musica
PRIVATE
$<TARGET_OBJECTS:tuvx_object>
)
if(USE_MUSICA)
add_subdirectory(musica)
endif()

####################
# MICM
if (ENABLE_MICM)
add_definitions(-DMUSICA_USE_MICM)
target_compile_features(musica PUBLIC cxx_std_20)

target_include_directories(musica
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib/micm/include>
$<INSTALL_INTERFACE:${INSTALL_MOD_DIR}>
)

install(
DIRECTORY
${PROJECT_SOURCE_DIR}/lib/micm/include/micm
DESTINATION
${INSTALL_MOD_DIR}
)
# MUSICA-Fortran
if(USE_MUSICA_FORTRAN)
add_subdirectory(musica-fortran)
endif()

####################
# CCPP

if(ENABLE_CCPP)
add_subdirectory(ccpp)
endif()


################################################################################
# Tests

# only include packaging if we are the top level project being built
if(PROJECT_IS_TOP_LEVEL AND ENABLE_TESTS)
if(ENABLE_TESTS)
enable_testing()
add_subdirectory(test)
add_subdirectory(musica/test)
endif()

################################################################################
# Packaging

# only include packaging if we are the top level project being built
if(PROJECT_IS_TOP_LEVEL)
add_subdirectory(packaging)
endif()
28 changes: 15 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,28 @@ RUN dnf -y update \
valgrind \
&& dnf clean all

# install json-fortran
# Install json-fortran
RUN curl -LO https://github.com/jacobwilliams/json-fortran/archive/8.2.0.tar.gz \
&& tar -zxvf 8.2.0.tar.gz \
&& cd json-fortran-8.2.0 \
&& export FC=gfortran \
&& mkdir build \
&& cd build \
&& cmake -D SKIP_DOC_GEN:BOOL=TRUE .. \
&& make install

# copy the musica core code
COPY . /musica/
# Set environment variables
ENV FC=gfortran
ENV JSON_FORTRAN_HOME="/usr/local/jsonfortran-gnu-8.2.0"

# get a tag and build the model
RUN mkdir /build \
&& cd /build \
&& export JSON_FORTRAN_HOME="/usr/local/jsonfortran-gnu-8.2.0" \
&& cmake \
-D ENABLE_TESTS=ON \
../musica \
&& make install -j 8
# Copy the musica code
COPY . musica

WORKDIR /build
# Build
RUN cd musica \
&& cmake -S . \
-B build \
-D ENABLE_TESTS=ON \
&& cd build \
&& make install -j 8

WORKDIR musica/build
67 changes: 0 additions & 67 deletions Dockerfile.ccpp

This file was deleted.

Loading

0 comments on commit 8d70c57

Please sign in to comment.