aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/quadratures.f9023
1 files changed, 20 insertions, 3 deletions
diff --git a/src/quadratures.f90 b/src/quadratures.f90
index c2be860..35b28c4 100644
--- a/src/quadratures.f90
+++ b/src/quadratures.f90
@@ -46,10 +46,11 @@ CONTAINS
procedure(funint) :: fun
procedure(quadrature) :: quad
- real(kind=8) :: val, subinterval_width, qbeg, qend
+ real(kind=8) :: val, subinterval_width, qbeg, qend, partsums(48)
+ logical :: partsums_mask(48) = .true.
real(kind=8), allocatable :: partval[:]
- integer(kind=8) :: min_i, max_i, i, subintervals_per_thread
+ integer(kind=8) :: min_i, max_i, i, j, subintervals_per_thread
integer(kind=4) :: im
allocate(partval[*])
@@ -68,9 +69,25 @@ CONTAINS
DO i = min_i, max_i
qend = ibeg + i * subinterval_width
qbeg = ibeg + (i - 1) * subinterval_width
- partval = partval + quad(qbeg, qend, fun)
+ val = quad(qbeg, qend, fun)
+
+ DO j = 1, 48
+ IF (partsums_mask(j)) THEN
+ partsums_mask(j) = .false.
+ partsums(j) = val
+ EXIT
+ END IF
+
+ val = val + partsums(j)
+ partsums_mask(j) = .true.
+ END DO
END DO
+ partval = 0
+ DO j = 1, 48
+ IF (.not. partsums_mask(j)) partval = partval + partsums(j)
+ END DO
+
IF (this_image() == 1 .and. num_images() > 1) THEN
sync images([(im, im = 2, num_images())])
partval = partval + sum([(partval[im], im = 2, num_images())])