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

Fixes the intent of the target array in the copy_data function #243

Merged
merged 1 commit into from
Nov 6, 2024
Merged
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
2 changes: 1 addition & 1 deletion cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,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 v0.10.0)
set_git_default(TUVX_GIT_TAG fbe0f8aa73f6630d230c6463b603d6ba64c65dcf)

FetchContent_Declare(tuvx
GIT_REPOSITORY ${TUVX_GIT_REPOSITORY}
Expand Down
16 changes: 8 additions & 8 deletions fortran/test/unit/util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ subroutine build_and_check_index_mapping_t(config)
type(mappings_t), pointer :: source_map, target_map
type(index_mappings_t), pointer :: index_mappings
type(error_t) :: error
real(dk), allocatable :: source_data(:), target_data(:)
real(dk) :: source_data(2,5), target_data(3,4)

allocate( f_map( 2 ) )
map => mapping_t( "Test", 2 )
Expand All @@ -302,14 +302,14 @@ subroutine build_and_check_index_mapping_t(config)
index_mappings => index_mappings_t( config, source_map, target_map, error )
ASSERT( error%is_success() )

source_data = (/ 1.0_dk, 2.0_dk, 3.0_dk, 4.0_dk, 5.0_dk /)
target_data = (/ 10.0_dk, 20.0_dk, 30.0_dk, 40.0_dk /)
source_data(2,:) = (/ 1.0_dk, 2.0_dk, 3.0_dk, 4.0_dk, 5.0_dk /)
target_data(2,:) = (/ 10.0_dk, 20.0_dk, 30.0_dk, 40.0_dk /)

call index_mappings%copy_data( source_data, target_data )
ASSERT_EQ( target_data( 1 ), 5.0_dk * 0.82_dk )
ASSERT_EQ( target_data( 2 ), 20.0_dk )
ASSERT_EQ( target_data( 3 ), 2.0_dk )
ASSERT_EQ( target_data( 4 ), 40.0_dk )
call index_mappings%copy_data( source_data(2,:), target_data(2,:) )
ASSERT_EQ( target_data( 2, 1 ), 5.0_dk * 0.82_dk )
ASSERT_EQ( target_data( 2, 2 ), 20.0_dk )
ASSERT_EQ( target_data( 2, 3 ), 2.0_dk )
ASSERT_EQ( target_data( 2, 4 ), 40.0_dk )
deallocate( index_mappings )
deallocate( source_map )
deallocate( target_map )
Expand Down
2 changes: 1 addition & 1 deletion fortran/util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ subroutine copy_data( this, source, target )

class(index_mappings_t), intent(inout) :: this
real(kind=musica_dk), target, contiguous, intent(in) :: source(:)
real(kind=musica_dk), target, contiguous, intent(in) :: target(:)
real(kind=musica_dk), target, contiguous, intent(inout) :: target(:)

call copy_data_c( this%mappings_c_, c_loc( source ), c_loc( target ) )

Expand Down
Loading