3 #include "sll_memory.h"
4 #include "sll_working_precision.h"
22 sll_real64,
dimension(:),
intent(in) ::
data
23 sll_int32,
intent(in) :: npts
24 sll_real64,
intent(in) :: delta
25 sll_real64,
dimension(:),
intent(in),
optional :: params
48 integration_func_params)
50 sll_real64,
dimension(:, :, :, :),
intent(in) :: data_4d
51 sll_real64,
dimension(:, :, :),
intent(out) :: data_3d
52 sll_int32,
intent(in) :: npts1
53 sll_int32,
intent(in) :: npts2
54 sll_int32,
intent(in) :: npts3
55 sll_int32,
intent(in) :: npts4
56 sll_real64,
intent(in) :: delta4
58 sll_real64,
dimension(:),
optional :: integration_func_params
59 sll_int32 :: i1, i2, i3, i4
62 if (npts1 >
size(data_4d, 1))
then
63 print *,
'#Problem for size1 in sll_s_compute_reduction_4d_to_3d_direction4'
64 print *,
'#Npts=', (/npts1, npts2, npts3, npts4/)
65 print *,
'#size(data_4d)=', (/ &
72 if (npts2 >
size(data_4d, 2))
then
73 print *,
'#Problem for size2 in sll_s_compute_reduction_4d_to_3d_direction4'
76 if (npts3 >
size(data_4d, 3))
then
77 print *,
'#Problem for size3 in sll_s_compute_reduction_4d_to_3d_direction4'
80 if (npts4 >
size(data_4d, 4))
then
81 print *,
'#Problem for size3 in sll_s_compute_reduction_4d_to_3d_direction4'
84 if (.not. (
present(integration_func)))
then
88 tmp = 0.5_f64*(data_4d(i1, i2, i3, 1) &
89 + data_4d(i1, i2, i3, npts4))
91 tmp = tmp + data_4d(i1, i2, i3, i4)
93 data_3d(i1, i2, i3) = tmp*delta4
102 data_3d(i1, i2, i3) = integration_func( &
103 data_4d(i1, i2, i3, :), &
106 integration_func_params)
122 integration_func_params)
124 sll_real64,
dimension(:, :, :, :),
intent(in) :: data_4d
125 sll_real64,
dimension(:, :, :),
intent(inout) :: data_3d
126 sll_int32,
intent(in) :: npts1
127 sll_int32,
intent(in) :: npts2
128 sll_int32,
intent(in) :: npts3
129 sll_int32,
intent(in) :: npts4
130 sll_real64,
intent(in) :: delta4
132 sll_real64,
dimension(:),
optional :: integration_func_params
133 sll_int32 :: i1, i2, i3, i4
136 if (npts1 >
size(data_4d, 1))
then
137 print *,
'#Problem for size1 in sll_s_compute_reduction_4d_to_3d_direction4'
138 print *,
'#Npts=', (/npts1, npts2, npts3, npts4/)
139 print *,
'#size(data_4d)=', (/ &
146 if (npts2 >
size(data_4d, 2))
then
147 print *,
'#Problem for size2 in sll_s_compute_reduction_4d_to_3d_direction4'
150 if (npts3 >
size(data_4d, 3))
then
151 print *,
'#Problem for size3 in sll_s_compute_reduction_4d_to_3d_direction4'
154 if (npts4 >
size(data_4d, 4))
then
155 print *,
'#Problem for size3 in sll_s_compute_reduction_4d_to_3d_direction4'
158 if (.not. (
present(integration_func)))
then
162 tmp = 0.5_f64*(data_4d(i1, i2, i3, 1) &
163 + data_4d(i1, i2, i3, npts4))
165 tmp = tmp + data_4d(i1, i2, i3, i4)
167 data_3d(i1, i2, i3) = data_3d(i1, i2, i3) + tmp*delta4
176 data_3d(i1, i2, i3) = data_3d(i1, i2, i3) + integration_func( &
177 data_4d(i1, i2, i3, :), &
180 integration_func_params)
197 integration_func_params)
199 sll_real64,
dimension(:, :, :, :),
intent(in) :: data_4d
200 sll_real64,
dimension(:, :),
intent(out) :: data_2d
201 sll_int32,
intent(in) :: npts1
202 sll_int32,
intent(in) :: npts2
203 sll_int32,
intent(in) :: npts3
204 sll_int32,
intent(in) :: npts4
205 sll_real64,
intent(in) :: delta3
206 sll_real64,
intent(in) :: delta4
208 sll_real64,
dimension(:),
optional :: integration_func_params
209 sll_int32 :: i1, i2, i3, i4
212 if (npts1 >
size(data_4d, 1))
then
213 print *,
'#Problem for size1 in sll_s_compute_reduction_4d_to_2d_direction34'
214 print *,
'Npts1=', npts1,
'size(data_4d,1)',
size(data_4d, 1)
217 if (npts2 >
size(data_4d, 2))
then
218 print *,
'#Problem for size2 in sll_s_compute_reduction_4d_to_2d_direction34'
221 if (npts3 >
size(data_4d, 3))
then
222 print *,
'#Problem for size3 in sll_s_compute_reduction_4d_to_2d_direction34'
225 if (npts4 >
size(data_4d, 4))
then
226 print *,
'#Problem for size3 in sll_s_compute_reduction_4d_to_2d_direction34'
229 if (.not. (
present(integration_func)))
then
232 data_2d(i1, i2) = 0._f64
234 tmp = 0.5_f64*(data_4d(i1, i2, i3, 1) &
235 + data_4d(i1, i2, i3, npts4))
237 tmp = tmp + data_4d(i1, i2, i3, i4)
240 data_2d(i1, i2) = data_2d(i1, i2) + 0.5_f64*tmp
243 tmp = 0.5_f64*(data_4d(i1, i2, i3, 1) &
244 + data_4d(i1, i2, i3, npts4))
246 tmp = tmp + data_4d(i1, i2, i3, i4)
249 data_2d(i1, i2) = data_2d(i1, i2) + tmp
253 tmp = 0.5_f64*(data_4d(i1, i2, i3, 1) &
254 + data_4d(i1, i2, i3, npts4))
256 tmp = tmp + data_4d(i1, i2, i3, i4)
259 data_2d(i1, i2) = data_2d(i1, i2) + 0.5_f64*tmp
261 data_2d(i1, i2) = data_2d(i1, i2)*delta3
265 if (
present(integration_func_params))
then
266 print *,
'integration_func_params is present'
268 print *,
'#not implemented yet'
269 print *,
'#in sll_s_compute_reduction_4d_to_2d_direction34'
284 integration_func_params)
286 sll_real64,
dimension(:, :, :, :),
intent(in) :: data_4d
287 sll_real64,
dimension(:, :),
intent(out) :: data_2d
288 sll_int32,
intent(in) :: npts1
289 sll_int32,
intent(in) :: npts2
290 sll_int32,
intent(in) :: npts3
291 sll_int32,
intent(in) :: npts4
292 sll_real64,
intent(in) :: delta1
293 sll_real64,
intent(in) :: delta2
295 sll_real64,
dimension(:),
optional :: integration_func_params
296 sll_int32 :: i1, i2, i3, i4
299 if (npts1 >
size(data_4d, 1))
then
300 print *,
'#Problem for size1 in compute_reduction_4d_to_2d_direction12'
301 print *,
'Npts1=', npts1,
'size(data_4d,1)',
size(data_4d, 1)
304 if (npts2 >
size(data_4d, 2))
then
305 print *,
'#Problem for size2 in compute_reduction_4d_to_2d_direction12'
306 print *,
'Npts2=', npts2,
'size(data_4d,2)',
size(data_4d, 2)
309 if (npts3 >
size(data_4d, 3))
then
310 print *,
'#Problem for size3 in compute_reduction_4d_to_2d_direction12'
311 print *,
'Npts3=', npts3,
'size(data_4d,3)',
size(data_4d, 3)
314 if (npts4 >
size(data_4d, 4))
then
315 print *,
'#Problem for size3 in compute_reduction_4d_to_2d_direction12'
316 print *,
'Npts4=', npts4,
'size(data_4d,4)',
size(data_4d, 4)
319 if (.not. (
present(integration_func)))
then
322 data_2d(i3, i4) = 0._f64
324 tmp = 0.5_f64*(data_4d(i1, 1, i3, i4) &
325 + data_4d(i1, npts2, i3, i4))
327 tmp = tmp + data_4d(i1, i2, i3, i4)
330 data_2d(i3, i4) = data_2d(i3, i4) + 0.5_f64*tmp
333 tmp = 0.5_f64*(data_4d(i1, 1, i3, i4) &
334 + data_4d(i1, npts2, i3, i4))
336 tmp = tmp + data_4d(i1, i2, i3, i4)
339 data_2d(i3, i4) = data_2d(i3, i4) + tmp
343 tmp = 0.5_f64*(data_4d(i1, 1, i3, i4) &
344 + data_4d(i1, npts2, i3, i4))
346 tmp = tmp + data_4d(i1, i2, i3, i4)
349 data_2d(i3, i4) = data_2d(i3, i4) + 0.5_f64*tmp
351 data_2d(i3, i4) = data_2d(i3, i4)*delta1
355 if (
present(integration_func_params))
then
356 print *,
'integration_func_params is present'
358 print *,
'#not implemented yet'
359 print *,
'#in compute_reduction_4d_to_2d_direction12'
374 integration_func_params)
376 sll_real64,
dimension(:, :, :, :),
intent(in) :: data_4d
377 sll_real64,
dimension(:, :, :),
intent(out) :: data_diag_2d
378 sll_int32,
intent(in) :: npts1
379 sll_int32,
intent(in) :: npts2
380 sll_int32,
intent(in) :: npts3
381 sll_int32,
intent(in) :: npts4
382 sll_real64,
intent(in) :: delta1
383 sll_real64,
intent(in) :: delta2
385 sll_real64,
dimension(:),
optional :: integration_func_params
386 sll_int32 :: i1, i2, i3, i4
391 if (npts1 >
size(data_4d, 1))
then
392 print *,
'#Problem for size1 in compute_reduction_4d_to_2d_direction12'
393 print *,
'Npts1=', npts1,
'size(data_4d,1)',
size(data_4d, 1)
396 if (npts2 >
size(data_4d, 2))
then
397 print *,
'#Problem for size2 in compute_reduction_4d_to_2d_direction12'
398 print *,
'Npts2=', npts2,
'size(data_4d,2)',
size(data_4d, 2)
401 if (npts3 >
size(data_4d, 3))
then
402 print *,
'#Problem for size3 in compute_reduction_4d_to_2d_direction12'
403 print *,
'Npts3=', npts3,
'size(data_4d,3)',
size(data_4d, 3)
406 if (npts4 >
size(data_4d, 4))
then
407 print *,
'#Problem for size3 in compute_reduction_4d_to_2d_direction12'
408 print *,
'Npts4=', npts4,
'size(data_4d,4)',
size(data_4d, 4)
411 if (.not. (
present(integration_func)))
then
414 data_diag_2d(i3, i4, 1:3) = 0._f64
416 tmp = 0.5_f64*(data_4d(i1, 1, i3, i4) &
417 + data_4d(i1, npts2, i3, i4))
418 tmp_l1 = 0.5_f64*(abs(data_4d(i1, 1, i3, i4)) &
419 + abs(data_4d(i1, npts2, i3, i4)))
420 tmp_l2 = 0.5_f64*((data_4d(i1, 1, i3, i4))**2 &
421 + (data_4d(i1, npts2, i3, i4))**2)
423 tmp = tmp + data_4d(i1, i2, i3, i4)
424 tmp_l1 = tmp_l1 + abs(data_4d(i1, i2, i3, i4))
425 tmp_l2 = tmp_l2 + data_4d(i1, i2, i3, i4)**2
428 tmp_l1 = tmp_l1*delta2
429 tmp_l2 = tmp_l2*delta2
430 data_diag_2d(i3, i4, 1) = data_diag_2d(i3, i4, 1) + 0.5_f64*tmp
431 data_diag_2d(i3, i4, 2) = data_diag_2d(i3, i4, 2) + 0.5_f64*tmp_l1
432 data_diag_2d(i3, i4, 3) = data_diag_2d(i3, i4, 3) + 0.5_f64*tmp_l2
435 tmp = 0.5_f64*(data_4d(i1, 1, i3, i4) &
436 + data_4d(i1, npts2, i3, i4))
437 tmp_l1 = 0.5_f64*(abs(data_4d(i1, 1, i3, i4)) &
438 + abs(data_4d(i1, npts2, i3, i4)))
439 tmp_l2 = 0.5_f64*((data_4d(i1, 1, i3, i4))**2 &
440 + (data_4d(i1, npts2, i3, i4))**2)
442 tmp = tmp + data_4d(i1, i2, i3, i4)
443 tmp_l1 = tmp_l1 + abs(data_4d(i1, i2, i3, i4))
444 tmp_l2 = tmp_l2 + data_4d(i1, i2, i3, i4)**2
447 tmp_l1 = tmp_l1*delta2
448 tmp_l2 = tmp_l2*delta2
449 data_diag_2d(i3, i4, 1) = data_diag_2d(i3, i4, 1) + tmp
450 data_diag_2d(i3, i4, 2) = data_diag_2d(i3, i4, 2) + tmp_l1
451 data_diag_2d(i3, i4, 3) = data_diag_2d(i3, i4, 3) + tmp_l2
455 tmp = 0.5_f64*(data_4d(i1, 1, i3, i4) &
456 + data_4d(i1, npts2, i3, i4))
457 tmp_l1 = 0.5_f64*(abs(data_4d(i1, 1, i3, i4)) &
458 + abs(data_4d(i1, npts2, i3, i4)))
459 tmp_l2 = 0.5_f64*((data_4d(i1, 1, i3, i4))**2 &
460 + (data_4d(i1, npts2, i3, i4))**2)
462 tmp = tmp + data_4d(i1, i2, i3, i4)
463 tmp_l1 = tmp_l1 + abs(data_4d(i1, i2, i3, i4))
464 tmp_l2 = tmp_l2 + data_4d(i1, i2, i3, i4)**2
467 tmp_l1 = tmp_l1*delta2
468 tmp_l2 = tmp_l2*delta2
469 data_diag_2d(i3, i4, 1) = data_diag_2d(i3, i4, 1) + 0.5_f64*tmp
470 data_diag_2d(i3, i4, 2) = data_diag_2d(i3, i4, 2) + 0.5_f64*tmp_l1
471 data_diag_2d(i3, i4, 3) = data_diag_2d(i3, i4, 3) + 0.5_f64*tmp_l2
473 data_diag_2d(i3, i4, 1:3) = data_diag_2d(i3, i4, 1:3)*delta1
477 if (
present(integration_func_params))
then
478 print *,
'integration_func_params is present'
480 print *,
'#not implemented yet'
481 print *,
'#in compute_reduction_4d_to_2d_direction12'
494 integration_func_params)
496 sll_real64,
dimension(:, :),
intent(in) :: data_2d
497 sll_real64,
intent(out) :: res
498 sll_int32,
intent(in) :: npts1
499 sll_int32,
intent(in) :: npts2
500 sll_real64,
intent(in) :: delta1
501 sll_real64,
intent(in) :: delta2
503 sll_real64,
dimension(:),
optional :: integration_func_params
507 if (npts1 >
size(data_2d, 1))
then
508 print *,
'#Problem for size1 in sll_s_compute_reduction_2d_to_0d'
509 print *,
'Npts1=', npts1,
'size(data_2d,1)',
size(data_2d, 1)
512 if (npts2 >
size(data_2d, 2))
then
513 print *,
'#Problem for size2 in sll_s_compute_reduction_2d_to_0d'
514 print *,
'Npts2=', npts2,
'size(data_2d,2)',
size(data_2d, 2)
517 if (.not. (
present(integration_func)))
then
520 tmp = 0.5_f64*(data_2d(i1, 1) &
521 + data_2d(i1, npts2))
523 tmp = tmp + data_2d(i1, i2)
526 res = res + 0.5_f64*tmp
529 tmp = 0.5_f64*(data_2d(i1, 1) &
530 + data_2d(i1, npts2))
532 tmp = tmp + data_2d(i1, i2)
539 tmp = 0.5_f64*(data_2d(i1, 1) &
540 + data_2d(i1, npts2))
542 tmp = tmp + data_2d(i1, i2)
545 res = res + 0.5_f64*tmp
549 if (
present(integration_func_params))
then
550 print *,
'integration_func_params is present'
552 print *,
'#not implemented yet'
553 print *,
'#in sll_s_compute_reduction_2d_to_0d'
559 sll_real64,
dimension(:),
intent(in) ::
data
560 sll_int32,
intent(in) :: npts
561 sll_real64,
intent(in) :: delta
562 sll_real64,
dimension(:),
intent(in),
optional :: func_params
566 if (
present(func_params))
then
567 if (
size(func_params) > 100)
then
568 print *,
'#size of func_params is >100'
572 res = 0.5*(
data(1) +
data(npts))
580 sll_real64,
dimension(:),
intent(in) ::
data
581 sll_int32,
intent(in) :: npts
582 sll_real64,
dimension(:),
intent(in) :: node_positions
588 res = res +
data(i)*(node_positions(i + 1) - node_positions(i))
real(kind=f64) function compute_integral_conservative_1d(data, Npts, node_positions)
subroutine, public sll_s_compute_reduction_2d_to_0d(data_2d, res, Npts1, Npts2, delta1, delta2, integration_func, integration_func_params)
real(kind=f64) function, public sll_f_compute_integral_trapezoid_1d(data, Npts, delta, func_params)
subroutine, public sll_s_compute_reduction_diag_4d_to_2d_direction12(data_4d, data_diag_2d, Npts1, Npts2, Npts3, Npts4, delta1, delta2, integration_func, integration_func_params)
subroutine, public sll_s_compute_reduction_4d_to_2d_direction34(data_4d, data_2d, Npts1, Npts2, Npts3, Npts4, delta3, delta4, integration_func, integration_func_params)
subroutine compute_reduction_4d_to_2d_direction12(data_4d, data_2d, Npts1, Npts2, Npts3, Npts4, delta1, delta2, integration_func, integration_func_params)
subroutine, public sll_s_compute_reduction_4d_to_3d_direction4(data_4d, data_3d, Npts1, Npts2, Npts3, Npts4, delta4, integration_func, integration_func_params)
subroutine compute_reduction_4d_to_3d_direction4_accumulate(data_4d, data_3d, Npts1, Npts2, Npts3, Npts4, delta4, integration_func, integration_func_params)
Module to select the kind parameter.