get_new_file_name Function

private function get_new_file_name(file) result(res)

Uses

    • utils

If file exits, get numeral to append to filename

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: file

file to be checked

Return Value character(len=:), allocatable


Source Code

        function get_new_file_name(file) result(res)
            !! If file exits, get numeral to append to filename 

            use utils, only : str

            !> file to be checked
            character(len=*), intent(IN) :: file

            character(len=:), allocatable :: res
            integer :: pos, i

            i = 1
            do
                pos = scan(trim(file), ".", back=.true.)
                res = file(1:pos-1)//" ("//str(i)//")"//file(pos:)
                if(.not. check_file(res))exit
                i = i + 1
            end do

        end function get_new_file_name