72 implicit none;
private
141 integer,
intent(in) :: os
142 character(:),
allocatable :: res
153 case default ; res =
'UNKNOWN'
189 character(len=255) :: val
190 integer :: length, rc
191 logical :: file_exists
192 logical,
save :: first_run = .true.
196 if (.not. first_run)
then
205 call get_environment_variable(
'OSTYPE', val, length, rc)
207 if (rc == 0 .and. length > 0)
then
209 if (index(val,
'linux') > 0)
then
216 if (index(val,
'darwin') > 0)
then
223 if (index(val,
'win') > 0 .or. index(val,
'msys') > 0)
then
230 if (index(val,
'cygwin') > 0)
then
237 if (index(val,
'SunOS') > 0 .or. index(val,
'solaris') > 0)
then
244 if (index(val,
'FreeBSD') > 0 .or. index(val,
'freebsd') > 0)
then
251 if (index(val,
'OpenBSD') > 0 .or. index(val,
'openbsd') > 0)
then
259 call get_environment_variable(
'OS', val, length, rc)
261 if (rc == 0 .and. length > 0 .and. index(val,
'Windows_NT') > 0)
then
264 call get_environment_variable(
'PROCESSOR_ARCHITECTURE', val, length, rc)
265 if (rc == 0 .and. length > 0 .and. index(val,
'x86') > 0)
then
273 inquire(file=
'/etc/os-release', exist=file_exists)
275 if (file_exists)
then
282 inquire(file=
'/usr/bin/sw_vers', exist=file_exists)
284 if (file_exists)
then
291 inquire(file=
'/bin/freebsd-version', exist=file_exists)
293 if (file_exists)
then
317 integer,
intent(in),
optional :: os
319 if (
present(os))
then
integer, parameter, public os_windowsx86
Native Microsoft Windows running on 32-bit x86 architecture.
integer, parameter, public os_solaris
Oracle Solaris / OpenSolaris derivatives.
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_openbsd
OpenBSD.
integer, parameter, public os_freebsd
FreeBSD and its direct derivatives.
integer, parameter, public os_macos
macOS (Darwin-based Apple operating system)
integer, parameter, public os_unknown
Unknown / undetected operating system.
logical function, public os_is_unix(os)
Return .true. if the current (or supplied) OS is Unix-like Convenience wrapper that returns ....
integer function, public get_os_type()
Determine the current operating system type Returns one of the OS_* constants.
pure character(:) function, allocatable, public os_name(os)
Return a human-readable string describing the OS type flag Converts any of the OS_* integer constants...
integer, parameter, public os_cygwin
Cygwin POSIX environment on Windows.