Add filter get/set id C API functions

This commit is contained in:
Paul Romano 2017-08-14 14:53:57 -05:00
parent 45993ab2d9
commit 9d737ea69e
3 changed files with 45 additions and 0 deletions

View file

@ -13,6 +13,12 @@ _dll.openmc_energy_filter_set_bins.errcheck = _error_handler
_dll.openmc_extend_filters.argtypes = [c_int32, POINTER(c_int32), POINTER(c_int32)]
_dll.openmc_extend_filters.restype = c_int
_dll.openmc_extend_filters.errcheck = _error_handler
_dll.openmc_filter_get_id.argtypes = [c_int32, POINTER(c_int32)]
_dll.openmc_filter_get_id.restype = c_int
_dll.openmc_filter_get_id.errcheck = _error_handler
_dll.openmc_filter_set_id.argtypes = [c_int32, c_int32]
_dll.openmc_filter_set_id.restype = c_int
_dll.openmc_filter_set_id.errcheck = _error_handler
_dll.openmc_filter_set_type.argtypes = [c_int32, c_char_p]
_dll.openmc_filter_set_type.restype = c_int
_dll.openmc_filter_set_type.errcheck = _error_handler

View file

@ -33,6 +33,8 @@ module openmc_api
public :: openmc_energy_filter_set_bins
public :: openmc_extend_filters
public :: openmc_extend_tallies
public :: openmc_filter_get_id
public :: openmc_filter_set_id
public :: openmc_filter_set_type
public :: openmc_finalize
public :: openmc_find

View file

@ -4,6 +4,7 @@ module tally_filter_header
use constants, only: MAX_LINE_LEN
use dict_header, only: DictIntInt
use error
use particle_header, only: Particle
use stl_vector, only: VectorInt, VectorReal
@ -12,6 +13,8 @@ module tally_filter_header
implicit none
private
public :: openmc_extend_filters
public :: openmc_filter_get_id
public :: openmc_filter_set_id
!===============================================================================
! TALLYFILTERMATCH stores every valid bin and weight for a filter
@ -154,4 +157,38 @@ contains
err = 0
end function openmc_extend_filters
function openmc_filter_get_id(index, id) result(err) bind(C)
! Return the ID of a filter
integer(C_INT32_T), value :: index
integer(C_INT32_T), intent(out) :: id
integer(C_INT) :: err
if (index >= 1 .and. index <= n_filters) then
id = filters(index) % obj % id
err = 0
else
err = E_OUT_OF_BOUNDS
end if
end function openmc_filter_get_id
function openmc_filter_set_id(index, id) result(err) bind(C)
! Set the ID of a filter
integer(C_INT32_T), value, intent(in) :: index
integer(C_INT32_T), value, intent(in) :: id
integer(C_INT) :: err
if (index >= 1 .and. index <= n_filters) then
if (allocated(filters(index) % obj)) then
filters(index) % obj % id = id
err = 0
else
err = E_FILTER_NOT_ALLOCATED
end if
else
err = E_OUT_OF_BOUNDS
end if
end function openmc_filter_set_id
end module tally_filter_header