new version of Lib_VTK_IO

This commit is contained in:
Martin Diehl 2013-12-17 13:24:34 +00:00
parent 5f06437e96
commit 676e621af2
4 changed files with 5779 additions and 1609 deletions

View File

@ -30,5 +30,6 @@ end module libs
#include "../lib/kdtree2.f90"
#endif
#include "../lib/IR_Precision.f90"
#include "../lib/Lib_Base64.f90"
#include "../lib/Lib_VTK_IO.f90"

View File

@ -12,26 +12,31 @@
!> @ingroup Library
!> @{
!> @defgroup IR_PrecisionLibrary IR_Precision
!> Portable kind-parameters module
!> @}
!> @ingroup Interface
!> @{
!> @defgroup IR_PrecisionInterface IR_Precision
!> Portable kind-parameters module
!> @}
!> @ingroup GlobalVarPar
!> @{
!> @defgroup IR_PrecisionGlobalVarPar IR_Precision
!> Portable kind-parameters module
!> @}
!> @ingroup PublicProcedure
!> @{
!> @defgroup IR_PrecisionPublicProcedure IR_Precision
!> Portable kind-parameters module
!> @}
!> @ingroup PrivateProcedure
!> @{
!> @defgroup IR_PrecisionPrivateProcedure IR_Precision
!> Portable kind-parameters module
!> @}
!> @brief Module IR_Precision makes available some portable kind-parameters and some useful procedures to deal with them.
@ -58,9 +63,7 @@ USE, intrinsic:: ISO_FORTRAN_ENV, only: stdout => OUTPUT_UNIT, stderr => ERROR_U
implicit none
private
public:: endianL,endianB,endian
#ifdef r16p
public:: R16P, FR16P, DR16P, MinR16P, MaxR16P, BIR16P, BYR16P, smallR16P, ZeroR16
#endif
public:: R8P, FR8P, DR8P, MinR8P, MaxR8P, BIR8P, BYR8P, smallR8P, ZeroR8
public:: R4P, FR4P, DR4P, MinR4P, MaxR4P, BIR4P, BYR4P, smallR4P, ZeroR4
public:: R_P, FR_P, DR_P, MinR_P, MaxR_P, BIR_P, BYR_P, smallR_P, Zero
@ -69,9 +72,11 @@ public:: I4P, FI4P, DI4P, MinI4P, MaxI4P, BII4P, BYI4P
public:: I2P, FI2P, DI2P, MinI2P, MaxI2P, BII2P, BYI2P
public:: I1P, FI1P, DI1P, MinI1P, MaxI1P, BII1P, BYI1P
public:: I_P, FI_P, DI_P, MinI_P, MaxI_P, BII_P, BYI_P
public:: NRknd, RPl, FRl
public:: NIknd, RIl, FIl
public:: check_endian
public:: bit_size
public:: str, strz, cton
public:: bit_size,byte_size
public:: str, strz, cton, bstr, bcton
public:: ir_initialized,IR_Init
public:: IR_Print
!-----------------------------------------------------------------------------------------------------------------------------------
@ -89,6 +94,8 @@ integer:: endian = endianL !< Bit ordering: Little endian (endianL),
! Real precision definitions:
#ifdef r16p
integer, parameter:: R16P = selected_real_kind(33,4931) !< 33 digits, range \f$[10^{-4931}, 10^{+4931} - 1]\f$; 128 bits.
#else
integer, parameter:: R16P = selected_real_kind(15,307) !< Defined as R8P; 64 bits.
#endif
integer, parameter:: R8P = selected_real_kind(15,307) !< 15 digits, range \f$[10^{-307} , 10^{+307} - 1]\f$; 64 bits.
integer, parameter:: R4P = selected_real_kind(6,37) !< 6 digits, range \f$[10^{-37} , 10^{+37} - 1]\f$; 32 bits.
@ -102,16 +109,12 @@ integer, parameter:: I_P = I4P !< Default integer precision.
! Format parameters useful for writing in a well-ascii-format numeric variables.
! Real output formats:
#ifdef r16p
character(10), parameter:: FR16P = '(E42.33E4)' !< Output format for kind=R16P variable.
#endif
character(10), parameter:: FR8P = '(E23.15E3)' !< Output format for kind=R8P variable.
character(9), parameter:: FR4P = '(E13.6E2)' !< Output format for kind=R4P variable.
character(10), parameter:: FR_P = FR8P !< Output format for kind=R_P variable.
! Real number of digits of output formats:
#ifdef r16p
integer, parameter:: DR16P = 42 !< Number of digits of output format FR16P.
#endif
integer, parameter:: DR8P = 23 !< Number of digits of output format FR8P.
integer, parameter:: DR4P = 13 !< Number of digits of output format FR4P.
integer, parameter:: DR_P = DR8P !< Number of digits of output format FR_P.
@ -132,62 +135,62 @@ integer, parameter:: DI4P = 11 !< Number of digits of output format I4P.
integer, parameter:: DI2P = 6 !< Number of digits of output format I2P.
integer, parameter:: DI1P = 4 !< Number of digits of output format I1P.
integer, parameter:: DI_P = DI4P !< Number of digits of output format I_P.
! List of kinds
integer, parameter:: NRknd=4 !< Number of defined real kinds.
integer, parameter:: RPl(1:NRknd)=[R16P,R8P,R4P,R_P] !< List of defined real kinds.
character(10), parameter:: FRl(1:NRknd)=[FR16P,FR8P,FR4P//' ',FR_P] !< List of defined real kinds output format.
integer, parameter:: NIknd=5 !< Number of defined integer kinds.
integer, parameter:: RIl(1:NIknd)=[I8P,I4P,I2P,I1P,I_P] !< List of defined integer kinds.
character(5), parameter:: FIl(1:NIknd)=[FI8P,FI4P,FI2P//' ',FI1P//' ',FI_P] !< List of defined integer kinds output format.
! Useful parameters for handling numbers ranges.
! Real min and max values:
#ifdef r16p
real(R16P), parameter:: MinR16P = -huge(1._R16P), MaxR16P = huge(1._R16P) !< Min and max values of kind=R16P variable.
#endif
real(R8P), parameter:: MinR8P = -huge(1._R8P ), MaxR8P = huge(1._R8P ) !< Min and max values of kind=R8P variable.
real(R4P), parameter:: MinR4P = -huge(1._R4P ), MaxR4P = huge(1._R4P ) !< Min and max values of kind=R4P variable.
real(R_P), parameter:: MinR_P = MinR8P, MaxR_P = MaxR8P !< Min and max values of kind=R_P variable.
! Real number of bits/bytes
#ifdef r16p
integer(I1P):: BIR16P, BYR16P !< Number of bits/bytes of kind=R16P variable.
#endif
integer(I2P):: BIR16P, BYR16P !< Number of bits/bytes of kind=R16P variable.
integer(I1P):: BIR8P, BYR8P !< Number of bits/bytes of kind=R8P variable.
integer(I1P):: BIR4P, BYR4P !< Number of bits/bytes of kind=R4P variable.
integer(I1P):: BIR_P, BYR_P !< Number of bits/bytes of kind=R_P variable.
! Real smallest values:
#ifdef r16p
real(R16P), parameter:: smallR16P = tiny(1._R16P) !< Smallest representable value of kind=R16P variable.
#endif
real(R8P), parameter:: smallR8P = tiny(1._R8P ) !< Smallest representable value of kind=R8P variable.
real(R4P), parameter:: smallR4P = tiny(1._R4P ) !< Smallest representable value of kind=R4P variable.
real(R_P), parameter:: smallR_P = smallR8P !< Smallest representable value of kind=R_P variable.
! Integer min and max values:
integer(I8P), parameter:: MinI8P = -huge(1_I8P)-1_I8P, MaxI8P = huge(1_I8P) !< Min and max values of kind=I8P variable.
integer(I4P), parameter:: MinI4P = -huge(1_I4P)-1_I4P, MaxI4P = huge(1_I4P) !< Min and max values of kind=I4P variable.
integer(I2P), parameter:: MinI2P = -huge(1_I2P)-1_I2P, MaxI2P = huge(1_I2P) !< Min and max values of kind=I2P variable.
integer(I1P), parameter:: MinI1P = -huge(1_I1P)-1_I1P, MaxI1P = huge(1_I1P) !< Min and max values of kind=I1P variable.
integer(I_P), parameter:: MinI_P = MinI4P, MaxI_P = MaxI4P !< Min and max values of kind=I_P variable.
integer(I8P), parameter:: MinI8P = -huge(1_I8P), MaxI8P = huge(1_I8P) !< Min and max values of kind=I8P variable.
integer(I4P), parameter:: MinI4P = -huge(1_I4P), MaxI4P = huge(1_I4P) !< Min and max values of kind=I4P variable.
integer(I2P), parameter:: MinI2P = -huge(1_I2P), MaxI2P = huge(1_I2P) !< Min and max values of kind=I2P variable.
integer(I1P), parameter:: MinI1P = -huge(1_I1P), MaxI1P = huge(1_I1P) !< Min and max values of kind=I1P variable.
integer(I_P), parameter:: MinI_P = MinI4P, MaxI_P = MaxI4P !< Min and max values of kind=I_P variable.
! Integer number of bits/bytes:
integer(I8P), parameter:: BII8P = bit_size(MaxI8P), BYI8P = bit_size(MaxI8P)/8_I8P !< Number of bits/bytes of kind=I8P variable.
integer(I4P), parameter:: BII4P = bit_size(MaxI4P), BYI4P = bit_size(MaxI4P)/8_I4P !< Number of bits/bytes of kind=I4P variable.
integer(I2P), parameter:: BII2P = bit_size(MaxI4P), BYI2P = bit_size(MaxI2P)/8_I2P !< Number of bits/bytes of kind=I2P variable.
integer(I2P), parameter:: BII2P = bit_size(MaxI2P), BYI2P = bit_size(MaxI2P)/8_I2P !< Number of bits/bytes of kind=I2P variable.
integer(I1P), parameter:: BII1P = bit_size(MaxI1P), BYI1P = bit_size(MaxI1P)/8_I1P !< Number of bits/bytes of kind=I1P variable.
integer(I_P), parameter:: BII_P = bit_size(MaxI_P), BYI_P = bit_size(MaxI_P)/8_I_P !< Number of bits/bytes of kind=I_P variable.
! Smallest real representable difference by the running calculator.
#ifdef r16p
real(R16P), parameter:: ZeroR16 = nearest(1._R16P, 1._R16P) - &
nearest(1._R16P,-1._R16P) !< Smallest representable difference of kind=R16P variable.
#endif
#ifdef pgf95
real(R16P), parameter:: ZeroR16 = 0._R16P
real(R8P), parameter:: ZeroR8 = 0._R8P
real(R4P), parameter:: ZeroR4 = 0._R4P
#else
real(R16P), parameter:: ZeroR16 = nearest(1._R16P, 1._R16P) - &
nearest(1._R16P,-1._R16P) !< Smallest representable difference of kind=R16P variable.
real(R8P), parameter:: ZeroR8 = nearest(1._R8P, 1._R8P) - &
nearest(1._R8P,-1._R8P) !< Smallest representable difference of kind=R8P variable.
nearest(1._R8P,-1._R8P) !< Smallest representable difference of kind=R8P variable.
real(R4P), parameter:: ZeroR4 = nearest(1._R4P, 1._R4P) - &
nearest(1._R4P,-1._R4P) !< Smallest representable difference of kind=R4P variable.
nearest(1._R4P,-1._R4P) !< Smallest representable difference of kind=R4P variable.
#endif
real(R_P), parameter:: Zero = ZeroR8 !< Smallest representable difference of kind=R_P variable.
real(R_P), parameter:: Zero = ZeroR8 !< Smallest representable difference of kind=R_P variable.
!> @}
!-----------------------------------------------------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------------------------------------------------
!> @brief Overloading of the intrinsic "bit_size" function for computing the number of bits of (also) real variables;
!> number, intent(\b IN):: <b>\em n</b> input number;
!> @brief Overloading of the intrinsic "bit_size" function for computing the number of bits of (also) real and character variables;
!> variable, intent(\b IN):: <b>\em n</b> input;
!> integer(I1P), intent(\b OUT):: <b>\em bits</b> output number of bits of input number.
!> @ingroup IR_PrecisionInterface
interface bit_size
@ -196,9 +199,25 @@ interface bit_size
bit_size_R16p, &
#endif
bit_size_R8P, &
bit_size_R4P
bit_size_R4P, &
bit_size_chr
endinterface
!> @brief Function for converting number, real and integer, to string (number to string type casting);
!> @brief Overloading of the "byte_size" function for computing the number of bytes.
!> @ingroup IR_PrecisionInterface
interface byte_size
module procedure &
byte_size_I8P, &
byte_size_I4P, &
byte_size_I2P, &
byte_size_I1P, &
#ifdef r16p
byte_size_R16p, &
#endif
byte_size_R8P, &
byte_size_R4P, &
byte_size_chr
endinterface
!> @brief Procedure for converting number, real and integer, to string (number to string type casting);
!> logical, intent(\b IN), optional:: <b>\em no_sign</b> flag for do not write sign;
!> number, intent(\b IN):: <b>\em n</b> input number;
!> string, intent(\b OUT):: <b>\em str</b> output string.
@ -206,17 +225,17 @@ endinterface
interface str
module procedure &
#ifdef r16p
str_R16P,strf_R16P,&
strf_R16P,str_R16P,&
#endif
str_R8P,strf_R8P, &
str_R4P,strf_R4P, &
str_I8P,strf_I8P, &
str_I4P,strf_I4P, &
str_I2P,strf_I2P, &
str_I1P,strf_I1P
strf_R8P ,str_R8P, &
strf_R4P ,str_R4P, &
strf_I8P ,str_I8P, &
strf_I4P ,str_I4P, &
strf_I2P ,str_I2P, &
strf_I1P ,str_I1P
endinterface
!> @brief Function for converting number, integer, to string, prefixing with the right number of zeros (number to string type
!> casting with zero padding);
!> @brief Procedure for converting number, integer, to string, prefixing with the right number of zeros (number to string type
!> casting with zero padding);
!> number, intent(\b IN), optional:: <b>\em no_zpad</b> number of padding zeros;
!> number, intent(\b IN):: <b>\em n </b> input number;
!> string, intent(\b OUT):: <b>\em str</b> output string.
@ -227,7 +246,7 @@ interface strz
strz_I2P, &
strz_I1P
endinterface
!> @brief Function for converting string to number, real or initeger, (string to number type casting);
!> @brief Procedure for converting string to number, real or initeger, (string to number type casting);
!> string, intent(\b IN):: <b>\em str</b> input string;
!> number, intent(\b OUT):: <b>\em n </b> output number.
!> @ingroup IR_PrecisionInterface
@ -243,11 +262,43 @@ interface cton
ctoi_I2P, &
ctoi_I1P
endinterface
!> @brief Procedure for converting number, real and integer, to bit-string (number to bit-string type casting);
!> number, intent(\b IN):: <b>\em n</b> input number;
!> string, intent(\b OUT):: <b>\em bstr</b> output bit-string.
!> @ingroup IR_PrecisionInterface
interface bstr
module procedure &
#ifdef r16p
bstr_R16P,&
#endif
bstr_R8P, &
bstr_R4P, &
bstr_I8P, &
bstr_I4P, &
bstr_I2P, &
bstr_I1P
endinterface
!> @brief Procedure for converting bit-string to number, real or initeger, (bit-string to number type casting);
!> string, intent(\b IN):: <b>\em bstr</b> input bit-string;
!> number, intent(\b OUT):: <b>\em n</b> output number.
!> @ingroup IR_PrecisionInterface
interface bcton
module procedure &
#ifdef r16p
bctor_R16P, &
#endif
bctor_R8P, &
bctor_R4P, &
bctoi_I8P, &
bctoi_I4P, &
bctoi_I2P, &
bctoi_I1P
endinterface
!-----------------------------------------------------------------------------------------------------------------------------------
contains
!> @ingroup IR_PrecisionPublicProcedure
!> @{
!>Function for checking if the type of the bit ordering of the running architecture is little endian.
!> @brief Procedure for checking if the type of the bit ordering of the running architecture is little endian.
pure function is_little_endian() result(is_little)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -262,9 +313,8 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction is_little_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.
!>@return endian
!> @brief 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.
subroutine check_endian()
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -283,55 +333,179 @@ contains
!> @ingroup IR_PrecisionPrivateProcedure
!> @{
#ifdef r16p
!> @brief Function for computing the number of bits of a real variable.
elemental function bit_size_R16P(i) result(bits)
!> @brief Procedure for computing the number of bits of a real variable.
elemental function bit_size_R16P(r) result(bits)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R16P), intent(IN):: i !< Real variable of which number of bits must be computed.
integer(I1P):: bits !< Number of bits of i.
real(R16P), intent(IN):: r !< Real variable whose number of bits must be computed.
integer(I2P):: bits !< Number of bits of r.
integer(I1P):: mold(1) !< "Molding" dummy variable for bits counting.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bits = size(transfer(i,mold))*8_I1P
bits = size(transfer(r,mold),dim=1,kind=I2P)*8_I2P
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bit_size_R16P
#endif
!> @brief Function for computing the number of bits of a real variable.
elemental function bit_size_R8P(i) result(bits)
!> @brief Procedure for computing the number of bits of a real variable.
elemental function bit_size_R8P(r) result(bits)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R8P), intent(IN):: i !< Real variable of which number of bits must be computed.
integer(I1P):: bits !< Number of bits of i.
real(R8P), intent(IN):: r !< Real variable whose number of bits must be computed.
integer(I1P):: bits !< Number of bits of r.
integer(I1P):: mold(1) !< "Molding" dummy variable for bits counting.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bits = size(transfer(i,mold))*8_I1P
bits = size(transfer(r,mold),dim=1,kind=I1P)*8_I1P
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bit_size_R8P
!> @brief Function for computing the number of bits of a real variable.
elemental function bit_size_R4P(i) result(bits)
!> @brief Procedure for computing the number of bits of a real variable.
elemental function bit_size_R4P(r) result(bits)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R4P), intent(IN):: i !< Real variable of which number of bits must be computed.
integer(I1P):: bits !< Number of bits of i.
real(R4P), intent(IN):: r !< Real variable whose number of bits must be computed.
integer(I1P):: bits !< Number of bits of r.
integer(I1P):: mold(1) !< "Molding" dummy variable for bits counting.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bits = size(transfer(i,mold))*8_I1P
bits = size(transfer(r,mold),dim=1,kind=I1P)*8_I1P
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bit_size_R4P
#ifdef r16p
!> @brief Function for converting real to string. This function achieves casting of real to string.
!> @brief Procedure for computing the number of bits of a character variable.
elemental function bit_size_chr(c) result(bits)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
character(*), intent(IN):: c !< Character variable whose number of bits must be computed.
integer(I4P):: bits !< Number of bits of c.
integer(I1P):: mold(1) !< "Molding" dummy variable for bits counting.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bits = size(transfer(c,mold),dim=1,kind=I1P)*8_I4P
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bit_size_chr
!> @brief Procedure for computing the number of bytes of an integer variable.
elemental function byte_size_I8P(i) result(bytes)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I8P), intent(IN):: i !< Integer variable whose number of bytes must be computed.
integer(I1P):: bytes !< Number of bytes of i.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bytes = bit_size(i)/8_I1P
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction byte_size_I8P
!> @brief Procedure for computing the number of bytes of an integer variable.
elemental function byte_size_I4P(i) result(bytes)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: i !< Integer variable whose number of bytes must be computed.
integer(I1P):: bytes !< Number of bytes of i.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bytes = bit_size(i)/8_I1P
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction byte_size_I4P
!> @brief Procedure for computing the number of bytes of an integer variable.
elemental function byte_size_I2P(i) result(bytes)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I2P), intent(IN):: i !< Integer variable whose number of bytes must be computed.
integer(I1P):: bytes !< Number of bytes of i.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bytes = bit_size(i)/8_I1P
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction byte_size_I2P
!> @brief Procedure for computing the number of bytes of an integer variable.
elemental function byte_size_I1P(i) result(bytes)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I1P), intent(IN):: i !< Integer variable whose number of bytes must be computed.
integer(I1P):: bytes !< Number of bytes of i.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bytes = bit_size(i)/8_I1P
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction byte_size_I1P
!> @brief Procedure for computing the number of bytes of a real variable.
elemental function byte_size_R16P(r) result(bytes)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R16P), intent(IN):: r !< Real variable whose number of bytes must be computed.
integer(I1P):: bytes !< Number of bytes of r.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bytes = bit_size(r)/8_I1P
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction byte_size_R16P
!> @brief Procedure for computing the number of bytes of a real variable.
elemental function byte_size_R8P(r) result(bytes)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R8P), intent(IN):: r !< Real variable whose number of bytes must be computed.
integer(I1P):: bytes !< Number of bytes of r.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bytes = bit_size(r)/8_I1P
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction byte_size_R8P
!> @brief Procedure for computing the number of bytes of a real variable.
elemental function byte_size_R4P(r) result(bytes)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R4P), intent(IN):: r !< Real variable whose number of bytes must be computed.
integer(I1P):: bytes !< Number of bytes of r.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bytes = bit_size(r)/8_I1P
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction byte_size_R4P
!> @brief Procedure for computing the number of bytes of a character variable.
elemental function byte_size_chr(c) result(bytes)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
character(*), intent(IN):: c !< Character variable whose number of bytes must be computed.
integer(I4P):: bytes !< Number of bytes of c.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bytes = bit_size(c)/8_I4P
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction byte_size_chr
!> @brief Procedure for converting real to string. This function achieves casting of real to string.
elemental function strf_R16P(fm,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -345,9 +519,8 @@ contains
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strf_R16P
#endif
!> @brief Function for converting real to string. This function achieves casting of real to string.
!> @brief Procedure for converting real to string. This function achieves casting of real to string.
elemental function strf_R8P(fm,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -362,7 +535,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strf_R8P
!> @brief Function for converting real to string. This function achieves casting of real to string.
!> @brief Procedure for converting real to string. This function achieves casting of real to string.
elemental function strf_R4P(fm,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -377,7 +550,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strf_R4P
!> @brief Function for converting integer to string. This function achieves casting of integer to string.
!> @brief Procedure for converting integer to string. This function achieves casting of integer to string.
elemental function strf_I8P(fm,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -392,7 +565,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strf_I8P
!> @brief Function for converting integer to string. This function achieves casting of integer to string.
!> @brief Procedure for converting integer to string. This function achieves casting of integer to string.
elemental function strf_I4P(fm,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -407,7 +580,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strf_I4P
!> @brief Function for converting integer to string. This function achieves casting of integer to string.
!> @brief Procedure for converting integer to string. This function achieves casting of integer to string.
elemental function strf_I2P(fm,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -422,7 +595,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strf_I2P
!> @brief Function for converting integer to string. This function achieves casting of integer to string.
!> @brief Procedure for converting integer to string. This function achieves casting of integer to string.
elemental function strf_I1P(fm,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -437,8 +610,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strf_I1P
#ifdef r16p
!> @brief Function for converting real to string. This function achieves casting of real to string.
!> @brief Procedure for converting real to string. This function achieves casting of real to string.
elemental function str_R16P(no_sign,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -454,9 +626,8 @@ contains
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction str_R16P
#endif
!> @brief Function for converting real to string. This function achieves casting of real to string.
!> @brief Procedure for converting real to string. This function achieves casting of real to string.
elemental function str_R8P(no_sign,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -473,7 +644,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction str_R8P
!> @brief Function for converting real to string. This function achieves casting of real to string.
!> @brief Procedure for converting real to string. This function achieves casting of real to string.
elemental function str_R4P(no_sign,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -490,7 +661,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction str_R4P
!> @brief Function for converting integer to string. This function achieves casting of integer to string.
!> @brief Procedure for converting integer to string. This function achieves casting of integer to string.
elemental function str_I8P(no_sign,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -508,7 +679,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction str_I8P
!> @brief Function for converting integer to string. This function achieves casting of integer to string.
!> @brief Procedure for converting integer to string. This function achieves casting of integer to string.
elemental function str_I4P(no_sign,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -526,7 +697,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction str_I4P
!> @brief Function for converting integer to string. This function achieves casting of integer to string.
!> @brief Procedure for converting integer to string. This function achieves casting of integer to string.
elemental function str_I2P(no_sign,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -544,7 +715,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction str_I2P
!> @brief Function for converting integer to string. This function achieves casting of integer to string.
!> @brief Procedure for converting integer to string. This function achieves casting of integer to string.
elemental function str_I1P(no_sign,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -562,7 +733,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction str_I1P
!> @brief Function for converting integer to string, prefixing with the right number of zeros. This function achieves casting of
!> @brief Procedure for converting integer to string, prefixing with the right number of zeros. This function achieves casting of
!> integer to string.
elemental function strz_I8P(nz_pad,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
@ -580,7 +751,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strz_I8P
!> @brief Function for converting integer to string, prefixing with the right number of zeros. This function achieves casting of
!> @brief Procedure for converting integer to string, prefixing with the right number of zeros. This function achieves casting of
!> integer to string.
elemental function strz_I4P(nz_pad,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
@ -598,7 +769,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strz_I4P
!> @brief Function for converting integer to string, prefixing with the right number of zeros. This function achieves casting of
!> @brief Procedure for converting integer to string, prefixing with the right number of zeros. This function achieves casting of
!> integer to string.
elemental function strz_I2P(nz_pad,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
@ -616,7 +787,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strz_I2P
!> @brief Function for converting integer to string, prefixing with the right number of zeros. This function achieves casting of
!> @brief Procedure for converting integer to string, prefixing with the right number of zeros. This function achieves casting of
!> integer to string.
elemental function strz_I1P(nz_pad,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
@ -634,8 +805,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strz_I1P
#ifdef r16p
!> @brief Function for converting string to real. This function achieves casting of string to real.
!> @brief Procedure for converting string to real. This function achieves casting of string to real.
function ctor_R16P(str,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -655,9 +825,8 @@ contains
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction ctor_R16P
#endif
!> @brief Function for converting string to real. This function achieves casting of string to real.
!> @brief Procedure for converting string to real. This function achieves casting of string to real.
function ctor_R8P(str,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -678,7 +847,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction ctor_R8P
!> @brief Function for converting string to real. This function achieves casting of string to real.
!> @brief Procedure for converting string to real. This function achieves casting of string to real.
function ctor_R4P(str,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -699,7 +868,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction ctor_R4P
!> @brief Function for converting string to integer. This function achieves casting of string to integer.
!> @brief Procedure for converting string to integer. This function achieves casting of string to integer.
function ctoi_I8P(str,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -720,7 +889,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction ctoi_I8P
!> @brief Function for converting string to integer. This function achieves casting of string to integer.
!> @brief Procedure for converting string to integer. This function achieves casting of string to integer.
function ctoi_I4P(str,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -741,7 +910,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction ctoi_I4P
!> @brief Function for converting string to integer. This function achieves casting of string to integer.
!> @brief Procedure for converting string to integer. This function achieves casting of string to integer.
function ctoi_I2P(str,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -762,7 +931,7 @@ contains
!---------------------------------------------------------------------------------------------------------------------------------
endfunction ctoi_I2P
!> @brief Function for converting string to integer. This function achieves casting of string to integer.
!> @brief Procedure for converting string to integer. This function achieves casting of string to integer.
function ctoi_I1P(str,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
@ -782,6 +951,201 @@ contains
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction ctoi_I1P
!> @brief Procedure for converting real to string of bits. This function achieves casting of real to bit-string.
!> @note It is assumed that R16P is represented by means of 128 bits, but this is not ensured in all architectures.
elemental function bstr_R16P(n) result(bstr)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R8P), intent(IN):: n !< Real to be converted.
character(128):: bstr !< Returned bit-string containing input number.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
write(bstr,'(B128.128)')n ! Casting of n to bit-string.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bstr_R16P
!> @brief Procedure for converting real to string of bits. This function achieves casting of real to bit-string.
!> @note It is assumed that R8P is represented by means of 64 bits, but this is not ensured in all architectures.
elemental function bstr_R8P(n) result(bstr)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R8P), intent(IN):: n !< Real to be converted.
character(64):: bstr !< Returned bit-string containing input number.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
write(bstr,'(B64.64)')n ! Casting of n to bit-string.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bstr_R8P
!> @brief Procedure for converting real to string of bits. This function achieves casting of real to bit-string.
!> @note It is assumed that R4P is represented by means of 32 bits, but this is not ensured in all architectures.
elemental function bstr_R4P(n) result(bstr)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R4P), intent(IN):: n !< Real to be converted.
character(32):: bstr !< Returned bit-string containing input number.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
write(bstr,'(B32.32)')n ! Casting of n to bit-string.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bstr_R4P
!> @brief Procedure for converting integer to string of bits. This function achieves casting of integer to bit-string.
!> @note It is assumed that I8P is represented by means of 64 bits, but this is not ensured in all architectures.
elemental function bstr_I8P(n) result(bstr)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I8P), intent(IN):: n !< Real to be converted.
character(64):: bstr !< Returned bit-string containing input number.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
write(bstr,'(B64.64)')n ! Casting of n to bit-string.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bstr_I8P
!> @brief Procedure for converting integer to string of bits. This function achieves casting of integer to bit-string.
!> @note It is assumed that I4P is represented by means of 32 bits, but this is not ensured in all architectures.
elemental function bstr_I4P(n) result(bstr)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: n !< Real to be converted.
character(32):: bstr !< Returned bit-string containing input number.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
write(bstr,'(B32.32)')n ! Casting of n to bit-string.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bstr_I4P
!> @brief Procedure for converting integer to string of bits. This function achieves casting of integer to bit-string.
!> @note It is assumed that I2P is represented by means of 16 bits, but this is not ensured in all architectures.
elemental function bstr_I2P(n) result(bstr)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I2P), intent(IN):: n !< Real to be converted.
character(16):: bstr !< Returned bit-string containing input number.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
write(bstr,'(B16.16)')n ! Casting of n to bit-string.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bstr_I2P
!> @brief Procedure for converting integer to string of bits. This function achieves casting of integer to bit-string.
!> @note It is assumed that I1P is represented by means of 8 bits, but this is not ensured in all architectures.
elemental function bstr_I1P(n) result(bstr)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I1P), intent(IN):: n !< Real to be converted.
character(8):: bstr !< Returned bit-string containing input number.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
write(bstr,'(B8.8)')n ! Casting of n to bit-string.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bstr_I1P
!> @brief Procedure for converting bit-string to real. This function achieves casting of bit-string to real.
elemental function bctor_R8P(bstr,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
character(*), intent(IN):: bstr !< String containing input number.
real(R8P), intent(IN):: knd !< Number kind.
real(R8P):: n !< Number returned.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
read(bstr,'(B'//trim(str(.true.,bit_size(knd)))//'.'//trim(str(.true.,bit_size(knd)))//')')n ! Casting of bstr to n.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bctor_R8P
!> @brief Procedure for converting bit-string to real. This function achieves casting of bit-string to real.
elemental function bctor_R4P(bstr,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
character(*), intent(IN):: bstr !< String containing input number.
real(R4P), intent(IN):: knd !< Number kind.
real(R4P):: n !< Number returned.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
read(bstr,'(B'//trim(str(.true.,bit_size(knd)))//'.'//trim(str(.true.,bit_size(knd)))//')')n ! Casting of bstr to n.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bctor_R4P
!> @brief Procedure for converting bit-string to integer. This function achieves casting of bit-string to integer.
elemental function bctoi_I8P(bstr,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
character(*), intent(IN):: bstr !< String containing input number.
integer(I8P), intent(IN):: knd !< Number kind.
integer(I8P):: n !< Number returned.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
read(bstr,'(B'//trim(str(.true.,bit_size(knd)))//'.'//trim(str(.true.,bit_size(knd)))//')')n ! Casting of bstr to n.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bctoi_I8P
!> @brief Procedure for converting bit-string to integer. This function achieves casting of bit-string to integer.
elemental function bctoi_I4P(bstr,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
character(*), intent(IN):: bstr !< String containing input number.
integer(I4P), intent(IN):: knd !< Number kind.
integer(I4P):: n !< Number returned.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
read(bstr,'(B'//trim(str(.true.,bit_size(knd)))//'.'//trim(str(.true.,bit_size(knd)))//')')n ! Casting of bstr to n.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bctoi_I4P
!> @brief Procedure for converting bit-string to integer. This function achieves casting of bit-string to integer.
elemental function bctoi_I2P(bstr,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
character(*), intent(IN):: bstr !< String containing input number.
integer(I2P), intent(IN):: knd !< Number kind.
integer(I2P):: n !< Number returned.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
read(bstr,'(B'//trim(str(.true.,bit_size(knd)))//'.'//trim(str(.true.,bit_size(knd)))//')')n ! Casting of bstr to n.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bctoi_I2P
!> @brief Procedure for converting bit-string to integer. This function achieves casting of bit-string to integer.
elemental function bctoi_I1P(bstr,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
character(*), intent(IN):: bstr !< String containing input number.
integer(I1P), intent(IN):: knd !< Number kind.
integer(I1P):: n !< Number returned.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
read(bstr,'(B'//trim(str(.true.,bit_size(knd)))//'.'//trim(str(.true.,bit_size(knd)))//')')n ! Casting of bstr to n.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction bctoi_I1P
!> @}
!> Subroutine for initilizing module's variables that are not initialized into the definition specification.
@ -795,12 +1159,10 @@ contains
! checking the bit ordering architecture
call check_endian
! computing the bits/bytes sizes of real variables
#ifdef r16p
BIR16P = bit_size(i=MaxR16P) ; BYR16P = BIR16P/8_I1P
#endif
BIR8P = bit_size(i=MaxR8P) ; BYR8P = BIR8P/8_I1P
BIR4P = bit_size(i=MaxR4P) ; BYR4P = BIR4P/8_I1P
BIR_P = bit_size(i=MaxR_P) ; BYR_P = BIR_P/8_I1P
BIR16P = bit_size(r=MaxR16P) ; BYR16P = BIR16P/8_I2P
BIR8P = bit_size(r=MaxR8P) ; BYR8P = BIR8P/8_I1P
BIR4P = bit_size(r=MaxR4P) ; BYR4P = BIR4P/8_I1P
BIR_P = bit_size(r=MaxR_P) ; BYR_P = BIR_P/8_I1P
ir_initialized = .true.
return
!---------------------------------------------------------------------------------------------------------------------------------
@ -808,60 +1170,57 @@ contains
!>Subroutine for printing to the standard output the kind definition of reals and integers and the utility variables.
!> @ingroup IR_PrecisionPublicProcedure
subroutine IR_Print()
subroutine IR_Print(myrank,Nproc)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN), optional:: myrank !< Actual rank process necessary for concurrent multi-processes calls.
integer(I4P), intent(IN), optional:: Nproc !< Number of MPI processes used.
character(DI4P):: rks !< String containing myrank.
integer(I4P):: rank,Np !< Dummy temporary variables.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
call IR_init
if (.not.ir_initialized) call IR_init
rank = 0 ; if (present(myrank)) rank = myrank ; Np = 1 ; if (present(Nproc)) Np = Nproc ; rks = 'rank'//trim(strz(Np,rank))
! printing informations
if (endian==endianL) then
write(stdout,'(A)') ' This architecture has LITTLE Endian bit ordering'
write(stdout,'(A)') trim(rks)//' This architecture has LITTLE Endian bit ordering'
else
write(stdout,'(A)') ' This architecture has BIG Endian bit ordering'
write(stdout,'(A)') trim(rks)//' This architecture has BIG Endian bit ordering'
endif
write(stdout,'(A)') ' Reals kind precision definition'
#ifdef r16p
write(stdout,'(A,I2,A,I2)') ' R16P Kind "',R16P,'" | FR16P format "'//FR16P//'" | DR16P chars ',DR16P
#endif
write(stdout,'(A,I2,A,I2)') ' R8P Kind "',R8P, '" | FR8P format "'//FR8P// '" | DR8P chars ',DR8P
write(stdout,'(A,I2,A,I2)') ' R4P Kind "',R4P, '" | FR4P format "'//FR4P//'" | DR4P chars ',DR4P
write(stdout,'(A)') ' Integers kind precision definition'
write(stdout,'(A,I2,A,I2)') ' I8P Kind "',I8P,'" | FI8P format "'//FI8P// '" | DI8P chars ',DI8P
write(stdout,'(A,I2,A,I2)') ' I4P Kind "',I4P,'" | FI4P format "'//FI4P// '" | DI4P chars ',DI4P
write(stdout,'(A,I2,A,I2)') ' I2P Kind "',I2P,'" | FI2P format "'//FI2P//'" | DI2P chars ',DI2P
write(stdout,'(A,I2,A,I2)') ' I1P Kind "',I1P,'" | FI1P format "'//FI1P//'" | DI1P chars ',DI1P
write(stdout,'(A)') ' Reals minimum and maximum values'
#ifdef r16p
write(stdout,'(A)') ' MinR16P "'//trim(str(n=MinR16P))//'" | MaxR16P "'//trim(str(n=MaxR16P))//'"'
#endif
write(stdout,'(A)') ' MinR8P "'//trim(str(n=MinR8P))//'" | MaxR8P "'//trim(str(n=MaxR8P))//'"'
write(stdout,'(A)') ' MinR4P "'//trim(str(n=MinR4P))//'" | MaxR4P "'//trim(str(n=MaxR4P))//'"'
write(stdout,'(A)') ' Reals bits/bytes sizes'
#ifdef r16p
write(stdout,'(A,I2,A,I2,A)') ' R16P bits "',BIR16P,'", bytes "',BYR16P,'"'
#endif
write(stdout,'(A,I2,A,I2,A)') ' R8P bits "',BIR8P,'", bytes "',BYR8P,'"'
write(stdout,'(A,I2,A,I2,A)') ' R4P bits "',BIR4P,'", bytes "',BYR4P,'"'
write(stdout,'(A,I2,A,I2,A)') ' R_P bits "',BIR_P,'", bytes "',BYR_P,'"'
write(stdout,'(A)') ' Integers minimum and maximum values'
write(stdout,'(A)') ' MinI8P "'//trim(str(n=MinI8P))//'" | MaxI8P "'//trim(str(n=MaxI8P))//'"'
write(stdout,'(A)') ' MinI4P "'//trim(str(n=MinI4P))//'" | MaxI4P "'//trim(str(n=MaxI4P))//'"'
write(stdout,'(A)') ' MinI2P "'//trim(str(n=MinI2P))//'" | MaxI2P "'//trim(str(n=MaxI2P))//'"'
write(stdout,'(A)') ' MinI1P "'//trim(str(n=MinI1P))//'" | MaxI1P "'//trim(str(n=MaxI1P))//'"'
write(stdout,'(A)') ' Integers bits/bytes sizes'
write(stdout,'(A,I2,A,I2,A)') ' I8P bits "',BII8P,'", bytes "',BYI8P,'"'
write(stdout,'(A,I2,A,I2,A)') ' I4P bits "',BII4P,'", bytes "',BYI4P,'"'
write(stdout,'(A,I2,A,I2,A)') ' I2P bits "',BII2P,'", bytes "',BYI2P,'"'
write(stdout,'(A,I2,A,I2,A)') ' I1P bits "',BII1P,'", bytes "',BYI1P,'"'
write(stdout,'(A,I2,A,I2,A)') ' I_P bits "',BII_P,'", bytes "',BYI_P,'"'
write(stdout,'(A)') ' Machine precisions'
#ifdef r16p
write(stdout,'(A,'//FR16P//')') ' ZeroR16 "',ZeroR16
#endif
write(stdout,'(A,'//FR8P// ')') ' ZeroR8 "',ZeroR8
write(stdout,'(A,'//FR4P// ')') ' ZeroR4 "',ZeroR4
write(stdout,'(A)') trim(rks)//' Reals kind precision definition'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R16P Kind "',R16P,'" | FR16P format "'//FR16P//'" | DR16P chars "',DR16P,'"'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R8P Kind "',R8P, '" | FR8P format "'//FR8P// '" | DR8P chars "',DR8P ,'"'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R4P Kind "',R4P, '" | FR4P format "'//FR4P//'" | DR4P chars "',DR4P ,'"'
write(stdout,'(A)') trim(rks)//' Integers kind precision definition'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I8P Kind "',I8P,'" | FI8P format "'//FI8P// '" | DI8P chars "',DI8P,'"'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I4P Kind "',I4P,'" | FI4P format "'//FI4P// '" | DI4P chars "',DI4P,'"'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I2P Kind "',I2P,'" | FI2P format "'//FI2P//'" | DI2P chars "',DI2P,'"'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I1P Kind "',I1P,'" | FI1P format "'//FI1P//'" | DI1P chars "',DI1P,'"'
write(stdout,'(A)') trim(rks)//' Reals minimum and maximum values'
write(stdout,'(A)') trim(rks)//' MinR16P "'//trim(str(n=MinR16P))//'" | MaxR16P "'//trim(str(n=MaxR16P))//'"'
write(stdout,'(A)') trim(rks)//' MinR8P "'//trim(str(n=MinR8P))// '" | MaxR8P "'//trim(str(n=MaxR8P))// '"'
write(stdout,'(A)') trim(rks)//' MinR4P "'//trim(str(n=MinR4P))// '" | MaxR4P "'//trim(str(n=MaxR4P))// '"'
write(stdout,'(A)') trim(rks)//' Reals bits/bytes sizes'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R16P bits "',BIR16P,'", bytes "',BYR16P,'"'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R8P bits "', BIR8P, '", bytes "',BYR8P, '"'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R4P bits "', BIR4P, '", bytes "',BYR4P, '"'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R_P bits "', BIR_P, '", bytes "',BYR_P, '"'
write(stdout,'(A)') trim(rks)//' Integers minimum and maximum values'
write(stdout,'(A)') trim(rks)//' MinI8P "'//trim(str(n=MinI8P))//'" | MaxI8P "'//trim(str(n=MaxI8P))//'"'
write(stdout,'(A)') trim(rks)//' MinI4P "'//trim(str(n=MinI4P))//'" | MaxI4P "'//trim(str(n=MaxI4P))//'"'
write(stdout,'(A)') trim(rks)//' MinI2P "'//trim(str(n=MinI2P))//'" | MaxI2P "'//trim(str(n=MaxI2P))//'"'
write(stdout,'(A)') trim(rks)//' MinI1P "'//trim(str(n=MinI1P))//'" | MaxI1P "'//trim(str(n=MaxI1P))//'"'
write(stdout,'(A)') trim(rks)//' Integers bits/bytes sizes'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I8P bits "',BII8P,'", bytes "',BYI8P,'"'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I4P bits "',BII4P,'", bytes "',BYI4P,'"'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I2P bits "',BII2P,'", bytes "',BYI2P,'"'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I1P bits "',BII1P,'", bytes "',BYI1P,'"'
write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I_P bits "',BII_P,'", bytes "',BYI_P,'"'
write(stdout,'(A)') trim(rks)//' Machine precisions'
write(stdout,'(A)') trim(rks)//' ZeroR16 "'//trim(str(.true.,ZeroR16))//'"'
write(stdout,'(A)') trim(rks)//' ZeroR8 "'//trim(str(.true.,ZeroR8 ))//'"'
write(stdout,'(A)') trim(rks)//' ZeroR4 "'//trim(str(.true.,ZeroR4 ))//'"'
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine IR_Print
endmodule IR_Precision

909
lib/Lib_Base64.f90 Normal file
View File

@ -0,0 +1,909 @@
!> @ingroup Library
!> @{
!> @defgroup Lib_Base64Library Lib_Base64
!> base64 encoding/decoding library
!> @}
!> @ingroup Interface
!> @{
!> @defgroup Lib_Base64Interface Lib_Base64
!> base64 encoding/decoding library
!> @}
!> @ingroup PublicProcedure
!> @{
!> @defgroup Lib_Base64PublicProcedure Lib_Base64
!> base64 encoding/decoding library
!> @}
!> @ingroup PrivateProcedure
!> @{
!> @defgroup Lib_Base64PrivateProcedure Lib_Base64
!> base64 encoding/decoding library
!> @}
!> @ingroup GlobalVarPar
!> @{
!> @defgroup Lib_Base64GlobalVarPar Lib_Base64
!> base64 encoding/decoding library
!> @}
!> @ingroup PrivateVarPar
!> @{
!> @defgroup Lib_Base64PrivateVarPar Lib_Base64
!> base64 encoding/decoding library
!> @}
!> This module contains base64 encoding/decoding procedures.
!> @todo \b Decoding: Implement decoding functions.
!> @todo \b DocComplete: Complete the documentation.
!> @ingroup Lib_Base64Library
module Lib_Base64
!-----------------------------------------------------------------------------------------------------------------------------------
USE IR_Precision ! Integers and reals precision definition.
!-----------------------------------------------------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------------------------------------------------
implicit none
private
public:: b64_encode
!public:: b64_decode
public:: pack_data
!-----------------------------------------------------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------------------------------------------------
!> @ingroup Lib_Base64GlobalVarPar
!> @{
!> @}
!> @ingroup Lib_Base64PrivateVarPar
!> @{
character(64):: base64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" !< Base64 alphabet.
!> @}
!-----------------------------------------------------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------------------------------------------------
!> @brief Subroutine for encoding numbers (integer and real) to base64.
!> @ingroup Lib_Base64Interface
interface b64_encode
module procedure b64_encode_R8_a, &
b64_encode_R4_a, &
b64_encode_I8_a, &
b64_encode_I4_a, &
b64_encode_I2_a, &
b64_encode_I1_a
endinterface
!!> @brief Subroutine for decoding numbers (integer and real) from base64.
!!> @ingroup Lib_Base64Interface
!interface b64_decode
! module procedure b64_decode_R8_a, &
! b64_decode_R4_a, &
! b64_decode_I8_a, &
! b64_decode_I4_a, &
! b64_decode_I2_a, &
! b64_decode_I1_a
!endinterface
!> @brief Subroutine for packing different kinds of data into single I1P array. This is useful for encoding different kinds
!> variables into a single stream of bits.
!> @ingroup Lib_Base64Interface
interface pack_data
module procedure pack_data_R8_R4,pack_data_R8_I8,pack_data_R8_I4,pack_data_R8_I2,pack_data_R8_I1, &
pack_data_R4_R8,pack_data_R4_I8,pack_data_R4_I4,pack_data_R4_I2,pack_data_R4_I1, &
pack_data_I8_R8,pack_data_I8_R4,pack_data_I8_I4,pack_data_I8_I2,pack_data_I8_I1, &
pack_data_I4_R8,pack_data_I4_R4,pack_data_I4_I8,pack_data_I4_I2,pack_data_I4_I1, &
pack_data_I2_R8,pack_data_I2_R4,pack_data_I2_I8,pack_data_I2_I4,pack_data_I2_I1, &
pack_data_I1_R8,pack_data_I1_R4,pack_data_I1_I8,pack_data_I1_I4,pack_data_I1_I2
endinterface
!-----------------------------------------------------------------------------------------------------------------------------------
contains
!> @ingroup Lib_Base64PrivateProcedure
!> @{
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_R8_R4(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R8P), intent(IN):: a1(1:) !< Firs data stream.
real(R4P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_R8_R4
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_R8_I8(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R8P), intent(IN):: a1(1:) !< First data stream.
integer(I8P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_R8_I8
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_R8_I4(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R8P), intent(IN):: a1(1:) !< First data stream.
integer(I4P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_R8_I4
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_R8_I2(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R8P), intent(IN):: a1(1:) !< First data stream.
integer(I2P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_R8_I2
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_R8_I1(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R8P), intent(IN):: a1(1:) !< First data stream.
integer(I1P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_R8_I1
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_R4_R8(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R4P), intent(IN):: a1(1:) !< Firs data stream.
real(R8P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_R4_R8
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_R4_I8(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R4P), intent(IN):: a1(1:) !< First data stream.
integer(I8P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_R4_I8
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_R4_I4(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R4P), intent(IN):: a1(1:) !< First data stream.
integer(I4P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_R4_I4
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_R4_I2(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R4P), intent(IN):: a1(1:) !< First data stream.
integer(I2P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_R4_I2
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_R4_I1(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
real(R4P), intent(IN):: a1(1:) !< First data stream.
integer(I1P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_R4_I1
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I8_R8(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I8P), intent(IN):: a1(1:) !< First data stream.
real(R8P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I8_R8
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I8_R4(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I8P), intent(IN):: a1(1:) !< First data stream.
real(R4P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I8_R4
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I8_I4(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I8P), intent(IN):: a1(1:) !< First data stream.
integer(I4P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I8_I4
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I8_I2(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I8P), intent(IN):: a1(1:) !< First data stream.
integer(I2P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I8_I2
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I8_I1(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I8P), intent(IN):: a1(1:) !< First data stream.
integer(I1P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I8_I1
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I4_R8(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: a1(1:) !< First data stream.
real(R8P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I4_R8
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I4_R4(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: a1(1:) !< First data stream.
real(R4P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I4_R4
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I4_I8(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: a1(1:) !< First data stream.
integer(I8P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I4_I8
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I4_I2(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: a1(1:) !< First data stream.
integer(I2P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I4_I2
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I4_I1(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: a1(1:) !< First data stream.
integer(I1P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I4_I1
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I2_R8(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I2P), intent(IN):: a1(1:) !< First data stream.
real(R8P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I2_R8
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I2_R4(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I2P), intent(IN):: a1(1:) !< First data stream.
real(R4P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I2_R4
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I2_I8(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I2P), intent(IN):: a1(1:) !< First data stream.
integer(I8P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I2_I8
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I2_I4(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I2P), intent(IN):: a1(1:) !< First data stream.
integer(I4P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I2_I4
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I2_I1(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I2P), intent(IN):: a1(1:) !< First data stream.
integer(I1P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I2_I1
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I1_R8(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I1P), intent(IN):: a1(1:) !< First data stream.
real(R8P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I1_R8
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I1_R4(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I1P), intent(IN):: a1(1:) !< First data stream.
real(R4P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I1_R4
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I1_I8(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I1P), intent(IN):: a1(1:) !< First data stream.
integer(I8P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I1_I8
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I1_I4(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I1P), intent(IN):: a1(1:) !< First data stream.
integer(I4P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I1_I4
!> @brief Subroutine for packing different kinds of data into single I1P array.
pure subroutine pack_data_I1_I2(a1,a2,packed)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I1P), intent(IN):: a1(1:) !< First data stream.
integer(I2P), intent(IN):: a2(1:) !< Second data stream.
integer(I1P), allocatable, intent(INOUT):: packed(:) !< Packed data into I1P array.
integer(I1P), allocatable:: p1(:) !< Temporary packed data of first stream.
integer(I1P), allocatable:: p2(:) !< Temporary packed data of second stream.
integer(I4P):: np !< Size of temporary packed data.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
np = size(transfer(a1,p1)) ; allocate(p1(1:np)) ; p1 = transfer(a1,p1)
np = size(transfer(a2,p2)) ; allocate(p2(1:np)) ; p2 = transfer(a2,p2)
if (allocated(packed)) deallocate(packed) ; allocate(packed(1:size(p1,dim=1)+size(p2,dim=1))) ; packed = [p1,p2]
deallocate(p1,p2)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine pack_data_I1_I2
!> @brief Subroutine for encoding bits (must be multiple of 24 bits) into base64 charcaters code (of length multiple of 4).
!> @note The bits stream are encoded in chunks of 24 bits as the following example (in little endian order):
!> @code
!> +--first octet--+-second octet--+--third octet--+
!> |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
!> +-----------+---+-------+-------+---+-----------+
!> |5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|
!> +--1.index--+--2.index--+--3.index--+--4.index--+
!> @endcode
!> The 4 indexes are stored into 4 elements 8 bits array, thus 2 bits of each array element are not used.
pure subroutine encode_bits(bits,padd,code)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I1P), intent(IN):: bits(1:) !< Bits to be encoded.
integer(I4P), intent(IN):: padd !< Number of padding characters ('=').
character(1), intent(OUT):: code(1:) !< Characters code.
integer(I1P):: sixb(1:4) !< 6 bits slices (stored into 8 bits integer) of 24 bits input.
integer(I8P):: c,e !< Counters.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
c = 1_I8P
do e=1_I8P,size(bits,dim=1),3_I8P ! loop over array elements: 3 bytes (24 bits) scanning
sixb = 0_I1P
call mvbits(bits(e ),2,6,sixb(1),0)
call mvbits(bits(e ),0,2,sixb(2),4) ; call mvbits(bits(e+1),4,4,sixb(2),0)
call mvbits(bits(e+1),0,4,sixb(3),2) ; call mvbits(bits(e+2),6,2,sixb(3),0)
call mvbits(bits(e+2),0,6,sixb(4),0)
sixb = sixb + 1_I1P
code(c :c )(1:1) = base64(sixb(1):sixb(1))
code(c+1:c+1)(1:1) = base64(sixb(2):sixb(2))
code(c+2:c+2)(1:1) = base64(sixb(3):sixb(3))
code(c+3:c+3)(1:1) = base64(sixb(4):sixb(4))
c = c + 4_I8P
enddo
if (padd>0) code(size(code,dim=1)-padd+1:)(1:1)='='
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine encode_bits
!> @brief Subroutine for encoding array numbers to base64 (R8P).
pure subroutine b64_encode_R8_a(nB,n,code)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: nB !< Number of bytes of single element of n.
real(R8P), intent(IN):: n(1:) !< Array of numbers to be encoded.
character(1), allocatable, intent(OUT):: code(:) !< Encoded array.
integer(I1P):: nI1P(1:((size(n,dim=1)*nB+2)/3)*3) !< One byte integer array containing n.
integer(I4P):: padd !< Number of padding characters ('=').
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
if (allocated(code)) deallocate(code) ; allocate(code(1:((size(n,dim=1)*nB+2)/3)*4)) ! allocating code chars
nI1P = transfer(n,nI1P) ! casting n to integer array of 1 byte elem
padd = mod((size(n,dim=1)*nB),3_I4P) ; if (padd>0_I4P) padd = 3_I4P - padd ! computing the number of padding characters
call encode_bits(bits=nI1P,padd=padd,code=code) ! encoding bits
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine b64_encode_R8_a
!> @brief Subroutine for encoding array numbers to base64 (R4P).
pure subroutine b64_encode_R4_a(nB,n,code)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: nB !< Number of bytes of single element of n.
real(R4P), intent(IN):: n(1:) !< Array of numbers to be encoded.
character(1), allocatable, intent(OUT):: code(:) !< Encoded array.
integer(I1P):: nI1P(1:((size(n,dim=1)*nB+2)/3)*3) !< One byte integer array containing n.
integer(I4P):: padd !< Number of padding characters ('=').
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
if (allocated(code)) deallocate(code) ; allocate(code(1:((size(n,dim=1)*nB+2)/3)*4)) ! allocating code chars
nI1P = transfer(n,nI1P) ! casting n to integer array of 1 byte elem
padd = mod((size(n,dim=1)*nB),3_I4P) ; if (padd>0_I4P) padd = 3_I4P - padd ! computing the number of padding characters
call encode_bits(bits=nI1P,padd=padd,code=code) ! encoding bits
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine b64_encode_R4_a
!> @brief Subroutine for encoding array numbers to base64 (I8P).
pure subroutine b64_encode_I8_a(nB,n,code)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: nB !< Number of bytes of single element of n.
integer(I8P), intent(IN):: n(1:) !< Array of numbers to be encoded.
character(1), allocatable, intent(OUT):: code(:) !< Encoded array.
integer(I1P):: nI1P(1:((size(n,dim=1)*nB+2)/3)*3) !< One byte integer array containing n.
integer(I4P):: padd !< Number of padding characters ('=').
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
if (allocated(code)) deallocate(code) ; allocate(code(1:((size(n,dim=1)*nB+2)/3)*4)) ! allocating code chars
nI1P = transfer(n,nI1P) ! casting n to integer array of 1 byte elem
padd = mod((size(n,dim=1)*nB),3_I4P) ; if (padd>0_I4P) padd = 3_I4P - padd ! computing the number of padding characters
call encode_bits(bits=nI1P,padd=padd,code=code) ! encoding bits
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine b64_encode_I8_a
!> @brief Subroutine for encoding array numbers to base64 (I4P).
pure subroutine b64_encode_I4_a(nB,n,code)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: nB !< Number of bytes of single element of n.
integer(I4P), intent(IN):: n(1:) !< Array of numbers to be encoded.
character(1), allocatable, intent(OUT):: code(:) !< Encoded array.
integer(I1P):: nI1P(1:((size(n,dim=1)*nB+2)/3)*3) !< One byte integer array containing n.
integer(I4P):: padd !< Number of padding characters ('=').
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
if (allocated(code)) deallocate(code) ; allocate(code(1:((size(n,dim=1)*nB+2)/3)*4)) ! allocating code chars
nI1P = transfer(n,nI1P) ! casting n to integer array of 1 byte elem
padd = mod((size(n,dim=1)*nB),3_I4P) ; if (padd>0_I4P) padd = 3_I4P - padd ! computing the number of padding characters
call encode_bits(bits=nI1P,padd=padd,code=code) ! encoding bits
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine b64_encode_I4_a
!> @brief Subroutine for encoding array numbers to base64 (I2P).
pure subroutine b64_encode_I2_a(nB,n,code)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: nB !< Number of bytes of single element of n.
integer(I2P), intent(IN):: n(1:) !< Array of numbers to be encoded.
character(1), allocatable, intent(OUT):: code(:) !< Encoded array.
integer(I1P):: nI1P(1:((size(n,dim=1)*nB+2)/3)*3) !< One byte integer array containing n.
integer(I4P):: padd !< Number of padding characters ('=').
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
if (allocated(code)) deallocate(code) ; allocate(code(1:((size(n,dim=1)*nB+2)/3)*4)) ! allocating code chars
nI1P = transfer(n,nI1P) ! casting n to integer array of 1 byte elem
padd = mod((size(n,dim=1)*nB),3_I4P) ; if (padd>0_I4P) padd = 3_I4P - padd ! computing the number of padding characters
call encode_bits(bits=nI1P,padd=padd,code=code) ! encoding bits
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine b64_encode_I2_a
!> @brief Subroutine for encoding array numbers to base64 (I1P).
pure subroutine b64_encode_I1_a(nB,n,code)
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P), intent(IN):: nB !< Number of bytes of single element of n.
integer(I1P), intent(IN):: n(1:) !< Array of numbers to be encoded.
character(1), allocatable, intent(OUT):: code(:) !< Encoded array.
integer(I1P):: nI1P(1:((size(n,dim=1)*nB+2)/3)*3) !< One byte integer array containing n.
integer(I4P):: padd !< Number of padding characters ('=').
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
if (allocated(code)) deallocate(code) ; allocate(code(1:((size(n,dim=1)*nB+2)/3)*4)) ! allocating code chars
nI1P = transfer(n,nI1P) ! casting n to integer array of 1 byte elem
padd = mod((size(n,dim=1)*nB),3_I4P) ; if (padd>0_I4P) padd = 3_I4P - padd ! computing the number of padding characters
call encode_bits(bits=nI1P,padd=padd,code=code) ! encoding bits
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine b64_encode_I1_a
!!> @brief Subroutine for decoding array numbers from base64 (R8P).
!pure subroutine b64_decode_R8_a(code,n)
!!--------------------------------------------------------------------------------------------------------------------------------
!implicit none
!real(R8P), intent(OUT):: n(1:) !< Number to be decoded.
!character(ncR8P*size(n,dim=1)), intent(IN):: code !< Encoded number.
!integer(I4P):: c,d !< Counters.
!!--------------------------------------------------------------------------------------------------------------------------------
!!--------------------------------------------------------------------------------------------------------------------------------
!d = 1_I4P
!do c=1,len(code),ncR8P
! call b64_decode_R8_s(code=code(c:c+ncR8P-1),n=n(d))
! d = d + 1_I4P
!enddo
!return
!!--------------------------------------------------------------------------------------------------------------------------------
!endsubroutine b64_decode_R8_a
!> @}
endmodule Lib_Base64

File diff suppressed because it is too large Load Diff