anyscalar_to_real128(3f) - [M_anything] convert integer or real parameter of any kind to real128 (LICENSE:MIT)
Synopsis
Description
Options
Results
Examples
Author
License
pure elemental function anyscalar_to_real128(valuein) result(d_out)
class(*),intent(in) :: valuein real(kind=128) :: d_out
This function uses polymorphism to allow input arguments of different types. It is used to create other procedures that can take many scalar arguments as input options.
VALUEIN input argument of a procedure to convert to type REAL128. May be of KIND kind=int8, kind=int16, kind=int32, kind=int64, kind=real32, kind=real64, or kind=real128
D_OUT The value of VALUIN converted to REAL128 (assuming it is actually in the range of type REAL128).
Sample program
program demo_anyscalar_to_real128 use, intrinsic :: iso_fortran_env, only : & & i8=>int8, i16=>int16, i32=>int32, i64=>int64 use, intrinsic :: iso_fortran_env, only : & & sp=>real32, dp=>real64, qp=>real128 implicit none ! call same function with many scalar input types write(*,*)minall(& & 2_i8, 7_i16, 8_i32, 9_i64, 2.0123123_sp, 3.0123_dp, 5.0_qp) write(*,*)minall(& & 5.0_qp, 3.0123_dp, 2.0123123_sp, 9_i64, 8_i32, 7_i16, 2_i8) containsResults:function minall(a,b,c,d,e,f,g) result (value) use M_anything, only : x=>anyscalar_to_real128 class(*),intent(in) :: a,b,c,d,e,f,g real(kind=qp) :: value value=min( x(a),x(b),x(c),x(d),x(e),x(f),x(g) ) end function minall
end program demo_anyscalar_to_real128
> 2.00000000000000000000000000000000000 > 2.00000000000000000000000000000000000
John S. Urban
Nemo Release 3.1 | anyscalar_to_real128 (3) | February 23, 2025 |