fpm_environment Module

This module contains procedures that interact with the programming environment.

  • [get_os_type] – Determine the OS type
  • [get_env] – return the value of an environment variable


Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: OS_CYGWIN = 4
integer, public, parameter :: OS_FREEBSD = 6
integer, public, parameter :: OS_LINUX = 1
integer, public, parameter :: OS_MACOS = 2
integer, public, parameter :: OS_OPENBSD = 7
integer, public, parameter :: OS_SOLARIS = 5
integer, public, parameter :: OS_UNKNOWN = 0
integer, public, parameter :: OS_WINDOWS = 3

Functions

public pure function OS_NAME(os)

Return string describing the OS type flag

Arguments

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

Return Value character(len=:), allocatable

public function delete_env(name) result(success)

Deletes an environment variable for the current environment using the C standard library Returns an error if the variable did not exist in the first place

Read more…

Arguments

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

Variable name

Return Value logical

public function get_command_arguments_quoted() result(args)

Arguments

None

Return Value character(len=:), allocatable

public function get_env(NAME, DEFAULT) result(VALUE)

get named environment variable value. It it is blank or not set return the optional default value !print , NAME, ” is not defined in the environment. Strange…” !print , “This processor doesn’t support environment variables. Boooh!”

Arguments

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

name of environment variable to get the value of

character(len=*), intent(in), optional :: DEFAULT

default value to return if the requested value is undefined or blank

Return Value character(len=:), allocatable

the returned value

public function get_os_type() result(r)

Determine the OS type

Read more…

Arguments

None

Return Value integer

public function os_is_unix(os)

Compare the output of get_os_type or the optional passed INTEGER value to the value for OS_WINDOWS and return .TRUE. if they match and .FALSE. otherwise

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional :: os

Return Value logical

public function separator() result(sep)

sample usage

Read more…

Arguments

None

Return Value character(len=1)

ifort_bug*!character(len=1),save :: sep_cache=’ ‘

public function set_env(name, value, overwrite)

Set an environment variable for the current environment using the C standard library

Read more…

Arguments

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

Variable name

character(len=*), intent(in) :: value

Variable value

logical, intent(in), optional :: overwrite

Should a former value be overwritten? default = .true.

Return Value logical