module routines

  implicit none
  save

contains

  subroutine b(nx,y,x)

    implicit none

    integer,intent(in) :: nx
    real(8),intent(in) :: x(:)
    complex(8),intent(out) :: y(2*nx-1)
    integer :: j

    do j=1,2*nx-1
       y(j)=1.
    end do

  end subroutine b

  subroutine a(n1, n2)

    implicit none

    integer,intent(in) :: n1, n2
    real(8) :: x(n1 + n2)

    complex(8) :: c(2, 2*n1-1)

    x = 0._8

    print *,x(1) ! shows zero
    call b(size(x), c(1, :), x)
    print *,x(1) ! should also show zero, but shows one

  end subroutine a

end module routines

program test
  
  use routines
  implicit none
   
  integer :: n1, n2

  n1 = 10
  n2 = 10

  call a(n1, n2)
  
end program test
