| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(case_params_t), | intent(in) | :: | params | |||
| character(len=*), | intent(in) | :: | restart_dir |
subroutine prune_restart_files(params, restart_dir) type(case_params_t), intent(in) :: params character(len=*), intent(in) :: restart_dir integer :: exitstat, first_to_delete character(len=32) :: first_to_delete_text character(len=3*path_len + 256) :: command if (params%restart_keep <= 0) return ! Keep the most recently written restart files in this restart directory. ! This mirrors the existing POSIX-shell style used for output directory ! creation; paths with spaces are not supported elsewhere in the solver. first_to_delete = params%restart_keep + 1 write(first_to_delete_text, '(i0)') first_to_delete command = 'if ls ' // trim(restart_dir) // '/restart_*.rst >/dev/null 2>&1; then ' // & 'ls -1t ' // trim(restart_dir) // '/restart_*.rst | tail -n +' // & trim(adjustl(first_to_delete_text)) // ' | xargs -r rm -f; fi' call execute_command_line(trim(command), exitstat=exitstat) if (exitstat /= 0) call fatal_error('restart', 'failed pruning old restart files in: '//trim(restart_dir)) end subroutine prune_restart_files