Added finalize module to better group post-simulation subroutines.

This commit is contained in:
Paul Romano 2012-01-17 16:21:13 -05:00
parent 4bc81d501d
commit e6aca9820a
5 changed files with 64 additions and 35 deletions

View file

@ -38,6 +38,12 @@ energy_grid.o: datatypes_header.o
energy_grid.o: global.o
energy_grid.o: output.o
finalize.o: global.o
finalize.o: hdf5_interface.o
finalize.o: output.o
finalize.o: tally.o
finalize.o: timing.o
fission.o: ace_header.o
fission.o: constants.o
fission.o: error.o
@ -121,7 +127,6 @@ interpolation.o: string.o
main.o: constants.o
main.o: global.o
main.o: hdf5_interface.o
main.o: initialize.o
main.o: intercycle.o
main.o: output.o

View file

@ -10,6 +10,7 @@ endf.o \
endf_header.o \
energy_grid.o \
error.o \
finalize.o \
fission.o \
geometry.o \
geometry_header.o \

49
src/finalize.F90 Normal file
View file

@ -0,0 +1,49 @@
module finalize
use global
use output, only: print_runtime
use tally, only: write_tallies, tally_statistics
use timing, only: timer_stop
#ifdef HDF5
use hdf5_interface, only: write_hdf5_summary, close_hdf5_output
#endif
implicit none
contains
!===============================================================================
! FINALIZE_RUN
!===============================================================================
subroutine finalize_run()
! Calculate statistics for tallies and write to tallies.out
if (.not. plotting) then
call tally_statistics()
if (master) call write_tallies()
end if
! show timing statistics
call timer_stop(time_total)
if (master) call print_runtime()
#ifdef HDF5
if (master) then
call write_hdf5_summary()
call close_hdf5_output()
end if
#endif
! deallocate arrays
call free_memory()
#ifdef MPI
! If MPI is in use and enabled, terminate it
call MPI_FINALIZE(mpi_err)
#endif
end subroutine finalize_run
end module finalize

View file

@ -46,7 +46,8 @@ contains
type(Universe), pointer :: univ
! Start initialization timer
! Start total and initialization timer
call timer_start(time_total)
call timer_start(time_initialize)
! Setup MPI

View file

@ -2,32 +2,25 @@ program main
use constants
use global
use finalize, only: finalize_run
use initialize, only: initialize_run
use intercycle, only: shannon_entropy, calculate_keff, synchronize_bank
use output, only: write_message, header, print_runtime
use output, only: write_message, header
use particle_header, only: Particle
use plot, only: run_plot
use physics, only: transport
use random_lcg, only: set_particle_seed
use source, only: get_source_particle
use string, only: to_str
use tally, only: synchronize_tallies, write_tallies, &
tally_statistics
use tally, only: synchronize_tallies
use timing, only: timer_start, timer_stop
#ifdef MPI
use mpi
#endif
#ifdef HDF5
use hdf5_interface, only: write_hdf5_summary, close_hdf5_output
#endif
implicit none
! start timer for total run time
call timer_start(time_total)
! set up problem
call initialize_run()
@ -36,30 +29,10 @@ program main
call run_plot()
else
call run_problem()
! Calculate statistics for tallies and write to tallies.out
call tally_statistics()
if (master) call write_tallies()
! show timing statistics
call timer_stop(time_total)
if (master) call print_runtime()
end if
! deallocate arrays
call free_memory()
#ifdef HDF5
if (master) then
call write_hdf5_summary()
call close_hdf5_output()
end if
#endif
#ifdef MPI
! If MPI is in use and enabled, terminate it
call MPI_FINALIZE(mpi_err)
#endif
! finalize run
call finalize_run()
contains