Line data Source code
1 : module m_glob_tofrom_loc
2 : use m_types_mpi
3 : use m_juDFT
4 : contains
5 1752000 : subroutine glob_to_loc(fmpi, glob_idx, pe, loc_idx)
6 : implicit none
7 : type(t_mpi), intent(in) :: fmpi
8 : integer, intent(in) :: glob_idx
9 : integer, intent(inout) :: pe, loc_idx
10 :
11 1752000 : pe = mod((glob_idx-1), fmpi%n_size)
12 1752000 : loc_idx = ((glob_idx-1)/fmpi%n_size) +1
13 1752000 : end subroutine glob_to_loc
14 :
15 0 : subroutine glob_from_loc(fmpi, idx, g)
16 : implicit none
17 : type(t_mpi), intent(in) :: fmpi
18 : integer, intent(in) :: idx
19 : integer, intent(inout) :: g
20 :
21 0 : g = fmpi%n_size * (idx-1) + fmpi%n_rank + 1
22 0 : end subroutine glob_from_loc
23 :
24 5892 : subroutine range_to_glob_to_loc(fmpi, glob_range, loc_range)
25 : implicit none
26 : type(t_mpi), intent(in) :: fmpi
27 : integer, intent(in) :: glob_range
28 : integer, intent(inout) :: loc_range
29 :
30 : integer :: idx, pe
31 :
32 5892 : idx = glob_range + 1
33 5892 : pe = -1
34 14730 : do while(pe /= fmpi%n_rank)
35 8838 : idx = idx -1
36 14730 : call glob_to_loc(fmpi, idx, pe, loc_range)
37 : enddo
38 5892 : end subroutine range_to_glob_to_loc
39 :
40 5964 : subroutine range_from_glob_to_loc(fmpi, glob_from, loc_from)
41 : implicit none
42 :
43 : type(t_mpi), intent(in) :: fmpi
44 : integer, intent(in) :: glob_from
45 : integer, intent(inout) :: loc_from
46 :
47 : integer :: idx, pe
48 :
49 5964 : idx = glob_from -1
50 5964 : pe = -1
51 14910 : do while(pe /= fmpi%n_rank)
52 8946 : idx = idx + 1
53 14910 : call glob_to_loc(fmpi, idx, pe, loc_from)
54 : enddo
55 5964 : end subroutine range_from_glob_to_loc
56 : end module m_glob_tofrom_loc
|