Set N_OUTVAR_TYPES to match the number of output variables

N_OUTVAR_TYPES is used as a loop counter in image mode and should
therefore match the number of output vatiables exactly (rather
than just be equal to or greater than).
Close global parameter file
Rewind global parameter file before reading
Write history file for selected variables