public interface cast
Casts/Transforms between Fortran and Python datatypes
Result is 1st argument to cast, object/scalar to cast 2nd argument
Use to cast/transform a Python object into a Fortran value
Use to cast/transform Fortran values into a Python object
and to cast an unspecific Python object into more specific objects, such
as list, tuple, dict
Fortran values can be scalars and character strings or character arrays
Fortran character strings are decoded as UTF-8
Python strings are encoded as UTF-8
For casting to numerical Fortran scalars, there is an optional 3rd argument "strict"
for cast: if strict=.false. it will try to convert numerical values to the requested
datatype (default: strict=.true.). This is the same as using cast_nonstrict.
Module Procedures
private function cast_to_list(li, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(list), |
intent(out) |
|
| :: |
li | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_dict(di, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(dict), |
intent(out) |
|
| :: |
di | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_tuple(tu, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(tuple), |
intent(out) |
|
| :: |
tu | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_NoneType(no, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(NoneType), |
intent(out) |
|
| :: |
no | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_ndarray(nd, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(ndarray), |
intent(out) |
|
| :: |
nd | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_object(plain_obj, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(object), |
intent(out) |
|
| :: |
plain_obj | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_char_1d(out_value, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
character(kind=C_CHAR), |
|
|
dimension(:), pointer | :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_chars(out_value, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
character(kind=C_CHAR,len=:), |
intent(out), |
|
allocatable | :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_int32(out_value, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
integer(kind=int32), |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_int32_flex(out_value, obj, strict) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
integer(kind=int32), |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
logical, |
intent(in) |
|
| :: |
strict | |
Return Value integer(kind=C_INT)
private function cast_from_int32(obj, in_value) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(object), |
intent(out) |
|
| :: |
obj | |
integer(kind=int32), |
intent(in) |
|
| :: |
in_value | |
Return Value integer(kind=C_INT)
private function cast_to_int64(out_value, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
integer(kind=int64), |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_int64_flex(out_value, obj, strict) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
integer(kind=int64), |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
logical, |
intent(in) |
|
| :: |
strict | |
Return Value integer(kind=C_INT)
private function cast_from_int64(obj, in_value) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(object), |
intent(out) |
|
| :: |
obj | |
integer(kind=int64), |
intent(in) |
|
| :: |
in_value | |
Return Value integer(kind=C_INT)
private function cast_to_real32(out_value, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
real(kind=real32), |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_real32_flex(out_value, obj, strict) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
real(kind=real32), |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
logical, |
intent(in) |
|
| :: |
strict | |
Return Value integer(kind=C_INT)
private function cast_from_real32(obj, in_value) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(object), |
intent(out) |
|
| :: |
obj | |
real(kind=real32), |
intent(in) |
|
| :: |
in_value | |
Return Value integer(kind=C_INT)
private function cast_to_real64(out_value, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
real(kind=real64), |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_real64_flex(out_value, obj, strict) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
real(kind=real64), |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
logical, |
intent(in) |
|
| :: |
strict | |
Return Value integer(kind=C_INT)
private function cast_from_real64(obj, in_value) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(object), |
intent(out) |
|
| :: |
obj | |
real(kind=real64), |
intent(in) |
|
| :: |
in_value | |
Return Value integer(kind=C_INT)
private function cast_to_complex_real32(out_value, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
complex(kind=real32), |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_complex_real32_flex(out_value, obj, strict) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
complex(kind=real32), |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
logical, |
intent(in) |
|
| :: |
strict | |
Return Value integer(kind=C_INT)
private function cast_from_complex_real32(obj, in_value) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(object), |
intent(out) |
|
| :: |
obj | |
complex(kind=real32), |
intent(in) |
|
| :: |
in_value | |
Return Value integer(kind=C_INT)
private function cast_to_complex_real64(out_value, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
complex(kind=real64), |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_complex_real64_flex(out_value, obj, strict) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
complex(kind=real64), |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
logical, |
intent(in) |
|
| :: |
strict | |
Return Value integer(kind=C_INT)
private function cast_from_complex_real64(obj, in_value) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(object), |
intent(out) |
|
| :: |
obj | |
complex(kind=real64), |
intent(in) |
|
| :: |
in_value | |
Return Value integer(kind=C_INT)
private function cast_to_logical(out_value, obj) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
logical, |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
Return Value integer(kind=C_INT)
private function cast_to_logical_flex(out_value, obj, strict) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
logical, |
intent(out) |
|
| :: |
out_value | |
class(object), |
intent(in) |
|
| :: |
obj | |
logical, |
intent(in) |
|
| :: |
strict | |
Return Value integer(kind=C_INT)
private function cast_from_logical(obj, in_value) result(ierror)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(object), |
intent(out) |
|
| :: |
obj | |
logical, |
intent(in) |
|
| :: |
in_value | |
Return Value integer(kind=C_INT)