mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Ability to write source separately when using state points.
This commit is contained in:
parent
c10e709ef3
commit
fced38901f
6 changed files with 46 additions and 33 deletions
|
|
@ -244,6 +244,7 @@ state_point.o: error.o
|
|||
state_point.o: global.o
|
||||
state_point.o: math.o
|
||||
state_point.o: output.o
|
||||
state_point.o: source.o
|
||||
state_point.o: string.o
|
||||
state_point.o: tally_header.o
|
||||
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ module global
|
|||
real(8), allocatable :: source_frac(:,:,:,:)
|
||||
|
||||
! Write source at end of simulation
|
||||
logical :: write_source = .false.
|
||||
logical :: source_separate = .false.
|
||||
|
||||
! ============================================================================
|
||||
! PARALLEL PROCESSING VARIABLES
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ contains
|
|||
verbosity_ = 0
|
||||
energy_grid_ = "union"
|
||||
seed_ = 0_8
|
||||
write_source_ = ""
|
||||
source_separate_ = ""
|
||||
no_reduce_ = ""
|
||||
source_ % file = ''
|
||||
source_ % space % type = ''
|
||||
|
|
@ -460,7 +460,7 @@ contains
|
|||
end if
|
||||
|
||||
! Check if the user has specified to write binary source file
|
||||
if (trim(write_source_) == 'on') write_source = .true.
|
||||
if (trim(source_separate_) == 'on') source_separate = .true.
|
||||
|
||||
! Check if the user has specified to write state points
|
||||
if (associated(write_state_point_)) then
|
||||
|
|
|
|||
|
|
@ -233,23 +233,12 @@ contains
|
|||
! can be used as a starting source in a new simulation
|
||||
!===============================================================================
|
||||
|
||||
subroutine write_source_binary(path)
|
||||
|
||||
character(*), optional :: path
|
||||
subroutine write_source_binary()
|
||||
|
||||
#ifdef MPI
|
||||
integer :: fh ! file handle
|
||||
integer(MPI_OFFSET_KIND) :: offset ! offset in memory (0=beginning of file)
|
||||
#endif
|
||||
|
||||
! Determine path to binary source file to write
|
||||
if (present(path)) then
|
||||
path_source = path
|
||||
else
|
||||
path_source = 'source.binary'
|
||||
end if
|
||||
|
||||
#ifdef MPI
|
||||
! ==========================================================================
|
||||
! PARALLEL I/O USING MPI-2 ROUTINES
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ module state_point
|
|||
use global
|
||||
use math, only: t_percentile
|
||||
use output, only: write_message, print_batch_keff
|
||||
use source, only: write_source_binary
|
||||
use string, only: to_str
|
||||
use tally_header, only: TallyObject
|
||||
|
||||
|
|
@ -86,25 +87,36 @@ contains
|
|||
! SOURCE BANK
|
||||
|
||||
if (run_mode == MODE_CRITICALITY) then
|
||||
! Get current offset for master
|
||||
if (master) call MPI_FILE_GET_POSITION(fh, offset, mpi_err)
|
||||
if (source_separate) then
|
||||
! If the user has specified that the source sites should be written in
|
||||
! a separate file, we make a call to the appropriate subroutine to
|
||||
! write it separately
|
||||
|
||||
! Determine offset on master process and broadcast to all processors
|
||||
call MPI_SIZEOF(offset, size_offset_kind, mpi_err)
|
||||
select case (size_offset_kind)
|
||||
case (4)
|
||||
call MPI_BCAST(offset, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, mpi_err)
|
||||
case (8)
|
||||
call MPI_BCAST(offset, 1, MPI_INTEGER8, 0, MPI_COMM_WORLD, mpi_err)
|
||||
end select
|
||||
path_source = "source." // trim(to_str(current_batch)) // ".binary"
|
||||
call write_source_binary()
|
||||
else
|
||||
! Otherwise, write the source sites in the state point file
|
||||
|
||||
! Set proper offset for source data on this processor
|
||||
call MPI_TYPE_SIZE(MPI_BANK, size_bank, mpi_err)
|
||||
offset = offset + size_bank*maxwork*rank
|
||||
! Get current offset for master
|
||||
if (master) call MPI_FILE_GET_POSITION(fh, offset, mpi_err)
|
||||
|
||||
! Write all source sites
|
||||
call MPI_FILE_WRITE_AT(fh, offset, source_bank(1), work, MPI_BANK, &
|
||||
MPI_STATUS_IGNORE, mpi_err)
|
||||
! Determine offset on master process and broadcast to all processors
|
||||
call MPI_SIZEOF(offset, size_offset_kind, mpi_err)
|
||||
select case (size_offset_kind)
|
||||
case (4)
|
||||
call MPI_BCAST(offset, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, mpi_err)
|
||||
case (8)
|
||||
call MPI_BCAST(offset, 1, MPI_INTEGER8, 0, MPI_COMM_WORLD, mpi_err)
|
||||
end select
|
||||
|
||||
! Set proper offset for source data on this processor
|
||||
call MPI_TYPE_SIZE(MPI_BANK, size_bank, mpi_err)
|
||||
offset = offset + size_bank*maxwork*rank
|
||||
|
||||
! Write all source sites
|
||||
call MPI_FILE_WRITE_AT(fh, offset, source_bank(1), work, MPI_BANK, &
|
||||
MPI_STATUS_IGNORE, mpi_err)
|
||||
end if
|
||||
end if
|
||||
|
||||
! Close binary source file
|
||||
|
|
@ -236,7 +248,18 @@ contains
|
|||
|
||||
! Write out source bank
|
||||
if (run_mode == MODE_CRITICALITY) then
|
||||
write(UNIT_STATE) source_bank
|
||||
if (source_separate) then
|
||||
! If the user has specified that the source sites should be written in
|
||||
! a separate file, we make a call to the appropriate subroutine to
|
||||
! write it separately
|
||||
|
||||
path_source = "source." // trim(to_str(current_batch)) // ".binary"
|
||||
call write_source_binary()
|
||||
else
|
||||
! Otherwise, write the source sites in the state point file
|
||||
|
||||
write(UNIT_STATE) source_bank
|
||||
end if
|
||||
end if
|
||||
|
||||
! Close binary state point file
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@
|
|||
<variable name="ptables_" tag="ptables" type="word" length="3" />
|
||||
<variable name="seed_" tag="seed" type="integer" />
|
||||
<variable name="source_" tag="source" type="source_xml" />
|
||||
<variable name="source_separate_" tag="source_separate" type="word" length="3" />
|
||||
<variable name="survival_" tag="survival_biasing" type="word" length="3" />
|
||||
<variable name="verbosity_" tag="verbosity" type="integer" />
|
||||
<variable name="trace_" tag="trace" type="integer-array" />
|
||||
<variable name="uniform_fs_" tag="uniform_fs" type="mesh_xml" dimension="1" />
|
||||
<variable name="write_source_" tag="write_source" type="word" length="3" />
|
||||
<variable name="write_state_point_" tag="write_state_point" type="integer-array" />
|
||||
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue