From 18ea0af331e255cd4497336a408187f9adb5e5c1 Mon Sep 17 00:00:00 2001 From: Sterling Date: Mon, 10 Jun 2013 12:35:59 -0400 Subject: [PATCH] Cleaned up implimentation of track output --- src/DEPENDENCIES | 1 + src/global.F90 | 3 +++ src/initialize.F90 | 2 ++ src/particle_restart.F90 | 20 ++++++++++++++++++++ src/physics.F90 | 16 ++++++---------- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/DEPENDENCIES b/src/DEPENDENCIES index c241153e76..dfe7390f1d 100644 --- a/src/DEPENDENCIES +++ b/src/DEPENDENCIES @@ -294,6 +294,7 @@ physics.o: material_header.o physics.o: mesh.o physics.o: output.o physics.o: particle_header.o +physics.o: particle_restart.o physics.o: particle_restart_write.o physics.o: random_lcg.o physics.o: search.o diff --git a/src/global.F90 b/src/global.F90 index e0f0bd5bbf..43f8025455 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -283,6 +283,9 @@ module global ! Particle restart run logical :: particle_restart_run = .false. + ! Particle track output + logical :: write_track = .false. + ! ============================================================================ ! CMFD VARIABLES diff --git a/src/initialize.F90 b/src/initialize.F90 index dd28f9bf9c..f8a474c545 100644 --- a/src/initialize.F90 +++ b/src/initialize.F90 @@ -311,6 +311,8 @@ contains i = i + 1 path_particle_restart = argv(i) particle_restart_run = .true. + case ('-tr', '-track', '--track') + write_track = .true. case default message = "Unknown command line option: " // argv(i) call fatal_error() diff --git a/src/particle_restart.F90 b/src/particle_restart.F90 index 07c7f5475e..e3bd96afb8 100644 --- a/src/particle_restart.F90 +++ b/src/particle_restart.F90 @@ -11,6 +11,7 @@ module particle_restart use physics, only: transport use random_lcg, only: set_particle_seed use source, only: initialize_particle + use string, only: to_str #ifdef HDF5 use hdf5_interface @@ -19,6 +20,7 @@ module particle_restart implicit none private public :: run_particle_restart + public :: write_particle_track #ifdef HDF5 integer(HID_T) :: hdf5_particle_file @@ -118,6 +120,7 @@ contains subroutine run_particle_restart() integer(8) :: particle_seed + character(MAX_FILE_LEN) :: filename ! initialize the particle to be tracked allocate(p) @@ -138,9 +141,22 @@ contains current_gen - 1)*n_particles + p % id call set_particle_seed(particle_seed) + ! Open particle track output file. + if (write_track) then + filename = trim(path_output) // 'track_' // trim(to_str(current_batch)) & + // '_' // trim(to_str(current_work)) // '.binary' + open(UNIT=UNIT_TRACK, FILE=filename, STATUS='replace', & + ACCESS='stream') + end if + ! transport neutron call transport() + ! Close particle track output file. + if (write_track) then + close(UNIT=UNIT_TRACK) + endif + ! write output if particle made it write(ou,*) 'Particle Successfully Transport:' write(ou,*) 'WEIGHT:', p % wgt @@ -150,4 +166,8 @@ contains end subroutine run_particle_restart + subroutine write_particle_track() + write(UNIT_TRACK) p % coord0 % xyz + end subroutine write_particle_track + end module particle_restart diff --git a/src/physics.F90 b/src/physics.F90 index e1c7f12c32..ba8eac3fa5 100644 --- a/src/physics.F90 +++ b/src/physics.F90 @@ -15,6 +15,7 @@ module physics use mesh, only: get_mesh_indices use output, only: write_message use particle_header, only: LocalCoord + use particle_restart, only: write_particle_track use particle_restart_write, only: write_particle_restart use random_lcg, only: prn use search, only: binary_search @@ -73,14 +74,13 @@ contains ! Force calculation of cross-sections by setting last energy to zero micro_xs % last_E = ZERO - if (run_mode == MODE_PARTICLE) then - open(UNIT=UNIT_TRACK, FILE='test', STATUS='replace', & - ACCESS='stream') - write(UNIT_TRACK) p % coord0 % xyz - end if - do while (p % alive) + ! Write particle track. + if (write_track) then + call write_particle_track() + endif + ! Calculate microscopic and macroscopic cross sections -- note: if the ! material is the same as the last material and the energy of the ! particle hasn't changed, we don't need to lookup cross sections again. @@ -185,10 +185,6 @@ contains end do - if (run_mode == MODE_PARTICLE) then - close(UNIT=UNIT_TRACK) - end if - end subroutine transport !===============================================================================