b64_encode_R16 Subroutine

private pure subroutine b64_encode_R16(n, code)

Arguments

Type IntentOptional AttributesName
real(kind=R16P), intent(in) :: n

Number to be encoded.

character(len=:), intent(out), allocatable:: code

Encoded scalar.

Description

Encode scalar number to base64 (R16P).

Calls

proc~~b64_encode_r16~~CallsGraph proc~b64_encode_r16 b64_encode_R16 proc~encode_bits encode_bits proc~b64_encode_r16->proc~encode_bits
Help

Variables

TypeVisibility AttributesNameInitial
integer(kind=I1P), public, allocatable:: nI1P(:)

One byte integer array containing n.

integer(kind=I4P), public :: padd

Number of padding characters ('=').


Source Code

  pure subroutine b64_encode_R16(n, code)
  !---------------------------------------------------------------------------------------------------------------------------------
  !< Encode scalar number to base64 (R16P).
  !---------------------------------------------------------------------------------------------------------------------------------
  real(R16P),                    intent(in)  :: n       !< Number to be encoded.
  character(len=:), allocatable, intent(out) :: code    !< Encoded scalar.
  integer(I1P),     allocatable              :: nI1P(:) !< One byte integer array containing n.
  integer(I4P)                               :: padd    !< Number of padding characters ('=').
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
  allocate(nI1P(1:((BYR16P+2)/3)*3)) ; nI1P = 0_I1P
  code = repeat(' ',((BYR16P+2)/3)*4)
  nI1P = transfer(n,nI1P)
  padd = mod((BYR16P),3_I2P) ; if (padd>0_I4P) padd = 3_I4P - padd
  call encode_bits(bits=nI1P,padd=padd,code=code)
  return
  !---------------------------------------------------------------------------------------------------------------------------------
  endsubroutine b64_encode_R16