bytes_to_anything(3f) - [M_anything] convert bytes(character)len=1):: array(:)) to standard types (LICENSE:MIT)
Synopsis
Description
Options
Return
Example
Author
License
subroutine bytes_to_anything(chars,anything)
character(len=1),allocatable :: chars(:) class(*) :: anything
This function uses polymorphism to allow input arguments of different types. It is used to create other procedures that can take many argument types as input options and convert them to a single type to simplify storing arbitrary data, to simplify generating data hashes, ...
CHARS The input value is an array of bytes (character(len=1)).
ANYTHING May be of KIND INTEGER(kind=int8), INTEGER(kind=int16), INTEGER(kind=int32), INTEGER(kind=int64), REAL(kind=real32, REAL(kind=real64), REAL(kind=real128), complex, or CHARACTER(len=*)
Sample program
program demo_bytes_to_anything use M_anything, only : bytes_to_anything use M_anything, only : anything_to_bytes implicit none character(len=1),allocatable :: chars(:) integer :: ints(10) integer :: i chars=anything_to_bytes([(i*i,i=1,size(ints))]) write(*,(/,4(1x,z2.2)))chars call bytes_to_anything(chars,ints) write(*,(*(g0,1x)))ints end program demo_bytes_to_anythingResults: >
> |
01 00 00 00
| ||||||||||||||||||||
John S. Urban
Nemo Release 3.1 | bytes_to_anything (3m_anything) | April 04, 2023 |