system_uname Subroutine

public subroutine system_uname(WHICH, NAMEOUT)

NAME

system_uname(3f) - [M_system] call a C wrapper that calls uname(3c) to get current system information from Fortran (LICENSE:PD)

SYNOPSIS

subroutine system_uname(WHICH,NAMEOUT)

 character(KIND=C_CHAR),intent(in) :: WHICH
 character(len=*),intent(out)      :: NAMEOUT

DESCRIPTION

    Given a letter, return a corresponding description of the current
    operating system. The NAMEOUT variable is assumed sufficiently
    large enough to hold the value.

    s   return the kernel name
    r   return the kernel release
    v   return the kernel version
    n   return the network node hostname
    m   return the machine hardware name
    T   test mode -- print all information, in the following order - srvnm

EXAMPLE

Call uname(3c) from Fortran

program demo_system_uname
   use M_system, only : system_uname
   implicit none
   integer,parameter          :: is=100
   integer                    :: i
   character(len=*),parameter :: letters='srvnmxT'
   character(len=is)          :: string=' '

   do i=1,len(letters)
      write(*,'(80("="))')
      call system_uname(letters(i:i),string)
      write(*,*)&
      &'=====> TESTING system_uname('//letters(i:i)//')--->'//trim(string)
   enddo

end program demo_system_uname

AUTHOR

John S. Urban

LICENSE

Public Domain

Arguments

Type IntentOptional Attributes Name
character(kind=C_CHAR), intent(in) :: WHICH
character(len=*), intent(out) :: NAMEOUT

Contents

Source Code


Source Code

subroutine system_uname(WHICH,NAMEOUT)
implicit none

! ident_28="@(#) M_system system_uname(3f) call my_uname(3c) which calls uname(3c)"

character(KIND=C_CHAR),intent(in) :: WHICH
character(len=*),intent(out)      :: NAMEOUT

! describe the C routine to Fortran
! void system_uname(char *which, char *buf, int *buflen);
interface
   subroutine system_uname_c(WHICH,BUF,BUFLEN) bind(C,NAME='my_uname')
      import c_char, c_int
      implicit none
      character(KIND=C_CHAR),intent(in)  :: WHICH
      character(KIND=C_CHAR),intent(out) :: BUF(*)
      integer(kind=c_int),intent(in)     :: BUFLEN
   end subroutine system_uname_c
end interface

   NAMEOUT='unknown'
   call system_uname_c(WHICH,NAMEOUT, INT(LEN(NAMEOUT),kind(0_c_int)))

end subroutine system_uname