Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,62 +112,3 @@ jobs:

- name: Run TUV-x comparison tests in container
run: docker run --name tuvx-comparison -t musica-tuvx-comparison bash -c 'pytest'

fetch-content:
name: FetchContent Integration Test
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
strategy:
fail-fast: false
matrix:
build_type: [Release]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Print branch name
run: echo "Branch name is $BRANCH_NAME"

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

- name: Build Docker base image
run: |
docker build -t musica-base -f docker/Dockerfile.fetch-content . \
--build-arg MUSICA_GIT_TAG=${BRANCH_NAME} --build-arg BUILD_TYPE=${{ matrix.build_type }} \
--target base

- name: Build gcc
run: |
docker build -t musica-gcc -f docker/Dockerfile.fetch-content . \
--build-arg MUSICA_GIT_TAG=${BRANCH_NAME} --build-arg BUILD_TYPE=${{ matrix.build_type }} \
--target gcc-test

- name: Build intel
run: |
docker build -t musica-intel -f docker/Dockerfile.fetch-content . \
--build-arg MUSICA_GIT_TAG=${BRANCH_NAME} --build-arg BUILD_TYPE=${{ matrix.build_type }} \
--target intel-test

- name: Build nvhpc
run: |
docker build -t musica-nvhpc -f docker/Dockerfile.fetch-content . \
--build-arg MUSICA_GIT_TAG=${BRANCH_NAME} --build-arg BUILD_TYPE=${{ matrix.build_type }} \
--target nvhpc-test

- name: Run tests in gcc container
run: docker run --name fetch-content-gcc -t musica-gcc bash -c 'make test ARGS="--rerun-failed --output-on-failure -j8"'

- name: Run tests in intel container
run: docker run --name fetch-content-intel -t musica-intel bash -c 'make test ARGS="--rerun-failed --output-on-failure -j8"'

- name: Run tests in nvhpc container
run: docker run --name fetch-content-nvhpc -t musica-nvhpc bash -c 'make test ARGS="--rerun-failed --output-on-failure -j8"'
72 changes: 72 additions & 0 deletions .github/workflows/fetch-content.yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: FetchContent

on:
push:
branches:
- main
pull_request:
workflow_dispatch:
Comment thread
boulderdaze marked this conversation as resolved.

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
fetch-content:
name: FetchContent Integration Test
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
strategy:
fail-fast: false
matrix:
build_type: [Release]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Print branch name
run: echo "Branch name is $BRANCH_NAME"

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

- name: Build Docker base image
run: |
docker build -t musica-base -f docker/Dockerfile.fetch-content . \
--build-arg MUSICA_GIT_TAG=${BRANCH_NAME} --build-arg BUILD_TYPE=${{ matrix.build_type }} \
--target base

- name: Build gcc
run: |
docker build -t musica-gcc -f docker/Dockerfile.fetch-content . \
--build-arg MUSICA_GIT_TAG=${BRANCH_NAME} --build-arg BUILD_TYPE=${{ matrix.build_type }} \
--target gcc-test

- name: Build intel
run: |
docker build -t musica-intel -f docker/Dockerfile.fetch-content . \
--build-arg MUSICA_GIT_TAG=${BRANCH_NAME} --build-arg BUILD_TYPE=${{ matrix.build_type }} \
--target intel-test

- name: Build nvhpc
run: |
docker build -t musica-nvhpc -f docker/Dockerfile.fetch-content . \
--build-arg MUSICA_GIT_TAG=${BRANCH_NAME} --build-arg BUILD_TYPE=${{ matrix.build_type }} \
--target nvhpc-test

- name: Run tests in gcc container
run: docker run --name fetch-content-gcc -t musica-gcc bash -c 'make test ARGS="--rerun-failed --output-on-failure -j8"'

- name: Run tests in intel container
run: docker run --name fetch-content-intel -t musica-intel bash -c 'make test ARGS="--rerun-failed --output-on-failure -j8"'

- name: Run tests in nvhpc container
run: docker run --name fetch-content-nvhpc -t musica-nvhpc bash -c 'make test ARGS="--rerun-failed --output-on-failure -j8"'
6 changes: 3 additions & 3 deletions fortran/test/integration/test_micm_api.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ program test_micm_api
use musica_state, only: conditions_t, state_t

#include "micm/util/error.hpp"
#include "musica/error.hpp"
#include "musica/utils/error.hpp"

#define ASSERT( expr ) call assert( expr, __FILE__, __LINE__ )
#define ASSERT_EQ( a, b ) call assert( a == b, __FILE__, __LINE__ )
Expand Down Expand Up @@ -190,7 +190,7 @@ subroutine test_api()
deallocate(micm)
deallocate(state)
micm => micm_t( "configs/v0/invalid", solver_type, error )
ASSERT( error%is_error( MUSICA_ERROR_CATEGORY_PARSING, MUSICA_PARSE_INVALID_CONFIG_FILE ) )
ASSERT( error%is_error( MUSICA_PARSE_ERROR_CATEGORY, MUSICA_PARSE_ERROR_CODE_INVALID_CONFIG_FILE ) )
ASSERT( .not. associated( micm ) )

write(*,*) "[test micm fort api] Finished."
Expand Down Expand Up @@ -650,7 +650,7 @@ subroutine test_api_v1_parser()
deallocate( micm )
deallocate( state )
micm => micm_t( "configs/v0/invalid", solver_type, error )
ASSERT( error%is_error( MUSICA_ERROR_CATEGORY_PARSING, MUSICA_PARSE_INVALID_CONFIG_FILE ) )
ASSERT( error%is_error( MUSICA_PARSE_ERROR_CATEGORY, MUSICA_PARSE_ERROR_CODE_INVALID_CONFIG_FILE ) )
ASSERT( .not. associated( micm ) )

write(*,*) "[test micm fort api] Finished."
Expand Down
2 changes: 1 addition & 1 deletion fortran/test/unit/util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
! Tests for the musica_util module
program test_util

#include "musica/error.hpp"
#include "musica/utils/error.hpp"

#define ASSERT( expr ) call assert( expr, __FILE__, __LINE__ )
#define ASSERT_EQ( a, b ) call assert( a == b, __FILE__, __LINE__ )
Expand Down
2 changes: 1 addition & 1 deletion fortran/util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
!
module musica_util

#include "musica/error.hpp"
#include "musica/utils/error.hpp"

use iso_c_binding, only: c_char, c_int, c_ptr, c_size_t, &
c_null_ptr, c_f_pointer
Expand Down
25 changes: 0 additions & 25 deletions include/musica/error.hpp

This file was deleted.

52 changes: 2 additions & 50 deletions include/musica/micm/micm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <musica/micm/chemistry.hpp>
#include <musica/micm/parse.hpp>
#include <musica/micm/solver_interface.hpp>
#include <musica/utils/error_code.hpp>
#include <musica/micm/solver_parameters.hpp>

#include <micm/solver/solver_result.hpp>
Expand All @@ -23,55 +24,6 @@
#include <utility>
#include <vector>

enum class MusicaErrCode
{
SpeciesNotFound = MUSICA_ERROR_CODE_SPECIES_NOT_FOUND,
SolverTypeNotFound = MUSICA_ERROR_CODE_SOLVER_TYPE_NOT_FOUND,
MappingNotFound = MUSICA_ERROR_CODE_MAPPING_NOT_FOUND,
MappingOptionsUndefined = MUSICA_ERROR_CODE_MAPPING_OPTIONS_UNDEFINED,
Unknown = MUSICA_ERROR_CODE_UNKNOWN,
UnsupportedSolverStatePair = MUSICA_ERROR_CODE_UNSUPPORTED_SOLVER_STATE_PAIR,
};

namespace std
{
template<>
struct is_error_condition_enum<MusicaErrCode> : true_type
{
};
} // namespace std

namespace
{
class MusicaErrorCategory : public std::error_category
{
public:
const char* name() const noexcept override
{
return MUSICA_ERROR_CATEGORY;
}
std::string message(int ev) const override
{
switch (static_cast<MusicaErrCode>(ev))
{
case MusicaErrCode::SpeciesNotFound: return "Species not found";
case MusicaErrCode::SolverTypeNotFound: return "Solver type not found";
case MusicaErrCode::MappingNotFound: return "Mapping not found";
case MusicaErrCode::MappingOptionsUndefined: return "Mapping options undefined";
case MusicaErrCode::Unknown: return "Unknown error";
case MusicaErrCode::UnsupportedSolverStatePair: return "Unsupported solver/state combination";
default: return "Unknown error";
}
}
};

const MusicaErrorCategory MUSICA_ERROR{};
} // namespace

inline std::error_code make_error_code(MusicaErrCode e)
{
return { static_cast<int>(e), MUSICA_ERROR };
}

namespace musica
{
Expand Down Expand Up @@ -130,7 +82,7 @@ namespace musica
return species.GetProperty<T>(property_name);
}
}
throw std::system_error(make_error_code(MusicaErrCode::SpeciesNotFound), "Species '" + species_name + "' not found");
throw musica::Exception(musica::MicmErrorCode::SpeciesNotFound, "Species '" + species_name + "' not found");
}

/// @brief Get the maximum number of grid cells per state
Expand Down
2 changes: 1 addition & 1 deletion include/musica/micm/micm_c_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <musica/micm/parse.hpp>
#include <musica/micm/solver_parameters.hpp>
#include <musica/micm/state.hpp>
#include <musica/util.hpp>
#include <musica/utils/util.hpp>

#include <micm/CPU.hpp>

Expand Down
48 changes: 1 addition & 47 deletions include/musica/micm/parse.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <musica/error.hpp>
#include <musica/utils/error.hpp>
#include <musica/micm/chemistry.hpp>
#include <musica/micm/micm.hpp>

Expand All @@ -9,53 +9,7 @@
#include <mechanism_configuration/v1/mechanism.hpp>

#include <stdexcept>
#include <system_error>

enum class MusicaParseErrc
{
ParsingFailed = MUSICA_PARSE_PARSING_FAILED,
InvalidConfigFile = MUSICA_PARSE_INVALID_CONFIG_FILE,
UnsupportedVersion = MUSICA_PARSE_UNSUPPORTED_VERSION,
FailedToCastToVersion = MUSICA_PARSE_FAILED_TO_CAST_TO_VERSION
};

namespace std
{
template<>
struct is_error_condition_enum<MusicaParseErrc> : true_type
{
};
} // namespace std

namespace
{
class MusicaParseErrorCategory : public std::error_category
{
public:
const char* name() const noexcept override
{
return MUSICA_ERROR_CATEGORY_PARSING;
}
std::string message(int ev) const override
{
switch (static_cast<MusicaParseErrc>(ev))
{
case MusicaParseErrc::ParsingFailed: return "Parsing failed";
case MusicaParseErrc::InvalidConfigFile: return "Invalid configuration file";
case MusicaParseErrc::UnsupportedVersion: return "Unsupported version";
case MusicaParseErrc::FailedToCastToVersion: return "Failed to cast to a specific mechanism configuration version";
default: return "Unknown error";
}
}
};

const MusicaParseErrorCategory MUSICA_PARSE_ERROR{};
} // namespace

inline std::error_code make_error_code(MusicaParseErrc e)
{
return { static_cast<int>(e), MUSICA_PARSE_ERROR };
}

namespace musica
{
Expand Down
9 changes: 4 additions & 5 deletions include/musica/micm/solver_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <map>
#include <memory>
#include <string>
#include <system_error>

namespace musica
{
Expand Down Expand Up @@ -62,31 +61,31 @@ namespace musica

/// @brief Set Rosenbrock solver parameters
/// @param params The parameters to set
/// @throws std::system_error if the solver is not a Rosenbrock solver
/// @throws musica::Exception if the solver is not a Rosenbrock solver
virtual void SetRosenbrockSolverParameters(const RosenbrockSolverParameters& params)
{
throw std::runtime_error("SetRosenbrockSolverParameters not supported by this solver");
}

/// @brief Set Backward Euler solver parameters
/// @param params The parameters to set
/// @throws std::system_error if the solver is not a Backward Euler solver
/// @throws musica::Exception if the solver is not a Backward Euler solver
virtual void SetBackwardEulerSolverParameters(const BackwardEulerSolverParameters& params)
{
throw std::runtime_error("SetBackwardEulerSolverParameters not supported by this solver");
}

/// @brief Get Rosenbrock solver parameters
/// @return The current parameters
/// @throws std::system_error if the solver is not a Rosenbrock solver
/// @throws musica::Exception if the solver is not a Rosenbrock solver
virtual RosenbrockSolverParameters GetRosenbrockSolverParameters() const
{
throw std::runtime_error("GetRosenbrockSolverParameters not supported by this solver");
}

/// @brief Get Backward Euler solver parameters
/// @return The current parameters
/// @throws std::system_error if the solver is not a Backward Euler solver
/// @throws musica::Exception if the solver is not a Backward Euler solver
virtual BackwardEulerSolverParameters GetBackwardEulerSolverParameters() const
{
throw std::runtime_error("GetBackwardEulerSolverParameters not supported by this solver");
Expand Down
Loading
Loading