path2vec Subroutine

public subroutine path2vec(file_path, vec_path)

Subroutine that creates a vector containing the folders of a file path

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: file_path
character(len=512), intent(out), dimension(:), allocatable :: vec_path

Calls

proc~~path2vec~~CallsGraph proc~path2vec path2vec proc~dir_separator dir_separator proc~path2vec->proc~dir_separator proc~is_linux is_linux proc~dir_separator->proc~is_linux

Called by

proc~~path2vec~~CalledByGraph proc~path2vec path2vec program~test_files test_files program~test_files->proc~path2vec

Source Code

   subroutine path2vec(file_path, vec_path)
   !! Subroutine that creates a vector containing the folders of a file path
   implicit none
   character(len = *),   intent(in ) :: file_path
   character(len = 512), intent(out), dimension(:), allocatable :: vec_path

      character(len = 512) :: dir
      character(len =   1) :: sep
      integer(kind = I4)   :: is1, is2, k

      sep = dir_separator()

      k   = 0
      is2 = len_trim( file_path )
      do

         is2 = index( file_path(1:is2 - 1), sep, back = .true. )

         if ( is2 > 0 ) then

            k = k + 1

         else

            exit

         endif

      enddo

      allocate( vec_path(1:k - 1) )

      is2 = index( file_path, sep, back = .true. )
      dir = file_path(1:is2 - 1)

      k = 0
      do

         is1 = index( file_path(1:is2 - 1), sep, back = .true. )

         if ( is1 > 0 ) then

            k = k + 1
            vec_path(k) = file_path( is1 + 1:is2 - 1 )

            is2 = is1

         else

            exit

         endif

      enddo

      vec_path = vec_path( size(vec_path):1:-1 )

   return
   endsubroutine path2vec