Skip to content

penf_stringify ​

PENF string-to-number (and viceversa) facility.

Source: src/lib/penf_stringify.F90

Dependencies

Contents ​

Interfaces ​

str_ascii ​

Convert string of any kind to ASCII string.

Module procedures: str_ascii_default

str_ucs4 ​

Convert string of any kind to UCS4 string.

Module procedures: str_ucs4_default

str ​

Convert number (real and integer) to string (number to string type casting).

Module procedures: strf_R8P, str_R8P, strf_R4P, str_R4P, strf_I8P, str_I8P, strf_I4P, str_I4P, strf_I2P, str_I2P, strf_I1P, str_I1P, str_bol, str_a_R8P, str_a_R4P, str_a_I8P, str_a_I4P, str_a_I2P, str_a_I1P

strz ​

Convert integer, to string, prefixing with the right number of zeros (integer to string type casting with zero padding).

Module procedures: strz_I8P, strz_I4P, strz_I2P, strz_I1P

cton ​

Convert string to number (real and integer, string to number type casting).

Module procedures: ctor_R8P, ctor_R4P, ctoi_I8P, ctoi_I4P, ctoi_I2P, ctoi_I1P

bstr ​

Convert number (real and integer) to bit-string (number to bit-string type casting).

Module procedures: bstr_R8P, bstr_R4P, bstr_I8P, bstr_I4P, bstr_I2P, bstr_I1P

bcton ​

Convert bit-string to number (real and integer, bit-string to number type casting).

Module procedures: bctor_R8P, bctor_R4P, bctoi_I8P, bctoi_I4P, bctoi_I2P, bctoi_I1P

Functions ​

str_ascii_default ​

Convert string of default kind to ASCII string.

fortran
 use penf
 character(len=:, kind=ASCII), allocatable :: string
 string = str_ascii('I was DEFAULT kind, but now I am ASCII')
 print "(A)", string

Attributes: pure

Returns: character(kind=ASCII, len=:)

fortran
function str_ascii_default(input) result(output)

Arguments

NameTypeIntentAttributesDescription
inputcharacter(len=*)inInput string of default kind.

str_ascii_ascii ​

Convert string of ASCII kind to ASCII string, just for convenience in sanitize strings.

fortran
 use penf
 character(len=:, kind=ASCII), allocatable :: string
 string = str_ascii('I was ASCII kind and I am still ASCII')
 print "(A)", string

Attributes: pure

Returns: character(kind=ASCII, len=:)

fortran
function str_ascii_ascii(input) result(output)

Arguments

NameTypeIntentAttributesDescription
inputcharacter(kind=ASCII, len=*)inInput string of ASCII kind.

str_ascii_ucs4 ​

Convert string of UCS4 kind to ASCII string.

fortran
 use penf
 character(len=:, kind=ASCII), allocatable :: string
 string = str_ascii(UCS4_'I was UCS4 kind, but now I am ASCII')
 print "(A)", string

Attributes: pure

Returns: character(kind=ASCII, len=:)

fortran
function str_ascii_ucs4(input) result(output)

Arguments

NameTypeIntentAttributesDescription
inputcharacter(kind=UCS4, len=*)inInput string of UCS4 kind.

str_ucs4_default ​

Convert string of default kind to UCS4 string.

fortran
 use penf
 character(len=:, kind=UCS4), allocatable :: string
 string = str_ascii('I was DEFAULT kind, but now I am UCS4')
 print "(A)", string

Attributes: pure

Returns: character(kind=UCS4, len=:)

fortran
function str_ucs4_default(input) result(output)

Arguments

NameTypeIntentAttributesDescription
inputcharacter(len=*)inInput string of default kind.

str_ucs4_ascii ​

Convert string of ASCII kind to UCS4 string.

fortran
 use penf
 character(len=:, kind=UCS4), allocatable :: string
 string = str_ascii(ASCII_'I was ASCII kind, but now I am UCS4')
 print "(A)", string

Attributes: pure

Returns: character(kind=UCS4, len=:)

fortran
function str_ucs4_ascii(input) result(output)

Arguments

NameTypeIntentAttributesDescription
inputcharacter(kind=ASCII, len=*)inInput string of ASCII kind.

str_ucs4_ucs4 ​

Convert string of UCS4 kind to UCS4 string, just for convenience in sanitize strings.

fortran
 use penf
 character(len=:, kind=UCS4), allocatable :: string
 string = str_ascii(UCS4_'I was UCS4 kind and I am still UCS4')
 print "(A)", string

Attributes: pure

Returns: character(kind=UCS4, len=:)

fortran
function str_ucs4_ucs4(input) result(output)

Arguments

NameTypeIntentAttributesDescription
inputcharacter(kind=UCS4, len=*)inInput string of UCS4 kind.

strf_R16P ​

Convert real to string.

fortran
 use penf
 print "(A)", str(fm=FR16P, n=1._R16P)

Attributes: elemental

Returns: character(len=DR16P)

fortran
function strf_R16P(fm, n) result(str)

Arguments

NameTypeIntentAttributesDescription
fmcharacter(len=*)inFormat different from the standard for the kind.
nreal(kind=R16P)inReal to be converted.

strf_R8P ​

Convert real to string.

fortran
 use penf
 print "(A)", str(fm=FR8P, n=1._R8P)

Attributes: elemental

Returns: character(len=DR8P)

fortran
function strf_R8P(fm, n) result(str)

Arguments

NameTypeIntentAttributesDescription
fmcharacter(len=*)inFormat different from the standard for the kind.
nreal(kind=R8P)inReal to be converted.

strf_R4P ​

Convert real to string.

fortran
 use penf
 print "(A)", str(fm=FR4P, n=1._R4P)

Attributes: elemental

Returns: character(len=DR4P)

fortran
function strf_R4P(fm, n) result(str)

Arguments

NameTypeIntentAttributesDescription
fmcharacter(len=*)inFormat different from the standard for the kind.
nreal(kind=R4P)inReal to be converted.

strf_I8P ​

Convert integer to string.

fortran
 use penf
 print "(A)", str(fm=FI8P, n=1_I8P)

Attributes: elemental

Returns: character(len=DI8P)

fortran
function strf_I8P(fm, n) result(str)

Arguments

NameTypeIntentAttributesDescription
fmcharacter(len=*)inFormat different from the standard for the kind.
ninteger(kind=I8P)inInteger to be converted.

strf_I4P ​

Convert integer to string.

fortran
 use penf
 print "(A)", str(fm=FI4P, n=1_I4P)

Attributes: elemental

Returns: character(len=DI4P)

fortran
function strf_I4P(fm, n) result(str)

Arguments

NameTypeIntentAttributesDescription
fmcharacter(len=*)inFormat different from the standard for the kind.
ninteger(kind=I4P)inInteger to be converted.

strf_I2P ​

Convert integer to string.

fortran
 use penf
 print "(A)", str(fm=FI2P, n=1_I2P)

Attributes: elemental

Returns: character(len=DI2P)

fortran
function strf_I2P(fm, n) result(str)

Arguments

NameTypeIntentAttributesDescription
fmcharacter(len=*)inFormat different from the standard for the kind.
ninteger(kind=I2P)inInteger to be converted.

strf_I1P ​

Convert integer to string.

fortran
 use penf
 print "(A)", str(fm=FI1P, n=1_I1P)

Attributes: elemental

Returns: character(len=DI1P)

fortran
function strf_I1P(fm, n) result(str)

Arguments

NameTypeIntentAttributesDescription
fmcharacter(len=*)inFormat different from the standard for the kind.
ninteger(kind=I1P)inInteger to be converted.

str_R16P ​

Convert real to string.

The string returned is read back exactly: by default it has the fixed width format FR16P, that has the significant digits always sufficient for an exact read back.

If compact is true the string returned is the shortest one that is read back exactly: the significant digits are increased until the number read back is equal to the input one. The plain decimal notation is used for decimal exponents in [-5, 15], the scientific one otherwise.

fortran
 use penf
 print "(A)", str(n=-1._R16P)
fortran
 use penf
 print "(A)", str(n=-1._R16P, no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=-1._R16P, compact=.true.)
fortran
 use penf
 print "(A)", str(n=0.1_R16P, compact=.true.)
fortran
 use penf
 print "(A)", str(n=-1._R16P, no_sign=.false.)
fortran
 use penf
 real(R16P) :: x(1:5)
 integer :: i
 logical :: exact
 x = [huge(1._R16P), tiny(1._R16P), 0.1_R16P, -1._R16P/3._R16P, 0._R16P]
 exact = .true.
 do i=1, 5
   exact = exact.and.(cton(str=str(n=x(i)), knd=1._R16P)==x(i))
   exact = exact.and.(cton(str=str(n=x(i), compact=.true.), knd=1._R16P)==x(i))
 enddo
 print "(L1)", exact

Attributes: elemental

Returns: character(len=DR16P)

fortran
function str_R16P(n, no_sign, compact) result(str)

Arguments

NameTypeIntentAttributesDescription
nreal(kind=R16P)inReal to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.
compactlogicalinoptionalFlag for the shortest exact string.

Call graph

str_R8P ​

Convert real to string.

The string returned is read back exactly: by default it has the fixed width format FR8P, that has the significant digits always sufficient for an exact read back.

If compact is true the string returned is the shortest one that is read back exactly: the significant digits are increased until the number read back is equal to the input one. The plain decimal notation is used for decimal exponents in [-5, 15], the scientific one otherwise.

fortran
 use penf
 print "(A)", str(n=-1._R8P)
fortran
 use penf
 print "(A)", str(n=-1._R8P, no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=-1._R8P, compact=.true.)
fortran
 use penf
 print "(A)", str(n=0.1_R8P, compact=.true.)
fortran
 use penf
 print "(A)", str(n=-1._R8P, no_sign=.false.)
fortran
 use penf
 real(R8P) :: x(1:5)
 integer :: i
 logical :: exact
 x = [huge(1._R8P), tiny(1._R8P), 0.1_R8P, -1._R8P/3._R8P, 0._R8P]
 exact = .true.
 do i=1, 5
   exact = exact.and.(cton(str=str(n=x(i)), knd=1._R8P)==x(i))
   exact = exact.and.(cton(str=str(n=x(i), compact=.true.), knd=1._R8P)==x(i))
 enddo
 print "(L1)", exact

Attributes: elemental

Returns: character(len=DR8P)

fortran
function str_R8P(n, no_sign, compact) result(str)

Arguments

NameTypeIntentAttributesDescription
nreal(kind=R8P)inReal to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.
compactlogicalinoptionalFlag for the shortest exact string.

Call graph

str_R4P ​

Convert real to string.

The string returned is read back exactly: by default it has the fixed width format FR4P, that has the significant digits always sufficient for an exact read back.

If compact is true the string returned is the shortest one that is read back exactly: the significant digits are increased until the number read back is equal to the input one. The plain decimal notation is used for decimal exponents in [-5, 15], the scientific one otherwise.

fortran
 use penf
 print "(A)", str(n=-1._R4P)
fortran
 use penf
 print "(A)", str(n=-1._R4P, no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=-1._R4P, compact=.true.)
fortran
 use penf
 print "(A)", str(n=0.1_R4P, compact=.true.)
fortran
 use penf
 print "(A)", str(n=-1._R4P, no_sign=.false.)
fortran
 use penf
 real(R4P) :: x(1:5)
 integer :: i
 logical :: exact
 x = [huge(1._R4P), tiny(1._R4P), 0.1_R4P, -1._R4P/3._R4P, 0._R4P]
 exact = .true.
 do i=1, 5
   exact = exact.and.(cton(str=str(n=x(i)), knd=1._R4P)==x(i))
   exact = exact.and.(cton(str=str(n=x(i), compact=.true.), knd=1._R4P)==x(i))
 enddo
 print "(L1)", exact

Attributes: elemental

Returns: character(len=DR4P)

fortran
function str_R4P(n, no_sign, compact) result(str)

Arguments

NameTypeIntentAttributesDescription
nreal(kind=R4P)inReal to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.
compactlogicalinoptionalFlag for the shortest exact string.

Call graph

str_I8P ​

Convert integer to string.

fortran
 use penf
 print "(A)", str(n=-1_I8P)
fortran
 use penf
 print "(A)", str(n=-1_I8P, no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=-1_I8P, no_sign=.false.)

Attributes: elemental

Returns: character(len=DI8P)

fortran
function str_I8P(n, no_sign) result(str)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I8P)inInteger to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.

Call graph

str_I4P ​

Converting integer to string.

fortran
 use penf
 print "(A)", str(n=-1_I4P)
fortran
 use penf
 print "(A)", str(n=-1_I4P, no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=-1_I4P, no_sign=.false.)

Attributes: elemental

Returns: character(len=DI4P)

fortran
function str_I4P(n, no_sign) result(str)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I4P)inInteger to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.

Call graph

str_I2P ​

Convert integer to string.

fortran
 use penf
 print "(A)", str(n=-1_I2P)
fortran
 use penf
 print "(A)", str(n=-1_I2P, no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=-1_I2P, no_sign=.false.)

Attributes: elemental

Returns: character(len=DI2P)

fortran
function str_I2P(n, no_sign) result(str)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I2P)inInteger to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.

Call graph

str_I1P ​

Convert integer to string.

fortran
 use penf
 print "(A)", str(n=-1_I1P)
fortran
 use penf
 print "(A)", str(n=-1_I1P, no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=-1_I1P, no_sign=.false.)

Attributes: elemental

Returns: character(len=DI1P)

fortran
function str_I1P(n, no_sign) result(str)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I1P)inInteger to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.

Call graph

str_bol ​

Convert logical to string.

fortran
 use penf
 print "(A)", str(n=.true.)

Attributes: elemental

Returns: character(len=1)

fortran
function str_bol(n) result(str)

Arguments

NameTypeIntentAttributesDescription
nlogicalinLogical to be converted.

str_a_R16P ​

Converting real array to string.

fortran
 use penf
 print "(A)", str(n=[1._R16P, -2._R16P])
fortran
 use penf
 print "(A)", str(n=[1._R16P, 2._R16P], no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=[1._R16P, -2._R16P], separator='|')
fortran
 use penf
 print "(A)", str(n=[1._R16P, -3._R16P], delimiters=['(', ')'])
fortran
 use penf
 print "(A)", str(n=[1._R16P, -2._R16P], compact=.true.)

Attributes: pure

Returns: character(len=:)

fortran
function str_a_R16P(n, no_sign, separator, delimiters, compact) result(str)

Arguments

NameTypeIntentAttributesDescription
nreal(kind=R16P)inReal array to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.
separatorcharacter(len=1)inoptionalEventual separator of array values.
delimiterscharacter(len=*)inoptionalEventual delimiters of array values.
compactlogicalinoptionalFlag for the shortest exact strings.

Call graph

str_a_R8P ​

Convert real array to string.

fortran
 use penf
 print "(A)", str(n=[1._R8P, -2._R8P])
fortran
 use penf
 print "(A)", str(n=[1._R8P, 2._R8P], no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=[1._R8P, -2._R8P], separator='|')
fortran
 use penf
 print "(A)", str(n=[1._R8P, -2._R8P], delimiters=['(', ')'])
fortran
 use penf
 print "(A)", str(n=[1._R8P, -2._R8P], compact=.true.)

Attributes: pure

Returns: character(len=:)

fortran
function str_a_R8P(n, no_sign, separator, delimiters, compact) result(str)

Arguments

NameTypeIntentAttributesDescription
nreal(kind=R8P)inReal array to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.
separatorcharacter(len=1)inoptionalEventual separator of array values.
delimiterscharacter(len=*)inoptionalEventual delimiters of array values.
compactlogicalinoptionalFlag for the shortest exact strings.

Call graph

str_a_R4P ​

Convert real array to string.

fortran
 use penf
 print "(A)", str(n=[1._R4P, -2._R4P])
fortran
 use penf
 print "(A)", str(n=[1._R4P, 2._R4P], no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=[1._R4P, -2._R4P], separator='|')
fortran
 use penf
 print "(A)", str(n=[1._R4P, -2._R4P], delimiters=['(', ')'])
fortran
 use penf
 print "(A)", str(n=[1._R4P, -2._R4P], compact=.true.)

Attributes: pure

Returns: character(len=:)

fortran
function str_a_R4P(n, no_sign, separator, delimiters, compact) result(str)

Arguments

NameTypeIntentAttributesDescription
nreal(kind=R4P)inReal array to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.
separatorcharacter(len=1)inoptionalEventual separator of array values.
delimiterscharacter(len=*)inoptionalEventual delimiters of array values.
compactlogicalinoptionalFlag for the shortest exact strings.

Call graph

str_a_I8P ​

Convert integer array to string.

fortran
 use penf
 print "(A)", str(n=[1_I8P, -2_I8P])
fortran
 use penf
 print "(A)", str(n=[1_I8P, 2_I8P], no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=[1_I8P, -2_I8P], separator='|')
fortran
 use penf
 print "(A)", str(n=[1_I8P, -2_I8P], delimiters=['(', ')'])

Attributes: pure

Returns: character(len=:)

fortran
function str_a_I8P(n, no_sign, separator, delimiters) result(str)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I8P)inInteger array to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.
separatorcharacter(len=1)inoptionalEventual separator of array values.
delimiterscharacter(len=*)inoptionalEventual delimiters of array values.

Call graph

str_a_I4P ​

Convert integer array to string.

fortran
 use penf
 print "(A)", str(n=[1_I4P, -2_I4P])
fortran
 use penf
 print "(A)", str(n=[1_I4P, 2_I4P], no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=[1_I4P, -2_I4P], separator='|')
fortran
 use penf
 print "(A)", str(n=[1_I4P, -2_I4P], delimiters=['(', ')'])

Attributes: pure

Returns: character(len=:)

fortran
function str_a_I4P(n, no_sign, separator, delimiters) result(str)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I4P)inInteger array to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.
separatorcharacter(len=1)inoptionalEventual separator of array values.
delimiterscharacter(len=*)inoptionalEventual delimiters of array values.

Call graph

str_a_I2P ​

Convert integer array to string.

fortran
 use penf
 print "(A)", str(n=[1_I2P, -2_I2P])
fortran
 use penf
 print "(A)", str(n=[1_I2P, 2_I2P], no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=[1_I2P, -2_I2P], separator='|')
fortran
 use penf
 print "(A)", str(n=[1_I2P, -2_I2P], delimiters=['(', ')'])

Attributes: pure

Returns: character(len=:)

fortran
function str_a_I2P(n, no_sign, separator, delimiters) result(str)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I2P)inInteger array to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.
separatorcharacter(len=1)inoptionalEventual separator of array values.
delimiterscharacter(len=*)inoptionalEventual delimiters of array values.

Call graph

str_a_I1P ​

Convert integer array to string.

fortran
 use penf
 print "(A)", str(n=[1_I1P, -2_I1P])
fortran
 use penf
 print "(A)", str(n=[1_I1P, 2_I1P], no_sign=.true.)
fortran
 use penf
 print "(A)", str(n=[1_I1P, -2_I1P], separator='|')
fortran
 use penf
 print "(A)", str(n=[1_I1P, -2_I1P], delimiters=['(', ')'])

Attributes: pure

Returns: character(len=:)

fortran
function str_a_I1P(n, no_sign, separator, delimiters) result(str)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I1P)inInteger array to be converted.
no_signlogicalinoptionalFlag for leaving out the sign.
separatorcharacter(len=1)inoptionalEventual separator of array values.
delimiterscharacter(len=*)inoptionalEventual delimiters of array values.

Call graph

tidy_real_string ​

Tidy a string representing a real number in scientific notation, e.g. -3.21E+0001 becomes -32.1.

The plain decimal notation is used for decimal exponents in [-5, 15], the scientific one otherwise, e.g. +1.0E+20. Not negative numbers are prefixed by the plus sign. Not finite numbers (NaN, Infinity) are left unchanged.

@note No need to add doctest: this is tested by a lot of doctests of other TBPs.

Attributes: pure

Returns: character(len=:)

fortran
function tidy_real_string(source, no_sign) result(string)

Arguments

NameTypeIntentAttributesDescription
sourcecharacter(len=*)inString representing the number in scientific notation.
no_signlogicalinoptionalFlag for leaving out the sign.

Call graph

is_little_endian ​

Check if the type of the bit ordering of the running architecture is little endian.

Attributes: pure

Returns: logical

fortran
function is_little_endian() result(is_little)

Call graph

strz_I8P ​

Converting integer to string, prefixing with the right number of zeros.

fortran
 use penf
 print "(A)", strz(n=1_I8P)
fortran
 use penf
 print "(A)", strz(n=1_I8P, nz_pad=5)

Attributes: elemental

Returns: character(len=DI8P)

fortran
function strz_I8P(n, nz_pad) result(str)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I8P)inInteger to be converted.
nz_padinteger(kind=I4P)inoptionalNumber of zeros padding.

strz_I4P ​

Convert integer to string, prefixing with the right number of zeros.

fortran
 use penf
 print "(A)", strz(n=1_I4P)
fortran
 use penf
 print "(A)", strz(n=1_I4P, nz_pad=5)

Attributes: elemental

Returns: character(len=DI4P)

fortran
function strz_I4P(n, nz_pad) result(str)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I4P)inInteger to be converted.
nz_padinteger(kind=I4P)inoptionalNumber of zeros padding.

strz_I2P ​

Convert integer to string, prefixing with the right number of zeros.

fortran
 use penf
 print "(A)", strz(n=1_I2P)
fortran
 use penf
 print "(A)", strz(n=1_I2P, nz_pad=3)

Attributes: elemental

Returns: character(len=DI2P)

fortran
function strz_I2P(n, nz_pad) result(str)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I2P)inInteger to be converted.
nz_padinteger(kind=I4P)inoptionalNumber of zeros padding.

strz_I1P ​

Convert integer to string, prefixing with the right number of zeros.

fortran
 use penf
 print "(A)", strz(n=1_I1P)
fortran
 use penf
 print "(A)", strz(n=1_I1P, nz_pad=3)

Attributes: elemental

Returns: character(len=DI1P)

fortran
function strz_I1P(n, nz_pad) result(str)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I1P)inInteger to be converted.
nz_padinteger(kind=I4P)inoptionalNumber of zeros padding.

ctor_R16P ​

Convert string to real.

fortran
 use penf
 print FR16P, cton(str='-1.0', knd=1._R16P)

Returns: real(kind=R16P)

fortran
function ctor_R16P(str, knd, pref, error) result(n)

Arguments

NameTypeIntentAttributesDescription
strcharacter(len=*)inString containing input number.
kndreal(kind=R16P)inNumber kind.
prefcharacter(len=*)inoptionalPrefixing string.
errorinteger(kind=I4P)outoptionalError trapping flag: 0 no errors, >0 error occurs.

ctor_R8P ​

Convert string to real.

fortran
 use penf
 print FR8P, cton(str='-1.0', knd=1._R8P)

Returns: real(kind=R8P)

fortran
function ctor_R8P(str, knd, pref, error) result(n)

Arguments

NameTypeIntentAttributesDescription
strcharacter(len=*)inString containing input number.
kndreal(kind=R8P)inNumber kind.
prefcharacter(len=*)inoptionalPrefixing string.
errorinteger(kind=I4P)outoptionalError trapping flag: 0 no errors, >0 error occurs.

ctor_R4P ​

Convert string to real.

fortran
 use penf
 print FR4P, cton(str='-1.0', knd=1._R4P)

Returns: real(kind=R4P)

fortran
function ctor_R4P(str, knd, pref, error) result(n)

Arguments

NameTypeIntentAttributesDescription
strcharacter(len=*)inString containing input number.
kndreal(kind=R4P)inNumber kind.
prefcharacter(len=*)inoptionalPrefixing string.
errorinteger(kind=I4P)outoptionalError trapping flag: 0 no errors, >0 error occurs.

ctoi_I8P ​

Convert string to integer.

fortran
 use penf
 print FI8P, cton(str='-1', knd=1_I8P)

Returns: integer(kind=I8P)

fortran
function ctoi_I8P(str, knd, pref, error) result(n)

Arguments

NameTypeIntentAttributesDescription
strcharacter(len=*)inString containing input number.
kndinteger(kind=I8P)inNumber kind.
prefcharacter(len=*)inoptionalPrefixing string.
errorinteger(kind=I4P)outoptionalError trapping flag: 0 no errors, >0 error occurs.

ctoi_I4P ​

Convert string to integer.

fortran
 use penf
 print FI4P, cton(str='-1', knd=1_I4P)

Returns: integer(kind=I4P)

fortran
function ctoi_I4P(str, knd, pref, error) result(n)

Arguments

NameTypeIntentAttributesDescription
strcharacter(len=*)inString containing input number.
kndinteger(kind=I4P)inNumber kind.
prefcharacter(len=*)inoptionalPrefixing string.
errorinteger(kind=I4P)outoptionalError trapping flag: 0 no errors, >0 error occurs.

ctoi_I2P ​

Convert string to integer.

fortran
 use penf
 print FI2P, cton(str='-1', knd=1_I2P)

Returns: integer(kind=I2P)

fortran
function ctoi_I2P(str, knd, pref, error) result(n)

Arguments

NameTypeIntentAttributesDescription
strcharacter(len=*)inString containing input number.
kndinteger(kind=I2P)inNumber kind.
prefcharacter(len=*)inoptionalPrefixing string.
errorinteger(kind=I4P)outoptionalError trapping flag: 0 no errors, >0 error occurs.

ctoi_I1P ​

Convert string to integer.

fortran
 use penf
 print FI1P, cton(str='-1', knd=1_I1P)

Returns: integer(kind=I1P)

fortran
function ctoi_I1P(str, knd, pref, error) result(n)

Arguments

NameTypeIntentAttributesDescription
strcharacter(len=*)inString containing input number.
kndinteger(kind=I1P)inNumber kind.
prefcharacter(len=*)inoptionalPrefixing string.
errorinteger(kind=I4P)outoptionalError trapping flag: 0 no errors, >0 error occurs.

bstr_R8P ​

Convert real to string of bits, most significant bit first on all architectures.

@note It is assumed that R8P is represented by means of 64 bits, but this is not ensured in all architectures.

fortran
 use penf
 print "(A)", bstr(n=1._R8P)
fortran
 use penf
 print "(L1)", bcton(bstr(n=-1._R8P/3._R8P), knd=1._R8P)==-1._R8P/3._R8P

Attributes: elemental

Returns: character(len=64)

fortran
function bstr_R8P(n) result(bstr)

Arguments

NameTypeIntentAttributesDescription
nreal(kind=R8P)inReal to be converted.

bstr_R4P ​

Convert real to string of bits, most significant bit first on all architectures.

@note It is assumed that R4P is represented by means of 32 bits, but this is not ensured in all architectures.

fortran
 use penf
 print "(A)", bstr(n=1._R4P)
fortran
 use penf
 print "(L1)", bcton(bstr(n=-1._R4P/3._R4P), knd=1._R4P)==-1._R4P/3._R4P

Attributes: elemental

Returns: character(len=32)

fortran
function bstr_R4P(n) result(bstr)

Arguments

NameTypeIntentAttributesDescription
nreal(kind=R4P)inReal to be converted.

bstr_I8P ​

Convert integer to string of bits.

@note It is assumed that I8P is represented by means of 64 bits, but this is not ensured in all architectures.

fortran
 use penf
 print "(A)", bstr(n=1_I8P)

Attributes: elemental

Returns: character(len=64)

fortran
function bstr_I8P(n) result(bstr)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I8P)inReal to be converted.

bstr_I4P ​

Convert integer to string of bits.

@note It is assumed that I4P is represented by means of 32 bits, but this is not ensured in all architectures.

fortran
 use penf
 print "(A)", bstr(n=1_I4P)

Attributes: elemental

Returns: character(len=32)

fortran
function bstr_I4P(n) result(bstr)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I4P)inReal to be converted.

bstr_I2P ​

Convert integer to string of bits.

@note It is assumed that I2P is represented by means of 16 bits, but this is not ensured in all architectures.

fortran
 use penf
 print "(A)", bstr(n=1_I2P)

Attributes: elemental

Returns: character(len=16)

fortran
function bstr_I2P(n) result(bstr)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I2P)inReal to be converted.

bstr_I1P ​

Convert integer to string of bits.

@note It is assumed that I1P is represented by means of 8 bits, but this is not ensured in all architectures.

fortran
 use penf
 print "(A)", bstr(n=1_I1P)

Attributes: elemental

Returns: character(len=8)

fortran
function bstr_I1P(n) result(bstr)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I1P)inReal to be converted.

bctor_R8P ​

Convert bit-string (most significant bit first) to real.

fortran
 use penf
 print FR8P, bcton('0011111111110000000000000000000000000000000000000000000000000000', knd=1._R8P)

Attributes: elemental

Returns: real(kind=R8P)

fortran
function bctor_R8P(bstr, knd) result(n)

Arguments

NameTypeIntentAttributesDescription
bstrcharacter(len=*)inString containing input number.
kndreal(kind=R8P)inNumber kind.

bctor_R4P ​

Convert bit-string (most significant bit first) to real.

fortran
 use penf
 print FR4P, bcton('00111111100000000000000000000000', knd=1._R4P)

Attributes: elemental

Returns: real(kind=R4P)

fortran
function bctor_R4P(bstr, knd) result(n)

Arguments

NameTypeIntentAttributesDescription
bstrcharacter(len=*)inString containing input number.
kndreal(kind=R4P)inNumber kind.

bctoi_I8P ​

Convert bit-string to integer.

fortran
 use penf
 print FI8P, bcton('0000000000000000000000000000000000000000000000000000000000000001', knd=1_I8P)

Attributes: elemental

Returns: integer(kind=I8P)

fortran
function bctoi_I8P(bstr, knd) result(n)

Arguments

NameTypeIntentAttributesDescription
bstrcharacter(len=*)inString containing input number.
kndinteger(kind=I8P)inNumber kind.

Call graph

bctoi_I4P ​

Convert bit-string to integer.

fortran
 use penf
 print FI4P, bcton('00000000000000000000000000000001', knd=1_I4P)

Attributes: elemental

Returns: integer(kind=I4P)

fortran
function bctoi_I4P(bstr, knd) result(n)

Arguments

NameTypeIntentAttributesDescription
bstrcharacter(len=*)inString containing input number.
kndinteger(kind=I4P)inNumber kind.

Call graph

bctoi_I2P ​

Convert bit-string to integer.

fortran
 use penf
 print FI2P, bcton('0000000000000001', knd=1_I2P)

Attributes: elemental

Returns: integer(kind=I2P)

fortran
function bctoi_I2P(bstr, knd) result(n)

Arguments

NameTypeIntentAttributesDescription
bstrcharacter(len=*)inString containing input number.
kndinteger(kind=I2P)inNumber kind.

Call graph

bctoi_I1P ​

Convert bit-string to integer.

fortran
 use penf
 print FI1P, bcton('00000001', knd=1_I1P)

Attributes: elemental

Returns: integer(kind=I1P)

fortran
function bctoi_I1P(bstr, knd) result(n)

Arguments

NameTypeIntentAttributesDescription
bstrcharacter(len=*)inString containing input number.
kndinteger(kind=I1P)inNumber kind.

Call graph