Skip to content

Commit e3b240e

Browse files
committed
250907.160937.CST 1. Drop support for MATLAB R2020a or earlier, because they cannot be tested using matlab-actions/setup-matlab. 2. misc improvements according to mlint, including replacing verLessThan with isMATLABReleaseOlderThan and datestr with datetime
1 parent e067a15 commit e3b240e

File tree

14 files changed

+35
-33
lines changed

14 files changed

+35
-33
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,6 @@ cython_debug/
232232

233233
# Version file
234234
_version.txt
235+
236+
# MathWorks files
237+
fintrf.h

README_mat.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ This is the README file for using PRIMA under MATLAB.
22

33
## Prerequisites
44

5-
PRIMA supports MATLAB R2018a and later releases. To use PRIMA, you need first
5+
PRIMA supports MATLAB R2020b and later releases. To use PRIMA, you need first
66
set up the [MEX](https://www.mathworks.com/help/matlab/ref/mex.html) of your MATLAB.
77
**The setup of MEX is a pure MATLAB usage problem and it has nothing to do with PRIMA.**
88

matlab/setup_tools/compile.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ function compile(solvers, mexdir, fortd, gateways, options)
165165
% https://stackoverflow.com/questions/79699706/matlab-2025a-vs-fortran-mex-files-with-internal-subroutines
166166
% https://fortran-lang.discourse.group/t/implementation-of-a-parametrized-objective-function-without-using-module-variables-or-internal-subroutines
167167
% https://stackoverflow.com/questions/79705107/fortran-implementating-a-parametrized-objective-function-without-using-module-v
168-
% The version number of R2025a is 25.1.
169-
support_internal_procedures = (verLessThan('matlab', '25.1') || ~verLessThan('matlab', '25.2') || ...
170-
~contains(compiler_manufacturer, 'gnu') || contains(compiler_options, '-ftrampoline-impl=heap'));
168+
matlab_supports_ip = (isMATLABReleaseOlderThan('R2025a') || ~isMATLABReleaseOlderThan('R2025b'));
169+
compiler_supports_ip = (~contains(compiler_manufacturer, 'gnu') || contains(compiler_options, '-ftrampoline-impl=heap'));
170+
support_internal_procedures = (matlab_supports_ip || compiler_supports_ip);
171171
if ~support_internal_procedures
172172
if verbose
173173
warning('prima:ThreadRecursionUnsafe', ...

matlab/setup_tools/create_all_precisions.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ function create_all_precisions(options_or_directory)
8787
end
8888
fprintf(fid, 'function precision_list = %s()\n', allprec);
8989
fprintf(fid, '%%%s ', upper(allprec));
90-
fprintf(fid, ' returns a cell array containing the names of all the precisions available for the\n');
90+
fprintf(fid, 'returns a cell array containing the names of all the precisions available for the\n');
9191
fprintf(fid, '%% Fortran solvers in this package.\n');
9292
fprintf(fid, '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n');
93-
fprintf(fid, '%% This file is created automatically by \n%% %s.m at %s.\n', mfilename, datestr(datetime(), 'yyyymmdd.HH:MM:SS'));
93+
fprintf(fid, '%% This file is created automatically\n%% by %s.m\n%% on %s.\n', mfilename, char(datetime()));
9494
fprintf(fid, '%% NEVER EDIT IT, OR THE EARTH WILL EXPLODE.\n');
9595
fprintf(fid, '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n');
9696
fprintf(fid, '%s', precision_list_string);

matlab/setup_tools/create_all_variants.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function create_all_variants(options_or_directory)
8181
fprintf(fid, ' returns a cell array containing the names of all the variants available for the\n');
8282
fprintf(fid, '%% Fortran solvers in this package.\n');
8383
fprintf(fid, '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n');
84-
fprintf(fid, '%% This file is created automatically by \n%% %s.m at %s.\n', mfilename, datestr(datetime(), 'yyyymmdd.HH:MM:SS'));
84+
fprintf(fid, '%% This file is created automatically\n%% by %s.m\n%% on %s.\n', mfilename, char(datetime()));
8585
fprintf(fid, '%% NEVER EDIT IT, OR THE EARTH WILL EXPLODE.\n');
8686
fprintf(fid, '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n');
8787
fprintf(fid, '%s', variant_list_string);

matlab/setup_tools/getfintrf.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
fileattrib(fintrf, '+w')
1818

1919
% Add time stamp to fintrf.
20-
time = datestr(datetime(), 'HH.MM.SS, yyyy-mm-dd');
20+
time = char(datetime());
2121
matv = [version, ', ', computer];
2222
S = fileread(fintrf);
23-
S = ['/* MATLAB version: ', matv, ' */', newline, '/* Retrieved at ', time, ' */', newline, S];
23+
S = ['/* MATLAB version: ', matv, ' */', newline, '/* Retrieved on ', time, ' */', newline, S];
2424
fid = fopen(fintrf, 'w'); % Open/create file for writing. Discard existing contents.
2525
if fid == -1
2626
error('Cannot open file %s', fintrf);

matlab/setup_tools/interform.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function interform(directory)
1111
outputdir = '.interform'; % The leading dot makes the directory hidden on Linux systems.
1212

1313
% Time stamp
14-
time_stamp = datestr(datetime(), 'yymmdd.HH:MM:SS');
14+
time_stamp = char(datetime());
1515

1616
% Do not perform refactoring in these subdirectories (if exist)
1717
ignoredir = {'original', 'backup', '.interform', 'trash', 'example', 'examples', 'test', 'tests', 'results', 'test_data', 'bak', 'bakf90'};
@@ -139,7 +139,7 @@ function refactor_file(filename)
139139
% the new file has the same name as the original one, then the original
140140
% file will be backed up in "ORIGINAL_FILE_NAME.bak".
141141

142-
time_stamp = datestr(datetime(), 'yymmdd.HH:MM:SS');
142+
time_stamp = char(datetime());
143143

144144
fid = fopen(filename, 'r'); % Open file for reading.
145145
if fid == -1
@@ -204,7 +204,7 @@ function refactor_file(filename)
204204
fprintf(fid, '!\n');
205205
fprintf(fid, '! See http://fortranwiki.org/fortran/show/Continuation+lines for details.\n');
206206
fprintf(fid, '!\n');
207-
fprintf(fid, '! Generated using the %s.m script by Zaikun ZHANG (www.zhangzk.net)\n! at %s.\n', mfilename, time_stamp);
207+
fprintf(fid, '! Generated using the %s.m script by Zaikun ZHANG (www.zhangzk.net)\n! on %s.\n', mfilename, time_stamp);
208208
fprintf(fid, '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n');
209209

210210
for i = 1 : length(strs)

matlab/tests/private/dataprof.m

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
function T = dataprof(frec, fmin, pdim, options)
1+
%function T = dataprof(frec, fmin, pdim, options)
2+
function T = dataprof(frec, fmin)
23
% To be implemented.
34

45
delsame = 0;
@@ -44,7 +45,10 @@
4445

4546
T = mean(T, 3);
4647

47-
sol = textread('solvers', '%s');
48+
fid = fopen('solvers','r');
49+
C = textscan(fid, '%s', 'Delimiter', '\n');
50+
fclose(fid);
51+
sol = C{1};
4852
for is = 1:ns
4953
sol{is} = regexprep(sol{is}, '_4test', '');
5054
%sol{is} = regexprep(sol{is}, 'newuoa', 'NEWUOA');
@@ -116,7 +120,7 @@
116120

117121
xlabel('$\log_2(\alpha), \quad \alpha = \mathrm{NF}/\mathrm{NF}_{\min}$', 'fontsize', fontsize, 'interpreter', 'latex');
118122
ylabel('$\pi_s(\alpha)$', 'fontsize', fontsize, 'interpreter', 'latex');
119-
xlabh = get(gca,'XLabel');
123+
%xlabh = get(gca,'XLabel');
120124
%set(xlabh,'Position',get(xlabh,'Position') - [0 .0175 0])
121125
set(gca,'FontSize',fontsize);
122126

@@ -146,7 +150,7 @@
146150
clf;
147151
hfig=figure(2);
148152
for is = 1:ns
149-
[xs, ys] = stairs([1:1.2*M]/(n+1), D(is, :));
153+
[xs, ys] = stairs((1:1.2*M)/(n+1), D(is, :));
150154
plot(xs, ys, lines{is}, 'Color', colors{is}, 'Linewidth',linewidth);
151155
hold on;
152156
end
@@ -164,7 +168,7 @@
164168

165169
xlabel('$\beta = \mathrm{NF}/(n+1)$', 'fontsize',fontsize, 'interpreter', 'latex');
166170
ylabel('$\delta_s(\beta)$', 'fontsize', fontsize, 'interpreter', 'latex');
167-
xlabh = get(gca, 'XLabel');
171+
%xlabh = get(gca, 'XLabel');
168172
%set(xlabh,'Position',get(xlabh,'Position') - [0 .0175 0])
169173
set(gca, 'FontSize', fontsize);
170174

matlab/tests/private/isequiv.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ function isequiv(solvers, options)
272272
function equiv = compare(solvers, prob, ir, single_test, options)
273273
pname = prob.name;
274274
objective = prob.objective;
275-
nonlcon = prob.nonlcon;
276275
x0 = prob.x0;
277276
n = length(x0);
278277

matlab/tests/private/prepare_test_dir.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
%PREPARE_TEST_DIR prepares a copy of the package in `test_dir` for the solver named `solver and test
33
% named `test_name`, with options in `test_options`, which specifies the competitor etc.
44

5-
if verLessThan('matlab', '9.10') && ispc
5+
if isMATLABReleaseOlderThan('R2020b') && ispc
66
callstack = dbstack;
77
funname = callstack(1).name; % Name of the current function
88
warning('%s may FAIL because ''copyfile'' of MATLAB R2020b or earlier may raise an error when handling unix symbolic links under Windows.', funname);

0 commit comments

Comments
 (0)