get_type(3f) - [M_anything] return array of strings containing type
names of arguments
(LICENSE:MIT)
function get_type(anything) result(chars)
class(*),intent(in) :: anything
or
class(*),intent(in) :: anything(..)
character(len=:),allocatable :: chars
This function uses polymorphism to allow input arguments of different
types. It is used by other procedures that can take many
argument types as input options.
VALUEIN input array or scalar to return type of
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=*)
CHARS The returned value is an array of names
Sample program
program demo_get_type
use M_anything, only : get_type
implicit none
integer :: i
write(*,*)get_type([(i*i,i=1,10)])
write(*,*)get_type([11.11,22.22,33.33])
write(*,*)get_type('This is a string')
write(*,*)get_type(30.0d0)
end program demo_get_type
Results:
int32
real32
character
real64
John S. Urban
MIT
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(*), | intent(in) | :: | anything(:) |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(*), | intent(in) | :: | anything |