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

Return a list of directory paths matching a requested system application.
More...

Detailed Description

Return a list of directory paths matching a requested system application.

This generic interface is meant to provide an easy unified cross-language way of detecting applications, particularly, vendor MPI installations on the system.
The original approach of implementing this functionality separately in different programming language environments proved messy.
This generic interface along with getPathMatch attempt to reduce multi-language code duplication to only one (Fortran) language.

Search Strategy
The search strategy relies on retrieving the output of the command system_profiler SPApplicationsDataType in Darwin OS.
The search strategy relies on retrieving the contents of the processor environmental PATH variable in Windows and Linux OS.
Each identified path will be checked to ensure it is a real path before inclusion in the result.

Parameters
[in]key: The input scalar character of default kind SK of arbitrary non-zero length type parameter containing a list of search keywords separated by the specified input sep character.
An empty key (with zero length type parameter) leads to returning all identified paths in the processor environment.
Similarly, an empty search keyword item in the input key evaluates to match all paths.
The input key must be null-terminated when the procedure is called from the C language.
[in]inc: The input scalar character of the same type and kind as the input key of arbitrary length type parameter containing the (partial) name of a target file, subfolder, or application that should be present in the output directory paths.
If the input inc is missing or empty, the entire list of paths matching key will be returned in the output list.
The input inc must be null-terminated when the procedure is called from the C language.
[in]sep: The input scalar character of the type and kind as key of length type parameter 1, containing the character to be used for separating search keywords provided in key.
The recommended value for sep is the returned value from getPathSep.
[out]list: The output scalar character of the same type and kind as the input key, containing a list of the identified paths matching the input search keywords without case-sensitivity.
The paths, if any more than one are detected, are separated by the specified input sep character.
The interpretation of the output contents of list depends on the value of the input/output argument lenList.
[in,out]lenList: The input/output scalar integer of default kind IK.
On input, it must contain the positive-valued length of the slice of list buffer to be used for storing the results.
On output, depending on its value, lenList can signal different scenarios:
  1. A positive output value larger than its input value implies the slice list contains the directory path only partially.
    In such a case, user may want to call the routine with a larger input buffer list length specified via lenList to store the path in full.
  2. A positive output value smaller than its input value implies the slice list(1:lenList) contains the directory path in full.
  3. A negative output value implies that and error occurred and/or no installed application path matching the specified keywords could be found.
    In such a case, the slice list(1 : abs(lenList)) contains a description of the error or other informative messages.
    The interpretation of the value of abs(lenList) is subject to the same rules for the positive value of lenList laid out above.
  4. A zero output value implies that no installed application path matching the specified keywords could be found on the system.
A value of MAX_LEN_FILE_PATH for lenList should be more than sufficient with focused keyword search.
If the input key contents are expected to match many paths, a longer buffer list may be needed.
In such cases, the length of the environmental PATH variable can be used a rule of thumb for input value of lenList.


Possible calling interfaces

call setPathMatch(key, inc, sep, list, lenList)
Return a list of directory paths matching a requested system application.
This module contains classes and procedures for manipulating system file/folder paths.
Definition: pm_sysPath.F90:274
Warning
The condition 0 < lenList must hold for the corresponding input arguments.
The input argument key must be null-terminated when the procedure is called from the C language.
Remarks
The procedures under discussion are impure.
Note
This generic interface is primarily intended for access from other programming language environments.
For a more flexible within-Fortran interface see the generic function interface getPathMatch.
See also
getPathMatch
setPathMatch


Example usage

1program example
2
3 use pm_kind, only: LK, IK, SK
4 use pm_io, only: display_type
5 use pm_sysPath, only: getPathSep
6 use pm_sysPath, only: setPathMatch
8
9 implicit none
10
11 integer(IK) :: lenList
12 type(display_type) :: disp
13 character(:, SK), allocatable :: list
14 disp = display_type(file = "main.out.F90")
15
16 call disp%skip()
17 call disp%show("lenList = 9999")
18 lenList = 9999
19 call disp%show("list = repeat(' ', lenList)")
20 list = repeat(' ', lenList)
21 call disp%show("call setPathMatch(key = SK_'', inc = SK_'', sep = getPathSep(), list = list, lenList = lenList)")
22 call setPathMatch(key = SK_'', inc = SK_'', sep = getPathSep(), list = list, lenList = lenList)
23 call disp%show("lenList")
24 call disp%show( lenList )
25 call disp%show("getReplaced(trim(list), getPathSep(), new_line(SK_'a'))")
26 call disp%show( getReplaced(trim(list), getPathSep(), new_line(SK_'a')) , deliml = SK_"""" )
27 call disp%skip()
28
29 call disp%skip()
30 call disp%show("lenList = 9999")
31 lenList = 9999
32 call disp%show("list = repeat(' ', lenList)")
33 list = repeat(' ', lenList)
34 call disp%show("call setPathMatch(key = SK_'intel:oneapi:mpi:', inc = SK_'', sep = getPathSep(), list = list, lenList = lenList)")
35 call setPathMatch(key = SK_'intel:oneapi:mpi:', inc = SK_'', sep = getPathSep(), list = list, lenList = lenList)
36 call disp%show("lenList")
37 call disp%show( lenList )
38 call disp%show("getReplaced(trim(list), SK_':', new_line(SK_'a'))")
39 call disp%show( getReplaced(trim(list), SK_':', new_line(SK_'a')) , deliml = SK_"""" )
40 call disp%skip()
41
42 call disp%skip()
43 call disp%show("lenList = 9999")
44 lenList = 9999
45 call disp%show("list = repeat(' ', lenList)")
46 list = repeat(' ', lenList)
47 call disp%show("call setPathMatch(key = SK_'intel:oneapi:mpi', inc = SK_'mpiexec', sep = getPathSep(), list = list, lenList = lenList)")
48 call setPathMatch(key = SK_'intel:oneapi:mpi', inc = SK_'mpiexec', sep = getPathSep(), list = list, lenList = lenList)
49 call disp%show("lenList")
50 call disp%show( lenList )
51 call disp%show("getReplaced(trim(list), getPathSep(), new_line(SK_'a'))")
52 call disp%show( getReplaced(trim(list), getPathSep(), new_line(SK_'a')) , deliml = SK_"""" )
53 call disp%skip()
54
55end program example
Generate and return an arrayNew of the same type and kind as the input array, in which the requested ...
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
Generate and return the path separator character used by the runtime processor shell for separating p...
This module contains procedures and generic interfaces for replacing patterns within arrays of variou...
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
2lenList = 9999
3list = repeat(' ', lenList)
4call setPathMatch(key = SK_'', inc = SK_'', sep = getPathSep(), list = list, lenList = lenList)
5lenList
6+3338
7getReplaced(trim(list), getPathSep(), new_line(SK_'a'))
8"/home/amir/gems/bin
9/usr/local/MATLAB/R2023b/bin
10/usr/local/sbin
11/usr/local/bin
12/usr/sbin
13/usr/bin
14/sbin
15/bin
16/usr/games
17/usr/local/games
18/usr/lib/wsl/lib
19/mnt/c/Ruby32-x64/bin
20/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/bin/
21/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/bin/release/
22/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/libfabric/bin/
23/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/libfabric/bin/utils/
24/mnt/c/Program Files (x86)/Intel/oneAPI/tbb/latest/redist/intel64/vc_mt/
25/mnt/c/Program Files (x86)/Intel/oneAPI/tbb/latest/redist/ia32/vc_mt/
26/mnt/c/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/redist/intel64_win/compiler
27/mnt/c/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/redist/ia32_win/compiler
28/mnt/c/Windows/system32
29/mnt/c/Windows
30/mnt/c/Windows/System32/Wbem
31/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
32/mnt/c/Windows/System32/OpenSSH/
33/mnt/c/Program Files/dotnet/
34/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
35/mnt/c/Program Files/MATLAB/R2024a/runtime/win64
36/mnt/c/Program Files/MATLAB/R2024a/bin
37/mnt/c/Program Files/MATLAB/R2023b/runtime/win64
38/mnt/c/Program Files/MATLAB/R2023b/bin
39/mnt/c/Program Files/MATLAB/R2022b/runtime/win64
40/mnt/c/Program Files/MATLAB/R2022b/bin
41/mnt/c/Program Files/MiKTeX/miktex/bin/x64/
42/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/
43/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/
44/mnt/c/Program Files/Git/cmd
45/mnt/c/Program Files/gs/gs10.00.0/bin
46/mnt/c/Program Files/PuTTY/
47/mnt/c/Program Files/MATLAB/R2020b/runtime/win64
48/mnt/c/Program Files/MATLAB/R2020b/bin
49/mnt/c/Program Files/MATLAB/R2019b/runtime/win64
50/mnt/c/Program Files/MATLAB/R2019b/bin
51/mnt/c/Program Files (x86)/Pulse Secure/VC142.CRT/X64/
52/mnt/c/Program Files (x86)/Pulse Secure/VC142.CRT/X86/
53/mnt/c/Program Files (x86)/Common Files/Pulse Secure/TNC Client Plugin/
54/mnt/c/Program Files (x86)/Intel/oneAPI/vpl/latest/bin
55/mnt/c/Program Files (x86)/Intel/oneAPI/tbb/latest/redist/intel64/vc_mt
56/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/libfabric/bin/utils
57/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/libfabric/bin
58/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/bin/release
59/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/bin
60/mnt/c/Program Files (x86)/Intel/oneAPI/mkl/latest/redist/intel64
61/mnt/c/Program Files (x86)/Intel/oneAPI/mkl/latest/bin/intel64
62/mnt/c/Program Files (x86)/Intel/oneAPI/itac/latest/bin
63/mnt/c/Program Files (x86)/Intel/oneAPI/itac/latest/dll
64/mnt/c/Program Files (x86)/Intel/oneAPI/ippcp/latest/redist/intel64
65/mnt/c/Program Files (x86)/Intel/oneAPI/ipp/latest/redist/intel64
66/mnt/c/Program Files (x86)/Intel/oneAPI/dpcpp-ct/latest/bin
67/mnt/c/Program Files (x86)/Intel/oneAPI/dnnl/latest/cpu_dpcpp_gpu_dpcpp/bin
68/mnt/c/Program Files (x86)/Intel/oneAPI/dev-utilities/latest/bin
69/mnt/c/Program Files (x86)/Intel/oneAPI/debugger/latest/gdb/intel64/bin
70/mnt/c/Users/amir/AppData/Local/quickstart_fortran/mingw64/bin
71/mnt/c/Users/amir/AppData/Local/quickstart_fortran/fpm
72/mnt/c/Users/amir/AppData/Local/quickstart_fortran/MinGit/mingw64/bin
73/mnt/c/Users/amir/AppData/Local/quickstart_fortran/utils
74/mnt/c/Program Files/CMake/bin
75/mnt/c/Users/amir/AppData/Local/Programs/Microsoft VS Code/bin
76/mnt/c/Users/amir/.dotnet/tools
77/mnt/c/Users/amir/AppData/Local/Pandoc/
78/snap/bin"
79
80
81lenList = 9999
82list = repeat(' ', lenList)
83call setPathMatch(key = SK_'intel:oneapi:mpi:', inc = SK_'', sep = getPathSep(), list = list, lenList = lenList)
84lenList
85+692
86getReplaced(trim(list), SK_':', new_line(SK_'a'))
87"/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/bin/
88/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/bin/release/
89/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/libfabric/bin/
90/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/libfabric/bin/utils/
91/mnt/c/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/redist/intel64_win/compiler
92/mnt/c/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/redist/ia32_win/compiler
93/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/libfabric/bin/utils
94/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/libfabric/bin
95/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/bin/release
96/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/bin"
97
98
99lenList = 9999
100list = repeat(' ', lenList)
101call setPathMatch(key = SK_'intel:oneapi:mpi', inc = SK_'mpiexec', sep = getPathSep(), list = list, lenList = lenList)
102lenList
103+110
104getReplaced(trim(list), getPathSep(), new_line(SK_'a'))
105"/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/bin/
106/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/bin"
107
108
Test:
test_pm_sysPath
Todo:
High Priority: The current Fortran standard 202x does not allow passing characters of non-default kind to the intrinsic Fortran statements and procedures.
As such, the implementation of this procedure for non-default character kinds leads to compile-time kind mismatch errors.
This procedure should be converted back to a generic interface in the future when non-default character kinds are also fully supported by the intrinsic functions.


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, Tuesday March 7, 2017, 7:03 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas Austin

Definition at line 6338 of file pm_sysPath.F90.


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