I found the real error. mpi_cast(del_chi,...) had mpi_real rather than mpi_double. I changed del_chi to a double precision at some point, and this was the error. Fixed now. Works the same as the old code (OdieCode, commit d0a2f7d802284c0fd6d42b17f17a1709116d6169) with the exception of rounding errors. Great! I now want to fix up the parameter file, then we are good to go for stampede.