Symplectic but not Hamiltonian Vector Fields In symplectic geometry, given a manifold $M$ with closed nondegenerate symplectic 2-form $\omega$, it is known that a vector field $X$ is Hamiltonian if $$\iota_X\omega=dH$$ for some smooth function $H\in C^\infty(M)$. A vector field is symplectic if it preserves the symplectic structure along the flow, i.e. $$\mathcal L_X\omega=0\,.$$
One of the easiest ways to check them is to note that if $X$ is symplectic then $\iota_X\omega$ is closed, and if $X$ is Hamiltonian then $\iota_X\omega$ is exact. Consequently, all Hamiltonian vector fields are symplectic but the converse is not true. Locally, however, Poincare lemma guarantees that every symplectic vector field is Hamiltonian.
Now consider symplectic 2-torus $(\mathbb T^2,d\theta\wedge d\phi)$ and a vector field $$X=\frac{\partial}{\partial \theta}\,.$$
Using the first de Rham cohomology, one usually concludes that $X$ is not Hamiltonian. However, I am unsure why: note that $\iota_X\omega=d\phi$, so it looks to me this is exact. Of course, we see that $\phi$ is not globally defined on $\mathbb T^2$, so perhaps this is not correct. But this argument would seem to imply that for symplectic 2-sphere $(S^2,d\theta\wedge d\phi)$, $X$ is not Hamiltonian (even though it should be, since it is symplectic and $$H^1_{\text{de Rham}}(S^2)=0\,.$$
Another example: Consider symplectic 2-sphere $(S^2,d\theta\wedge dh$), where $H(\theta,h)=h$ is a height function. In this case, the same vector field $X$ is Hamiltonian, since we obtained the required smooth Hamiltonian function $H$. Now I reverse the problem: consider another 2-torus $(\mathbb T^2,d\theta\wedge dh)$ and the same vector field $X$. Now it looks like $X$ is Hamiltonian, even though we know 
$$H^1_{\text{de Rham}}(\mathbb T^2)\neq0\,.$$
From my (naive) understanding, $H^1_{\text{de Rham}}(M)$ should be the only obstruction for a symplectic vector field to be Hamiltonian vector field, and not on the choice of the symplectic 2-form. 
Question: What has gone wrong here? For the first example, for instance, it may have to do with seeing that $d\phi$ is not exterior derivative of $\phi$, which I may have misunderstood.
 A: For the first problem, you have already detected where the problem lies: the variable $\phi$ is not a function defined on the whole manifold. Indeed, it is a priori a function in a chart on the manifold and a chart usually does not cover by itself the whole manifold.
On the other hand, the particular case of the torus is special because we can more or less canonically 'parametrize' the torus by $\mathbb{R}^2$ (which is its universal cover), for instance via the map $q: \mathbb{R}^2 \to \mathbb{R}^2 / \mathbb{Z}^2 \cong T^2$. As $\phi$ can be chosen to be one of two cartesian coordinates on $\mathbb{R}^2$, its derivative $d\phi$ (on the plane) is left invariant by any translation, in particular the ones by vectors in $\mathbb{Z}^2$. As such, $d\phi$ 'passes to the quotient' i.e. there exists a well-defined closed 1-form $\eta$ on $T^2$ such that $q^{\ast}\eta = d\phi$. This is another motivation to write $\eta = d\phi$, but note that $\phi$ itself would be a multi-valued function on the torus (and hence not a genuine function, so we wouldn't consider it as an antiderivative to $\eta$).
On the sphere, any chart misses at least one point, so again it is not surprising that one can find an antiderivative to a closed 1-form inside this chart. But if you can't extend $\phi$ and $\theta$ to the whole sphere, it is not clear how you can extend their derivatives to globally closed 1-forms in the first place: your problem possibly does not show up. Besides, the fact that the vector field $X = \partial/\partial \theta$ on the sphere can be globally defined (by rotation invariance and also by the null vectors at the poles) is not related to the (im)possibility that $\theta$ (or $d\theta$) is globally well-defined, but only to the fact that $X \lrcorner \omega$ is a closed (and exact) 1-form : an antiderivative is the height function, which is clearly not the angle 'function' $\theta$.

The obstruction to a symplectic vector field $X$ to be Hamiltonian is precisely whether the closed 1-form $X \lrcorner \omega$ is exact. In other words, does the cohomology class $[X \lrcorner \omega] \in H^1_{dR}(M; \mathbb{R})$ vanish? (The nonvanishing of this class is the obstruction to $X$ being Hamiltonian.) This question makes sense on any manifold; the point is that when $H^1_{dR}(M; \mathbb{R})=0$, then the answer is 'yes' whatever the symplectic field $X$. So on the 2-sphere, any symplectic vector field is Hamiltonian, whereas on the torus it depends on the symplectic vector field considered. Put differently, the (non)vanishing of the 1-cohomology group is the obstruction to the equality $Symp(M, \omega) = Ham(M, \omega)$.
