Global sections of flat scheme also flat? In the most naive form my question would be as follows: If $f:X\to \mathrm{Spec}\;A$ is a flat morphism of schemes is it true that $H^0(X,\mathcal{O}_X)$ is a flat $A$-module?
In general the answer is no: It is a theorem of Chase that a ring $A$ is coherent (meaning that every finitely generated ideal of $A$ is finitely presented) if and only if the product $\prod_I A$ is flat over $A$ for every set $I$. Hence if $A$ is not coherent one can find a set $I$ such that the global sections of $X=\coprod_I \mathrm{Spec}\;A$ are not flat over $A$ while of course $X$ is flat over $\mathrm{Spec}\;A$. An example of a non-coherent ring would be $\mathbb{Q}[X,Y_1,Y_2,\ldots]/(XY_1,XY_2,\ldots)$.
Does anyone know other examples for which the answer is no and which fulfill at least some finiteness conditions? For example is there a quasi-compact example?
Ultimately I'd love to know if it is true if $A$ is noetherian and $f$ is proper.
 A: For another counterexample, let $A$ be $k[u,v,w]/uw-v^2$ and let $X$ be the complement of the origin in the plane $\text{Spec} \ k[x,y]$.  Let $f$ be the restriction of the morphism of affine schemes corresponding to the map of rings $k[u,v,w]/uw-v^2 \to k[x,y]$ by $u\mapsto x^2$, $v\mapsto xy$, $w \mapsto y^2$.  The morphism $f$ is flat.  And by Hartog's theorem / S2 extension, $H^0(X,\mathcal{O}_X)$ equals $k[x,y]$.  But the ring homomorphism above is not flat: just consider the length when you quotient by the maximal ideal $\langle u,v,w\rangle $ in the domain ring.
If you assume that $A$ is Noetherian and $f$ is proper, then flatness should follow by Stein factorization.
A: Here is a example with proper morphism over a noetherian base. We consider a DVR $R$, and we note $S=\mathrm{Spec}(R)$. Let $X/S$ be a proper flat curve $X/R$ which is not cohomologically flat, that is $\mathrm{R}^{1}f_{\ast}\mathcal{O}_X$ has actually torsion, and that $\mathrm{H}^{0}(X,\mathcal{O} _{X})=R$ (such a curve exists, for example, one can consider the proper  minimal regular model of some projective smooth curve on $\mathrm{Frac}(R)$ without rational point, see for example Raynaud's paper on picard functor where you can find example for genus one curve). Then I claim that for some integer $n\gg 1$, the reduction $X_n:=X\otimes_R R/\pi^n$ provides an example that we need. Indeed, since $X/S$ is flat, we have the following short exact sequence 
$$
0\rightarrow \mathcal{O}_{X}\rightarrow \mathcal{O}_X\rightarrow \mathcal{O} _{X_n}\rightarrow 0
$$
here the first map is multiplication by $\pi^n$. Now the long exact sequence tells us 
$$
0\rightarrow \mathrm{H}^{0}(X,\mathcal{O}_{X})\rightarrow \mathrm{H}^0(X,\mathcal{O}_X)\rightarrow \mathrm{H}^{0}(X,\mathcal{O} _{X_n})\rightarrow \mathrm{H}^{1}(X,\mathcal{O}_{X})[\pi^n]\rightarrow 0
$$
Here the first map is the multiplication by $\pi^n$, while the last member is the $\pi^n$-torsion of $\mathrm{H}^{1}(X,\mathcal{O} _{X})$. Now when $n$ becomes sufficiently large, the last member becomes stable. On the other hand, $\mathrm{H}^{0}(X,\mathcal{O} _{X})=R$, hence we get the following exact sequence of $R$-modules 
$$
0\rightarrow R/\pi^n R \rightarrow \mathrm{H}^{0}(X,\mathcal{O} _{X_n})\rightarrow \mathrm{H}^{1}(X,\mathcal{O}_{X})[\pi^n]\rightarrow 0.
$$
So in this way, we see that $\mathrm{H}^{0}(X,\mathcal{O} _{X_n})$ cannot be flat (hence free) over $R/\pi^n$ as such a free module must be of length a multiple of n, which is impossible since the last member of the previous short exact sequence is stable and non zero for $n\gg 0$. 
