subroutine close_idempotence_files
! Close the intermediate idempotence-check files, deleting them in the process
! Re-open the original OUT.DAT and MFILE.DAT output files, ready to write
! the final data, now model evaluation idempotence has been checked
use global_variables, only: output_prefix
use constants, only: nout, mfile
implicit none
! Close idempotence files, deleting them in the process
close(unit = nout, status="delete")
close(unit = mfile, status="delete")
! Re-open original output file and mfile, appending future output to them
open(unit=nout, file=trim(output_prefix)//'OUT.DAT', action='write', position='append')
open(unit=mfile, file=trim(output_prefix)//'MFILE.DAT', action='write', position='append')
end subroutine close_idempotence_files