Which causes thomas coefficients arrays upper_diag and lower_diag in diff_nonperiodic to be of size n-2 instead of n. Surprisingly this doesn't lead to a compile time error, nor runtime error. Just a failed unit test.
Reason seems to be that reverse returns an allocatable array. MWE:
program main
implicit none
real :: a(4), b(4)
real, allocatable :: c(:)
a = [1., 2., 3., 4.]
b = reverse(a) ! Should be (4 3 2 1)
c = reverse(a) ! Should be (4 3 2 1)
write(*,*) 'b is', b ! 0 0 0 0
write(*,*) 'c is', c ! empty array
contains
function reverse(x)
!! Returns input array in reverse order
!! (1 2 3 4) -> (4 3 2 1)
real, intent(in) :: x(:)
real, allocatable :: reverse(:)
reverse = x(size(x):1:-1)
end function reverse
end program main
Compilation started at Mon Jan 23 10:45:45
nvfortran test_reverse.f90 && ./a.out
b is 0.000000 0.000000 0.000000 0.000000
c is
Compilation finished at Mon Jan 23 10:45:46
Workaround is straightforward: there is actually no need for returned array to be allocatable since size(x) is known.
Which causes thomas coefficients arrays
upper_diag
andlower_diag
indiff_nonperiodic
to be of sizen-2
instead ofn
. Surprisingly this doesn't lead to a compile time error, nor runtime error. Just a failed unit test.Reason seems to be that
reverse
returns an allocatable array. MWE:Workaround is straightforward: there is actually no need for returned array to be allocatable since
size(x)
is known.