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

Return evenly spaced integer or character sequence starting at start with jump sizes of step.
More...

Detailed Description

Return evenly spaced integer or character sequence starting at start with jump sizes of step.

The value of the last element of the output array is determined by the size of the array: range(size(range)) = start + step * (size(range) - 1).
If range is of type character, then replace size with len in the above formula.

Parameters
[out]range: The output sequence that can be,
  1. a scalar character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) of length type parameter 1,
  2. a contiguous array of rank 1 of type integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64),
containing the evenly-spaced sequence within the interval starting with start and with jumps of size step.
[in]stop: The input scalar of the same type and kind as start representing the end point of the output range.
If stop is of type character, then it must be of length type parameter 1.
[in]step: The non-zero input scalar of type integer representing the size of the interval between adjacent values in the output range.
  1. If range is of type character, then step must have the default integer kind IK.
  2. If range is of type integer, then step must have the same type kind parameter as range.
(optional, default = 1)


Possible calling interfaces

! Integer sequence.
call setRange(range(:), start)
call setRange(range(:), start, step)
! Character sequence.
call setRange(range, start)
call setRange(range, start, step)
Return evenly spaced integer or character sequence starting at start with jump sizes of step.
This module contains procedures and generic interfaces for generating ranges of discrete character,...
Warning
The condition step /= 0 must hold for the corresponding input arguments.
The condition len(start) == 1 must hold for the corresponding input character arguments.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
See also
getRange
setRange
getLinSpace
setLinSpace
getLogSpace
setLogSpace


Example usage

1program example
2
3 use pm_kind, only: LK, SK
4 use pm_io, only: display_type
5 use pm_arrayRange, only: setRange
6
7 implicit none
8
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("!real range")
16 call disp%show("!%%%%%%%%%%")
17 call disp%skip
18
19 block
20 real :: range(10) ! all non-default kinds are also supported.
21
22 call disp%skip
23 call disp%show("size(range)")
24 call disp%show( size(range) )
25 call disp%show("call setRange(range, 0.)")
26 call setRange(range, 0.)
27 call disp%show("range")
28 call disp%show( range )
29 call disp%skip
30
31 call disp%skip
32 call disp%show("size(range)")
33 call disp%show( size(range) )
34 call disp%show("call setRange(range, 1.)")
35 call setRange(range, 1.)
36 call disp%show("range")
37 call disp%show( range )
38 call disp%skip
39
40 call disp%skip
41 call disp%show("size(range)")
42 call disp%show( size(range) )
43 call disp%show("call setRange(range, -huge(1.))")
44 call setRange(range, -huge(1.))
45 call disp%show("range")
46 call disp%show( range )
47 call disp%skip
48
49 call disp%skip
50 call disp%show("size(range)")
51 call disp%show( size(range) )
52 call disp%show("call setRange(range, 0., -2.5)")
53 call setRange(range, 0., -2.5)
54 call disp%show("range")
55 call disp%show( range )
56 call disp%skip
57
58 call disp%skip
59 call disp%show("size(range)")
60 call disp%show( size(range) )
61 call disp%show("call setRange(range, 0., +2.5)")
62 call setRange(range, 0., +2.5)
63 call disp%show("range")
64 call disp%show( range )
65 call disp%skip
66
67 end block
68
69 call disp%skip
70 call disp%show("!%%%%%%%%%%%%%%%")
71 call disp%show("!character range")
72 call disp%show("!%%%%%%%%%%%%%%%")
73 call disp%skip
74
75 block
76 character(5) :: range ! all non-default kinds are also supported.
77 call disp%skip
78 call disp%show("call setRange(range, 'A')")
79 call setRange(range, 'A')
80 call disp%show("range")
81 call disp%show( range )
82 call disp%skip
83
84 call disp%skip
85 call disp%show("call setRange(range, 'A', 2)")
86 call setRange(range, 'A', 2)
87 call disp%show("range")
88 call disp%show( range )
89 call disp%skip
90
91 call disp%skip
92 call disp%show("call setRange(range, 'A', 3)")
93 call setRange(range, 'A', 3)
94 call disp%show("range")
95 call disp%show( range )
96 call disp%skip
97
98 call disp%skip
99 call disp%show("call setRange(range, 'A', 3)")
100 call setRange(range, 'A', 3)
101 call disp%show("range")
102 call disp%show( range )
103 call disp%skip
104
105 call disp%skip
106 call disp%show("call setRange(range, 'Z', -2)")
107 call setRange(range, 'Z', -2)
108 call disp%show("range")
109 call disp%show( range )
110 call disp%skip
111 end block
112
113 call disp%skip
114 call disp%show("!%%%%%%%%%%%%%")
115 call disp%show("!integer range")
116 call disp%show("!%%%%%%%%%%%%%")
117 call disp%skip
118
119 block
120 integer :: range(5) ! all non-default kinds are also supported.
121 call disp%skip
122 call disp%show("call setRange(range, 0)")
123 call setRange(range, 0)
124 call disp%show("range")
125 call disp%show( range )
126 call disp%skip
127
128 call disp%skip
129 call disp%show("call setRange(range, 0, 2)")
130 call setRange(range, 0, 2)
131 call disp%show("range")
132 call disp%show( range )
133 call disp%skip
134
135 call disp%skip
136 call disp%show("call setRange(range, 0, 3)")
137 call setRange(range, 0, 3)
138 call disp%show("range")
139 call disp%show( range )
140 call disp%skip
141
142 call disp%skip
143 call disp%show("call setRange(range, 0, 3)")
144 call setRange(range, 0, 3)
145 call disp%show("range")
146 call disp%show( range )
147 call disp%skip
148
149 call disp%skip
150 call disp%show("call setRange(range, 0, -2)")
151 call setRange(range, 0, -2)
152 call disp%show("range")
153 call disp%show( range )
154 call disp%skip
155 end block
156
157end 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 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!real range
4!%%%%%%%%%%
5
6
7size(range)
8+10
9call setRange(range, 0.)
10range
11+0.00000000, +0.140129846E-44, +0.280259693E-44, +0.420389539E-44, +0.560519386E-44, +0.700649232E-44, +0.840779079E-44, +0.980908925E-44, +0.112103877E-43, +0.126116862E-43
12
13
14size(range)
15+10
16call setRange(range, 1.)
17range
18+1.00000000, +1.00000012, +1.00000024, +1.00000036, +1.00000048, +1.00000060, +1.00000072, +1.00000083, +1.00000095, +1.00000107
19
20
21size(range)
22+10
23call setRange(range, -huge(1.))
24range
25-0.340282347E+39, -0.340282326E+39, -0.340282306E+39, -0.340282286E+39, -0.340282266E+39, -0.340282245E+39, -0.340282225E+39, -0.340282205E+39, -0.340282184E+39, -0.340282164E+39
26
27
28size(range)
29+10
30call setRange(range, 0., -2.5)
31range
32+0.00000000, -2.50000000, -5.00000000, -7.50000000, -10.0000000, -12.5000000, -15.0000000, -17.5000000, -20.0000000, -22.5000000
33
34
35size(range)
36+10
37call setRange(range, 0., +2.5)
38range
39+0.00000000, +2.50000000, +5.00000000, +7.50000000, +10.0000000, +12.5000000, +15.0000000, +17.5000000, +20.0000000, +22.5000000
40
41
42!%%%%%%%%%%%%%%%
43!character range
44!%%%%%%%%%%%%%%%
45
46
47call setRange(range, 'A')
48range
49ABCDE
50
51
52call setRange(range, 'A', 2)
53range
54ACEGI
55
56
57call setRange(range, 'A', 3)
58range
59ADGJM
60
61
62call setRange(range, 'A', 3)
63range
64ADGJM
65
66
67call setRange(range, 'Z', -2)
68range
69ZXVTR
70
71
72!%%%%%%%%%%%%%
73!integer range
74!%%%%%%%%%%%%%
75
76
77call setRange(range, 0)
78range
79+0, +1, +2, +3, +4
80
81
82call setRange(range, 0, 2)
83range
84+0, +2, +4, +6, +8
85
86
87call setRange(range, 0, 3)
88range
89+0, +3, +6, +9, +12
90
91
92call setRange(range, 0, 3)
93range
94+0, +3, +6, +9, +12
95
96
97call setRange(range, 0, -2)
98range
99+0, -2, -4, -6, -8
100
101
Test:
test_pm_arrayRange


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:
Fatemeh Bagheri, Tuesday 08:49 PM, August 10, 2021, Dallas, TX

Definition at line 695 of file pm_arrayRange.F90.


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