Fix the MPI unknown error caused by bounds error in outforce

Also tidy up some routines generating warnings because of unused
declared variables.