Line data Source code
1 :
2 826962528 : function map_global_array_index_to_local_index(iGLobal, jGlobal, iLocal, jLocal , nblk, np_rows, np_cols, my_prow, my_pcol) &
3 : result(possible)
4 : use iso_c_binding, only : c_int
5 : implicit none
6 :
7 : integer(kind=c_int) :: pi, pj, li, lj, xi, xj
8 : integer(kind=c_int), intent(in) :: iGlobal, jGlobal, nblk, np_rows, np_cols, my_prow, my_pcol
9 : integer(kind=c_int), intent(out) :: iLocal, jLocal
10 : logical :: possible
11 :
12 826962528 : possible = .true.
13 826962528 : iLocal = 0
14 826962528 : jLocal = 0
15 :
16 826962528 : pi = prow(iGlobal, nblk, np_rows)
17 :
18 826962528 : if (my_prow .ne. pi) then
19 282863776 : possible = .false.
20 282863776 : return
21 : endif
22 :
23 544098752 : pj = pcol(jGlobal, nblk, np_cols)
24 :
25 544098752 : if (my_pcol .ne. pj) then
26 0 : possible = .false.
27 0 : return
28 : endif
29 544098752 : li = (iGlobal-1)/(np_rows*nblk) ! block number for rows
30 544098752 : lj = (jGlobal-1)/(np_cols*nblk) ! block number for columns
31 :
32 544098752 : xi = mod( (iGlobal-1),nblk)+1 ! offset in block li
33 544098752 : xj = mod( (jGlobal-1),nblk)+1 ! offset in block lj
34 :
35 544098752 : iLocal = li * nblk + xi
36 544098752 : jLocal = lj * nblk + xj
37 :
38 544098752 : end function
39 :
|