[UP]


Manual Reference Pages  - anyscalar_to_real128 (3)

NAME

anyscalar_to_real128(3f) - [M_anything] convert integer or real parameter of any kind to real128 (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Results
Example
Author
License

SYNOPSIS

pure elemental function anyscalar_to_real128(valuein) result(d_out)

    class(*),intent(in) :: valuein
    real(kind=128)      :: d_out

DESCRIPTION

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.

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

RESULTS

D_OUT The value of VALUIN converted to REAL128 (assuming it is actually in the range of type REAL128).

EXAMPLE

Sample program

    program demo_anyscalar_to_real128
    use, intrinsic :: iso_fortran_env, only : int8, int16, int32, int64
    use, intrinsic :: iso_fortran_env, only : real32, real64, real128
    implicit none
       ! call same function with many scalar input types
       write(*,*)squarei(2_int8)
       write(*,*)squarei(2_int16)
       write(*,*)squarei(2_int32)
       write(*,*)squarei(2_int64)
       write(*,*)squarei(2_real32)
       write(*,*)squarei(2_real64)
       write(*,*)squarei(2_real128)
    contains

function squarei(invalue) result (dvalue) use M_anything, only : anyscalar_to_real128 class(*),intent(in) :: invalue real(kind=real128) :: invalue_local real(kind=real128) :: dvalue invalue_local=anyscalar_to_real128(invalue) dvalue=invalue_local*invalue_local end function squarei

end program demo_anyscalar_to_real128

AUTHOR

John S. Urban

LICENSE

Public Domain


anyscalar_to_real128 (3) October 17, 2020
Generated by manServer 1.08 from 22cf345e-85ff-46fd-a9b9-1fa6d11f3a78 using man macros.