diff --git a/src/bnorml.f90 b/src/bnorml.f90 index 3c2078b1..7c8a352c 100644 --- a/src/bnorml.f90 +++ b/src/bnorml.f90 @@ -344,12 +344,20 @@ end subroutine bnorml ! Complete an odd field under (theta,zeta) -> (-theta,-zeta). ! The theta=0 column maps to itself, without advancing the toroidal row. +! For Nz=1, bnorml evaluates only theta indices 0..(Nt+1)/2 of the single row. subroutine mirror_normal_field(Nt, Nz, Nzwithsym, field) implicit none integer, intent(in) :: Nt, Nz, Nzwithsym real, intent(inout) :: field(Nt*Nz) integer :: jj, kk, source, target + if (Nz.eq.1) then + do jj = (Nt+1)/2 + 1, Nt-1 + field(1+jj) = -field(1+Nt-jj) + enddo + return + endif + do kk = 1, Nz-Nzwithsym do jj = 0, Nt-1 source = 1 + jj + kk*Nt diff --git a/tests/virtual_casing_symmetry.f90 b/tests/virtual_casing_symmetry.f90 index 58d9c5f1..9b264e97 100644 --- a/tests/virtual_casing_symmetry.f90 +++ b/tests/virtual_casing_symmetry.f90 @@ -18,8 +18,13 @@ program test_virtual_casing_symmetry enddo enddo Nzwithsym = min(Nz, (Nz+3)/2) - field = 0.0 - field(1:Nt*Nzwithsym) = expected(1:Nt*Nzwithsym) + ! Poison every sample that bnorml does not evaluate. + field = huge(1.0) + if (Nz.eq.1) then + field(1:(Nt+1)/2+1) = expected(1:(Nt+1)/2+1) + else + field(1:Nt*Nzwithsym) = expected(1:Nt*Nzwithsym) + endif call mirror_normal_field(Nt, Nz, Nzwithsym, field) if (maxval(abs(field-expected)).gt.2.e-14) error stop 'periodic symmetry mismatch' deallocate(expected, field)