Implemented a profile resorter and introduce convenience variables nmax
and ntot in the grid file to have shortcuts to total number of cells
Remove write statemet
Fixed the last bugs... Function has to work now!