Decode base64 string to float32 array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | input | |||
| real(kind=real32), | intent(out), | allocatable | :: | values(:) | ||
| integer, | intent(out) | :: | n |
subroutine decode_base64_to_float32(input, values, n) !! Decode base64 string to float32 array use iso_fortran_env, only: int8, int32 implicit none character(*), intent(in) :: input real(real32), allocatable, intent(out) :: values(:) integer, intent(out) :: n integer(int8), allocatable :: bytes(:) integer :: nbytes, i integer(int32) :: ival call base64_decode_bytes(input, bytes, nbytes) n = nbytes / 4 allocate(values(n)) do i = 1, n ival = ior(ior(ior( & iand(int(bytes((i-1)*4 + 1), int32), 255), & ishft(iand(int(bytes((i-1)*4 + 2), int32), 255), 8)), & ishft(iand(int(bytes((i-1)*4 + 3), int32), 255), 16)), & ishft(iand(int(bytes((i-1)*4 + 4), int32), 255), 24)) values(i) = transfer(ival, values(i)) end do deallocate(bytes) end subroutine decode_base64_to_float32