ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
readRestart.m
Go to the documentation of this file.
1%> \brief
2%> Return a list of objects of class [pm.sampling.FileContentsRestartDRAM](@ref FileContentsRestartDRAM)
3%> containing the content(s) of the ParaMonte simulation output restart
4%> file(s) whose path(s) match the specified input ``pattern`` or the
5%> simulation specification ``sampler.spec.outputFileName``.<br>
6%>
7%> \warning
8%> This method is to be only used for post-processing of the output
9%> restart file(s) of an already finished simulation.<br>
10%> Although possible, this method is NOT meant
11%> to be called by all processes in
12%> MPI-parallel simulations.<br>
13%>
14%> \warning
15%> Currently, only the restart output files in ASCII format can be read via this method.<br>
16%> The binary restart files are not meant to be parsed via this method.<br>
17%> To request for ASCII restart output files in simulations,
18%> set the input simulation specification,
19%>
20%> \code{.m}
21%> sampler.spec.restartFileFormat = "ascii"
22%> \endcode
23%>
24%> where ``sampler`` can be an instance of any one of the ParaMonte
25%> sampler classes, such as [pm.sampling.Paradram](@ref Paradram).<br>
26%>
27%> \warning
28%> Avoid using this routine for very large long simulations.<br>
29%> Reading the full restart file of a large-scale simulation problem
30%> can be extremely memory-intensive.<br>
31%>
32%> \param[in] self : The input parent object of class [pm.sampling.Sampler](@ref Sampler)
33%> which is **implicitly** passed to this dynamic method (not by the user).<br>
34%> \param[in] pattern : The input scalar MATLAB string containing the pattern matching
35%> the desired restart file(s) whose contents is to be read.<br>
36%> The specified ``pattern`` only needs to partially identify
37%> the name of the simulation to which the restart file belongs.<br>
38%> For example, specifying ``"./mydir/mysim"`` as input will
39%> lead to a search for file(s) beginning with "mysim" and
40%> ending with ``"_restart.txt"`` inside the directory ``"./mydir/"``.<br>
41%> If there are multiple files matching in the input ``pattern``,
42%> then all such files will be read and returned as elements of a list.<br>
43%> If the specified pattern is a valid existing URL, the file will be
44%> downloaded as a temporary file to the local system, its contents
45%> shall be parsed and the file will be subsequently removed.<br>
46%> If the input ``pattern`` is empty, then the method will search
47%> for any possible candidate files with the appropriate suffix
48%> in the current working directory.<br>
49%> (optional, default = ``sampler.spec.outputFileName`` or ``"./"``)
50%>
51%> \return
52%> ``restartList`` : The output MATLAB cell array of objects
53%> of class [pm.sampling.FileContentsRestart](@ref FileContentsRestart),
54%> each of which corresponds to the contents
55%> of a unique restart file.<br>
56%>
57%> \interface{readRestart}
58%> \code{.m}
59%>
60%> sampler = pm.sampling.Sampler();
61%> restartList = sampler.readRestart();
62%> restartList = sampler.readRestart([]);
63%> restartList = sampler.readRestart(pattern);
64%>
65%> \endcode
66%>
67%> \note
68%> See the documentation of the sampler subclasses
69%> (e.g., [pm.sampling.Paradram](@ref Paradram)) for example usage in action.<br>
70%>
71%> \example{readRestart}
72%> \code{.m}
73%>
74%> sampler.readRestart("./out/test_run_");
75%>
76%> sampler.spec.outputFileName = "./out/test_run_";
77%> sampler.readRestart();
78%>
79%> sampler.readRestart("./out/test_run_", ",");
80%>
81%> sampler.spec.outputSeparator = ",";
82%> sampler.readRestart("./out/test_run_");
83%>
84%> sampler.spec.outputFileName = "./out/test_run_";
85%> sampler.spec.outputSeparator = ",";
86%> sampler.readRestart();
87%>
88%> \endcode
89%>
90%> \final{readRestart}
91%>
92%> \author
93%> \JoshuaOsborne, May 21 2024, 12:35 AM, University of Texas at Arlington<br>
94%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
95%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
96%>
97function restartList = readRestart(self, pattern)
98 if nargin < 2
99 if 0 < pm.array.len(self.spec.outputFileName)
100 pattern = string(self.spec.outputFileName);
101 else
102 pattern = [];
103 end
104 end
105 ftype = "restart";
106 pathList = self.findfile(ftype, pattern);
107 restartList = cell(length(pathList), 1);
108 for ifile = length(pathList) : -1 : 1
109 if ~self.silent
110 disp("processing file: """ + pathList(ifile) + """");
111 end
112 restartList{ifile} = pm.sampling.FileContentsRestartDRAM(pathList(ifile), self.silent);
113 end
114end
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared libraries.
function list()
Return a list of MATLAB strings containing the names of OS platforms supported by the ParaMonte MATLA...
This is the base class for generating objects that contain the contents of a restart file generated b...
This is the base class for generating objects that contain the contents of a restart file generated b...
This is the ParaDRAM class for generating instances of serial and parallel Delayed-Rejection Adaptive...
Definition: Paradram.m:14
This is the base class for the ParaMonte sampler routines.
Definition: Sampler.m:21
function parallel()
Return a scalar MATLAB logical that is true if and only if the current installation of MATLAB contain...
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...