Skip to content

Commit

Permalink
merging
Browse files Browse the repository at this point in the history
  • Loading branch information
K20shores committed Jun 3, 2024
2 parents b7e001b + a48047e commit 1c099f5
Showing 1 changed file with 51 additions and 10 deletions.
61 changes: 51 additions & 10 deletions fortran/tuvx.F90
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ end function get_grid_c
procedure constructor
end interface tuvx_t

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

type :: grid_map_t
type(c_ptr), private :: ptr
contains
! get a reference to a grid
procedure :: get_grid => get
procedure :: get
! Deallocate the tuvx instance
final :: finalize_grid_map_t
end type grid_map_t
Expand All @@ -75,13 +76,27 @@ end function get_grid_c

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

contains
type :: grid_t
type(c_ptr), private :: ptr
contains
procedure :: get
! Deallocate the tuvx instance
final :: finalize_grid_t
end type grid_t

interface grid_t
procedure grid_t_constructor
end interface grid_t

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

contains

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Grid map type
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!> Construct a grid map instance
function grid_map_t_constructor() result(this)
type(grid_map_t), pointer :: this

Expand All @@ -90,27 +105,51 @@ function grid_map_t_constructor() result(this)
this%ptr = c_null_ptr
end function grid_map_t_constructor

subroutine get(this, grid, error)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!> Get a grid given its name and units
function get(this, grid_name, grid_units, error) result(grid)
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

class(grid_map_t), intent(inout) :: this
character(len=*), intent(in) :: grid_name
character(len=*), intent(in) :: grid_units
type(grid_t) :: grid
type(error_t), intent(inout) :: error
type(error_t_c) :: error_c
character(len=1, kind=c_char) :: c_grid_name(len_trim(grid_name)+1)
character(len=1, kind=c_char) :: c_grid_units(len_trim(grid_name)+1)

grid = grid_t()
grid%ptr = get_grid_c(this%ptr, error_c)
grid%ptr = get_grid_c(this%ptr, grid_name, grid_units, error_c)

error = error_t(error_c)
end subroutine get

end function get

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!> Deallocate the grid map instance
subroutine finalize_grid_map_t(this)
type(grid_map_t), intent(inout) :: this

end subroutine finalize_grid_map_t

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Grid type
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!> Deallocate the grid instance
subroutine finalize_grid_t(this)
type(grid_t), intent(inout) :: this

end subroutine finalize_grid_t

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! tuvx type
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!> Construct a tuvx instance
function constructor(config_path, error) result( this )
use musica_util, only: error_t_c, error_t

Expand Down Expand Up @@ -142,6 +181,7 @@ end function constructor

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!> Get the grid map
function get_grids(this, error) result(grid_map)
use musica_util, only: error_t, error_t_c

Expand All @@ -159,6 +199,7 @@ end function get_grids

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!> Deallocate the tuvx instance
subroutine finalize(this)
use musica_util, only: error_t, error_t_c
type(tuvx_t), intent(inout) :: this
Expand Down

0 comments on commit 1c099f5

Please sign in to comment.