diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 53ebb6bc..c1f10917 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -41,7 +41,7 @@ jobs: git config --global user.email "actions@github.com" git commit -am "Auto-format code using Clang-Format" || echo "No changes to commit" - - name: Push changes to main-formatting branch + - name: Push changes to clang-tidy-format branch if: steps.check-changes.outcome != 'success' run: git push origin HEAD:clang-tidy-format diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fa1ab4d..cf2b1189 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ endif() include(CMakeDependentOption) option(TUVX_ENABLE_MPI "Enable MPI parallel support" OFF) cmake_dependent_option(TUVX_ENABLE_OPENMP "Enable OpenMP support" OFF "TUVX_ENABLE_MPI" OFF) +option(TUVX_ENABLE_LAPACK "Enable LAPACK" OFF) option(TUVX_ENABLE_TESTS "Build tests" ON) option(TUVX_ENABLE_BENCHMARK "Build benchmark examples" OFF) option(TUVX_ENABLE_COVERAGE "Enable code coverage output" OFF) @@ -107,8 +108,6 @@ target_link_libraries(tuv-x PUBLIC musica::tuvx yaml-cpp::yaml-cpp - ${BLAS_LIBRARIES} - ${LAPACK_LIBRARIES} ) target_include_directories(tuv-x @@ -120,6 +119,14 @@ if(TUVX_ENABLE_OPENMP) target_link_libraries(tuv-x PUBLIC OpenMP::OpenMP_Fortran) endif() +if(TUVX_ENABLE_LAPACK) + target_link_libraries(tuv-x + PUBLIC + ${LAPACK_LIBRARIES} + ${BLAS_LIBRARIES} + ) +endif() + ################################################################################ # TUV-x docs @@ -158,8 +165,8 @@ endif() ################################################################################ # benchmarking -if(TUVX_ENABLE_BENCHMARK) +if(TUVX_ENABLE_BENCHMARK AND TUVX_ENABLE_LAPACK) add_subdirectory(benchmark) endif() -################################################################################ +################################################################################ \ No newline at end of file diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index d451d662..851713fd 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -4,9 +4,11 @@ include(FetchContent) # ############################################################################## # LAPACK -find_package(BLAS) -find_package(LAPACK) -find_package(LAPACKE) +if(TUVX_ENABLE_LAPACK) + find_package(LAPACK) + find_package(LAPACKE) + find_package(BLAS) +endif() # ############################################################################## # Memory check diff --git a/cmake/test_util.cmake b/cmake/test_util.cmake index 7cdade62..637f4da1 100644 --- a/cmake/test_util.cmake +++ b/cmake/test_util.cmake @@ -26,13 +26,16 @@ function(create_standard_test) cmake_parse_arguments(${prefix} " " "${singleValues}" "${multiValues}" ${ARGN}) add_executable(test_${TEST_NAME} ${TEST_SOURCES}) set_target_properties(test_${TEST_NAME} PROPERTIES LINKER_LANGUAGE Fortran) - target_link_libraries(test_${TEST_NAME} PUBLIC musica::tuvx tuvx_test_utils ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} GTest::gtest_main) + target_link_libraries(test_${TEST_NAME} PUBLIC musica::tuvx tuvx_test_utils GTest::gtest_main) if(TUVX_ENABLE_OPENMP) target_link_libraries(test_${TEST_NAME} PUBLIC OpenMP::OpenMP_Fortran) endif() if(NOT DEFINED TEST_WORKING_DIRECTORY) set(TEST_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") endif() + if(TUVX_ENABLE_LAPACK) + target_link_libraries(test_${TEST_NAME} PUBLIC ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) + endif() add_tuvx_test(${TEST_NAME} test_${TEST_NAME} "" ${TEST_WORKING_DIRECTORY}) endfunction(create_standard_test) @@ -49,9 +52,12 @@ function(create_standard_cxx_test) cmake_parse_arguments(${prefix} "${optionalValues}" "${singleValues}" "${multiValues}" ${ARGN}) add_executable(test_${TEST_NAME} ${TEST_SOURCES}) + target_link_libraries(test_${TEST_NAME} PUBLIC musica::tuvx GTest::gtest_main) - target_include_directories(test_${TEST_NAME} PUBLIC ${LAPACK_INCLUDE_DIRS}) - target_link_libraries(test_${TEST_NAME} PUBLIC LAPACK::LAPACK ${LAPACKE_LIBRARIES} musica::tuvx GTest::gtest_main) + if(TUVX_ENABLE_LAPACK) + target_include_directories(test_${TEST_NAME} PUBLIC ${LAPACK_INCLUDE_DIRS}) + target_link_libraries(test_${TEST_NAME} PUBLIC LAPACK::LAPACK ${LAPACKE_LIBRARIES}) + endif() # link additional libraries foreach(library ${TEST_LIBRARIES}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6dd3a25b..efe2b40a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,12 @@ target_compile_features(tuvx_object PUBLIC cxx_std_11) set_target_properties(tuvx_object PROPERTIES Fortran_MODULE_DIRECTORY ${TUVX_MOD_DIR}) +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "IntelLLVM") + target_compile_definitions(tuvx_object PUBLIC TUVX_COMPILE_WITH_INTEL) +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + target_compile_definitions(tuvx_object PUBLIC TUVX_COMPILE_WITH_GCC) +endif() + target_include_directories( tuvx_object PUBLIC $ @@ -16,29 +22,17 @@ target_include_directories( $ $) -message(STATUS "blas libraries: ${BLAS_LIBRARIES}") -message(STATUS "lapack libraries: ${LAPACK_LIBRARIES}") - target_link_libraries(tuvx_object PRIVATE PkgConfig::netcdff PkgConfig::netcdfc yaml-cpp::yaml-cpp) -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "IntelLLVM") - target_compile_definitions(tuvx_object PUBLIC TUVX_COMPILE_WITH_INTEL) -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - target_compile_definitions(tuvx_object PUBLIC TUVX_COMPILE_WITH_GCC) -endif() - -if(BLAS_LIBRARIES) - target_link_libraries(tuvx_object PRIVATE ${BLAS_LIBRARIES}) -else() - message(FATAL_ERROR "BLAS Libraries not found.") -endif() - -if(LAPACK_LIBRARIES) - target_link_libraries(tuvx_object PRIVATE ${LAPACK_LIBRARIES} LAPACK::LAPACK) -else() - message(FATAL_ERROR "LAPACK libraries not found.") +if(TUVX_ENABLE_LAPACK) + target_link_libraries(tuvx_object + PRIVATE + ${LAPACK_LIBRARIES} + LAPACK::LAPACK + ${BLAS_LIBRARIES} + ) endif() # tuvx library @@ -101,12 +95,13 @@ target_sources( spherical_geometry.F90 util.F90) +add_subdirectory(linear_algebras) add_subdirectory(cross_sections) add_subdirectory(grids) -add_subdirectory(linear_algebras) add_subdirectory(profiles) add_subdirectory(quantum_yields) add_subdirectory(radiative_transfer) add_subdirectory(spectral_weights) add_subdirectory(util) + ################################################################################ diff --git a/src/core.F90 b/src/core.F90 index f1a9faf8..2cc465b3 100644 --- a/src/core.F90 +++ b/src/core.F90 @@ -14,6 +14,7 @@ module tuvx_core use tuvx_photolysis_rates, only : photolysis_rates_t use tuvx_profile_warehouse, only : profile_warehouse_t use tuvx_radiative_transfer, only : radiative_transfer_t + use tuvx_radiator_warehouse, only : radiator_warehouse_t use tuvx_solver, only : radiation_field_t use tuvx_spherical_geometry, only : spherical_geometry_t @@ -28,6 +29,7 @@ module tuvx_core ! with a host application type(grid_warehouse_t), pointer :: grid_warehouse_ => null() type(profile_warehouse_t), pointer :: profile_warehouse_ => null() + type(radiator_warehouse_t), pointer :: radiator_warehouse_ => null() type(spherical_geometry_t), pointer :: spherical_geometry_ => null() type(la_sr_bands_t), pointer :: la_sr_bands_ => null() type(radiative_transfer_t), pointer, public :: radiative_transfer_ => null() @@ -47,6 +49,10 @@ module tuvx_core procedure :: get_profile ! Returns the profile warehouse procedure :: get_profile_warehouse + ! Returns a radiator from the warehouse + procedure :: get_radiator + ! Returns the radiator warehouse + procedure :: get_radiator_warehouse ! Returns an updater for use TUV-x data procedure, private :: get_grid_updater, get_profile_updater, & get_radiator_updater @@ -357,12 +363,47 @@ function get_profile_warehouse( this ) result( profile_warehouse ) class(core_t), intent(in) :: this class(profile_warehouse_t), pointer :: profile_warehouse - call assert_msg( 423051914, associated( this%profile_warehouse_ ), & + call assert_msg( 573031914, associated( this%profile_warehouse_ ), & "Profiles not available" ) profile_warehouse => this%profile_warehouse_ end function get_profile_warehouse +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + function get_radiator( this, radiator_name ) result( radiator ) + ! Returns a copy of a radiator from the warehouse + + use musica_assert, only : assert_msg + use tuvx_radiator, only : radiator_t + + class(core_t), intent(in) :: this + character(len=*), intent(in) :: radiator_name + class(radiator_t), pointer :: radiator + + call assert_msg( 685097977, associated( & + this%radiative_transfer_ ), "Radiators not available" ) + radiator => this%radiative_transfer_%radiator_warehouse_%get_radiator( radiator_name ) + + end function get_radiator + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + function get_radiator_warehouse( this ) result( radiator_warehouse ) + ! Returns a copy of a radiator from the warehouse + + use musica_assert, only : assert_msg + use tuvx_radiator, only : radiator_t + + class(core_t), intent(in) :: this + class(radiator_warehouse_t), pointer :: radiator_warehouse + + call assert_msg( 923051934, associated( & + this%radiative_transfer_ ), "Radiators not available" ) + radiator_warehouse => this%radiative_transfer_%radiator_warehouse_ + + end function get_radiator_warehouse + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! function get_grid_updater( this, grid, found ) result( updater ) diff --git a/src/linear_algebras/CMakeLists.txt b/src/linear_algebras/CMakeLists.txt index 9d1d6c66..246fa2b4 100644 --- a/src/linear_algebras/CMakeLists.txt +++ b/src/linear_algebras/CMakeLists.txt @@ -3,8 +3,11 @@ target_sources(tuvx_object PRIVATE - lapack.F90 linpack.F90 ) +if(TUVX_ENABLE_LAPACK) + target_sources(tuvx_object PRIVATE lapack.F90) +endif() + ################################################################################ diff --git a/src/radiative_transfer/radiative_transfer.F90 b/src/radiative_transfer/radiative_transfer.F90 index 50f02daf..13c1b05f 100644 --- a/src/radiative_transfer/radiative_transfer.F90 +++ b/src/radiative_transfer/radiative_transfer.F90 @@ -11,7 +11,6 @@ module tuvx_radiative_transfer use musica_string, only : string_t use tuvx_cross_section_warehouse, only : cross_section_warehouse_t use tuvx_grid_warehouse, only : grid_warehouse_t - use tuvx_grid_warehouse, only : grid_warehouse_t use tuvx_la_sr_bands, only : la_sr_bands_t use tuvx_profile, only : profile_t use tuvx_profile_warehouse, only : profile_warehouse_ptr, profile_warehouse_t @@ -23,8 +22,6 @@ module tuvx_radiative_transfer use tuvx_solver_factory, only : solver_allocate, solver_builder, solver_type_name use tuvx_spherical_geometry, only : spherical_geometry_t - - implicit none private diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 52649f39..1d625374 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,7 +2,11 @@ # Test utilities add_library(tuvx_test_utils unit/test_utils.F90) -target_link_libraries(tuvx_test_utils PUBLIC LAPACK::LAPACK musica::tuvx) +target_link_libraries(tuvx_test_utils PUBLIC musica::tuvx) + +if(TUVX_ENABLE_LAPACK) + target_link_libraries(tuvx_test_utils PUBLIC LAPACK::LAPACK) +endif() set_target_properties(tuvx_test_utils PROPERTIES Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/test_include diff --git a/test/unit/linear_algebra/CMakeLists.txt b/test/unit/linear_algebra/CMakeLists.txt index 436ce7a6..cc506f3c 100644 --- a/test/unit/linear_algebra/CMakeLists.txt +++ b/test/unit/linear_algebra/CMakeLists.txt @@ -6,8 +6,9 @@ include(test_util) # ############################################################################## # tests -create_standard_cxx_test(NAME tridiagonal_solver SOURCES - test_tridiagonal_solver.cpp) create_standard_cxx_test(NAME error_function SOURCES test_error_function.cpp) +if(TUVX_ENABLE_LAPACK) + create_standard_cxx_test(NAME tridiagonal_solver SOURCES test_tridiagonal_solver.cpp) +endif() # ##############################################################################