delete_file Subroutine

public subroutine delete_file(file, stat)

delete a file by filename

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: file
integer, intent(out), optional :: stat

[optional] Result of remove(), 0 on success


Source Code

subroutine delete_file(file, stat)
    character(len=*), intent(in) :: file
    !> [optional] Result of remove(), 0 on success
    integer, optional, intent(out) :: stat
    logical :: exist
    integer :: iostat
    iostat = 0
    inquire(file=file, exist=exist)
    if (exist) iostat = c_remove(file//c_null_char)
    if (present(stat)) stat = iostat
end subroutine delete_file