diff --git a/src/finalize.F90 b/src/finalize.F90 index 93a3c7b086..c4dcaf0623 100644 --- a/src/finalize.F90 +++ b/src/finalize.F90 @@ -6,7 +6,7 @@ module finalize use timing, only: timer_start, timer_stop #ifdef HDF5 - use hdf5_interface, only: hdf5_write_timing, hdf5_close_output + use hdf5_interface, only: hdf5_write_results, hdf5_close_output #endif implicit none @@ -37,7 +37,7 @@ contains #ifdef HDF5 ! Write time statistics to HDF5 output if (master) then - call hdf5_write_timing() + call hdf5_write_results() call hdf5_close_output() end if #endif diff --git a/src/geometry.F90 b/src/geometry.F90 index 856b149c51..3457719556 100644 --- a/src/geometry.F90 +++ b/src/geometry.F90 @@ -8,7 +8,7 @@ module geometry use output, only: write_message use particle_header, only: LocalCoord, deallocate_coord use string, only: to_str - use tally, only: score_surface_current + use tally, only: score_surface_current, add_to_score implicit none @@ -263,12 +263,17 @@ contains ! forward slightly so that if the mesh boundary is on the surface, it is ! still processed - if (tallies_on .and. n_current_tallies > 0) then - ! TODO: Find a better solution to score surface currents than - ! physically moving the particle forward slightly + if (tallies_on) then + if (n_current_tallies > 0) then + ! TODO: Find a better solution to score surface currents than + ! physically moving the particle forward slightly - p % coord0 % xyz = p % coord0 % xyz + TINY_BIT * p % coord0 % uvw - call score_surface_current() + p % coord0 % xyz = p % coord0 % xyz + TINY_BIT * p % coord0 % uvw + call score_surface_current() + end if + + ! Score to global leakage tally + call add_to_score(global_tallies(LEAKAGE), p % wgt) end if ! Display message diff --git a/src/hdf5_interface.F90 b/src/hdf5_interface.F90 index 006c6cf3c9..fafe30109c 100644 --- a/src/hdf5_interface.F90 +++ b/src/hdf5_interface.F90 @@ -101,6 +101,17 @@ contains end subroutine hdf5_write_summary +!=============================================================================== +! HDF5_WRITE_RESULTS +!=============================================================================== + + subroutine hdf5_write_results() + + call hdf5_write_timing() + call hdf5_write_global_tallies() + + end subroutine hdf5_write_results + !=============================================================================== ! HDF5_WRITE_GEOMETRY !=============================================================================== @@ -410,6 +421,30 @@ contains end subroutine hdf5_write_materials +!=============================================================================== +! HDF5_WRITE_GLOBAL_TALLIES +!=============================================================================== + + subroutine hdf5_write_global_tallies() + + integer :: rank = 1 + integer(HSIZE_T) :: dims(1) = (/ 2 /) + + call h5ltmake_dataset_double_f(hdf5_output_file, "k_analog", & + rank, dims, (/ global_tallies(K_ANALOG) % sum, & + global_tallies(K_ANALOG) % sum_sq /), hdf5_err) + call h5ltmake_dataset_double_f(hdf5_output_file, "k_collision", & + rank, dims, (/ global_tallies(K_COLLISION) % sum, & + global_tallies(K_COLLISION) % sum_sq /), hdf5_err) + call h5ltmake_dataset_double_f(hdf5_output_file, "k_tracklength", & + rank, dims, (/ global_tallies(K_TRACKLENGTH) % sum, & + global_tallies(K_TRACKLENGTH) % sum_sq /), hdf5_err) + call h5ltmake_dataset_double_f(hdf5_output_file, "leakage", & + rank, dims, (/ global_tallies(LEAKAGE) % sum, & + global_tallies(LEAKAGE) % sum_sq /), hdf5_err) + + end subroutine hdf5_write_global_tallies + !=============================================================================== ! HDF5_WRITE_TALLIES !=============================================================================== diff --git a/src/intercycle.F90 b/src/intercycle.F90 index db51dcb31c..5ecd79fe84 100644 --- a/src/intercycle.F90 +++ b/src/intercycle.F90 @@ -387,7 +387,9 @@ contains integer :: n ! active cycle number real(8) :: k_cycle ! single cycle estimate of keff +#ifdef MPI real(8) :: global_temp(N_GLOBAL_TALLIES) +#endif message = "Calculate cycle keff..." call write_message(8) diff --git a/src/output.F90 b/src/output.F90 index 5da98d1ca7..0446ba5676 100644 --- a/src/output.F90 +++ b/src/output.F90 @@ -942,22 +942,31 @@ contains write(ou,100) "Total time for finalization", time_finalize % elapsed write(ou,100) "Total time elapsed", time_total % elapsed - ! display header block - call header("Run Statistics") - ! display calculate rate and final keff total_particles = n_particles * n_cycles speed = real(total_particles) / (time_inactive % elapsed + & time_active % elapsed) string = to_str(speed) write(ou,101) "Calculation Rate", trim(string) - write(ou,102) "Final Keff", keff, keff_std + + ! display header block for results + call header("Results") + + ! write global tallies + write(ou,102) "k-effective (Analog)", global_tallies(K_ANALOG) % sum, & + global_tallies(K_ANALOG) % sum_sq + write(ou,102) "k-effective (Collision)", global_tallies(K_COLLISION) % sum, & + global_tallies(K_COLLISION) % sum_sq + write(ou,102) "k-effective (Track-length)", global_tallies(K_TRACKLENGTH) % sum, & + global_tallies(K_TRACKLENGTH) % sum_sq + write(ou,102) "Leakage Fraction", global_tallies(LEAKAGE) % sum, & + global_tallies(LEAKAGE) % sum_sq write(ou,*) ! format for write statements 100 format (1X,A,T35,"= ",ES11.4," seconds") -101 format (1X,A,T20,"= ",A," neutrons/second") -102 format (1X,A,T20,"= ",F8.5," +/- ",F8.5) +101 format (1X,A,T35,"= ",A," neutrons/second") +102 format (1X,A,T30,"= ",F8.5," +/- ",F8.5) end subroutine print_runtime diff --git a/src/tally.F90 b/src/tally.F90 index ce4fbd511c..af6d93e738 100644 --- a/src/tally.F90 +++ b/src/tally.F90 @@ -1546,12 +1546,16 @@ contains integer :: i ! index in tallies array type(TallyObject), pointer :: t => null() + ! Calculate statistics for user-defined tallies do i = 1, n_tallies t => tallies(i) call calculate_statistics(t % scores) end do + ! Calculate statistics for global tallies + call calculate_statistics(global_tallies) + end subroutine tally_statistics end module tally