diff --git a/src/cmfd_data.F90 b/src/cmfd_data.F90
index e0c67c5a61..8f33b86d9d 100644
--- a/src/cmfd_data.F90
+++ b/src/cmfd_data.F90
@@ -30,7 +30,7 @@ contains
if (.not. cmfd_run_2grp) call compute_xs()
! check neutron balance
-! call neutron_balance(670)
+ call neutron_balance(670)
! fix 2 grp cross sections
if (cmfd_run_2grp) call fix_2_grp()
@@ -153,7 +153,7 @@ contains
! get total rr and convert to total xs
cmfd % totalxs(h,i,j,k) = t % scores(2,score_index) % sum / flux
- write(200,*) cmfd % totalxs(h,i,j,k)
+
! get p1 scatter rr and convert to p1 scatter xs
cmfd % p1scattxs(h,i,j,k) = t % scores(3,score_index) % sum / flux
diff --git a/src/cmfd_input.F90 b/src/cmfd_input.F90
index 91f15f6f3d..0b4dd07f1b 100644
--- a/src/cmfd_input.F90
+++ b/src/cmfd_input.F90
@@ -176,12 +176,13 @@ contains
subroutine create_cmfd_tally()
- use datatypes, only: dict_add_key, dict_get_key
- use error, only: fatal_error, warning
+ use datatypes, only: dict_add_key, dict_get_key
+ use error, only: fatal_error, warning
use global
- use mesh_header, only: StructuredMesh
+ use mesh_header, only: StructuredMesh
use string
- use tally_header, only: TallyObject, TallyScore
+ use tally, only: setup_active_cmfdtallies
+ use tally_header, only: TallyObject, TallyScore
use xml_data_cmfd_t
integer :: i ! loop counter
@@ -209,9 +210,9 @@ contains
n_current_tallies = n_user_current_tallies + n_cmfd_current_tallies
! Allocate list of pointers for tallies by type
- if (.not. allocated(analog_tallies)) allocate(analog_tallies(n_analog_tallies))
- if (.not. allocated(tracklength_tallies)) allocate(tracklength_tallies(n_tracklength_tallies))
- if (.not. allocated(current_tallies)) allocate(current_tallies(n_current_tallies))
+ if (.not. allocated(analog_tallies) .and. n_analog_tallies > 0) allocate(analog_tallies(n_analog_tallies))
+ if (.not. allocated(tracklength_tallies) .and. n_tracklength_tallies > 0) allocate(tracklength_tallies(n_tracklength_tallies))
+ if (.not. allocated(current_tallies) .and. n_current_tallies > 0) allocate(current_tallies(n_current_tallies))
! allocate mesh
if (.not. allocated(meshes)) allocate(meshes(n_meshes))
@@ -286,6 +287,11 @@ contains
t % n_filter_bins = 0
t % stride = 0
+ ! set number of nucilde bins
+ allocate(t % nuclide_bins(1))
+ t % nuclide_bins(1) = -1
+ t % n_nuclide_bins = 1
+
! record tally id which is equivalent to loop number
t % id = i
@@ -412,6 +418,9 @@ contains
end do
+ call setup_active_cmfdtallies()
+ tallies_on = .true.
+
end subroutine create_cmfd_tally
!===============================================================================
diff --git a/src/criticality.F90 b/src/criticality.F90
index 96bfee7aa0..32d7ae7e5f 100644
--- a/src/criticality.F90
+++ b/src/criticality.F90
@@ -11,7 +11,7 @@ module criticality
use source, only: get_source_particle
use state_point, only: write_state_point, replay_batch_history
use string, only: to_str
- use tally, only: synchronize_tallies, setup_active_tallies
+ use tally, only: synchronize_tallies, setup_active_usertallies
use timing, only: timer_start, timer_stop
#ifdef HDF5
@@ -181,7 +181,7 @@ contains
tallies_on = .true.
call timer_stop(time_inactive)
call timer_start(time_active)
- call setup_active_tallies()
+ call setup_active_usertallies()
end if
end subroutine finalize_batch
diff --git a/src/fixed_source.F90 b/src/fixed_source.F90
index 5cde3cfa3e..4be4c6257c 100644
--- a/src/fixed_source.F90
+++ b/src/fixed_source.F90
@@ -9,7 +9,7 @@ module fixed_source
copy_source_attributes
use state_point, only: write_state_point
use string, only: to_str
- use tally, only: synchronize_tallies, setup_active_tallies
+ use tally, only: synchronize_tallies, setup_active_usertallies
use timing, only: timer_start, timer_stop
#ifdef HDF5
@@ -32,7 +32,7 @@ contains
! Turn timer and tallies on
tallies_on = .true.
- call setup_active_tallies()
+ call setup_active_usertallies()
call timer_start(time_active)
! ==========================================================================
diff --git a/src/global.F90 b/src/global.F90
index 42410c70bf..32d9e5694c 100644
--- a/src/global.F90
+++ b/src/global.F90
@@ -336,7 +336,7 @@ module global
integer :: cmfd_begin = 1
! when and how long to flush cmfd tallies during inactive batches
- integer :: cmfd_inact_flush(2) = (/10,1/)
+ integer :: cmfd_inact_flush(2) = (/9999,1/)
! batch to last flush before active batches
integer :: cmfd_act_flush = 0
diff --git a/src/output.F90 b/src/output.F90
index e9c959742a..24efb395ec 100644
--- a/src/output.F90
+++ b/src/output.F90
@@ -1188,8 +1188,13 @@ contains
entropy(current_batch)
! write out accumulated k-effective if after first active batch
- if (current_batch > n_inactive + 1) write(UNIT=OUTPUT_UNIT, &
- FMT='(3X, F8.5," +/-",F8.5)', ADVANCE='NO') keff, keff_std
+ if (current_batch > n_inactive + 1) then
+ write(UNIT=OUTPUT_UNIT, FMT='(3X, F8.5," +/-",F8.5)', ADVANCE='NO') &
+ keff, keff_std
+ else
+ write(UNIT=OUTPUT_UNIT, FMT='(23X)', ADVANCE='NO')
+ end if
+
! write out cmfd keff if it is active
if (cmfd_on) write(UNIT=OUTPUT_UNIT, FMT='(3X, F8.5)', ADVANCE='NO') &
@@ -1200,7 +1205,7 @@ contains
FMT='(3X, F8.5)', ADVANCE='NO') cmfd % entropy
! next line
- write(UNIT=OUTPUT_UNIT,FMT=*)
+ write(UNIT=OUTPUT_UNIT, FMT=*)
end subroutine print_batch_keff
diff --git a/src/tally.F90 b/src/tally.F90
index 7e7bb9d3d7..6c8a4bbb62 100755
--- a/src/tally.F90
+++ b/src/tally.F90
@@ -57,6 +57,7 @@ contains
position = 0
do i = 1, n_tallies
+
t => tallies(i)
! initialize number of filter bins
@@ -264,6 +265,7 @@ contains
! determine different filter bins for the same tally in order to score to it
TALLY_LOOP: do while (associated(curr_ptr))
+
t => tallies(analog_tallies(curr_ptr % data))
! =======================================================================
@@ -2374,9 +2376,9 @@ contains
! SETUP_ACTIVE_USERTALLIES
!===============================================================================
- subroutine setup_active_tallies()
+ subroutine setup_active_usertallies()
- integer :: i ! loop counter
+ integer :: i ! loop counter
type(ListInt), pointer :: curr_ptr ! pointer to current list node
type(ListInt), pointer :: tall_ptr ! pointer to active tallies only
@@ -2495,6 +2497,100 @@ contains
! nullify the temporary pointer
if (associated(curr_ptr)) nullify(curr_ptr)
- end subroutine setup_active_tallies
+ end subroutine setup_active_usertallies
+
+!===============================================================================
+! SETUP_ACTIVE_CMFDTALLIES
+!===============================================================================
+
+ subroutine setup_active_cmfdtallies()
+
+ integer :: i ! loop counter
+ type(ListInt), pointer :: curr_ptr ! pointer to current list node
+ type(ListInt), pointer :: tall_ptr ! pointer to active tallies only
+
+ ! check to see if actives tallies has been allocated
+ tall_ptr => active_tallies
+ if (associated(active_tallies)) then
+ message = 'Active tallies should not exist before CMFD tallies!'
+ call fatal_error()
+ end if
+
+ ! check to see if analog tallies have already been allocated
+ curr_ptr => null()
+ if (associated(active_analog_tallies)) then
+ message = 'Active analog tallies should not exist before CMFD tallies!'
+ call fatal_error()
+ end if
+
+ do i = n_cmfd_analog_tallies + n_user_analog_tallies, n_user_analog_tallies + 1, -1
+
+ ! allocate node
+ allocate(curr_ptr)
+
+ ! set the tally index
+ curr_ptr % data = i
+ curr_ptr % next => active_analog_tallies
+ active_analog_tallies => curr_ptr
+
+ ! set indices in active tallies
+ allocate(tall_ptr)
+ tall_ptr % data = analog_tallies(i)
+ tall_ptr % next => active_tallies
+ active_tallies => tall_ptr
+
+ end do
+
+ ! check to see if tracklength tallies have already been allocated
+ curr_ptr => null()
+ if (associated(active_tracklength_tallies)) then
+ message = 'Active tracklength tallies should not exist before CMFD tallies!'
+ call fatal_error()
+ end if
+
+ do i = n_cmfd_tracklength_tallies + n_user_tracklength_tallies, n_user_tracklength_tallies + 1, -1
+
+ ! allocate node
+ allocate(curr_ptr)
+
+ ! set the tally index
+ curr_ptr % data = i
+ curr_ptr % next => active_tracklength_tallies
+ active_tracklength_tallies => curr_ptr
+
+ ! set indices in active tallies
+ allocate(tall_ptr)
+ tall_ptr % data = tracklength_tallies(i)
+ tall_ptr % next => active_tallies
+ active_tallies => tall_ptr
+
+ end do
+
+ ! check to see if current tallies have already been allocated
+ curr_ptr => null()
+ if (associated(active_current_tallies)) then
+ message = 'Active current tallies should not exist before CMFD tallies!'
+ call fatal_error()
+ end if
+
+ do i = n_cmfd_current_tallies + n_user_current_tallies, n_user_current_tallies + 1, -1
+
+ ! allocate node
+ allocate(curr_ptr)
+
+ ! set the tally index
+ curr_ptr % data = i
+ curr_ptr % next => active_current_tallies
+ active_current_tallies => curr_ptr
+
+ ! set indices in active tallies
+ allocate(tall_ptr)
+ tall_ptr % data = current_tallies(i)
+ tall_ptr % next => active_tallies
+ active_tallies => tall_ptr
+
+ end do
+
+ end subroutine setup_active_cmfdtallies
end module tally
diff --git a/src/templates/cmfd_t.xml b/src/templates/cmfd_t.xml
index 58df402a94..94a372ef90 100644
--- a/src/templates/cmfd_t.xml
+++ b/src/templates/cmfd_t.xml
@@ -30,7 +30,7 @@
-
+