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

Generate and return .true. if the input array is sorted in descending order (with the possibility of elements being equal), otherwise, generate and return .false.. More...

Detailed Description

Generate and return .true. if the input array is sorted in descending order (with the possibility of elements being equal), otherwise, generate and return .false..

Parameters
[in]array: The input contiguous array of rank 1 of either
  1. type css_pdt or,
  2. type css_type or,
  3. type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) of arbitrary length type parameter or,
  4. type integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64) or,
  5. type logical of kind any supported by the processor (e.g., LK) or,
  6. type complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128) or,
  7. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128) or,
or,
  1. a scalar of type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) of arbitrary length type parameter,
whose elements will be checked for an all descending order
(with the possibility of elements being equal).
Returns
sorted : An output logical of default kind LK that is .true. if all elements of the input array are in descending order (with the possibility of elements being equal) or all equal. Otherwise, it is .false..


Possible calling interfaces

descending = isDescending(array)
Generate and return .true. if the input array is sorted in descending order (with the possibility of ...
This module contains procedures and generic interfaces for various sorting tasks.
Warning
The output of this procedure is .true. when the input array has zero length.
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
isSorted
isAscending
setSorted
setSorted


Example usage

1program example
2
3 use pm_kind, only: SK, IK, LK ! all intrinsic types and kinds are supported.
5 use pm_io, only: display_type
6
7 implicit none
8
9 type(display_type) :: disp
10
11 disp = display_type(file = "main.out.F90")
12
13 call disp%skip()
14 call disp%show("isDescending('')")
15 call disp%show( isDescending('') )
16 call disp%skip()
17 call disp%show("isDescending('?Aa')")
18 call disp%show( isDescending('?Aa') )
19 call disp%skip()
20 call disp%show("isDescending('A!b')")
21 call disp%show( isDescending('A!b') )
22 call disp%skip()
23 call disp%show("isDescending('zxw')")
24 call disp%show( isDescending('zxw') )
25 call disp%skip()
26 call disp%show("isDescending('AAA')")
27 call disp%show( isDescending('AAA') )
28 call disp%skip()
29
30 call disp%skip()
31 call disp%show("isDescending([character(0) ::])")
32 call disp%show( isDescending([character(0) ::]) )
33 call disp%skip()
34 call disp%show("isDescending(['?', 'A', 'a'])")
35 call disp%show( isDescending(['?', 'A', 'a']) )
36 call disp%skip()
37 call disp%show("isDescending(['A', '!', 'b'])")
38 call disp%show( isDescending(['A', '!', 'b']) )
39 call disp%skip()
40 call disp%show("isDescending(['z', 'x', 'w'])")
41 call disp%show( isDescending(['z', 'x', 'w']) )
42 call disp%skip()
43 call disp%show("isDescending(['A', 'A', 'A'])")
44 call disp%show( isDescending(['A', 'A', 'A']) )
45 call disp%skip()
46
47 call disp%skip()
48 call disp%show("isDescending([integer ::])")
49 call disp%show( isDescending([integer ::]) )
50 call disp%skip()
51 call disp%show("isDescending([+1, +2, +3])")
52 call disp%show( isDescending([+1, +2, +3]) )
53 call disp%skip()
54 call disp%show("isDescending([-1, -2, -3])")
55 call disp%show( isDescending([-1, -2, -3]) )
56 call disp%skip()
57 call disp%show("isDescending([-1, +2, -3])")
58 call disp%show( isDescending([-1, +2, -3]) )
59 call disp%skip()
60 call disp%show("isDescending([-1, -1, -1])")
61 call disp%show( isDescending([-1, -1, -1]) )
62 call disp%skip()
63
64 call disp%skip()
65 call disp%show("isDescending([logical ::])")
66 call disp%show( isDescending([logical ::]) )
67 call disp%skip()
68 call disp%show("isDescending([.false., .false., .true.])")
69 call disp%show( isDescending([.false., .false., .true.]) )
70 call disp%skip()
71 call disp%show("isDescending([.true., .false., .false.])")
72 call disp%show( isDescending([.true., .false., .false.]) )
73 call disp%skip()
74 call disp%show("isDescending([.false., .true., .false.])")
75 call disp%show( isDescending([.false., .true., .false.]) )
76 call disp%skip()
77 call disp%show("isDescending([.true., .true., .true.])")
78 call disp%show( isDescending([.true., .true., .true.]) )
79 call disp%skip()
80
81 call disp%skip()
82 call disp%show("isDescending([complex ::])")
83 call disp%show( isDescending([complex ::]) )
84 call disp%skip()
85 call disp%show("isDescending([(+1., -1.), (+2., -2.), (+3., -3.)])")
86 call disp%show( isDescending([(+1., -1.), (+2., -2.), (+3., -3.)]) )
87 call disp%skip()
88 call disp%show("isDescending([(-1., +1.), (-2., +2.), (-3., +3.)])")
89 call disp%show( isDescending([(-1., +1.), (-2., +2.), (-3., +3.)]) )
90 call disp%skip()
91 call disp%show("isDescending([(-1., +1.), (+2., -2.), (-3., +3.)])")
92 call disp%show( isDescending([(-1., +1.), (+2., -2.), (-3., +3.)]) )
93 call disp%skip()
94 call disp%show("isDescending([(-1., +1.), (-1., +1.), (-1., +1.)])")
95 call disp%show( isDescending([(-1., +1.), (-1., +1.), (-1., +1.)]) )
96 call disp%skip()
97 call disp%show("isDescending([(-1., +1.), (-1., -2.), (-1., +3.)])")
98 call disp%show( isDescending([(-1., +1.), (-1., -2.), (-1., +3.)]) )
99 call disp%skip()
100
101 call disp%skip()
102 call disp%show("isDescending([real ::])")
103 call disp%show( isDescending([real ::]) )
104 call disp%skip()
105 call disp%show("isDescending([+1., +2., +3.])")
106 call disp%show( isDescending([+1., +2., +3.]) )
107 call disp%skip()
108 call disp%show("isDescending([-1., -2., -3.])")
109 call disp%show( isDescending([-1., -2., -3.]) )
110 call disp%skip()
111 call disp%show("isDescending([-1., +2., -3.])")
112 call disp%show( isDescending([-1., +2., -3.]) )
113 call disp%skip()
114 call disp%show("isDescending([-1., -1., -1.])")
115 call disp%show( isDescending([-1., -1., -1.]) )
116 call disp%skip()
117
118#if PDT_ENABLED
119 ! \bug
120 ! Intel ifort 2022.3 cannot handle aliases for pdt names (e.g., strc => css_pdt).
121 block
122 use pm_container, only: css_pdt
123 call disp%skip()
124 call disp%show("isDescending([css_pdt('is'), css_pdt( 'sorted'), css_pdt('string')])")
125 call disp%show( isDescending([css_pdt('is'), css_pdt( 'sorted'), css_pdt('string')]) )
126 call disp%skip()
127 call disp%show("isDescending([css_pdt('string'), css_pdt('is'), css_pdt('sorted')])")
128 call disp%show( isDescending([css_pdt('string'), css_pdt('is'), css_pdt('sorted')]) )
129 call disp%skip()
130 call disp%show("isDescending([css_pdt('same string'), css_pdt('same '), css_pdt('same')])")
131 call disp%show( isDescending([css_pdt('same string'), css_pdt('same '), css_pdt('same')]) )
132 call disp%skip()
133 end block
134#endif
135
136end 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 the derived types for generating allocatable containers of scalar,...
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
This is the css_pdt parameterized type for generating instances of container of scalar of string obje...
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
3T
4
5isDescending('?Aa')
6F
7
8isDescending('A!b')
9F
10
11isDescending('zxw')
12T
13
14isDescending('AAA')
15T
16
17
18isDescending([character(0) ::])
19T
20
21isDescending(['?', 'A', 'a'])
22F
23
24isDescending(['A', '!', 'b'])
25F
26
27isDescending(['z', 'x', 'w'])
28T
29
30isDescending(['A', 'A', 'A'])
31T
32
33
34isDescending([integer ::])
35T
36
37isDescending([+1, +2, +3])
38F
39
40isDescending([-1, -2, -3])
41T
42
43isDescending([-1, +2, -3])
44F
45
46isDescending([-1, -1, -1])
47T
48
49
50isDescending([logical ::])
51T
52
53isDescending([.false., .false., .true.])
54F
55
56isDescending([.true., .false., .false.])
57T
58
59isDescending([.false., .true., .false.])
60F
61
62isDescending([.true., .true., .true.])
63T
64
65
66isDescending([complex ::])
67T
68
69isDescending([(+1., -1.), (+2., -2.), (+3., -3.)])
70F
71
72isDescending([(-1., +1.), (-2., +2.), (-3., +3.)])
73T
74
75isDescending([(-1., +1.), (+2., -2.), (-3., +3.)])
76F
77
78isDescending([(-1., +1.), (-1., +1.), (-1., +1.)])
79T
80
81isDescending([(-1., +1.), (-1., -2.), (-1., +3.)])
82T
83
84
85isDescending([real ::])
86T
87
88isDescending([+1., +2., +3.])
89F
90
91isDescending([-1., -2., -3.])
92T
93
94isDescending([-1., +2., -3.])
95F
96
97isDescending([-1., -1., -1.])
98T
99
100
Test:
test_pm_arraySort


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, April 21, 2017, 3:54 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin

Definition at line 1724 of file pm_arraySort.F90.


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