From b7e001bfb57e8136a061d50789a23ed07e1aa299 Mon Sep 17 00:00:00 2001 From: Kyle Shores Date: Mon, 3 Jun 2024 15:46:26 -0500 Subject: [PATCH] saving progress --- .../test_tuvx_api.F90 | 3 ++- fortran/tuvx.F90 | 24 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/fortran/test/fetch_content_integration/test_tuvx_api.F90 b/fortran/test/fetch_content_integration/test_tuvx_api.F90 index 88f306c4..c654b9fd 100644 --- a/fortran/test/fetch_content_integration/test_tuvx_api.F90 +++ b/fortran/test/fetch_content_integration/test_tuvx_api.F90 @@ -70,7 +70,8 @@ subroutine test_tuvx_solve() ! radiators = tuvx%create_radiators( ) ! update conditions for each time step - ! grid => grids%get( "height", "m" ) + grid => grids%get( "height", "m", error ) + ASSERT( error%is_success() ) ! grid%edges_(:) = some_input_array(:) ! grid%mid_points_(:) = more_input_data(:) diff --git a/fortran/tuvx.F90 b/fortran/tuvx.F90 index 118f2e8a..5517358b 100644 --- a/fortran/tuvx.F90 +++ b/fortran/tuvx.F90 @@ -34,6 +34,14 @@ function get_grid_map_c(tuvx, error) bind(C, name="get_grid_map") type(error_t_c), intent(inout) :: error type(c_ptr) :: get_grid_map_c end function get_grid_map_c + + function get_grid_c(grid_map, grid_name, grid_units, error) bind(C, name="get_grid") + use musica_util, only: error_t_c + import c_ptr + type(c_ptr), value, intent(in) :: grid_map + type(error_t_c), intent(inout) :: error + type(c_ptr) :: get_grid_c + end function get_grid_c end interface !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -55,6 +63,8 @@ end function get_grid_map_c type :: grid_map_t type(c_ptr), private :: ptr contains + ! get a reference to a grid + procedure :: get_grid => get ! Deallocate the tuvx instance final :: finalize_grid_map_t end type grid_map_t @@ -80,6 +90,18 @@ function grid_map_t_constructor() result(this) this%ptr = c_null_ptr end function grid_map_t_constructor + subroutine get(this, grid, error) + use musica_util, only: error_t, error_t_c + type(grid_map_t), intent(inout) :: this + type(grid_t), pointer :: grid + type(error_t), intent(inout) :: error + type(error_t_c) :: error_c + + grid = grid_t() + grid%ptr = get_grid_c(this%ptr, error_c) + error = error_t(error_c) + end subroutine get + subroutine finalize_grid_map_t(this) type(grid_map_t), intent(inout) :: this @@ -130,7 +152,7 @@ function get_grids(this, error) result(grid_map) grid_map = grid_map_t() grid_map%ptr = get_grid_map_c(this%ptr, error_c) - + error = error_t(error_c) end function get_grids