ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
version.m
Go to the documentation of this file.
1%> \brief
2%> Return a scalar MATLAB string containing
3%> the current ParaMonte generic or MATLAB library version numbers,
4%> or optionally, the major, minor, or the patch version number.
5%>
6%> \param[in] lang : The input scalar MATLAB string that can be either:<br>
7%> <ol>
8%> <li> the value ``"generic"``, indicating
9%> the generic library version found in the root directory of
10%> the [ParaMonte library repository](https://github.com/cdslaborg/paramonte).<br>
11%> <li> the value ``"matlab"``, indicating
12%> the MATLAB library version found in the ``src/matlab`` subdirectory in
13%> the [ParaMonte library repository](https://github.com/cdslaborg/paramonte).<br>
14%> </ol>
15%> The input version must be in triplet format (e.g., ``"1.2.3"``).<br>
16%> If the input value is empty ``[]``, the default value is used.<br>
17%> (**optional**, default = ``"matlab"``)
18%> \param[in] type : The input scalar MATLAB string that can be either:<br>
19%> <ol>
20%> <li> the value ``"all"``, indicating
21%> the full version number output in the format ``"major.minor.patch"``.<br>
22%> <li> the value ``"major"``, indicating
23%> the full version number output in the format ``"major"``.<br>
24%> <li> the value ``"minor"``, indicating
25%> the full version number output in the format ``"minor"``.<br>
26%> <li> the value ``"patch"``, indicating
27%> the full version number output in the format ``"patch"``.<br>
28%> </ol>
29%> If the input value is empty ``[]``, the default value is used.<br>
30%> (**optional**, default = ``"all"``)
31%>
32%> \return
33%> ``vernum`` : The output scalar MATLAB string containing the requested
34%> current generic or language-specific ParaMonte library version.<br>
35%>
36%> \interface{version}
37%> \code{.m}
38%>
39%> vernum = pm.lib.version()
40%> vernum = pm.lib.version([])
41%> vernum = pm.lib.version(lang)
42%>
43%> vernum = pm.lib.version([], [])
44%> vernum = pm.lib.version([], type)
45%> vernum = pm.lib.version(lang, [])
46%> vernum = pm.lib.version(lang, type)
47%>
48%> \endcode
49%>
50%> \warning
51%> If the routine fails to find the respective VERSION files within the local ParaMonte library,
52%> it will return the value ``"UNKNOWN"`` for the output ``vernum``.
53%>
54%> \example{version}
55%> \include{lineno} example/lib/version/main.m
56%> \output{version}
57%> \include{lineno} example/lib/version/main.out.m
58%>
59%> \final{version}
60%>
61%> \author
62%> \JoshuaOsborne, May 21 2024, 8:13 PM, University of Texas at Arlington<br>
63%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
64%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
65function vernum = version(lang, type)
66
67 if nargin < 2
68 type = [];
69 end
70 if nargin < 1
71 lang = [];
72 end
73 if ~isempty(type)
74 type = string(lower(type));
75 else
76 type = "all";
77 end
78 if ~isempty(lang)
79 lang = string(lower(lang));
80 else
81 lang = "matlab";
82 end
83
84 % persistent vernum_persistent;
85 % if isempty(vernum_persistent)
86 % vernum_persistent = struct();
87 % end
88 %
89 % if ~isfield(vernum_persistent, lang)
90 % try
91 % fid = fopen(fullfile(pm.lib.path.auxil(), "VERSION." + lang + ".md"));
92 % vernum_persistent.(lang) = string(strip(fgetl(fid)));
93 % fclose(fid);
94 % catch
95 % vernum_persistent.(lang) = "UNKNOWN";
96 % end
97 % end
98 %
99 % vernum = vernum_persistent.(lang);
100
101 try
102 version_file = fullfile(pm.lib.path.auxil(), "VERSION." + lang + ".md");
103 fid = fopen(version_file);
104 vernum = string(strip(fgetl(fid)));
105 fclose(fid);
106 catch
107 vernum = "UNKNOWN";
108 end
109
110 if ~strcmp(type, "all")
111 triplet = strsplit(vernum, ".");
112 if strcmp(type, "major")
113 vernum = string(triplet(1));
114 elseif strcmp(type, "minor") && numel(triplet) > 1
115 vernum = string(triplet(2));
116 elseif strcmp(type, "patch") && numel(triplet) > 2
117 vernum = string(triplet(3));
118 end
119 end
120
121end
function version(in silent)
Return a scalar MATLAB string containing the latest available ParaMonte MATLAB version newer than the...
function find(in vendor)
Return a list of scalar MATLAB strings containing the paths to all detected mpiexec binaries installe...
function lib()
Return a scalar MATLAB string containing the path to the lib directory of the ParaMonte library packa...
function root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.