Commit e94b1594 authored by Roy Fabrice's avatar Roy Fabrice
Browse files

wip: intruction of some of amr2cell_hdf5 modifs

parent 9df51be6
......@@ -52,10 +52,11 @@ module mpi_process_m
contains
procedure :: Init => Init_mpi_process
procedure :: Print => Print_mpi_process
procedure :: Set_grid
end type mpi_process_t
contains
!----------------------------------------------------------------------------------------------------------------------------------
!> Initialize process
subroutine Init_mpi_process(process)
......@@ -70,6 +71,7 @@ contains
end subroutine Init_mpi_process
!----------------------------------------------------------------------------------------------------------------------------------
!> Print process
subroutine Print_mpi_process(process)
......@@ -81,4 +83,111 @@ contains
end subroutine Print_mpi_process
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Set_grid(this, cube_to_proc, param, proc_to_cube)
class(mpi_process_t), intent(inout) :: this
integer(kind=4), intent(in), dimension(:) :: cube_to_proc
type(type_parameter_pfof_snap), intent(in) :: param
integer(kind=4), intent(in), dimension(:) :: proc_to_cube
integer(kind=IDKIND) :: my_cube_id, dist_cube_id
integer(kind=4), dimension(3) :: my_cube_coords
integer(kind=4), dimension(3) :: dist_coords
integer(kind=4) :: direction
integer(kind=4) :: mpierr
my_cube_id = proc_to_cube(procid+1)
call id_to_coord(my_cube_id, my_cube_coords, dims)
! we are looking for the neighbours with respect to the cube coordinates
do direction = 1, 3
dist_coords = my_cube_coords
dist_coords(direction) = mod(my_cube_coords(direction)-1+dims(direction),dims(direction))
call coord_to_id(dist_coords, dist_cube_id, dims)
info_proc%global_comm%neighbours(direction*2-1) = cube_to_proc(dist_cube_id)
dist_coords(direction) = mod(my_cube_coords(direction)+1, dims(direction))
call coord_to_id(dist_coords, dist_cube_id, dims)
info_proc%global_comm%neighbours(direction*2) = cube_to_proc(dist_cube_id)
end do
#ifdef debug
print *,'neighbours with respect to the data cubes coordinates:',procid,&
' ; ', info_proc%global_comm%neighbours
#endif
info_proc%global_comm%name = mpi_comm_world
info_proc%global_comm%dims = dims
info_proc%global_comm%pid = procid
info_proc%global_comm%size = procnb
info_proc%global_comm%periods = periods
info_proc%global_comm%color = 0
info_proc%global_comm%coords = my_cube_coords
if(param%gatherwrite_factor > 1) then
#ifdef DEBUG
if(procid==0) then
print *, '*** creating specific communicator for gathered cube output ***'
end if
#endif
commcolorwrite = my_cube_coords(1)/param%gatherwrite_factor + &
(my_cube_coords(2)/param%gatherwrite_factor) * (dims(1)/param%gatherwrite_factor) &
+ (my_cube_coords(3)/param%gatherwrite_factor) * (dims(1)/param%gatherwrite_factor)*&
(dims(1)/param%gatherwrite_factor)
call mpi_comm_split(MPI_COMM_WORLD, commcolorwrite, procid, mpisubcubewrite, mpierr)
call mpi_comm_rank(mpisubcubewrite, scprocidwrite, mpierr)
call mpi_comm_size(mpisubcubewrite, scprocnbwrite, mpierr)
info_proc%write_comm%name = mpisubcubewrite
info_proc%write_comm%dims = 0
info_proc%write_comm%pid = scprocidwrite
info_proc%write_comm%size = scprocnbwrite
info_proc%write_comm%periods = .false.
info_proc%write_comm%color = commcolorwrite
info_proc%write_comm%coords = 0
info_proc%write_comm%neighbours = 0
else
info_proc%write_comm%name = -1
info_proc%write_comm%dims = -1
info_proc%write_comm%pid = -1
info_proc%write_comm%size = -1
info_proc%write_comm%periods = .false.
info_proc%write_comm%color = -1
info_proc%write_comm%coords = -1
info_proc%write_comm%neighbours = -1
end if
if(param%gatherread_factor > 1) then
#ifdef DEBUG
if(procid==0) then
print *, '*** creating specific communicator for gathered cube input ***'
end if
#endif
commcolorread = my_cube_coords(1)/param%gatherread_factor + &
(my_cube_coords(2)/param%gatherread_factor) * (dims(1)/param%gatherread_factor) &
+ (my_cube_coords(3)/param%gatherread_factor) * (dims(1)/param%gatherread_factor)* &
(dims(1)/param%gatherread_factor)
call mpi_comm_split(MPI_COMM_WORLD, commcolorread, procid, mpisubcuberead, mpierr)
call mpi_comm_rank(mpisubcuberead, scprocidread, mpierr)
call mpi_comm_size(mpisubcuberead, scprocnbread, mpierr)
info_proc%read_comm%name = mpisubcuberead
info_proc%read_comm%dims = 0
info_proc%read_comm%pid = scprocidread
info_proc%read_comm%size = scprocnbread
info_proc%read_comm%periods = .false.
info_proc%read_comm%color = commcolorread
info_proc%read_comm%coords = 0
info_proc%read_comm%neighbours = 0
else
info_proc%read_comm%name = -1
info_proc%read_comm%dims = -1
info_proc%read_comm%pid = -1
info_proc%read_comm%size = -1
info_proc%read_comm%periods = .false.
info_proc%read_comm%color = -1
info_proc%read_comm%coords = -1
info_proc%read_comm%neighbours = -1
end if
end subroutine Set_grid
end module mpi_process_m
......@@ -7,8 +7,12 @@ OBJDIR=../../obj/
MODDIR=../../mod/
VPATH= $(COMMONDIR):.
SRC = modconstant.f90 \
mpi_process_m.f90 \
SRC = error_handling_m.f90 \
char_utils_m.f90 \
mpi_process_m.f90 \
timer_m.f90 \
shared_variables_m.f90 \
constants_m.f90 \
type_info_ramses_mod.f90\
modmpicommons.f90 \
modindex.f90 \
......
......@@ -29,7 +29,8 @@ program Friend
use fortran_hdf5_manage_interface_m, only : hdf5_finalize, hdf5_init
use modio, only : Print_screen_parameters, Init_parameters, Read_ramses, The_end, Title, Write_timings
use modmpicom, only : Setcommunicators
use modmpicommons, only : Emergencystop, procid, procnb
! use modmpicommons, only : Emergencystop, procid, procnb
use shared_variables_m
use modreadcube, only : Readcube, Selectreadcubetype
use modtiming, only : tfof, tfofinit, tfofloc, timeint, tobs, tout, traccord, tread, treadfile
use modvarcommons, only : nres
......@@ -37,7 +38,7 @@ program Friend
use modwritedmcube, only : Selectwritedmcube, Writedmcube
use modwritestarcube, only : Selectwritestarcube, Writestarcube
use mpi
use select_dm_mod, only : Select_dm_particles
use select_dm_m, only : Select_dm_particles
implicit none
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment