Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
boulderdaze committed Jun 18, 2024
2 parents 46c9243 + 5b25651 commit 0d14d2c
Show file tree
Hide file tree
Showing 24 changed files with 268 additions and 160 deletions.
6 changes: 3 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ IncludeCategories:
- Regex: '<(musica)\/'
Priority: 2
# MICM, TUV-X headers
- Regex: '<(micm|tuvx)[[:alnum:].\Q/-_\E]+>'
- Regex: '<(micm|tuvx)[[:alnum:].(-|_)*]+>'
Priority: 3
# External libraries headers
- Regex: '<([[:alnum:].\Q/-_\E]+)\/'
- Regex: '<[[:alnum:].(-|_)*]+\/'
Priority: 4
# System headers
- Regex: '<[[:alnum:].\Q/-_\E]+>'
- Regex: '<[[:alnum:].(-|_)*]+>'
Priority: 5
# Main, local, private headers
- Regex: '".*'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/clang_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
workflow_dispatch:

jobs:
format:
Expand Down
26 changes: 23 additions & 3 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,28 @@ jobs:
- run: pip install -r python/requirements.txt --user

- name: Run Cmake
if: matrix.compiler.cpp != 'g++-13'
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
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
- name: Run Cmake
if: matrix.compiler.cpp == 'g++-13'
run: |
PYTHON_PATH=$(which python)
# for some reason gcc 13 was having issues finding the correct osx sdk
# it seems it was a known issue: https://github.com/actions/runner-images/issues/9997
# for some reason, passing in an empty string for the osx sysroot fixed the issue
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 \
-D CMAKE_OSX_SYSROOT=""
- name: Build
run: cmake --build build --verbose
Expand All @@ -49,6 +68,7 @@ jobs:
run: |
cd build
ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose -j 10
fortran:
runs-on: macos-latest
strategy:
Expand All @@ -65,7 +85,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_ENABLE_TUVX=OFF -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_BUILD_FORTRAN_INTERFACE=ON

- name: Build
run: cmake --build build --verbose --parallel 10
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,9 @@ endif()
if(MUSICA_ENABLE_PYTHON_LIBRARY)
add_subdirectory(python)
endif()

###
# Configure and display a summary file for how musica was built.
###
include(summary)

4 changes: 2 additions & 2 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ endif()
if (MUSICA_ENABLE_MICM AND MUSICA_BUILD_C_CXX_INTERFACE)

set_git_default(MICM_GIT_REPOSITORY https://github.com/NCAR/micm.git)
set_git_default(MICM_GIT_TAG inline_version)
set_git_default(MICM_GIT_TAG 401add1bb3d0db9cd13464ed0566dc2599f02ca9)

FetchContent_Declare(micm
GIT_REPOSITORY ${MICM_GIT_REPOSITORY}
Expand All @@ -74,7 +74,7 @@ if (MUSICA_ENABLE_TUVX AND MUSICA_BUILD_C_CXX_INTERFACE)
set(TUVX_INSTALL_INCLUDE_DIR ${MUSICA_INSTALL_INCLUDE_DIR} CACHE STRING "" FORCE)

set_git_default(TUVX_GIT_REPOSITORY https://github.com/NCAR/tuv-x.git)
set_git_default(TUVX_GIT_TAG pic)
set_git_default(TUVX_GIT_TAG f8961c1a6cd66cf619b32fce1f124a78e9a4ea18)

FetchContent_Declare(tuvx
GIT_REPOSITORY ${TUVX_GIT_REPOSITORY}
Expand Down
41 changes: 41 additions & 0 deletions cmake/musica.settings.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# MUSICA Configuration Summary

## General
----------
MUSICA Version: @musica-distribution_VERSION@
Configured On: @BUILD_CONFIG_DATE@
Host System: @CMAKE_SYSTEM_PROCESSOR@-@CMAKE_SYSTEM_NAME@-@CMAKE_SYSTEM_VERSION@
Build Directory: @CMAKE_BINARY_DIR@
Install Prefix: @CMAKE_INSTALL_PREFIX@

## Compilers and Flags
----------------------

C Compiler: @C_COMPILER_NAME_INFO@
C++ Compiler: @CXX_COMPILER_NAME_INFO@
Fortran Compiler: @Fortran_COMPILER_NAME_INFO@

CFLAGS: @CMAKE_C_FLAGS@
CXXFLAGS: @CMAKE_CXX_FLAGS@
Fortran Flags: @CMAKE_Fortran_FLAGS@
LDFLAGS: @CMAKE_EXE_LINKER_FLAGS@

## Parallel I/O
---------------

MPI: @MUSICA_ENABLE_MPI@
OPENMP: @MUSICA_ENABLE_OPENMP@

## Interfaces:
--------------

CXX Interface: @MUSICA_BUILD_C_CXX_INTERFACE@
Fortran Interface: @MUSICA_BUILD_FORTRAN_INTERFACE@
Python Library: @MUSICA_ENABLE_PYTHON_LIBRARY@

## Dependencies:
----------------

MICM: @MUSICA_ENABLE_MICM_INFO@
TUV-X: @MUSICA_ENABLE_TUVX_INFO@
PyBind11: @MUSICA_ENABLE_PYTHON_LIBRARY_INFO@
51 changes: 51 additions & 0 deletions cmake/summary.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Parse out a few individual variables
string(TIMESTAMP BUILD_CONFIG_DATE "%Y-%m-%d %H:%M:%S")
get_filename_component(C_COMPILER_NAME ${CMAKE_C_COMPILER} NAME)
set(C_COMPILER_NAME_INFO "${C_COMPILER_NAME} (${CMAKE_C_COMPILER_VERSION})")

if(MUSICA_BUILD_C_CXX_INTERFACE)
get_filename_component(CXX_COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME)
set(CXX_COMPILER_NAME_INFO "${CXX_COMPILER_NAME} (${CMAKE_CXX_COMPILER_VERSION})")
else()
set(CXX_COMPILER_NAME_INFO " ")
endif()

if(MUSICA_BUILD_FORTRAN_INTERFACE)
get_filename_component(Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
set(Fortran_COMPILER_NAME_INFO "${Fortran_COMPILER_NAME}")
if(${CMAKE_Fortran_COMPILER_VERSION})
set(Fortran_COMPILER_NAME_INFO "${Fortran_COMPILER_NAME_INFO} (${CMAKE_Fortran_COMPILER_VERSION})")
endif()
else()
set(Fortran_COMPILER_NAME " ")
endif()

if(MUSICA_ENABLE_MICM)
set(MUSICA_ENABLE_MICM_INFO "ON (repo: ${MICM_GIT_REPOSITORY} tag: ${MICM_GIT_TAG})")
else()
set(MUSICA_ENABLE_MICM_INFO "OFF")
endif()

if(MUSICA_ENABLE_TUVX)
set(MUSICA_ENABLE_TUVX_INFO "ON (repo: ${TUVX_GIT_REPOSITORY} tag: ${TUVX_GIT_TAG})")
else()
set(MUSICA_ENABLE_TUVX_INFO "OFF")
endif()

if(MUSICA_ENABLE_PYTHON_LIBRARY)
set(MUSICA_ENABLE_PYTHON_LIBRARY_INFO "ON (repo: ${PYBIND11_GIT_REPOSITORY} tag: ${PYBIND11_GIT_TAG})")
else()
set(MUSICA_ENABLE_PYTHON_LIBRARY_INFO "OFF")
endif()

# Configure musica.settings file
configure_file("${CMAKE_SOURCE_DIR}/cmake/musica.settings.in"
"${CMAKE_BINARY_DIR}/musica.settings"
@ONLY)

# Read in settings file, print out.
# Avoid using system-specific calls so that this
# might also work on Windows.
file(READ "${CMAKE_BINARY_DIR}/musica.settings"
MUSICA_SETTINGS)
message(STATUS ${MUSICA_SETTINGS})
5 changes: 3 additions & 2 deletions docker/Dockerfile.fortran-nvhpc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
FROM nvcr.io/nvidia/nvhpc:23.7-devel-cuda12.2-ubuntu22.04

ARG MUSICA_GIT_TAG=main
ARG BUILD_TYPE=release

RUN apt update \
&& apt -y install \
Expand Down Expand Up @@ -50,7 +51,7 @@ COPY . musica
RUN cd musica \
&& cmake -S . \
-B build \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_BUILD_TYPE=${BUILD_TYPE} \
&& cd build \
&& make install -j

Expand All @@ -62,7 +63,7 @@ ENV FC=nvfortran
RUN cd musica/fortran/test/fetch_content_integration \
&& mkdir build && cd build \
&& cmake .. \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_BUILD_TYPE=${BUILD_TYPE} \
-D CMAKE_EXE_LINKER_FLAGS="-Wl,--copy-dt-needed-entries" \
-D MUSICA_GIT_TAG=${MUSICA_GIT_TAG} \
&& make -j
Expand Down
14 changes: 3 additions & 11 deletions fortran/test/fetch_content_integration/test_tuvx_api.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ end subroutine test_tuvx_api
subroutine test_tuvx_api_invalid_config()
type(tuvx_t), pointer :: tuvx
type(error_t) :: error
character(len=256) :: config_path
character(len=256) :: config_path

config_path = "invalid_config"

tuvx => tuvx_t(config_path, error)
! ASSERT( .not. error%is_success() )
ASSERT( .not. error%is_success() )

end subroutine test_tuvx_api_invalid_config

Expand All @@ -75,23 +75,15 @@ subroutine test_tuvx_solve()
grids = tuvx%get_grids( error )
ASSERT( error%is_success() )

! profiles = tuvx%create_profiles( )
! radiators = tuvx%create_radiators( )

! update conditions for each time step
grid => grids%get( "height", "km", error )
! ASSERT( error%is_success() )
ASSERT( error%is_success() )

call grid%set_edges( edges, error )
ASSERT( error%is_success() )

call grid%set_midpoints( midpoints, error )
ASSERT( error%is_success() )

! profile => profiles%get( "O3", "mol m-3" )

! call tuvx%solve( grids, profiles, radiators, photo_rates )

deallocate( tuvx )
deallocate( grid )

Expand Down
2 changes: 1 addition & 1 deletion fortran/tuvx.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module musica_tuvx
function create_tuvx_c(config_path, error) bind(C, name="CreateTuvx")
use musica_util, only: error_t_c
import c_ptr, c_int, c_char
character(kind=c_char), intent(in) :: config_path(*)
character(len=1, kind=c_char), intent(in) :: config_path(*)
type(error_t_c), intent(inout) :: error
type(c_ptr) :: create_tuvx_c
end function create_tuvx_c
Expand Down
6 changes: 2 additions & 4 deletions include/musica/component_versions.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* Copyright (C) 2023-2024 National Center for Atmospheric Research
*
* SPDX-License-Identifier: Apache-2.0
*/
// Copyright (C) 2023-2024 National Center for Atmospheric Research
// SPDX-License-Identifier: Apache-2.0
#pragma once

#ifdef __cplusplus
Expand Down
17 changes: 8 additions & 9 deletions include/musica/micm.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
/* Copyright (C) 2023-2024 National Center for Atmospheric Research
*
* SPDX-License-Identifier: Apache-2.0
*
* This file contains the defintion of the MICM class, which represents a multi-component reactive transport model.
* It also includes functions for creating and deleting MICM instances with c bindings.
*/
// Copyright (C) 2023-2024 National Center for Atmospheric Research
// SPDX-License-Identifier: Apache-2.0
//
// This file contains the defintion of the MICM class, which represents a multi-component reactive transport model.
// It also includes functions for creating and deleting MICM instances with c bindings.
#pragma once

#include <musica/util.hpp>

#include <micm/configure/solver_config.hpp>
#include <micm/process/process_set.hpp>
#include <micm/solver/rosenbrock.hpp>
#include <micm/solver/rosenbrock_solver_parameters.hpp>
#include <micm/solver/solver.hpp>
#include <micm/util/matrix.hpp>
#include <micm/process/process_set.hpp>

#include <memory>
#include <string>
Expand Down Expand Up @@ -130,7 +128,8 @@ namespace musica
private:
using DenseMatrixPolicy = micm::Matrix<double>;
using SparseMatrixPolicy = micm::SparseMatrix<double, micm::SparseMatrixStandardOrdering>;
using SolverPolicy = typename micm::RosenbrockSolverParameters::template SolverType<micm::ProcessSet, micm::LinearSolver<SparseMatrixPolicy, micm::LuDecomposition>>;
using SolverPolicy = typename micm::RosenbrockSolverParameters::
template SolverType<micm::ProcessSet, micm::LinearSolver<SparseMatrixPolicy, micm::LuDecomposition>>;
using Rosenbrock = micm::Solver<SolverPolicy, micm::State<DenseMatrixPolicy, SparseMatrixPolicy>>;

std::unique_ptr<Rosenbrock> solver_;
Expand Down
27 changes: 15 additions & 12 deletions include/musica/tuvx.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/* Copyright (C) 2023-2024 National Center for Atmospheric Research
*
* SPDX-License-Identifier: Apache-2.0
*
* This file contains the defintion of the TUVX class, which represents a photolysis calculator.
* It also includes functions for creating and deleting TUVX instances with c binding.
*/
// Copyright (C) 2023-2024 National Center for Atmospheric Research
// SPDX-License-Identifier: Apache-2.0
//
// This file contains the defintion of the TUVX class, which represents a photolysis calculator.
// It also includes functions for creating and deleting TUVX instances with c binding.
#pragma once

#include <musica/util.hpp>
Expand Down Expand Up @@ -82,10 +80,16 @@ namespace musica
// for use by musica interanlly. If tuvx ever gets rewritten in C++, these functions will
// go away but the C API will remain the same and downstream projects (like CAM-SIMA) will
// not need to change
void *InternalCreateTuvx(const char* config_path, std::size_t config_path_length, int *error_code);
void *InternalCreateTuvx(const char *config_path, std::size_t config_path_length, int *error_code);
void InternalDeleteTuvx(void *tuvx, int *error_code);
void *InternalGetGridMap(void *tuvx, int *error_code);
void *InternalGetGrid(void *grid_map, const char* grid_name, std::size_t grid_name_length, const char* grid_units, std::size_t grid_units_length, int *error_code);
void *InternalGetGrid(
void *grid_map,
const char *grid_name,
std::size_t grid_name_length,
const char *grid_units,
std::size_t grid_units_length,
int *error_code);
void InternalDeleteGrid(void *grid, int *error_code);
void InternalSetEdges(void *grid, double edges[], std::size_t num_edges, int *error_code);
void InternalSetMidpoints(void *grid, double midpoints[], std::size_t num_midpoints, int *error_code);
Expand All @@ -99,11 +103,10 @@ namespace musica
public:
TUVX();

/// @brief Create an instance ove tuvx from a configuration file
/// @brief Create an instance of tuvx from a configuration file
/// @param config_path Path to configuration file or directory containing configuration file
/// @param error Error struct to indicate success or failure
/// @return 0 on success, 1 on failure in parsing configuration file
void Create(const char* config_path, Error *error);
void Create(const char *config_path, Error *error);

/// @brief Create a grid map. For now, this calls the interal tuvx fortran api, but will allow the change to c++ later on
/// to be transparent to downstream projects
Expand Down
6 changes: 2 additions & 4 deletions include/musica/util.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* Copyright (C) 2023-2024 National Center for Atmospheric Research
*
* SPDX-License-Identifier: Apache-2.0
*/
// Copyright (C) 2023-2024 National Center for Atmospheric Research
// SPDX-License-Identifier: Apache-2.0
#pragma once

#include <cstddef>
Expand Down
6 changes: 2 additions & 4 deletions include/musica/version.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* Copyright (C) 2023-2024 National Center for Atmospheric Research
*
* SPDX-License-Identifier: Apache-2.0
*/
// Copyright (C) 2023-2024 National Center for Atmospheric Research
// SPDX-License-Identifier: Apache-2.0
#pragma once

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit 0d14d2c

Please sign in to comment.