Establishing compactness of manifolds for the purposes of applying Chern-Gauss-Bonnet A unit sphere possesses an induced metric,
$$ds^2=d\theta^2 + r^2\sin^2\theta d\phi^2$$
By applying the Cartan formalism, for a basis $e^\theta = d\theta$ and $e^\phi=r\sin\theta d\phi$, I found,
$$R^{\phi}_\theta = e^\theta \wedge e^\phi$$
and $R^\theta_\phi=-R^\phi_\theta$. The Pfaffian of the curvature $2$-form, as it is skew-symmetric, is simply,
$$\mathrm{Pf}[\mathcal{R}]=e^\theta \wedge e^\phi$$
I can now apply the Chern-Gauss-Bonnet theorem:
$$\frac{1}{2\pi}\int_{S^2} e^\theta \wedge e^\phi =2$$
which implies the genus of a sphere is $g=0$ as expected. As a physicist, none of this has been beyond my capabilities in differential geometry. But to apply the Chern-Gauss-Bonnet theorem, I had to know that $M=S^2$ was compact. Is there a way to prove this in a physicist-friendly manner, and more generally are there procedures to do so for general manifolds $M$?
The reason I ask is because when I'm solving the Einstein field equations, and I get a metric, I'd like to know if the spacetime is compact, so I can apply Chern-Gauss-Bonnet to gain additional information, i.e. the number of handles.
 A: It's possible I've misread your intent, but here are a couple of thoughts on why your question seems unlikely to have a simple answer:
Mathematicians have idioms for showing a manifold is compact, e.g., it's a closed, bounded subset of some Euclidean space; a smooth, closed subvariety of some projective space; a bundle with compact fibres over a compact base, .... Further, mathematicians construct explicit metrics by starting with a known manifold, covering with (usually dense) open sets on which the metric can be expressed conveniently, and proving these metrics extend to the entire space. These proofs depend on the known global structure of the manifold.
In my experience, physicists' situation (when they ask questions such as yours) is usually different: There is a coordinate representation of a metric, and the issue is to find a compact Riemannian or Lorentzian manifold and a dense, open set on which the "global" metric has the given coordinate representation. That's a difficult problem in general.
In your example of the round sphere, the metric came from a known parametrization of the sphere minus a closed half-longitude. If that fact had not been known, and only the coordinate expression for the metric were given, it would not have been so easy to determine your metric came from a compact manifold.
If these comments don't address what you want, it would help if you could say more about the form in which metrics come to you.
A: EDIT: as remarked in the comments, this answer (which in any case was intended as heuristic) contains some mistakes - in particular the part about compactness of the domain of the parametrisation is wrong by the very definition of manifold.
As user86418 said, mathematicians (which I am not) usually approach the problem in a different way: first you are given a topological manifold, the metric being an additional structure you put on it.
In a sense, your question is ill-defined: the same coordinate expression of a metric could live on different topological manifold. E.g. $dx^2+dy^2$ could be the metric on $R^2$ but also, with $x\in [0,1], y\in[0,1]$, $(0,y)\sim(1,y)$, $(x,0)\sim(x,1)$ on the flat 2-torus, a 2-dim, compact, boundaryless manifold. The metric you write, with different conditions on the angular variables from those you implicitly assumed, could as well be a metric on $ RP^2$.
In any case, to try and say something about your questions, let us assume you are given a coordinate expression with the coordinates varying in some given domain. I think that one could then say that if such a domain is compact, then the metric is defined on a compact manifold.
This is very naive and plenty of things can go wrong, e.g.


*

*the coordinates you are using may only cover part of the manifold. Since the manifold is not given this does not make much sense, a more rigorous way of saying would probably be that the manifold defined by your choices of coordinates can be embedded isometrically in another manifold.


Related symptoms of the problem could be that the manifold you get is incomplete (think Schwarzschild) or has boundary (by all means, these are just heuristic remarks, not theorems).


*

*the metric you get actually has singularities at some points. Therefore you have to remove the points from your manifolds, losing compactness and getting an incomplete manifold.

*the metric is not really well defined: checking that you are not defining twice its value at a point in inconsistent ways, or that you are not missing some points might be very tricky. 
