Skip to content
Snippets Groups Projects
Commit b6c9fd75 authored by Antoine Cyril David Hoffmann's avatar Antoine Cyril David Hoffmann
Browse files

2D parallel distribution

parent f85f7606
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,10 @@ MODULE grid ...@@ -35,7 +35,10 @@ MODULE grid
REAL(dp), PUBLIC, PROTECTED :: deltar, deltaz REAL(dp), PUBLIC, PROTECTED :: deltar, deltaz
INTEGER, PUBLIC, PROTECTED :: irs, ire, izs, ize INTEGER, PUBLIC, PROTECTED :: irs, ire, izs, ize
INTEGER, PUBLIC :: ir,iz ! counters INTEGER, PUBLIC :: ir,iz ! counters
integer(C_INTPTR_T), PUBLIC :: local_nkr, local_nkr_offset, local_nz, local_nz_offset integer(C_INTPTR_T), PUBLIC :: local_nkr, local_nz
integer(C_INTPTR_T), PUBLIC :: local_nkr_offset, local_nz_offset
INTEGER, PUBLIC :: local_np_e, local_np_i
integer(C_INTPTR_T), PUBLIC :: local_np_e_offset, local_np_i_offset
! Grids containing position in fourier space ! Grids containing position in fourier space
REAL(dp), DIMENSION(:), ALLOCATABLE, PUBLIC :: krarray REAL(dp), DIMENSION(:), ALLOCATABLE, PUBLIC :: krarray
...@@ -69,12 +72,12 @@ CONTAINS ...@@ -69,12 +72,12 @@ CONTAINS
SUBROUTINE init_1Dgrid_distr SUBROUTINE init_1Dgrid_distr
write(*,*) Nr ! write(*,*) Nr
local_nkr = (Nr/2+1)/num_procs local_nkr = (Nr/2+1)/num_procs_kr
write(*,*) local_nkr ! write(*,*) local_nkr
local_nkr_offset = my_id*local_nkr local_nkr_offset = rank_r*local_nkr
if (my_id .EQ. num_procs-1) local_nkr = (Nr/2+1)-local_nkr_offset if (rank_r .EQ. num_procs_kr-1) local_nkr = (Nr/2+1)-local_nkr_offset
END SUBROUTINE init_1Dgrid_distr END SUBROUTINE init_1Dgrid_distr
...@@ -83,13 +86,14 @@ CONTAINS ...@@ -83,13 +86,14 @@ CONTAINS
IMPLICIT NONE IMPLICIT NONE
INTEGER :: ip INTEGER :: ip
ips_e = 1; ipe_e = pmaxe + 1 CALL decomp1D(pmaxe+1, num_procs_p, rank_p, ips_e, ipe_e)
ips_i = 1; ipe_i = pmaxi + 1 CALL decomp1D(pmaxi+1, num_procs_p, rank_p, ips_i, ipe_i)
ALLOCATE(parray_e(ips_e:ipe_e)) ALLOCATE(parray_e(ips_e:ipe_e))
ALLOCATE(parray_i(ips_i:ipe_i)) ALLOCATE(parray_i(ips_i:ipe_i))
DO ip = ips_e,ipe_e; parray_e(ip) = (ip-1); END DO DO ip = ips_e,ipe_e; parray_e(ip) = (ip-1); END DO
DO ip = ips_i,ipe_i; parray_i(ip) = (ip-1); END DO DO ip = ips_i,ipe_i; parray_i(ip) = (ip-1); END DO
! Ghosts boundaries ! Ghosts boundaries
ipsg_e = ips_e - 2; ipeg_e = ipe_e + 2; ipsg_e = ips_e - 2; ipeg_e = ipe_e + 2;
ipsg_i = ips_i - 2; ipeg_i = ipe_i + 2; ipsg_i = ips_i - 2; ipeg_i = ipe_i + 2;
...@@ -119,7 +123,7 @@ CONTAINS ...@@ -119,7 +123,7 @@ CONTAINS
! Precomputations ! Precomputations
jmaxe_dp = real(jmaxe,dp) jmaxe_dp = real(jmaxe,dp)
jmaxi_dp = real(jmaxi,dp) jmaxi_dp = real(jmaxi,dp)
END SUBROUTINE set_jgrid END SUBROUTINE set_jgrid
...@@ -245,4 +249,18 @@ CONTAINS ...@@ -245,4 +249,18 @@ CONTAINS
bari = (jmaxi+1)*p_ + j_ + 1 bari = (jmaxi+1)*p_ + j_ + 1
END FUNCTION END FUNCTION
SUBROUTINE decomp1D( n, numprocs, myid, s, e )
INTEGER :: n, numprocs, myid, s, e
INTEGER :: nlocal
INTEGER :: deficit
nlocal = n / numprocs
s = myid * nlocal + 1
deficit = MOD(n,numprocs)
s = s + MIN(myid,deficit)
IF (myid .LT. deficit) nlocal = nlocal + 1
e = s + nlocal - 1
IF (e .GT. n .OR. myid .EQ. numprocs-1) e = n
END SUBROUTINE decomp1D
END MODULE grid END MODULE grid
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment