is_classic_flang Function

public function is_classic_flang(compiler) result(classic)

Whether a compiler named flang is classic flang: its driver runs the flang1 program installed next to it, which LLVM flang does not have

Arguments

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

Return Value logical


Variables

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: bin_dir
character(len=:), public, allocatable :: path

Source Code

function is_classic_flang(compiler) result(classic)
    character(len=*), intent(in) :: compiler
    logical :: classic

    character(len=:), allocatable :: path, bin_dir

    classic = .false.

    ! A compiler given by name is looked up on the PATH
    if (scan(compiler, '/\') > 0) then
        path = compiler
    else
        path = which(compiler)
    end if
    if (len_trim(path) == 0) return

    bin_dir = dirname(path)
    classic = exists(bin_dir//'flang1') .or. exists(bin_dir//'flang1.exe')

end function is_classic_flang