Skip to content
Snippets Groups Projects
Commit eaea43bc authored by Roy Fabrice's avatar Roy Fabrice
Browse files

associate_cells_to_cube in dev

parent b6ca0636
Branches
Tags
No related merge requests found
......@@ -47,6 +47,7 @@ module cubes_array_m
type(cube_t), allocatable, dimension(:) :: elts
contains
procedure :: Assign => Assign_cubes_to_process
procedure :: Associate => Associate_cells_to_cubes
procedure :: Init => Init_cubes_array
end type cubes_array_t
......@@ -95,74 +96,17 @@ contains
call mpi_allgather(cells_per_cube , this%ncubes, MPI_INTEGER, ncells_cube_proc, this%ncubes, MPI_INTEGER,mpi_process%comm%name, mpierr)
if(mpi_process%rank==0) then
do iproc = 1, mpi_process%comm%size
write(OUTPUT_UNIT,*) 'CELLS_PROC_CUBE:', ncells_cube_proc(:,iproc)
end do
end if
ncube_left = this%ncubes
do while (ncube_left > 0)
do iproc = 1, mpi_process%comm%size
icube = maxloc(ncells_cube_proc(:,iproc),dim=1)
cube_to_process(icube) = iproc-1
this%elts(icube)%process_rank = iproc-1
ncells_cube_proc(icube,:) = 0
ncube_left = ncube_left - 1
if(mpi_process%rank==0) write(OUTPUT_UNIT,*) 'CUBEID=',icube, iproc
end do
end do
! maxs_ranks(1,:) = cells_per_cube(1:this%ncubes)
! maxs_ranks(2,:) = mpi_process%rank
! call mpi_allreduce(MPI_IN_PLACE, maxs_ranks, this%ncubes, MPI_2INTEGER, MPI_MAXLOC, mpi_process%comm%name, mpierr)
! do icube = 1, this%ncubes
! this%elts(icube)%process_rank = maxs_ranks(2,icube)
! cube_to_process(icube) = maxs_ranks(2,icube)
! end do
! if(mpi_process%rank==4) write(OUTPUT_UNIT,*) 'CUBE ',cells_per_cube(1:this%ncubes), ' CUBE'
! if(mpi_process%rank==5) write(OUTPUT_UNIT,*) 'CUBE ',cells_per_cube(1:this%ncubes), ' CUBE'
! ! check if each process will write at least one cube
! allocate(ncube_per_process(mpi_process%comm%size), stat=alloc_stat, errmsg=error_message)
! if(alloc_stat /= 0) then
! call Allocate_error('ncube_per_process','Assign_cubes_to_process', error_message, alloc_stat, mpi_process%rank)
! end if
! ncube_per_process = 0
! do icube = 1, this%ncubes
! ncube_per_process(cube_to_process(icube)+1) = ncube_per_process(cube_to_process(icube)+1) + 1
! end do
! ! if one of the processes has 0 cube to write
! if(minval(ncube_per_process) == 0) then
! nb_receiver = count(ncube_per_process==0)
! ! at least one process has no cube to write
! nb_sender = count(ncube_per_process==maxval(ncube_per_process))
! allocate(sender_id(nb_sender), stat=alloc_stat, errmsg=error_message)
! if(alloc_stat /= 0) then
! call Allocate_error('sender_id','Assign_cubes_to_process', error_message, alloc_stat, mpi_process%rank)
! end if
! allocate(receiver_id(nb_receiver), stat=alloc_stat, errmsg=error_message)
! if(alloc_stat /= 0) then
! call Allocate_error('receiver_id','Assign_cubes_to_process', error_message, alloc_stat, mpi_process%rank)
! end if
! receiver_id = minloc(ncube_per_process)
! sender_id = maxloc(ncube_per_process)
! ! check if this process has no cube
! if(ncube_per_process(mpi_process%rank+1)==0) then
! my_cube = maxloc(cells_per_cube(1:this%ncubes),dim=1)
! if
! end if
! write(OUTPUT_UNIT,*) 'ZERO : ',nb_receiver, nb_sender, receiver_id, sender_id
! end if
! write(OUTPUT_UNIT,*) 'maxs & ranks'
! do icube=1, this%ncubes
! write(OUTPUT_UNIT,*) maxs_ranks(:,icube)
! end do
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Assign_cubes_to_process ends on process', mpi_process%rank
......@@ -170,6 +114,31 @@ contains
end subroutine Assign_cubes_to_process
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Associate_cells_to_cubes(this, cells_array, global_cells_per_cube)
use cells_array_m, only : cells_array_t
class(cubes_array_t),intent(inout) :: this
type(cells_array_t),intent(inout) :: cells_array
integer, dimension(*), intent(in) :: global_cells_per_cube
integer :: icell
integer :: icube
! allocate cells_array for each cube
do icube = 1, this%ncubes
end do
end subroutine Associate_cells_to_cubes
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Init_cubes_array(this, amr2cube_parameters, ramses_info)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment