Fixed crash in redistribute_cg

A weird memory error (Sigsegv in a completely unrelated part of the code)
happened on some combinations of threads/nodes.
The size of f and state was undercalculated on those circunstances, causing
memory corruption.
This has been fixed in this commit by re-enabling the old piece of code that reallocates
both data structures.
Also , reduced the amount of SHMEM consumed by moving cgcm_state to the heap.

Tested with 8p.