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

Generate and return the conversion of the input value to a integer value of default kind IK. More...

Detailed Description

Generate and return the conversion of the input value to a integer value of default kind IK.

Parameters
[in]val: The input scalar or array of arbitrary rank of either
  1. type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU), or
  2. type logical of kind any supported by the processor (e.g., LK), or
whose value will be converted to an output of type integer of default kind IK.
Returns
conversion : The scalar or array of the same shape as the input val of the type integer of default kind IK, containing the conversion of the input value val.
  1. If the input val is a logical that evaluates to .true., then conversion = 1_IK, otherwise conversion = 0_IK.
  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_val2int, only: getInt
conversion = getInt(val)
Generate and return the conversion of the input value to a integer value of default kind IK.
Definition: pm_val2int.F90:109
This module contains procedures and types for facilitating the conversion of values of different type...
Definition: pm_val2int.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_val2int, only: getInt
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 integer.")
16 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
17 call disp%skip()
18
19 call disp%skip()
20 call disp%show("getInt(.true._LK)")
21 call disp%show( getInt(.true._LK) )
22 call disp%skip()
23
24 call disp%skip()
25 call disp%show("getInt(.false._LK)")
26 call disp%show( getInt(.false._LK) )
27 call disp%skip()
28
29 call disp%skip()
30 call disp%show("getInt([.true._LK, .false._LK, .true._LK])")
31 call disp%show( getInt([.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 integer.")
37 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
38 call disp%skip()
39
40 call disp%skip()
41 call disp%show("getInt(SK_'1')")
42 call disp%show( getInt(SK_'1') )
43 call disp%skip()
44
45 call disp%skip()
46 call disp%show("getInt(SK_'123456')")
47 call disp%show( getInt(SK_'123456') )
48 call disp%skip()
49
50 call disp%skip()
51 call disp%show("getInt(SK_'1 -1')")
52 call disp%show( getInt(SK_'1 -1') )
53 call disp%skip()
54
55 call disp%skip()
56 call disp%show("getInt(SK_'1, -1')")
57 call disp%show( getInt(SK_'1, -1') )
58 call disp%skip()
59
60 call disp%skip()
61 call disp%show("getInt(SK_'3, paramonte, (1, -1)')")
62 call disp%show( getInt(SK_'3, paramonte, (1, -1)') )
63 call disp%skip()
64
65 call disp%skip()
66 call disp%show("getInt(SK_'-3, (1, -1), paramonte')")
67 call disp%show( getInt(SK_'-3, (1, -1), paramonte') )
68 call disp%skip()
69
70 call disp%skip()
71 call disp%show("getInt([character(10,SK) :: '1, -1', '1, paramonte', '100, -100'])")
72 call disp%show( getInt([character(10,SK) :: '1, -1', '1, paramonte', '100, -100']) )
73 call disp%skip()
74
75 call disp%skip()
76 call disp%show("getInt(SK_'1, -1, paramonte')")
77 call disp%show( getInt(SK_'1, -1, paramonte') )
78 call disp%skip()
79
80 call disp%skip()
81 call disp%show("getInt(SK_'1, paramonte')")
82 call disp%show( getInt(SK_'1, paramonte') )
83 call disp%skip()
84
85 call disp%skip()
86 call disp%show("getInt(SK_'1')")
87 call disp%show( getInt(SK_'1') )
88 call disp%skip()
89
90 call disp%skip()
91 call disp%show("getInt([character(10,SK) :: '1, -1', '10', '100, -100'])")
92 call disp%show( getInt([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 integer.
4!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6
7getInt(.true._LK)
8+1
9
10
11getInt(.false._LK)
12+0
13
14
15getInt([.true._LK, .false._LK, .true._LK])
16+1, +0, +1
17
18
19!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20! Convert string values to integer.
21!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22
23
24getInt(SK_'1')
25+1
26
27
28getInt(SK_'123456')
29+123456
30
31
32getInt(SK_'1 -1')
33+1
34
35
36getInt(SK_'1, -1')
37+1
38
39
40getInt(SK_'3, paramonte, (1, -1)')
41+3
42
43
44getInt(SK_'-3, (1, -1), paramonte')
45-3
46
47
48getInt([character(10,SK) :: '1, -1', '1, paramonte', '100, -100'])
49+1, +1, +100
50
51
52getInt(SK_'1, -1, paramonte')
53+1
54
55
56getInt(SK_'1, paramonte')
57+1
58
59
60getInt(SK_'1')
61+1
62
63
64getInt([character(10,SK) :: '1, -1', '10', '100, -100'])
65+1, +10, +100
66
67
Test:
test_pm_val2int


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 Austin

Definition at line 109 of file pm_val2int.F90.


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