DCS
a Driven-Cavity Open source Simulator code
 All Classes Files Functions Variables Groups Pages
IR_Precision

Portable kind-parameters module. More...

+ Collaboration diagram for IR_Precision:

Data Types

module  ir_precision
 Module IR_Precision makes available some portable kind-parameters and some useful procedures to deal with them. More...
 

Detailed Description

Portable kind-parameters module.


Data Type Documentation

module ir_precision

Module IR_Precision makes available some portable kind-parameters and some useful procedures to deal with them.

It also provides variables that contain the minimum and maximum representable values, smallest real values and smallest representable differences by the running calculator.

Finally the module provides procedures to convert a string to number and vice versa, a function to check the endianism of the running calculator and a procedure to print all the aboves values.

Note
The quadruple precision R16P could be activated defining r16p pre-processor flag (e.g. -Dr16p). Furthermore if compiling with Portland Group Compiler define the pre-processor flag pgf95 to avoid error in computing Zero variables: pgf compiler doesn't accept nearest built-in function in variables initialization.
Author
Stefano Zaghi
Version
1.0
Date
2012-04-24
Todo:
g95_test: Test g95 compiler

Definition at line 110 of file IR_Precision.f90.

Public Member Functions

subroutine, public ir_init ()
 Subroutine for initilizing module's variables that are not initialized into the definition specification. More...
 
subroutine, public ir_print (myrank, Nproc)
 Subroutine for printing to the standard output the kind definition of reals and integers and the utility variables. More...
 

Private Member Functions

elemental integer(i2p) function bit_size_r16p (r)
 Procedure for computing the number of bits of a real variable. More...
 
elemental integer(i1p) function bit_size_r8p (r)
 Procedure for computing the number of bits of a real variable. More...
 
elemental integer(i1p) function bit_size_r4p (r)
 Procedure for computing the number of bits of a real variable. More...
 
elemental integer(i4p) function bit_size_chr (c)
 Procedure for computing the number of bits of a character variable. More...
 
elemental integer(i1p) function byte_size_i8p (i)
 Procedure for computing the number of bytes of an integer variable. More...
 
elemental integer(i1p) function byte_size_i4p (i)
 Procedure for computing the number of bytes of an integer variable. More...
 
elemental integer(i1p) function byte_size_i2p (i)
 Procedure for computing the number of bytes of an integer variable. More...
 
elemental integer(i1p) function byte_size_i1p (i)
 Procedure for computing the number of bytes of an integer variable. More...
 
elemental integer(i1p) function byte_size_r16p (r)
 Procedure for computing the number of bytes of a real variable. More...
 
elemental integer(i1p) function byte_size_r8p (r)
 Procedure for computing the number of bytes of a real variable. More...
 
elemental integer(i1p) function byte_size_r4p (r)
 Procedure for computing the number of bytes of a real variable. More...
 
elemental integer(i4p) function byte_size_chr (c)
 Procedure for computing the number of bytes of a character variable. More...
 
elemental character(dr16p) function strf_r16p (fm, n)
 Procedure for converting real to string. More...
 
elemental character(dr8p) function strf_r8p (fm, n)
 Procedure for converting real to string. More...
 
elemental character(dr4p) function strf_r4p (fm, n)
 Procedure for converting real to string. More...
 
elemental character(di8p) function strf_i8p (fm, n)
 Procedure for converting integer to string. More...
 
elemental character(di4p) function strf_i4p (fm, n)
 Procedure for converting integer to string. More...
 
elemental character(di2p) function strf_i2p (fm, n)
 Procedure for converting integer to string. More...
 
elemental character(di1p) function strf_i1p (fm, n)
 Procedure for converting integer to string. More...
 
elemental character(dr16p) function str_r16p (no_sign, n)
 Procedure for converting real to string. More...
 
elemental character(dr8p) function str_r8p (no_sign, n)
 Procedure for converting real to string. More...
 
elemental character(dr4p) function str_r4p (no_sign, n)
 Procedure for converting real to string. More...
 
elemental character(di8p) function str_i8p (no_sign, n)
 Procedure for converting integer to string. More...
 
elemental character(di4p) function str_i4p (no_sign, n)
 Procedure for converting integer to string. More...
 
elemental character(di2p) function str_i2p (no_sign, n)
 Procedure for converting integer to string. More...
 
elemental character(di1p) function str_i1p (no_sign, n)
 Procedure for converting integer to string. More...
 
elemental character(di8p) function strz_i8p (nz_pad, n)
 Procedure for converting integer to string, prefixing with the right number of zeros. More...
 
elemental character(di4p) function strz_i4p (nz_pad, n)
 Procedure for converting integer to string, prefixing with the right number of zeros. More...
 
elemental character(di2p) function strz_i2p (nz_pad, n)
 Procedure for converting integer to string, prefixing with the right number of zeros. More...
 
elemental character(di1p) function strz_i1p (nz_pad, n)
 Procedure for converting integer to string, prefixing with the right number of zeros. More...
 
real(r16p) function ctor_r16p (str, knd)
 Procedure for converting string to real. More...
 
real(r8p) function ctor_r8p (str, knd)
 Procedure for converting string to real. More...
 
real(r4p) function ctor_r4p (str, knd)
 Procedure for converting string to real. More...
 
integer(i8p) function ctoi_i8p (str, knd)
 Procedure for converting string to integer. More...
 
integer(i4p) function ctoi_i4p (str, knd)
 Procedure for converting string to integer. More...
 
integer(i2p) function ctoi_i2p (str, knd)
 Procedure for converting string to integer. More...
 
integer(i1p) function ctoi_i1p (str, knd)
 Procedure for converting string to integer. More...
 
elemental character(128) function bstr_r16p (n)
 Procedure for converting real to string of bits. More...
 
elemental character(64) function bstr_r8p (n)
 Procedure for converting real to string of bits. More...
 
elemental character(32) function bstr_r4p (n)
 Procedure for converting real to string of bits. More...
 
elemental character(64) function bstr_i8p (n)
 Procedure for converting integer to string of bits. More...
 
elemental character(32) function bstr_i4p (n)
 Procedure for converting integer to string of bits. More...
 
elemental character(16) function bstr_i2p (n)
 Procedure for converting integer to string of bits. More...
 
elemental character(8) function bstr_i1p (n)
 Procedure for converting integer to string of bits. More...
 
elemental real(r8p) function bctor_r8p (bstr, knd)
 Procedure for converting bit-string to real. More...
 
elemental real(r4p) function bctor_r4p (bstr, knd)
 Procedure for converting bit-string to real. More...
 
elemental integer(i8p) function bctoi_i8p (bstr, knd)
 Procedure for converting bit-string to integer. More...
 
elemental integer(i4p) function bctoi_i4p (bstr, knd)
 Procedure for converting bit-string to integer. More...
 
elemental integer(i2p) function bctoi_i2p (bstr, knd)
 Procedure for converting bit-string to integer. More...
 
elemental integer(i1p) function bctoi_i1p (bstr, knd)
 Procedure for converting bit-string to integer. More...
 
logical, public ir_initialized = .false.
 Flag for chcecking the initialization of some variables that must be initialized by IR_Init. More...
 
integer, parameter, public endianl = 1
 Little endian parameter. More...
 
integer, parameter, public endianb = 0
 Big endian parameter. More...
 
integer, public endian = endianL
 Bit ordering: Little endian (endianL), or Big endian (endianB). More...
 
integer, parameter, public r16p = selected_real_kind(15, 307)
 Defined as R8P; 64 bits. More...
 
integer, parameter, public r8p = selected_real_kind(15, 307)
 15 digits, range $[10^{-307} , 10^{+307} - 1]$; 64 bits. More...
 
integer, parameter, public r4p = selected_real_kind(6, 37)
 6 digits, range $[10^{-37} , 10^{+37} - 1]$; 32 bits. More...
 
integer, parameter, public r_p = R8P
 Default real precision. More...
 
integer, parameter, public i8p = selected_int_kind(18)
 Range $[-2^{63},+2^{63} - 1]$, 19 digits plus sign; 64 bits. More...
 
integer, parameter, public i4p = selected_int_kind(9)
 Range $[-2^{31},+2^{31} - 1]$, 10 digits plus sign; 32 bits. More...
 
integer, parameter, public i2p = selected_int_kind(4)
 Range $[-2^{15},+2^{15} - 1]$, 5 digits plus sign; 16 bits. More...
 
integer, parameter, public i1p = selected_int_kind(2)
 Range $[-2^{7} ,+2^{7} - 1]$, 3 digits plus sign; 8 bits. More...
 
integer, parameter, public i_p = I4P
 Default integer precision. More...
 
character(10), parameter, public fr16p = '(E42.33E4)'
 Output format for kind=R16P variable. More...
 
character(10), parameter, public fr8p = '(E23.15E3)'
 Output format for kind=R8P variable. More...
 
character(9), parameter, public fr4p = '(E13.6E2)'
 Output format for kind=R4P variable. More...
 
character(10), parameter, public fr_p = FR8P
 Output format for kind=R_P variable. More...
 
integer, parameter, public dr16p = 42
 Number of digits of output format FR16P. More...
 
integer, parameter, public dr8p = 23
 Number of digits of output format FR8P. More...
 
integer, parameter, public dr4p = 13
 Number of digits of output format FR4P. More...
 
integer, parameter, public dr_p = DR8P
 Number of digits of output format FR_P. More...
 
character(5), parameter, public fi8p = '(I20)'
 Output format for kind=I8P variable. More...
 
character(5), parameter, public fi4p = '(I11)'
 Output format for kind=I4P variable. More...
 
character(4), parameter, public fi2p = '(I6)'
 Output format for kind=I2P variable. More...
 
character(4), parameter, public fi1p = '(I4)'
 Output format for kind=I1P variable. More...
 
character(5), parameter, public fi_p = FI4P
 Output format for kind=I_P variable. More...
 
integer, parameter, public di8p = 20
 Number of digits of output format I8P. More...
 
integer, parameter, public di4p = 11
 Number of digits of output format I4P. More...
 
integer, parameter, public di2p = 6
 Number of digits of output format I2P. More...
 
integer, parameter, public di1p = 4
 Number of digits of output format I1P. More...
 
integer, parameter, public di_p = DI4P
 Number of digits of output format I_P. More...
 
integer, parameter, public nrknd =4
 Number of defined real kinds. More...
 
integer, dimension(1:nrknd),
parameter, public 
rpl =[R16P,R8P,R4P,R_P]
 List of defined real kinds. More...
 
character(10), dimension(1:nrknd),
parameter, public 
frl =[FR16P,FR8P,FR4P//' ',FR_P]
 List of defined real kinds output format. More...
 
integer, parameter, public niknd =5
 Number of defined integer kinds. More...
 
integer, dimension(1:niknd),
parameter, public 
ril =[I8P,I4P,I2P,I1P,I_P]
 List of defined integer kinds. More...
 
character(5), dimension(1:niknd),
parameter, public 
fil =[FI8P,FI4P,FI2P//' ',FI1P//' ',FI_P]
 List of defined integer kinds output format. More...
 
real(r16p), parameter, public minr16p = -huge(1._R16P)
 
real(r16p), parameter, public maxr16p = huge(1._R16P)
 Min and max values of kind=R16P variable. More...
 
real(r8p), parameter, public minr8p = -huge(1._R8P )
 
real(r8p), parameter, public maxr8p = huge(1._R8P )
 Min and max values of kind=R8P variable. More...
 
real(r4p), parameter, public minr4p = -huge(1._R4P )
 
real(r4p), parameter, public maxr4p = huge(1._R4P )
 Min and max values of kind=R4P variable. More...
 
real(r_p), parameter, public minr_p = MinR8P
 
real(r_p), parameter, public maxr_p = MaxR8P
 Min and max values of kind=R_P variable. More...
 
integer(i2p), public bir16p
 
integer(i2p), public byr16p
 Number of bits/bytes of kind=R16P variable. More...
 
integer(i1p), public bir8p
 
integer(i1p), public byr8p
 Number of bits/bytes of kind=R8P variable. More...
 
integer(i1p), public bir4p
 
integer(i1p), public byr4p
 Number of bits/bytes of kind=R4P variable. More...
 
integer(i1p), public bir_p
 
integer(i1p), public byr_p
 Number of bits/bytes of kind=R_P variable. More...
 
real(r16p), parameter, public smallr16p = tiny(1._R16P)
 Smallest representable value of kind=R16P variable. More...
 
real(r8p), parameter, public smallr8p = tiny(1._R8P )
 Smallest representable value of kind=R8P variable. More...
 
real(r4p), parameter, public smallr4p = tiny(1._R4P )
 Smallest representable value of kind=R4P variable. More...
 
real(r_p), parameter, public smallr_p = smallR8P
 Smallest representable value of kind=R_P variable. More...
 
integer(i8p), parameter, public mini8p = -huge(1_I8P)
 
integer(i8p), parameter, public maxi8p = huge(1_I8P)
 Min and max values of kind=I8P variable. More...
 
integer(i4p), parameter, public mini4p = -huge(1_I4P)
 
integer(i4p), parameter, public maxi4p = huge(1_I4P)
 Min and max values of kind=I4P variable. More...
 
integer(i2p), parameter, public mini2p = -huge(1_I2P)
 
integer(i2p), parameter, public maxi2p = huge(1_I2P)
 Min and max values of kind=I2P variable. More...
 
integer(i1p), parameter, public mini1p = -huge(1_I1P)
 
integer(i1p), parameter, public maxi1p = huge(1_I1P)
 Min and max values of kind=I1P variable. More...
 
integer(i_p), parameter, public mini_p = MinI4P
 
integer(i_p), parameter, public maxi_p = MaxI4P
 Min and max values of kind=I_P variable. More...
 
integer(i8p), parameter, public bii8p = bit_size(MaxI8P)
 
integer(i8p), parameter, public byi8p = bit_size(MaxI8P)/8_I8P
 Number of bits/bytes of kind=I8P variable. More...
 
integer(i4p), parameter, public bii4p = bit_size(MaxI4P)
 
integer(i4p), parameter, public byi4p = bit_size(MaxI4P)/8_I4P
 Number of bits/bytes of kind=I4P variable. More...
 
integer(i2p), parameter, public bii2p = bit_size(MaxI2P)
 
integer(i2p), parameter, public byi2p = bit_size(MaxI2P)/8_I2P
 Number of bits/bytes of kind=I2P variable. More...
 
integer(i1p), parameter, public bii1p = bit_size(MaxI1P)
 
integer(i1p), parameter, public byi1p = bit_size(MaxI1P)/8_I1P
 Number of bits/bytes of kind=I1P variable. More...
 
integer(i_p), parameter, public bii_p = bit_size(MaxI_P)
 
integer(i_p), parameter, public byi_p = bit_size(MaxI_P)/8_I_P
 Number of bits/bytes of kind=I_P variable. More...
 
real(r16p), parameter, public zeror16 = nearest(1._R16P, 1._R16P) - nearest(1._R16P, -1._R16P)
 Smallest representable difference of kind=R16P variable. More...
 
real(r8p), parameter, public zeror8 = nearest(1._R8P, 1._R8P) - nearest(1._R8P, -1._R8P)
 Smallest representable difference of kind=R8P variable. More...
 
real(r4p), parameter, public zeror4 = nearest(1._R4P, 1._R4P) - nearest(1._R4P, -1._R4P)
 Smallest representable difference of kind=R4P variable. More...
 
real(r_p), parameter, public zero = ZeroR8
 Smallest representable difference of kind=R_P variable. More...
 
character(8), parameter fi8pzp = '(I20.19)'
 Output format with zero prefixing for kind=I8P variable. More...
 
character(8), parameter fi4pzp = '(I11.10)'
 Output format with zero prefixing for kind=I4P variable. More...
 
character(6), parameter fi2pzp = '(I6.5)'
 Output format with zero prefixing for kind=I2P variable. More...
 
character(6), parameter fi1pzp = '(I4.3)'
 Output format with zero prefixing for kind=I1P variable. More...
 
character(8), parameter fi_pzp = FI4PZP
 Output format with zero prefixing for kind=I_P variable. More...
 
pure logical function is_little_endian ()
 Procedure for checking if the type of the bit ordering of the running architecture is little endian. More...
 
subroutine, public check_endian ()
 Subroutine for checking the type of bit ordering (big or little endian) of the running architecture; the result is stored into the "endian" global variable. More...