Encode scalar number to base64 (R8P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=R8P), | intent(in) | :: | n | Number to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
pure subroutine b64_encode_R8(n, code)
!---------------------------------------------------------------------------------------------------------------------------------
!< Encode scalar number to base64 (R8P).
!---------------------------------------------------------------------------------------------------------------------------------
real(R8P), 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:((BYR8P+2)/3)*3)) ; nI1P = 0_I1P
code = repeat(' ',((BYR8P+2)/3)*4)
nI1P = transfer(n,nI1P)
padd = mod((BYR8P),3_I1P) ; if (padd>0_I4P) padd = 3_I4P - padd
call encode_bits(bits=nI1P,padd=padd,code=code)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine b64_encode_R8