Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
datadist.f90
Go to the documentation of this file.
1! Copyright (c) 2019-2021, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
35 use mpi_f08, only : mpi_comm
36 implicit none
37 private
38
39 type dist_t
40 type(mpi_comm) :: comm
41 integer :: pe_rank
42 integer :: pe_size
43 integer :: l
44 integer :: r
45 integer :: m
46 integer :: ip
47 end type dist_t
48
50 type, extends(dist_t) :: linear_dist_t
51 contains
52 procedure :: num_local => linear_dist_ip
53 procedure :: num_global => linear_dist_m
54 procedure :: start_idx => linear_dist_start
55 procedure :: end_idx => linear_dist_end
56 end type linear_dist_t
57
58 interface linear_dist_t
59 module procedure linear_dist_init
60 end interface linear_dist_t
61
62 public :: linear_dist_t
63
64contains
65
66 function linear_dist_init(n, rank, size, comm) result(this)
67 integer, intent(in) :: n
68 integer :: rank
69 integer :: size
70 type(mpi_comm) :: comm
71 type(linear_dist_t), target :: this
72
73 this%M = n
74 this%comm = comm
75 this%pe_rank = rank
76 this%pe_size = size
77
78 this%L = floor(dble(this%M) / dble(this%pe_size))
79 this%R = modulo(this%M, this%pe_size)
80 this%Ip = floor((dble(this%M) + dble(this%pe_size) - &
81 dble(this%pe_rank) - 1d0) / dble(this%pe_size))
82 end function linear_dist_init
83
84 pure function linear_dist_ip(this) result(n)
85 class(linear_dist_t), intent(in) :: this
86 integer :: n
87 n = this%Ip
88 end function linear_dist_ip
89
90 pure function linear_dist_m(this) result(M)
91 class(linear_dist_t), intent(in) :: this
92 integer :: m
93 m = this%M
94 end function linear_dist_m
95
96 pure function linear_dist_start(this) result(start)
97 class(linear_dist_t), intent(in) :: this
98 integer :: start
99 start = this%pe_rank * this%L + min(this%pe_rank, this%R)
100 end function linear_dist_start
101
102 function linear_dist_end(this) result(end)
103 class(linear_dist_t), intent(inout) :: this
104 integer :: end
105 end = linear_dist_start(this) + (this%Ip - 1)
106 end function linear_dist_end
107end module datadist
Definition comm.F90:1
Defines practical data distributions.
Definition datadist.f90:34
type(linear_dist_t) function, target linear_dist_init(n, rank, size, comm)
Definition datadist.f90:67
pure integer function linear_dist_ip(this)
Definition datadist.f90:85
pure integer function linear_dist_m(this)
Definition datadist.f90:91
pure integer function linear_dist_start(this)
Definition datadist.f90:97
integer function linear_dist_end(this)
Definition datadist.f90:103
Load-balanced linear distribution .
Definition datadist.f90:50