Join restart_dir to restart_file, accounting for potential existence of path in restart_file already.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(inout) | :: | restart_dir | |||
character(len=*), | intent(inout) | :: | restart_file |
subroutine add_restart_dir_to_file(restart_dir, restart_file)
character(len = *), intent(in out) :: restart_dir, restart_file
integer :: ind_slash
! prepend restart_dir to restart_file
! append trailing slash if not exists
if (restart_dir(len_trim(restart_dir):) /= "/") restart_dir = trim(restart_dir)//"/"
!Determine if restart file contains "/" if so split on this point to give DIR//FILE
!so restart files are created in DIR//restart_dir//FILE
ind_slash = index(restart_file, "/", .true.)
if (ind_slash == 0) then !No slash present
restart_file = trim(restart_dir) // trim(restart_file)
else !Slash present
restart_file = trim(restart_file(1:ind_slash)) // trim(restart_dir) // trim(restart_file(ind_slash+1:))
end if
end subroutine add_restart_dir_to_file