ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
getFileName.m
Go to the documentation of this file.
1%> \brief
2%> Return a scalar MATLAB string containing
3%> a file name based on the current date and time.
4%>
5%> \details
6%> This functionality is primarily used by the ParaMonte
7%> samplers to generate random output file base name for
8%> situations where the user does not specify a name.
9%>
10%> \param[in] prefix : The input scalar MATLAB string,
11%> containing the desired prefix, e.g.,
12%> ParaDRAM, ParaDISE, ParaNest, ...<br>
13%> (**optional**, default = ``""``)
14%>
15%> \return
16%> ``str`` : The output scalar MATLAB string containing
17%> an output file name based on the current date and time.<br>
18%> The following represents the template used across
19%> all programming language environments:<br>
20%> \code{.m}
21%> YYYYMMDD_HHMMSS_MMM
22%> \endcode
23%> or
24%> \code{.m}
25%> prefix_YYYYMMDD_HHMMSS_MMM
26%> \endcode
27%> where,
28%> <ol>
29%> <li> ``prefix`` is replaced with the input ``prefix`` name.
30%> <li> ``YYYY`` is replaced with the current Gregorian year.
31%> <li> ``MM`` is replaced with the current month of year.
32%> <li> ``DD`` is replaced with the current day of month.
33%> <li> ``HH`` is replaced with the current hour of day.
34%> <li> ``MM`` is replaced with the current minute of hour.
35%> <li> ``SS`` is replaced with the current second of minute.
36%> <li> ``MMM`` is replaced with the current millisecond of second.
37%> </ol>
38%>
39%> \interface{getFileName}
40%> \code{.m}
41%>
42%> str = pm.io.getFileName()
43%> str = pm.io.getFileName([])
44%> str = pm.io.getFileName(prefix)
45%>
46%> \endcode
47%>
48%> \example{getFileName}
49%> \include{lineno} example/io/getFileName/main.m
50%> \output{getFileName}
51%> \include{lineno} example/io/getFileName/main.out.m
52%>
53%> \final{getFileName}
54%>
55%> \author
56%> \JoshuaOsborne, May 21 2024, 6:13 PM, University of Texas at Arlington<br>
57%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
58%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
59function str = getFileName(prefix)
60 if nargin < 1
61 prefix = [];
62 end
63 str = datestr(now, 'yyyymmdd_HHMMSS_FFF');
64 % MATLAB recommends replacing the above with the following.
65 % The plan was to keep the old syntax as it is not clear
66 % when the new syntax was introduced.
67 %str = string(datetime('now', 'format', 'yyyyMMdd_HHmmss_SSS'))
68 if ~isempty(prefix)
69 str = string(prefix) + "_" + str;
70 end
71end
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared library directories.
function getFileName(in prefix)
Return a scalar MATLAB string containing a file name based on the current date and time.