fix bug when loading nuclides using capi: invalid index updating

This commit is contained in:
liangjg 2019-02-05 21:02:26 -05:00
parent 4878a4601d
commit 5f571a5eaf
2 changed files with 4 additions and 5 deletions

View file

@ -703,15 +703,13 @@ contains
end function openmc_nuclide_name
subroutine extend_nuclides() bind(C)
integer :: n
type(Nuclide), allocatable :: new_nuclides(:)
! allocate extra space in nuclides array
n = n_nuclides
allocate(new_nuclides(n + 1))
new_nuclides(1:n) = nuclides(:)
allocate(new_nuclides(n_nuclides + 1))
new_nuclides(1:n_nuclides) = nuclides(:)
call move_alloc(FROM=new_nuclides, TO=nuclides)
n = n + 1
n_nuclides = n_nuclides + 1
end subroutine
end module nuclide_header

View file

@ -131,6 +131,7 @@ def test_nuclide_mapping(capi_init):
def test_load_nuclide(capi_init):
openmc.capi.load_nuclide('H3')
openmc.capi.load_nuclide('Pu239')
with pytest.raises(exc.DataError):
openmc.capi.load_nuclide('Pu3')