Given a library name and folder, find extension and prefix
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | lib_name | |||
character(len=*), | intent(in) | :: | lib_dir | |||
character(len=:), | intent(out), | allocatable | :: | prefix | ||
character(len=:), | intent(out), | allocatable | :: | suffix | ||
logical, | intent(out) | :: | found |
subroutine lib_get_trailing(lib_name,lib_dir,prefix,suffix,found) character(*), intent(in) :: lib_name,lib_dir character(:), allocatable, intent(out) :: prefix,suffix logical, intent(out) :: found character(*), parameter :: extensions(*) = [character(11) :: '.dll.a','.a','.dylib','.dll'] logical :: is_file character(:), allocatable :: noext,tokens(:),path integer :: l,k ! Extract name with no extension call split(lib_name,tokens,'.') noext = trim(tokens(1)) ! Get library extension: find file name: NAME.a, NAME.dll.a, NAME.dylib, libNAME.a, etc. found = .false. suffix = "" prefix = "" with_pref: do l=1,2 if (l==2) then prefix = "lib" else prefix = "" end if find_ext: do k=1,size(extensions) path = join_path(lib_dir,prefix//noext//trim(extensions(k))) inquire(file=path,exist=is_file) if (is_file) then suffix = trim(extensions(k)) found = .true. exit with_pref end if end do find_ext end do with_pref if (.not.found) then prefix = "" suffix = "" end if end subroutine lib_get_trailing