# flibs/platform(n) 1.0 "flibs"

## NAME

flibs/platform - Platform-dependent routines and features

## TABLE OF CONTENTS

TABLE OF CONTENTS
SYNOPSIS
DESCRIPTION
ROUTINES
COMPILING
COPYRIGHT

## SYNOPSIS

use platform
platform_system( command, status )
os_type = platform_get_os()
platform_type = platform_get_platform()
call platform_get_environment_variable( envvar, value)

## DESCRIPTION

The platform contains parameters to identify the platform the program is running on and several routines to interact with the operating system, for instance:

- The parameter PLATFORM_OS identifies the operating system and the parameter PLATFORM_PLATFORM identifies the general category.
- The subroutine platform_system() hides the platform-specific details of running an external command or program.

## ROUTINES

The module contains the following routines:

use platform
  To import the subroutines, use this module.
platform_system( command, status )
  Run an external command or program, optionally retrieving the status of that command.
  character(len=*) command
    Command to run (note: this is quite likely platform-dependent)
  integer status
    Optional argument returning the status (note: the information contained in it is not very reliable - some systems do not give any informatio)
os_type = platform_get_os()
  Return the type of operating system, one of: PLATFORM_OS_WINDOWS_95, PLATFORM_OS_WINDOWS_NT, PLATFORM_OS_MACOS, PLATFORM_OS_SUNOS, PLATFORM_OS_LINUX, PLATFORM_OS_UNIX
platform_type = platform_get_platform()
  Return the category of platform, one of: PLATFORM_PLATFORM_WINDOWS, PLATFORM_PLATFORM_MAC, PLATFORM_PLATFORM_UNIX
call platform_get_environment_variable( envvar, value)
  Retrieve the value of an environment variable. There is no indication of whether the variable indeed exists and it is up to the calling program to provide a string argument sufficiently long to hold the value.
  character(len=*) envvar
    The name of the environment variable (note: this is case-sensitive on some platforms, case-insensitive on others. This is entirely up to the platform).
  character(len=*) envvar
    Value of the environment variable upon return. As the underlying routines give no indication of its existence, it is probably best to fill it with a known value first (like: "????") to check it.

## COMPILING

There is nothing magic about this module: the platform-specific information has to be provided at compile time via preprocessor macros. As almost all Fortran compilers offer a preprocessor option, this should cause little trouble. The makefile for this module contains a template for how to do this.

Operating System dependency:

It should be compiled by defining several preprocessing macros, to select from the various operating systems and compilers for which this module is made for. Choose your OS between one of these:

_OS_WINDOWS_95 , _OS_WINDOWS_NT , _OS_MAC , _OS_SUN , _OS_LINUX , _OS_UNIX

System fortran extension:

Depending on the compiler, the SYSTEM fortran extension is provided as a subroutine or a function. See in your manual for the specific settings. For example, this is a short list of compilers and their particular SYSTEM provided:

- subroutine: Intel Fortran, gfortran
- function : g95.

Choose your SYSTEM version between one of these:

_PLATFORM_SYSTEM_SUBROUTINE , _PLATFORM_SYSTEM_FUNCTION Environment variables extension: The fortran 2003 standard introduces a standard way of accessing to the environment variables. Older compilers does not match that standard but provide extensions to access to environment variables. Choose your option between one of these:

_INTEL_FORTRAN_PORTABILITY_ROUTINES , _FORTRAN_2003

## COPYRIGHT

Copyright © 2005 Arjen Markus <arjenmarkus@sourceforge.net>