get_os_type Function

public function get_os_type() result(res)

Uses

    • forgex
    • forgex_enums_m

Todo

Arguments

None

Return Value integer


Source Code

   function get_os_type() result(res)
      use :: forgex, only: operator(.in.)
      use :: forgex_enums_m
      implicit none
      integer :: res
      integer, save :: res_save
      logical, save :: is_first = .true.

      character(LEN_ENV_VAR) :: val1, val2
      integer :: len1, len2, stat1, stat2

      if (.not. is_first) then
         res = res_save
         return
      end if

      res = OS_UNKNOWN

      call get_environment_variable(name='OS', value=val1, length=len1, status= stat1)

      if (stat1 == 0 .and. len1 > 0) then
         if ("Windows_NT" .in. val1) then
            res_save = OS_WINDOWS
            res = res_save
            is_first = .false.
            return
         end if
      end if

      call get_environment_variable(name='OSTYPE', value=val2, length=len2, status= stat2)
      if (stat2 == 0 .and. len2 > 0) then
         !! @todo
      end if
   end function get_os_type