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:
-
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.
-
A positive output value smaller than its input value implies the slice
list(1:lenList) contains the directory path in full.
-
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.
-
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 ⛓
Return a list of directory paths matching a requested system application.
This module contains classes and procedures for manipulating system file/folder paths.
- 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.
- 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 ⛓
11 integer(IK) :: lenList
12 type(display_type) :: disp
13 character(:, SK),
allocatable :: list
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)")
25 call disp%show(
"getReplaced(trim(list), getPathSep(), new_line(SK_'a'))")
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)
38 call disp%show(
"getReplaced(trim(list), SK_':', new_line(SK_'a'))")
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)
51 call disp%show(
"getReplaced(trim(list), getPathSep(), new_line(SK_'a'))")
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.
This is a generic method of the derived type display_type with pass attribute.
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...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example output ⛓
3list
= repeat(
' ', lenList)
9/usr/local/MATLAB/R2023b/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
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/
82list
= repeat(
' ', lenList)
83call setPathMatch(key
= SK_
'intel:oneapi:mpi:', inc
= SK_
'', sep
= getPathSep(), list
= list, lenList
= lenList)
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"
100list
= repeat(
' ', lenList)
101call setPathMatch(key
= SK_
'intel:oneapi:mpi', inc
= SK_
'mpiexec', sep
= getPathSep(), list
= list, lenList
= lenList)
105"/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/bin/
106/mnt/c/Program Files (x86)/Intel/oneAPI/mpi/latest/bin"
- 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.
-
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.
-
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.
- Copyright
- Computational Data Science Lab
- 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.