Boundary Conditions
Fixed Boundary Mean
Including Edge Values
A fixed boundary condition sets the edge values before an aggregate is calculated.
Program
Play the program to choose the boundary value and recompute the field mean.
fixed_boundary_mean.f90
Replay: real traced execution (multi-file project)
program fixed_boundary_mean_demo
implicit none
real :: field(5)
real :: boundary_value
real :: total
real :: mean_value
integer :: i
field = [0.0, 2.0, 4.0, 6.0, 0.0]
boundary_value = 0.0
field(1) = boundary_value
field(5) = boundary_value
total = 0.0
do i = 1, 5
total = total + field(i)
end do
mean_value = total / 5.0
print '(F0.1, 1X, F0.1)', boundary_value, mean_value
end program fixed_boundary_mean_demo
program fixed_boundary_mean_demo
implicit none
real :: field(5)
real :: boundary_value
real :: total
real :: mean_value
integer :: i
field = [0.0, 2.0, 4.0, 6.0, 0.0]
boundary_value = -5.0
field(1) = boundary_value
field(5) = boundary_value
total = 0.0
do i = 1, 5
total = total + field(i)
end do
mean_value = total / 5.0
print '(F0.1, 1X, F0.1)', boundary_value, mean_value
end program fixed_boundary_mean_demo
program fixed_boundary_mean_demo
implicit none
real :: field(5)
real :: boundary_value
real :: total
real :: mean_value
integer :: i
field = [0.0, 2.0, 4.0, 6.0, 0.0]
boundary_value = 10.0
field(1) = boundary_value
field(5) = boundary_value
total = 0.0
do i = 1, 5
total = total + field(i)
end do
mean_value = total / 5.0
print '(F0.1, 1X, F0.1)', boundary_value, mean_value
end program fixed_boundary_mean_demo
field ← [0.0, 2.0, 4.0, 6.0, 0.0]
9field = [0.0, 2.0, 4.0, 6.0, 0.0]10boundary_value = 0.0values this step[0.0, 2.0, 4.0, 6.0, 0.0]fieldboundary_value ← 0.0
9field = [0.0, 2.0, 4.0, 6.0, 0.0]10boundary_value = 0.011field(1) = boundary_valuevalues this step0.0boundary_valuefield(1) ← 0.0
10boundary_value = 0.011field(1) = boundary_value12field(5) = boundary_valuevalues this step0.0field(1)field(5) ← 0.0
11field(1) = boundary_value12field(5) = boundary_value13total = 0.0values this step0.0field(5)total ← 0.0
12field(5) = boundary_value13total = 0.014do i = 1, 5values this step0.0totali ← 1
13total = 0.014do i = 1, 515 total = total + field(i)values this step1itotal ← 0.0
14do i = 1, 515 total = total + field(i)16end dovalues this step0.0total0.0field(1)i ← 2
13total = 0.014do i = 1, 515 total = total + field(i)values this step2itotal ← 2.0
14do i = 1, 515 total = total + field(i)16end dovalues this step2.0total2.0field(2)i ← 3
13total = 0.014do i = 1, 515 total = total + field(i)values this step3itotal ← 6.0
14do i = 1, 515 total = total + field(i)16end dovalues this step6.0total4.0field(3)i ← 4
13total = 0.014do i = 1, 515 total = total + field(i)values this step4itotal ← 12.0
14do i = 1, 515 total = total + field(i)16end dovalues this step12.0total6.0field(4)i ← 5
13total = 0.014do i = 1, 515 total = total + field(i)values this step5itotal ← 12.0
14do i = 1, 515 total = total + field(i)16end dovalues this step12.0total0.0field(5)mean_value ← 2.4
16end do17mean_value = total / 5.018print '(F0.1, 1X, F0.1)', boundary_value, mean_valuevalues this step2.4mean_value12.0totalprint '(F0.1, 1X, F0.1)', boundary_value, mean_value
17 mean_value = total / 5.018 print '(F0.1, 1X, F0.1)', boundary_value, mean_value19end program fixed_boundary_mean_demooutput0.0 2.4values this step0.0boundary_value2.4mean_value
field ← [0.0, 2.0, 4.0, 6.0, 0.0]
9field = [0.0, 2.0, 4.0, 6.0, 0.0]10boundary_value = -5.0values this step[0.0, 2.0, 4.0, 6.0, 0.0]fieldboundary_value ← -5.0
9field = [0.0, 2.0, 4.0, 6.0, 0.0]10boundary_value = -5.011field(1) = boundary_valuevalues this step-5.0boundary_valuefield(1) ← -5.0
10boundary_value = -5.011field(1) = boundary_value12field(5) = boundary_valuevalues this step-5.0field(1)field(5) ← -5.0
11field(1) = boundary_value12field(5) = boundary_value13total = 0.0values this step-5.0field(5)total ← 0.0
12field(5) = boundary_value13total = 0.014do i = 1, 5values this step0.0totali ← 1
13total = 0.014do i = 1, 515 total = total + field(i)values this step1itotal ← -5.0
14do i = 1, 515 total = total + field(i)16end dovalues this step-5.0total-5.0field(1)i ← 2
13total = 0.014do i = 1, 515 total = total + field(i)values this step2itotal ← -3.0
14do i = 1, 515 total = total + field(i)16end dovalues this step-3.0total2.0field(2)i ← 3
13total = 0.014do i = 1, 515 total = total + field(i)values this step3itotal ← 1.0
14do i = 1, 515 total = total + field(i)16end dovalues this step1.0total4.0field(3)i ← 4
13total = 0.014do i = 1, 515 total = total + field(i)values this step4itotal ← 7.0
14do i = 1, 515 total = total + field(i)16end dovalues this step7.0total6.0field(4)i ← 5
13total = 0.014do i = 1, 515 total = total + field(i)values this step5itotal ← 2.0
14do i = 1, 515 total = total + field(i)16end dovalues this step2.0total-5.0field(5)mean_value ← 0.4
16end do17mean_value = total / 5.018print '(F0.1, 1X, F0.1)', boundary_value, mean_valuevalues this step0.4mean_value2.0totalprint '(F0.1, 1X, F0.1)', boundary_value, mean_value
17 mean_value = total / 5.018 print '(F0.1, 1X, F0.1)', boundary_value, mean_value19end program fixed_boundary_mean_demooutput-5.0 0.4values this step-5.0boundary_value0.4mean_value
field ← [0.0, 2.0, 4.0, 6.0, 0.0]
9field = [0.0, 2.0, 4.0, 6.0, 0.0]10boundary_value = 10.0values this step[0.0, 2.0, 4.0, 6.0, 0.0]fieldboundary_value ← 10.0
9field = [0.0, 2.0, 4.0, 6.0, 0.0]10boundary_value = 10.011field(1) = boundary_valuevalues this step10.0boundary_valuefield(1) ← 10.0
10boundary_value = 10.011field(1) = boundary_value12field(5) = boundary_valuevalues this step10.0field(1)field(5) ← 10.0
11field(1) = boundary_value12field(5) = boundary_value13total = 0.0values this step10.0field(5)total ← 0.0
12field(5) = boundary_value13total = 0.014do i = 1, 5values this step0.0totali ← 1
13total = 0.014do i = 1, 515 total = total + field(i)values this step1itotal ← 10.0
14do i = 1, 515 total = total + field(i)16end dovalues this step10.0total10.0field(1)i ← 2
13total = 0.014do i = 1, 515 total = total + field(i)values this step2itotal ← 12.0
14do i = 1, 515 total = total + field(i)16end dovalues this step12.0total2.0field(2)i ← 3
13total = 0.014do i = 1, 515 total = total + field(i)values this step3itotal ← 16.0
14do i = 1, 515 total = total + field(i)16end dovalues this step16.0total4.0field(3)i ← 4
13total = 0.014do i = 1, 515 total = total + field(i)values this step4itotal ← 22.0
14do i = 1, 515 total = total + field(i)16end dovalues this step22.0total6.0field(4)i ← 5
13total = 0.014do i = 1, 515 total = total + field(i)values this step5itotal ← 32.0
14do i = 1, 515 total = total + field(i)16end dovalues this step32.0total10.0field(5)mean_value ← 6.4
16end do17mean_value = total / 5.018print '(F0.1, 1X, F0.1)', boundary_value, mean_valuevalues this step6.4mean_value32.0totalprint '(F0.1, 1X, F0.1)', boundary_value, mean_value
17 mean_value = total / 5.018 print '(F0.1, 1X, F0.1)', boundary_value, mean_value19end program fixed_boundary_mean_demooutput10.0 6.4values this step10.0boundary_value6.4mean_value
fixed boundary
The first and last field entries are assigned before the aggregate.
interior data
Interior values stay unchanged while boundary values vary.
aggregate effect
The mean includes both fixed boundary values and interior values.