ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_val2real::getReal Interface Reference

Generate and return the conversion of the input value to a real value of default kind RK. More...

Detailed Description

Generate and return the conversion of the input value to a real value of default kind RK.

Parameters
[in]val: The input scalar or array of arbitrary rank of either
  type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU), or
  type logical of kind any supported by the processor (e.g., LK), or
  whose value will be converted to an output of type real of default kind RK.
Returns
conversion : The scalar or array of the same shape as the input val of the type real of default kind RK, containing the conversion of the input value val.
  1. If the input val is a logical that evaluates to .true., then conversion = 1._RK, otherwise conversion = 0._RK.
  2. If the input val is a character, then conversion is the result of the List-directed I/O action read(val,*) conversion.


Possible calling interfaces

use pm_val2real, only: getReal
conversion = getReal(val)
Generate and return the conversion of the input value to a real value of default kind RK.
This module contains procedures and types for facilitating the conversion of values of different type...
Definition: pm_val2real.F90:43
Remarks
The procedures under discussion are pure.
The procedures under discussion are elemental.
See also
getStr
setStr
getInt
setInt
getLogical
setLogical
getComplex
setComplex
getReal
setReal


Example usage

1program example
2
3 use pm_kind, only: IK
4 use pm_kind, only: LK, SK ! all processor types and kinds are supported.
5 use pm_io, only: display_type
6 use pm_val2real, only: getReal
7
8 implicit none
9
10 type(display_type) :: disp
11 disp = display_type(file = "main.out.F90")
12
13 call disp%skip()
14 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
15 call disp%show("! Convert logical values to real.")
16 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
17 call disp%skip()
18
19 call disp%skip()
20 call disp%show("getReal(.true._LK)")
21 call disp%show( getReal(.true._LK) )
22 call disp%skip()
23
24 call disp%skip()
25 call disp%show("getReal(.false._LK)")
26 call disp%show( getReal(.false._LK) )
27 call disp%skip()
28
29 call disp%skip()
30 call disp%show("getReal([.true._LK, .false._LK, .true._LK])")
31 call disp%show( getReal([.true._LK, .false._LK, .true._LK]) )
32 call disp%skip()
33
34 call disp%skip()
35 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
36 call disp%show("! Convert string values to real.")
37 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
38 call disp%skip()
39
40 call disp%skip()
41 call disp%show("getReal(SK_'1.e0')")
42 call disp%show( getReal(SK_'1.e0') )
43 call disp%skip()
44
45 call disp%skip()
46 call disp%show("getReal(SK_'123456.d0')")
47 call disp%show( getReal(SK_'123456.d0') )
48 call disp%skip()
49
50 call disp%skip()
51 call disp%show("getReal(SK_'1.d0 -1.d0')")
52 call disp%show( getReal(SK_'1.d0 -1.d0') )
53 call disp%skip()
54
55 call disp%skip()
56 call disp%show("getReal(SK_'1.d0, -1.d0')")
57 call disp%show( getReal(SK_'1.d0, -1.d0') )
58 call disp%skip()
59
60 call disp%skip()
61 call disp%show("getReal(SK_'3., paramonte, (1.d0, -1.e0)')")
62 call disp%show( getReal(SK_'3., paramonte, (1.d0, -1.e0)') )
63 call disp%skip()
64
65 call disp%skip()
66 call disp%show("getReal(SK_'-3., (1., -1.), paramonte')")
67 call disp%show( getReal(SK_'-3., (1., -1.), paramonte') )
68 call disp%skip()
69
70 call disp%skip()
71 call disp%show("getReal([character(10,SK) :: '1, -1', '1, paramonte', '100, -100'])")
72 call disp%show( getReal([character(10,SK) :: '1, -1', '1, paramonte', '100, -100']) )
73 call disp%skip()
74
75 call disp%skip()
76 call disp%show("getReal(SK_'1., -1., paramonte')")
77 call disp%show( getReal(SK_'1., -1., paramonte') )
78 call disp%skip()
79
80 call disp%skip()
81 call disp%show("getReal(SK_'1., paramonte')")
82 call disp%show( getReal(SK_'1., paramonte') )
83 call disp%skip()
84
85 call disp%skip()
86 call disp%show("getReal(SK_'1.d0')")
87 call disp%show( getReal(SK_'1.d0') )
88 call disp%skip()
89
90 call disp%skip()
91 call disp%show("getReal([character(10,SK) :: '1, -1', '10', '100, -100'])")
92 call disp%show( getReal([character(10,SK) :: '1, -1', '10', '100, -100']) )
93 call disp%skip()
94
95end program example
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3! Convert logical values to real.
4!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6
7getReal(.true._LK)
8+1.0000000000000000
9
10
11getReal(.false._LK)
12+0.0000000000000000
13
14
15getReal([.true._LK, .false._LK, .true._LK])
16+1.0000000000000000, +0.0000000000000000, +1.0000000000000000
17
18
19!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20! Convert string values to real.
21!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22
23
24getReal(SK_'1.e0')
25+1.0000000000000000
26
27
28getReal(SK_'123456.d0')
29+123456.00000000000
30
31
32getReal(SK_'1.d0 -1.d0')
33+1.0000000000000000
34
35
36getReal(SK_'1.d0, -1.d0')
37+1.0000000000000000
38
39
40getReal(SK_'3., paramonte, (1.d0, -1.e0)')
41+3.0000000000000000
42
43
44getReal(SK_'-3., (1., -1.), paramonte')
45-3.0000000000000000
46
47
48getReal([character(10,SK) :: '1, -1', '1, paramonte', '100, -100'])
49+1.0000000000000000, +1.0000000000000000, +100.00000000000000
50
51
52getReal(SK_'1., -1., paramonte')
53+1.0000000000000000
54
55
56getReal(SK_'1., paramonte')
57+1.0000000000000000
58
59
60getReal(SK_'1.d0')
61+1.0000000000000000
62
63
64getReal([character(10,SK) :: '1, -1', '10', '100, -100'])
65+1.0000000000000000, +10.000000000000000, +100.00000000000000
66
67
Test:
test_pm_val2real


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, September 1, 2017, 12:00 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin

Definition at line 105 of file pm_val2real.F90.


The documentation for this interface was generated from the following file: