8 use,
intrinsic :: iso_fortran_env, only: compiler_version, compiler_options
12 implicit none;
private
14 public :: get_compiler
18 function get_compiler(is_standalone)
result(res)
19 logical,
intent(in) :: is_standalone
20 character(:),
allocatable :: res
24 if (is_standalone)
then
25 call get_environment_variable(
'FC', length=l, status = ios, trim_name = .true.)
28 res = get_caller_name()
32 allocate(
character(len=max(l, 1)) :: res)
33 call get_environment_variable(
'FC', res, status = ios, trim_name = .true.)
34 if (ios /= 0) res =
''
37 res = get_compilerinfo()
44 function get_compilerinfo()
result(res)
45 character(:),
allocatable :: res
48 character(:),
allocatable :: version
53 if (
index(version,
'gcc') > 0)
then
55 else if (
index(version,
'intel') > 0)
then
56 if (
index(version,
'classic') > 0)
then
60 res = merge(
'ia32 ',
'ifort',
index(version,
'IA-32') > 0)
73 else if (
index(version,
'nvfortran') > 0)
then
75 else if (
index(version,
'nag fortran') > 0)
then
77 else if (
index(version,
'flang') > 0)
then
79 else if (
index(version,
'ibm xl') > 0)
then
81 else if (
index(version,
'lahey/fujitsu') > 0)
then
83 else if (
index(version,
'lfortran') > 0)
then
88 function get_caller_name()
result(res)
90 use fpx_process_windows,
only: get_parent_pid_windows, get_process_name_windows
91 character(:),
allocatable :: res
98 pid = get_parent_pid_windows()
103 res = get_process_name_windows(pid)
104 if (is_compiler(res))
exit
109 character(:),
allocatable :: res
121 res = get_process_name_posix(pid)
122 if (is_compiler(res))
exit
141 function normalized_name(name)
result(res)
142 character(:),
allocatable,
intent(in) :: name
143 character(:),
allocatable :: res
147 if (.not.
allocated(name))
then
151 pos =
index(name,
'.')
169 logical function is_compiler(name)
170 character(:),
allocatable,
intent(in) :: name
172 character(:),
allocatable :: exe
174 exe = normalized_name(name)
196 is_compiler = .false.
integer, parameter, public os_windows
Microsoft Windows (native, 32-bit or 64-bit).
integer, parameter, public os_linux
Linux (any distribution, including GNU/Linux).
integer, parameter, public os_macos
macOS (Darwin-based Apple operating system)
integer function, public get_os_type()
Determine the current operating system type Returns one of the OS_* constants.
integer function, public get_parent_pid_posix()
Return parent PID (PPID) on POSIX systems.
pure character(len_trim(str)) function, public lowercase(str)
Convert string to lower case (respects contents of quotes).
Locate the position of a substring.