function out=g2c(psi0) %converts grided array to a column vector
[NN N]=size(psi0);
out=reshape(psi0',N*NN,1);