Skip to content

Features

Kind Parameters

Real kinds

ParameterPrecisionRangeSize
R16P33 digits[104931, 10+49311]128 bit
R8P15 digits[10307, 10+3071]64 bit
R4P6 digits[1037, 10+371]32 bit

Integer kinds

ParameterRangeSize
I8P[263, +2631]64 bit
I4P[231, +2311]32 bit
I2P[215, +2151]16 bit
I1P[27, +271]8 bit

Format Strings

Each kind has a matching format string for print / write statements:

KindFormat stringExample output
R16PFR16P = '(E42.33E4)'-0.100000000000000000000000000000000E+0001
R8PFR8P = '(E23.15E3)'-0.100000000000000E+001
R4PFR4P = '(E13.6E2)'-0.100000E+01
I8PFI8P = '(I20)' -1
I4PFI4P = '(I11)' -1
I2PFI2P = '(I6)' -1
I1PFI1P = '(I4)' -1
fortran
use penf
call penf_init

real(R8P)    :: x = -1.0_R8P
integer(I4P) :: n = 42_I4P

print FR8P, x !  -0.100000000000000E+001
print FI4P, n !          42

Modules

PENF is composed of four modules that build upon each other:

  • penf_global_parameters_variables — all portable kind parameters, format strings, and character kinds
  • penf_b_sizebit_size() and byte_size() extended to reals and characters
  • penf_stringify — comprehensive number↔string conversions: str(), strz(), cton(), bstr(), bcton()
  • penf_allocatable_memory — allocatable memory utilities: allocate_variable(), assign_allocatable(), memory tracking
  • penf — main module, re-exports everything and provides check_endian(), digit(), penf_init(), penf_print()

Any feature request is welcome — open an issue on GitHub.