M_system Module

NAME

M_system(3fm) - [M_system::INTRO] Fortran interface to C system interface
(LICENSE:PD)

SYNOPSIS

Public objects:

! ENVIRONMENT
use M_system, only : set_environment_variable, system_unsetenv, &
system_putenv, system_getenv

use M_system, only :  system_intenv, system_readenv, system_clearenv
! FILE SYSTEM
use M_system, only : system_getcwd, system_link,       &
system_mkfifo, system_remove, system_rename,           &
system_umask, system_unlink, fileglob,                 &
system_rmdir, system_chdir, system_mkdir,              &
system_stat, system_isdir, system_islnk, system_isreg, &
system_isblk, system_ischr, system_isfifo,             &
system_realpath,                                       &
system_access,                                         &
system_utime,                                          &
system_system,                                         &
system_issock, system_perm,                            &
system_dir,                                            &
system_memcpy

!x!use M_system, only : system_getc, system_putc
! ERROR PROCESSING
use M_system, only : system_errno, system_perror
! INFO
use M_system, only : system_getegid, system_geteuid, system_getgid, &
system_gethostname, system_getpid, system_getppid, system_setsid, &
system_getsid, system_getuid, system_uname
! SIGNALS
use M_system, only : system_kill,system_signal
! RANDOM NUMBERS
use M_system, only : system_rand, system_srand
! PROCESS INFORMATION
use M_system, only : system_cpu_time

DESCRIPTION

M_system(3fm) is a collection of Fortran procedures that call C or a
C wrapper using the ISO_C_BINDING interface to access system calls.
System calls are a special set of functions used by programs to
communicate directly with an operating system.

Generally, system calls are slower than normal function calls because
when you make a call control is relinquished to the operating system
to perform the system call. In addition, depending on the nature of
the system call, your program may be blocked by the OS until the
system call has finished, thus making the execution time of your
program even longer.

One rule-of-thumb that should always be followed when calling a system
call -- Always check the return value.

ENVIRONMENT ACCESS

    o  system_putenv(3f):     call putenv(3c)
    o  system_getenv(3f):     function call to get_environment_variable(3f)
    o  system_unsetenv(3f):   call unsetenv(3c) to remove variable
                              from environment
    o  set_environment_variable(3f): set environment variable by
                                     calling setenv(3c)

    o  system_initenv(3f):    initialize environment table for reading
    o  system_readenv(3f):    read next entry from environment table
    o  system_clearenv(3f):   emulate clearenv(3c) to clear environment

FILE SYSTEM

    o  system_chdir(3f):      call chdir(3c) to change current
                              directory of a process
    o  system_getcwd(3f):     call getcwd(3c) to get pathname of
                              current working directory

    o  system_stat(3f):       determine system information of file
                              by name
    o  system_perm(3f):       create string representing file
                              permission and type
    o  system_access(3f):     determine filename access or existence
    o  system_isdir(3f):      determine if filename is a directory
    o  system_islnk(3f):      determine if filename is a link
    o  system_isreg(3f):      determine if filename is a regular file
    o  system_isblk(3f):      determine if filename is a block device
    o  system_ischr(3f):      determine if filename is a character device
    o  system_isfifo(3f):     determine if filename is a fifo - named pipe
    o  system_issock(3f):     determine if filename is a socket
    o  system_realpath(3f):   resolve a pathname

    o  system_chmod(3f):      call chmod(3c) to set file permission mode
    o  system_chown(3f):      call chown(3c) to set file owner
    o  system_getumask(3f):   call umask(3c) to get process permission mask
    o  system_setumask(3f):   call umask(3c) to set process permission mask

    o  system_mkdir(3f):      call mkdir(3c) to create empty directory
    o  system_mkfifo(3f):     call mkfifo(3c) to create a special FIFO file
    o  system_link(3f):       call link(3c) to create a filename link

    o  system_rename(3f):     call rename(3c) to change filename

    o  system_remove(3f):     call remove(3c) to remove file
    o  system_rmdir(3f):      call rmdir(3c) to remove empty directory
    o  system_unlink(3f):     call unlink(3c) to remove a link to a file
    o  system_utime(3f):      call utime(3c) to set file access and
                              modification times
    o  system_dir(3f):        read name of files in specified directory
                              matching a wildcard string

    o  fileglob(3f): Returns list of files using a file globbing pattern

STREAM IO

    o  system_getc(3f): get a character from stdin
    o  system_putc(3f): put a character on stdout

RANDOM NUMBERS

    o  system_srand(3f): call srand(3c)
    o  system_rand(3f): call rand(3c)

C ERROR INFORMATION

    o  system_errno(3f): return errno(3c)
    o  system_perror(3f): call perror(3c) to display last C error message

QUERIES

    o  system_geteuid(3f): call geteuid(3c)
    o  system_getuid(3f): call getuid(3c)
    o  system_getegid(3f): call getegid(3c)
    o  system_getgid(3f): call getgid(3c)
    o  system_getpid(3f): call getpid(3c)
    o  system_getppid(3f): call getppid(3c)
    o  system_gethostname(3f): get name of current host
    o  system_uname(3f): call my_uname(3c) which calls uname(3c)
    o  system_getlogin(3f): get login name
    o  system_getpwuid(3f): get login name associated with given UID
    o  system_getgrgid(3f): get group name associated with given GID
    o  system_cpu_time(3f) : get processor time in seconds using times(3c)

SYSTEM COMMANDS

    o  system_system(3f): call execute_command_line(3c) outputting messages

FUTURE DIRECTIONS

A good idea of what system routines are commonly required is to refer
to the POSIX binding standards. (Note: IEEE 1003.9-1992 was withdrawn 6
February 2003.) The IEEE standard covering Fortran 77 POSIX bindings
is available online, though currently (unfortunately) only from
locations with appropriate subscriptions to the IEEE server (e.g.,
many university networks). For those who do have such access, the link
is: POSIX Fortran 77 Language Interfaces (IEEE Std 1003.9-1992) (pdf)

SEE ALSO

Some vendors provide their own way to access POSIX functions and make
those available as modules; for instance ...

   o the IFPORT module of Intel
   o or the f90_* modules of NAG.
   o There are also other compiler-independent efforts to make the
     POSIX procedures accessible from Fortran...

      o Posix90 (doc),
      o flib.a platform/files and directories,
      o fortranposix.


Contents


Variables

Type Visibility Attributes Name Initial
integer(kind=mode_t), public, bind(c,name="0") :: ACCESSPERMS
integer(kind=mode_t), public, bind(c,name="0") :: DEFFILEMODE
integer(kind=c_int), public, parameter :: F_OK = 0
integer(kind=mode_t), public, bind(c,name="0") :: RWX_G
integer(kind=mode_t), public, bind(c,name="0") :: RWX_O
integer(kind=mode_t), public, bind(c,name="0") :: RWX_U
integer(kind=mode_t), public, bind(c,name="0") :: R_GRP
integer(kind=c_int), public, parameter :: R_OK = 4
integer(kind=mode_t), public, bind(c,name="0") :: R_OTH
integer(kind=mode_t), public, bind(c,name="0") :: R_USR
integer(kind=mode_t), public, bind(c,name="0") :: W_GRP
integer(kind=c_int), public, parameter :: W_OK = 2
integer(kind=mode_t), public, bind(c,name="0") :: W_OTH
integer(kind=mode_t), public, bind(c,name="0") :: W_USR
integer(kind=mode_t), public, bind(c,name="0") :: X_GRP
integer(kind=c_int), public, parameter :: X_OK = 1
integer(kind=mode_t), public, bind(c,name="0") :: X_OTH
integer(kind=mode_t), public, bind(c,name="0") :: X_USR
integer, public, parameter :: mode_t = int32

Interfaces

interface

  • public function system_alarm(seconds) bind(c, name="alarm")

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), value :: seconds

    Return Value integer(kind=c_int)

interface

  • public function system_calloc(nelem, elsize) bind(c, name="calloc")

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=C_SIZE_T), value :: nelem
    integer(kind=C_SIZE_T), value :: elsize

    Return Value integer(kind=C_INTPTR_T)

interface

  • public pure function system_clock() bind(c, name="clock")

    Arguments

    None

    Return Value integer(kind=C_LONG)

interface

NAME

system_errno(3f) - [M_system:ERROR_PROCESSING] C error return value
(LICENSE:PD)

SYNOPSIS

integer(kind=c_int) function system_errno()

DESCRIPTION

Many C routines return an error code which can be queried by errno.
The M_system(3fm) is primarily composed of Fortran routines that
call C routines. In the cases where an error code is returned vi
system_errno(3f) these routines will indicate it.

EXAMPLE

Sample program:

program demo_system_errno
use M_system, only : system_errno, system_unlink, system_perror
implicit none
integer :: stat
stat=system_unlink('not there/OR/anywhere')
if(stat.ne.0)then
        write(*,*)'err=',system_errno()
        call system_perror('*demo_system_errno*')
endif
end program demo_system_errno

Typical Results:

err=           2
*demo_system_errno*: No such file or directory
  • public function system_errno() bind(C,name="my_errno")

    Arguments

    None

    Return Value integer(kind=c_int)

interface

  • public subroutine system_free(ptr) bind(c, name="0")

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=C_INTPTR_T), value :: ptr

interface

NAME

system_getegid(3f) - [M_system:QUERY] get the effective group ID (GID) of
                     current process from Fortran by calling getegid(3c)
(LICENSE:PD)

SYNOPSIS

integer(kind=c_int) function system_getegid()

DESCRIPTION

    The getegid() function returns the effective group ID of the
    calling process.

RETURN VALUE

    The getegid() should always be successful and no return value is
    reserved to indicate an error.

ERRORS

    No errors are defined.

SEE ALSO

    getegid(), system_geteuid(), getuid(), setegid(), seteuid(), setgid(),
    setregid(), setreuid(), setuid()

EXAMPLE

Get group ID from Fortran

program demo_system_getegid
use M_system, only : system_getegid
implicit none
   write(*,*)'GID=',system_getegid()
end program demo_system_getegid
  • public function system_getegid() bind(C,name="getegid")

    Arguments

    None

    Return Value integer(kind=c_int)

interface

NAME

system_geteuid(3f) - [M_system:QUERY] get effective UID of current
                     process from Fortran by calling geteuid(3c)
(LICENSE:PD)

SYNOPSIS

integer(kind=c_int) function system_geteuid()

DESCRIPTION

    The system_geteuid(3f) function shall return the effective user
    ID of the calling process. The geteuid() function shall always be
    successful and no return value is reserved to indicate the error.

EXAMPLE

Get group ID from Fortran:

program demo_system_geteuid
use M_system, only : system_geteuid
implicit none
   write(*,*)'EFFECTIVE UID=',system_geteuid()
end program demo_system_geteuid
  • public function system_geteuid() bind(C,name="geteuid")

    Arguments

    None

    Return Value integer(kind=c_int)

interface

NAME

system_getgid(3f) - [M_system:QUERY] get the real group ID (GID) of
                 current process from Fortran by calling getgid(3c)
(LICENSE:PD)

SYNOPSIS

integer(kind=c_int) function system_getgid()

DESCRIPTION

    The getgid() function returns the real group ID of the calling
    process.

RETURN VALUE

    The getgid() should always be successful and no return value is
    reserved to indicate an error.

ERRORS

    No errors are defined.

SEE ALSO

    getegid(), system_geteuid(), getuid(), setegid(), seteuid(), setgid(),
    setregid(), setreuid(), setuid()

EXAMPLE

Get group ID from Fortran

program demo_system_getgid
use M_system, only : system_getgid
implicit none
   write(*,*)'GID=',system_getgid()
end program demo_system_getgid
  • public function system_getgid() bind(C,name="getgid")

    Arguments

    None

    Return Value integer(kind=c_int)

interface

NAME

system_getpid(3f) - [M_system:QUERY] get PID (process ID) of current
                    process from Fortran by calling getpid(3c)
(LICENSE:PD)

SYNOPSIS

integer function system_getpid()

DESCRIPTION

    The system_getpid() function returns the process ID of the
    calling process.

RETURN VALUE

    The value returned is the integer process ID. The system_getpid()
    function shall always be successful and no return value is reserved
    to indicate an error.

EXAMPLE

Get process PID from Fortran

program demo_system_getpid
use M_system, only : system_getpid
implicit none
   write(*,*)'PID=',system_getpid()
end program demo_system_getpid
  • public pure function system_getpid() bind(C,name="getpid")

    Arguments

    None

    Return Value integer(kind=c_int)

interface

NAME

system_getppid(3f) - [M_system:QUERY] get parent process ID (PPID) of
                     current process from Fortran by calling getppid(3c)
(LICENSE:PD)

SYNOPSIS

integer(kind=c_int) function system_getppid()

DESCRIPTION

    The system_getppid() function returns the parent process ID of
    the calling process.

RETURN VALUE

    The system_getppid() function should always be successful and no
    return value is reserved to indicate an error.

ERRORS

    No errors are defined.

SEE ALSO

    exec, fork(), getpgid(), getpgrp(), getpid(), kill(),
    setpgid(), setsid()

EXAMPLE

Get parent process PID (PPID) from Fortran

program demo_system_getppid
use M_system, only : system_getppid
implicit none
   write(*,*)'PPID=',system_getppid()
end program demo_system_getppid
  • public function system_getppid() bind(C,name="getppid")

    Arguments

    None

    Return Value integer(kind=c_int)

interface

NAME

    system_getsid(3f) - [M_system:QUERY] get the process group ID of
                        a session leader
    (LICENSE:PD)

SYNOPSIS

    integer(kind=c_int) function system_getsid(pid)
    integer(kind=c_int) :: pid

DESCRIPTION

    The system_getsid() function obtains the process group ID of the
    process that is the session leader of the process specified by pid.
    If pid is 0, it specifies the calling process.

RETURN VALUE

    Upon successful completion, system_getsid() shall return
    the process group ID of the session leader of the specified
    process. Otherwise, it shall return -1 and set errno to indicate
    the error.

EXAMPLE

Get SID from Fortran

program demo_system_getsid
use M_system,      only : system_getsid
use ISO_C_BINDING, only : c_int
implicit none
   write(*,*)'SID=',system_getsid(0_c_int)
end program demo_system_getsid
  • public function system_getsid(c_pid) bind(C,name="getsid")

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int) :: c_pid

    Return Value integer(kind=c_int)

interface

NAME

system_getuid(3f) - [M_system:QUERY] get real UID of current process
                    from Fortran by calling getuid(3c)
(LICENSE:PD)

SYNOPSIS

integer(kind=c_int) function system_getuid()

DESCRIPTION

    The system_getuid(3f) function shall return the real user ID
    of the calling process. The getuid() function shall always be
    successful and no return value is reserved to indicate the error.

EXAMPLE

Get group ID from Fortran:

program demo_system_getuid
use M_system, only : system_getuid
implicit none
   write(*,*)'UID=',system_getuid()
end program demo_system_getuid

Results:

UID=      197609
  • public function system_getuid() bind(C,name="getuid")

    Arguments

    None

    Return Value integer(kind=c_int)

interface

  • public subroutine system_initenv() bind(C,NAME="0")

    Arguments

    None

interface

NAME

system_kill(3f) - [M_system:SIGNALS] send a signal to a process or
                  a group of processes
(LICENSE:PD)

SYNOPSIS

integer(kind=c_int) function system_kill(pid,sig)

   integer,intent(in) :: pid
   integer,intent(in) :: sig

DESCRIPTION

The kill() function shall send a signal to a process or a group of
processes specified by pid. The signal to be sent is specified by
sig and is either one from the list given in <signal.h> or 0. If sig
is 0 (the null signal), error checking is performed but no signal
is actually sent. The null signal can be used to check the validity
of pid.

For a process to have permission to send a signal to a process
designated by pid, unless the sending process has appropriate
privileges, the real or effective user ID of the sending process
shall match the real or saved set-user-ID of the receiving process.

If pid is greater than 0, sig shall be sent to the process whose
process ID is equal to pid.

If pid is 0, sig shall be sent to all processes (excluding an
unspecified set of system processes) whose process group ID is equal
to the process group ID of the sender, and for which the process has
permission to send a signal.

If pid is -1, sig shall be sent to all processes (excluding an
unspecified set of system processes) for which the process has
permission to send that signal.

If pid is negative, but not -1, sig shall be sent to all processes
(excluding an unspecified set of system processes) whose process
group ID is equal to the absolute value of pid, and for which the
process has permission to send a signal.

If the value of pid causes sig to be generated for the sending process,
and if sig is not blocked for the calling thread and if no other
thread has sig unblocked or is waiting in a sigwait() function for
sig, either sig or at least one pending unblocked signal shall be
delivered to the sending thread before kill() returns.

The user ID tests described above shall not be applied when sending
SIGCONT to a process that is a member of the same session as the
sending process.

An implementation that provides extended security controls may impose
further implementation-defined restrictions on the sending of signals,
including the null signal. In particular, the system may deny the
existence of some or all of the processes specified by pid.

The kill() function is successful if the process has permission to
send sig to any of the processes specified by pid. If kill() fails,
no signal shall be sent.

RETURN VALUE

Upon successful completion, 0 shall be returned. Otherwise, -1 shall be
returned and errno set to indicate the error.

ERRORS

The kill() function shall fail if:

EINVAL  The value of the sig argument is an invalid or unsupported
        signal number.
EPERM   The process does not have permission to send the signal to
        any receiving process.
ESRCH   No process or process group can be found corresponding to
        that specified by pid. The following sections are informative.

EXAMPLE

Sample program:

program demo_system_kill
use M_system, only : system_kill
use M_system, only : system_perror
implicit none
integer           :: i,pid,ios,ierr,signal=9
character(len=80) :: argument

   do i=1,command_argument_count()
      ! get arguments from command line
      call get_command_argument(i, argument)
      ! convert arguments to integers assuming they are PID numbers
      read(argument,'(i80)',iostat=ios) pid
      if(ios.ne.0)then
         write(*,*)'bad PID=',trim(argument)
      else
         write(*,*)'kill SIGNAL=',signal,' PID=',pid
      ! send signal SIGNAL to pid PID
         ierr=system_kill(pid,signal)
      ! write message if an error was detected
         if(ierr.ne.0)then
            call system_perror('*demo_system_kill*')
         endif
      endif
   enddo
end program demo_system_kill

SEE ALSO

getpid(), raise(), setsid(), sigaction(), sigqueue(),
  • public function system_kill(c_pid, c_signal) result(c_ierr) bind(c,name="kill")

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), intent(in), value :: c_pid
    integer(kind=c_int), intent(in), value :: c_signal

    Return Value integer(kind=c_int)

interface

  • public function system_malloc(size) bind(c, name="malloc")

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=C_SIZE_T), value :: size

    Return Value integer(kind=C_INTPTR_T)

interface

  • public subroutine system_memcpy(dest, src, n) bind(C,name="0")

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=C_INTPTR_T), value :: dest
    integer(kind=C_INTPTR_T), value :: src
    integer(kind=C_SIZE_T), value :: n

interface

NAME

system_rand(3f) - [M_system:PSEUDORANDOM] call pseudo-random number
                  generator rand(3c)
(LICENSE:PD)

SYNOPSIS

integer(kind=c_int) :: function system_rand()

DESCRIPTION

Use rand(3c) to generate pseudo-random numbers.

EXAMPLE

Sample program:

   program demo_system_rand
   use M_system, only : system_srand, system_rand
   implicit none
   integer :: i

   call system_srand(1001)
   do i=1,10
      write(*,*)system_rand()
   enddo
   write(*,*)

   end program demo_system_rand

expected results:

  1512084687
  1329390995
  1874040748
    60731048
   239808950
  2017891911
    22055588
  1105177318
   347750200
  1729645355

  1512084687
  1329390995
  1874040748
    60731048
   239808950
  2017891911
    22055588
  1105177318
   347750200
  1729645355
  • public function system_rand() bind(C,name="rand")

    Arguments

    None

    Return Value integer(kind=c_int)

interface

  • public function system_realloc(ptr, size) bind(c, name="realloc")

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=C_INTPTR_T), value :: ptr
    integer(kind=C_SIZE_T), value :: size

    Return Value integer(kind=C_INTPTR_T)

interface

NAME

    system_setsid(3f) - [M_system:QUERY] create session and set the
                        process group ID of a session leader
    (LICENSE:PD)

SYNOPSIS

    integer(kind=c_int) function system_setsid(pid)
    integer(kind=c_int) :: pid

DESCRIPTION

    The setsid() function creates a new session, if the calling
    process is not a process group leader. Upon return the calling
    process shall be the session leader of this new session, shall be
    the process group leader of a new process group, and shall have no
    controlling terminal. The process group ID of the calling process
    shall be set equal to the process ID of the calling process. The
    calling process shall be the only process in the new process
    group and the only process in the new session.

RETURN VALUE

    Upon successful completion, setsid() shall return the value
    of the new process group ID of the calling process. Otherwise,
    it shall return -1 and set errno to indicate the error.

ERRORS

    The setsid() function shall fail if:

     o The calling process is already a process group leader
     o the process group ID of a process other than the calling
       process matches the process ID of the calling process.

EXAMPLE

Set SID from Fortran

program demo_system_setsid
use M_system,      only : system_setsid
implicit none
   write(*,*)'SID=',system_setsid()
end program demo_system_setsid
  • public function system_setsid() bind(C,name="setsid")

    Arguments

    None

    Return Value integer(kind=c_int)

interface

NAME

system_srand(3f) - [M_system:PSEUDORANDOM] set seed for pseudo-random
                   number generator system_rand(3f)
(LICENSE:PD)

SYNOPSIS

subroutine system_srand()

DESCRIPTION

system_srand(3f) calls the C routine srand(3c) The
srand(3c)/system_srand(3f) function uses its argument as the seed
for a new sequence of pseudo-random integers to be returned by
system_rand(3f)/rand(3c). These sequences are repeatable by calling
system_srand(3f) with the same seed value. If no seed value is
provided, the system_rand(3f) function is automatically seeded with
a value of 1.

EXAMPLE

Sample program:

   program demo_system_srand
   use M_system, only : system_srand, system_rand
   implicit none
   integer :: i,j
   do j=1,2
      call system_srand(1001)
      do i=1,10
         write(*,*)system_rand()
      enddo
      write(*,*)
   enddo
   end program demo_system_srand

expected results:

  1512084687
  1329390995
  1874040748
    60731048
   239808950
  2017891911
    22055588
  1105177318
   347750200
  1729645355

  1512084687
  1329390995
  1874040748
    60731048
   239808950
  2017891911
    22055588
  1105177318
   347750200
  1729645355

SEE ALSO

drand48(3c), random(3c)
  • public subroutine system_srand(seed) bind(c,name="0")

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), intent(in) :: seed

interface

  • public function system_time(tloc) bind(c, name="time")

    Arguments

    Type IntentOptional Attributes Name
    type(C_PTR), value :: tloc

    Return Value integer(kind=C_LONG)


Functions

public impure elemental function system_access(pathname, amode)

elemental impure logical function system_access(pathname,amode)

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: pathname
integer, intent(in) :: amode

Return Value logical

public function system_chmod(filename, mode) result(ierr)

Sample program:

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename
integer, intent(in), value :: mode

Return Value integer

public impure elemental function system_chown(dirname, owner, group)

elemental impure logical function system_chown(path,owner,group)

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: dirname
integer, intent(in) :: owner
integer, intent(in) :: group

Return Value logical

public function system_dir(directory, pattern, ignorecase)

function system_dir(directory,pattern,ignorecase)

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in), optional :: directory
character(len=*), intent(in), optional :: pattern
logical, intent(in), optional :: ignorecase

Return Value character(len=:), allocatable, (:)

public function system_getenv(name, default) result(value)

Sample setting an environment variable from Fortran:

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name
character(len=*), intent(in), optional :: default

Return Value character(len=:), allocatable

public function system_getgrgid(gid) result(gname)

function system_getgrgid(gid) result (gname)

Read more…

Arguments

Type IntentOptional Attributes Name
class(*), intent(in) :: gid

Return Value character(len=:), allocatable

public function system_getlogin() result(fname)

function system_getlogin() result (fname)

Read more…

Arguments

None

Return Value character(len=:), allocatable

public function system_getpwuid(uid) result(uname)

function system_getpwuid(uid) result (uname)

Read more…

Arguments

Type IntentOptional Attributes Name
class(*), intent(in) :: uid

Return Value character(len=:), allocatable

public function system_getumask() result(umask_value)

integer function system_getumask() result (umask_value)

Read more…

Arguments

None

Return Value integer

public impure elemental function system_isblk(pathname)

system_isblk(3f) - [M_system:QUERY_FILE] checks if argument is a block device (LICENSE:PD)

Read more…

Arguments

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

Return Value logical

public impure elemental function system_ischr(pathname)

elemental impure logical function system_ischr(pathname)

Read more…

Arguments

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

Return Value logical

public impure elemental function system_isdir(dirname)

elemental impure logical function system_isdir(pathname)

Read more…

Arguments

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

Return Value logical

public impure elemental function system_isfifo(pathname)

elemental impure logical function system_isfifo(pathname)

Read more…

Arguments

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

Return Value logical

public impure elemental function system_islnk(pathname)

Sample program:

Read more…

Arguments

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

Return Value logical

public impure elemental function system_isreg(pathname)

elemental impure logical function system_isreg(pathname)

Read more…

Arguments

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

Return Value logical

public function system_issock(pathname)

elemental impure logical function system_issock(pathname)

Read more…

Arguments

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

Return Value logical

public impure elemental function system_link(oldname, newname) result(ierr)

Creating a Link to a File

Read more…

Arguments

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

Return Value integer

public function system_mkdir(dirname, mode) result(ierr)

Sample program:

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: dirname
integer, intent(in) :: mode

Return Value integer

public function system_mkfifo(pathname, mode) result(err)

function system_mkfifo(pathname,mode) result(ierr)

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: pathname
integer, intent(in) :: mode

Return Value integer

public function system_perm(mode) result(perms)

function system_perm(mode) result (perms)

Read more…

Arguments

Type IntentOptional Attributes Name
class(*), intent(in) :: mode

Return Value character(len=:), allocatable

public function system_readenv() result(string)

Sample program:

Read more…

Arguments

None

Return Value character(len=:), allocatable

public function system_realpath(input) result(string)

Sample program:

Read more…

Arguments

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

Return Value character(len=:), allocatable

public impure elemental function system_remove(path) result(err)

elemental impure function system_remove(path) result(err)

Read more…

Arguments

Type IntentOptional Attributes Name
character, intent(in) :: path

Return Value integer(kind=c_int)

public function system_rename(input, output) result(ierr)

function system_rename(input,output) result(ierr)

Read more…

Arguments

Type IntentOptional Attributes Name
character, intent(in) :: input
character, intent(in) :: output

Return Value integer

public function system_rmdir(dirname) result(err)

Sample program:

Read more…

Arguments

Type IntentOptional Attributes Name
character, intent(in) :: dirname

Return Value integer(kind=c_int)

public function system_setumask(umask_value) result(old_umask)

Sample program

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: umask_value

Return Value integer

public function system_system(command)

Sample program

Read more…

Arguments

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

Return Value integer

public impure elemental function system_unlink(fname) result(ierr)

Removing a link to a file

Read more…

Arguments

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

Return Value integer

public function system_utime(pathname, times)

The utime() function may fail if:

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: pathname
integer, intent(in), optional :: times(2)

Return Value logical


Subroutines

public subroutine fileglob(glob, list)

fileglob(3f) - [M_system:QUERY_FILE] Read output of an ls(1) command from Fortran (LICENSE:PD)

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: glob
character(len=*), pointer :: list(:)

public subroutine set_environment_variable(NAME, VALUE, STATUS)

subroutine set_environment_variable(NAME, VALUE, STATUS)

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*) :: NAME
character(len=*) :: VALUE
integer, intent(out), optional :: STATUS

public subroutine system_chdir(path, err)

Sample run output:

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*) :: path
integer, intent(out), optional :: err

public subroutine system_clearenv(ierr)

Sample program:

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(out), optional :: ierr

public subroutine system_closedir(dir, ierr)

Sample program

Read more…

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: dir
integer, intent(out), optional :: ierr

public subroutine system_cpu_time(total, user, system)

Sample program:

Read more…

Arguments

Type IntentOptional Attributes Name
real, intent(out) :: total
real, intent(out) :: user
real, intent(out) :: system

public subroutine system_getcwd(output, ierr)

Sample program:

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=:), intent(out), allocatable :: output
integer, intent(out) :: ierr

public subroutine system_gethostname(NAME, IERR)

Sample program:

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=:), intent(out), allocatable :: NAME
integer, intent(out) :: IERR

public subroutine system_opendir(dirname, dir, ierr)

subroutine system_opendir(dirname,dir,ierr)

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: dirname
type(c_ptr) :: dir
integer, intent(out), optional :: ierr

public subroutine system_perror(prefix)

Sample program:

Read more…

Arguments

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

public subroutine system_putenv(string, err)

Sample setting an environment variable from Fortran:

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: string
integer, intent(out), optional :: err

public subroutine system_readdir(dir, filename, ierr)

subroutine system_readdir(dir,filename,ierr)

Read more…

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: dir
character(len=:), intent(out), allocatable :: filename
integer, intent(out) :: ierr

public subroutine system_rewinddir(dir)

Sample program:

Read more…

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: dir

public subroutine system_signal(signum, handler_routine)

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: signum
procedure(handler), optional :: handler_routine

public subroutine system_stat(pathname, values, ierr)

CALL SYSTEM_STAT(NAME, VALUES [, STATUS],[DEBUG])

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: pathname
integer(kind=int64), intent(out) :: values(13)
integer, intent(out), optional :: ierr

public subroutine system_uname(WHICH, NAMEOUT)

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

Read more…

Arguments

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

public subroutine system_unsetenv(name, ierr)

subroutine system_unsetenv(name,ierr)

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name
integer, intent(out), optional :: ierr