Have openmc_next_batch return a status

This commit is contained in:
Paul Romano 2017-11-03 09:46:48 -05:00
parent 9f66edb7fb
commit ac565724dc

View file

@ -58,10 +58,9 @@ contains
call openmc_simulation_init()
BATCH_LOOP: do current_batch = 1, n_max_batches
call openmc_next_batch()
if (satisfy_triggers) exit BATCH_LOOP
end do BATCH_LOOP
do
if (openmc_next_batch() < 0) exit
end do
call time_active % stop()
@ -73,7 +72,8 @@ contains
! OPENMC_NEXT_BATCH
!===============================================================================
subroutine openmc_next_batch() bind(C)
function openmc_next_batch() result(retval) bind(C)
integer(C_INT) :: retval
type(Particle) :: p
integer(8) :: i_work
@ -119,7 +119,16 @@ contains
call finalize_batch()
end subroutine openmc_next_batch
! Check simulation ending criteria
if (current_batch == n_max_batches) then
retval = -1
elseif (satisfy_triggers) then
retval = -2
else
retval = 0
end if
end function openmc_next_batch
!===============================================================================
! INITIALIZE_HISTORY
@ -174,6 +183,9 @@ contains
integer :: i
! Increment current batch
current_batch = current_batch + 1
if (run_mode == MODE_FIXEDSOURCE) then
call write_message("Simulating batch " // trim(to_str(current_batch)) &
// "...", 6)
@ -427,6 +439,9 @@ contains
end if
end if
! Reset current batch
current_batch = 0
end subroutine openmc_simulation_init
!===============================================================================