  The quantum correlations of $N$ noninteracting spinless fermions in their
ground state can be expressed in terms of a two-point function called the
kernel. Here we develop a general and compact method for computing the kernel
in a general trapping potential in terms of the Green's function for the
corresponding single particle Schr\"odinger equation. For smooth potentials the
method allows a simple alternative derivation of the local density
approximation for the density and of the sine kernel in the bulk part of the
trap in the large $N$ limit. It also recovers the density and the kernel of the
so-called {\em Airy gas} at the edge. This method allows to analyse the quantum
correlations in the ground state when the potential has a singular part with a
fast variation in space. For the square step barrier of height $V_0$, we derive
explicit expressions for the density and for the kernel. For large Fermi energy
$\mu>V_0$ it describes the interpolation between two regions of different
densities in a Fermi gas, each described by a different sine kernel. Of
particular interest is the {\em critical point} of the square well potential
when $\mu=V_0$. In this critical case, while there is a macroscopic number of
fermions in the lower part of the step potential, there is only a finite $O(1)$
number of fermions on the shoulder, and moreover this number is independent of
$\mu$. In particular, the density exhibits an algebraic decay $\sim 1/x^2$,
where $x$ is the distance from the jump. Furthermore, we show that the critical
behaviour around $\mu = V_0$ exhibits universality with respect with the shape
of the barrier. This is established (i) by an exact solution for a smooth
barrier (the Woods-Saxon potential) and (ii) by establishing a general relation
between the large distance behavior of the kernel and the scattering amplitudes
of the single-particle wave-function.
