Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow TUV-x radiator data to be updated through the API #108

Merged
merged 35 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0e3edb2
add radiator gettier
boulderdaze Jul 23, 2024
90c4317
fix invalid args
boulderdaze Jul 23, 2024
831e435
fix args
boulderdaze Jul 23, 2024
604e6d0
fix comments
boulderdaze Jul 24, 2024
b8ed7d1
add cross section to create radiator?
boulderdaze Jul 24, 2024
a8452a3
remove cross section
boulderdaze Jul 24, 2024
ed0d163
use radiative transfer to get warehouse
boulderdaze Jul 24, 2024
647042b
fixing implicit error for radiator
boulderdaze Jul 24, 2024
d4489dc
test code for malloc failure
boulderdaze Jul 25, 2024
90add49
revert back
boulderdaze Jul 26, 2024
b576b27
remove debug code
boulderdaze Jul 26, 2024
19fcc7e
fix seg fault from getter
boulderdaze Jul 29, 2024
6a0d60e
minor fix
boulderdaze Jul 30, 2024
b663dae
test code
boulderdaze Jul 31, 2024
559f3c5
test code
boulderdaze Jul 31, 2024
0a6f990
test code
boulderdaze Jul 31, 2024
7a2c6d4
test
boulderdaze Jul 31, 2024
521d2e4
test
boulderdaze Jul 31, 2024
8fdd93c
write stringt
boulderdaze Jul 31, 2024
32a37f5
write stringt
boulderdaze Jul 31, 2024
676bb7c
make lapack optional
boulderdaze Aug 1, 2024
288bba7
disalbe all the tests'
boulderdaze Aug 1, 2024
08df809
remove cmake error message
boulderdaze Aug 1, 2024
e1cac0f
disable blas library
boulderdaze Aug 1, 2024
c94329b
rm lapack
boulderdaze Aug 2, 2024
e5e5cd6
fix lfalse
boulderdaze Aug 2, 2024
5a663fd
comment out lapack
boulderdaze Aug 2, 2024
db8375a
disable blas library
boulderdaze Aug 2, 2024
f78eb1b
clean up
boulderdaze Aug 5, 2024
355dc32
fix cmake error
boulderdaze Aug 5, 2024
9de9140
enable regression test
boulderdaze Aug 5, 2024
27a7aa7
fix bug
boulderdaze Aug 5, 2024
82ba166
assert error digit
boulderdaze Aug 5, 2024
f8ae5a2
remove newline
boulderdaze Aug 5, 2024
0e27463
remove a comment
boulderdaze Aug 7, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
git config --global user.email "[email protected]"
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

Expand Down
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -158,8 +165,8 @@ endif()
################################################################################
# benchmarking

if(TUVX_ENABLE_BENCHMARK)
if(TUVX_ENABLE_BENCHMARK AND TUVX_ENABLE_LAPACK)
add_subdirectory(benchmark)
endif()

################################################################################
################################################################################
10 changes: 7 additions & 3 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ include(FetchContent)
# ##############################################################################
# LAPACK

find_package(BLAS)
find_package(LAPACK)
find_package(LAPACKE)
# find_package(BLAS)

if(TUVX_ENABLE_LAPACK)
find_package(LAPACK)
find_package(LAPACKE)
find_package(BLAS)
endif()

# ##############################################################################
# Memory check
Expand Down
12 changes: 9 additions & 3 deletions cmake/test_util.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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})
Expand Down
35 changes: 15 additions & 20 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,30 @@ 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 $<BUILD_INTERFACE:${TUVX_MOD_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
$<INSTALL_INTERFACE:${TUVX_INSTALL_MOD_DIR}>
$<INSTALL_INTERFACE:${TUVX_INSTALL_INCLUDE_DIR}>)

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
Expand Down Expand Up @@ -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)

################################################################################
43 changes: 42 additions & 1 deletion src/core.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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 )
Expand Down
5 changes: 4 additions & 1 deletion src/linear_algebras/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

################################################################################
3 changes: 0 additions & 3 deletions src/radiative_transfer/radiative_transfer.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 5 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions test/unit/linear_algebra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
# ##############################################################################
Loading