mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
added user option to set number of sub-processes for CMFD calculation
This commit is contained in:
parent
8842de3629
commit
b03ec60963
3 changed files with 21 additions and 62 deletions
|
|
@ -31,19 +31,19 @@ contains
|
|||
|
||||
integer :: ierr ! petsc error code
|
||||
|
||||
! set how many processors to run cmfd on
|
||||
n_procs_cmfd = min(n_procs_cmfd,n_procs)
|
||||
|
||||
! initialize mpi communicator
|
||||
call petsc_init_mpi()
|
||||
if(current_batch == n_inactive + 1) call petsc_init_mpi()
|
||||
|
||||
! filter procs
|
||||
if (rank < 1) then
|
||||
if (rank < n_procs_cmfd) then
|
||||
|
||||
! initialize slepc/petsc (communicates to world)
|
||||
if(current_batch == n_inactive + 1) call SlepcInitialize &
|
||||
& (PETSC_NULL_CHARACTER,ierr)
|
||||
|
||||
! set global variable for number of procs in cmfd calc
|
||||
call MPI_COMM_SIZE(PETSC_COMM_WORLD,n_procs_cmfd,ierr)
|
||||
|
||||
! only run if master process
|
||||
if (master) then
|
||||
|
||||
|
|
@ -140,77 +140,31 @@ contains
|
|||
!===============================================================================
|
||||
! PETSC_INIT_MPI
|
||||
!===============================================================================
|
||||
!
|
||||
! subroutine petsc_init_mpi()
|
||||
!
|
||||
! integer :: new_comm ! new communicator
|
||||
! integer :: orig_group ! original MPI group for MPI_COMM_WORLD
|
||||
! integer :: new_group ! new MPI group subset of orig_group
|
||||
! integer,allocatable :: ranks(:) ! ranks to include for petsc
|
||||
! integer :: k ! iteration counter
|
||||
!
|
||||
! ! set ranks 0-6 or min
|
||||
! if (n_procs >= 6) then
|
||||
! if (.not. allocated(ranks)) allocate(ranks(0:5))
|
||||
! ranks = (/0,1,2,3,4,5/)
|
||||
! else
|
||||
! if (.not. allocated(ranks)) allocate(ranks(0:n_procs-1))
|
||||
! ranks = (/(k,k=0,n_procs-1)/)
|
||||
! end if
|
||||
!
|
||||
! ! get the original mpi group
|
||||
! call MPI_COMM_GROUP(MPI_COMM_WORLD,orig_group,mpi_err)
|
||||
!
|
||||
! ! new group init
|
||||
! call MPI_GROUP_INCL(orig_group,size(ranks),ranks,new_group,mpi_err)
|
||||
!
|
||||
! ! create new communicator
|
||||
! call MPI_COMM_CREATE(MPI_COMM_WORLD,new_group,new_comm,mpi_err)
|
||||
!
|
||||
! ! deallocate ranks
|
||||
! if (allocated(ranks)) deallocate(ranks)
|
||||
!
|
||||
! ! set PETSC_COMM_WORLD to this subset
|
||||
! PETSC_COMM_WORLD = new_comm
|
||||
!
|
||||
! end subroutine petsc_init_mpi
|
||||
|
||||
!===============================================================================
|
||||
! PETSC_INIT_MPI
|
||||
!===============================================================================
|
||||
|
||||
|
||||
subroutine petsc_init_mpi()
|
||||
|
||||
|
||||
integer :: new_comm ! new communicator
|
||||
integer :: orig_group ! original MPI group for MPI_COMM_WORLD
|
||||
integer :: new_group ! new MPI group subset of orig_group
|
||||
integer,allocatable :: ranks(:) ! ranks to include for petsc
|
||||
integer :: k ! iteration counter
|
||||
integer :: nprocs
|
||||
|
||||
nprocs = 1
|
||||
|
||||
! set ranks 0-6 or min
|
||||
if (nprocs >= 6) then
|
||||
if (.not. allocated(ranks)) allocate(ranks(0:5))
|
||||
ranks = (/0,1,2,3,4,5/)
|
||||
else
|
||||
if (.not. allocated(ranks)) allocate(ranks(0:nprocs-1))
|
||||
ranks = (/(k,k=0,nprocs-1)/)
|
||||
end if
|
||||
|
||||
|
||||
! set ranks
|
||||
if (.not. allocated(ranks)) allocate(ranks(0:n_procs_cmfd - 1))
|
||||
ranks = (/(k,k=0,n_procs_cmfd - 1)/)
|
||||
|
||||
! get the original mpi group
|
||||
call MPI_COMM_GROUP(MPI_COMM_WORLD,orig_group,mpi_err)
|
||||
|
||||
|
||||
! new group init
|
||||
call MPI_GROUP_INCL(orig_group,size(ranks),ranks,new_group,mpi_err)
|
||||
|
||||
|
||||
! create new communicator
|
||||
call MPI_COMM_CREATE(MPI_COMM_WORLD,new_group,new_comm,mpi_err)
|
||||
|
||||
|
||||
! deallocate ranks
|
||||
if (allocated(ranks)) deallocate(ranks)
|
||||
|
||||
|
||||
! set PETSC_COMM_WORLD to this subset
|
||||
PETSC_COMM_WORLD = new_comm
|
||||
|
||||
|
|
|
|||
|
|
@ -93,6 +93,10 @@ contains
|
|||
! create tally objects
|
||||
call create_cmfd_tally()
|
||||
|
||||
! set number of CMFD processors and report to user
|
||||
n_procs_cmfd = n_cmfd_procs_
|
||||
if (master) write(*,*) "CMFD Running on",n_procs_cmfd," processors."
|
||||
|
||||
end subroutine read_cmfd_xml
|
||||
|
||||
!===============================================================================
|
||||
|
|
|
|||
|
|
@ -15,5 +15,6 @@
|
|||
<variable name="mesh_" tag="mesh" type="mesh_xml" />
|
||||
<variable name="norm_" tag="norm" type="double" />
|
||||
<variable name="feedback_" tag="feedback" type="logical" default=".false."/>
|
||||
<variable name="n_cmfd_procs_" tag = "n_procs" type="integer" default="1" />
|
||||
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue