Portable Kind Parameters
Integer and real kind parameters for 1, 2, 4, 8, and 16-byte representations — guaranteed portable across compilers and architectures.
A KISS library for portable, parametrized numerical types in modern Fortran (2003+)
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| Parameter | Precision | Range | Size |
|---|---|---|---|
R16P | 33 digits | 128 bit | |
R8P | 15 digits | 64 bit | |
R4P | 6 digits | 32 bit |
| Parameter | Range | Size |
|---|---|---|
I8P | 64 bit | |
I4P | 32 bit | |
I2P | 16 bit | |
I1P | 8 bit |
Each kind has a matching format string for print / write statements:
| Kind | Format string | Example output |
|---|---|---|
R16P | FR16P = '(E42.33E4)' | -0.100000000000000000000000000000000E+0001 |
R8P | FR8P = '(E23.15E3)' | -0.100000000000000E+001 |
R4P | FR4P = '(E13.6E2)' | -0.100000E+01 |
I8P | FI8P = '(I20)' | -1 |
I4P | FI4P = '(I11)' | -1 |
I2P | FI2P = '(I6)' | -1 |
I1P | FI1P = '(I4)' | -1 |
Contributions are welcome — see the Contributing page.
PENF is distributed under a multi-licensing system:
Anyone interested in using, developing, or contributing to PENF is welcome — pick the license that best fits your needs.