63
63
64
64
mod_pth = [pwd , filesep , ' MODEL' , filesep , ' forward_src' , filesep ];
65
65
66
- % On PCs, add the Cygwin folder to the PATH environment
67
- % Added 08-2018
68
- % Noticed a problem with the definition of the cygwin path when not
69
- % installed in c:\cygwin
66
+ % 2025-04-23: Removed the CYGWIN dependency for WSL. Running CYGWIN
67
+ % requires TephraProb < 1.7.4
70
68
if ispc
71
- % path1 = getenv('PATH');
72
-
73
- % % Retrieve architecture
74
- % if strcmp(computer('arch'), 'win64')
75
- % pathC = 'C:\cygwin64\bin';
76
- % elseif strcmp(computer('arch'), 'win32')
77
- % pathC = 'C:\cygwin\bin';
78
- % end
79
-
80
- % % Check if path exists
81
- % if ~exist(pathC, 'dir') == 7
82
- % % Check if the path to cygwin has already been saved
83
- % if exist('CODE/VAR/cygwin.mat', file)
84
- % load('CODE/VAR/cygwin.mat', 'pathC');
85
-
86
- % % If not, retrieve it
87
- % else
88
- % choice = questdlg('Did you already install CYGWIN?', ...
89
- % 'CYGWIN', ...
90
- % 'Yes','No','Yes');
91
- % % Handle response
92
- % switch choice
93
- % case 'Yes'
94
- % sprintf('Select the cygwin\bin directory\n');
95
- % pathC = uigetdir('C:\', 'Select the cygwin\bin directory');
96
- % save('CODE/VAR/cygwin.mat', 'pathC');
97
- % case 'No'
98
- % url('https://cygwin.com/install.html');
99
- % return
100
- % end
101
- % end
102
- % end
103
-
104
- % % Check if the cygwin path is already in the environment
105
- % if isempty(strfind(path1,pathC))
106
- % setenv('PATH', [path1,';',pathC,';']);
107
- % end
108
-
109
- % if ~exist([pwd, filesep, 'MODEL', filesep, 'tephra2-2012.exe'], 'file')
110
- % warning('You need to manually compile Tephra2 on Cygwin!')
111
- % fprintf('\t1. Open the Cygwin terminal\n')
112
- % fprintf('\t2. Navigate to TephraProb\\MODEL\\ and type: \n')
113
- % fprintf('\t\t make clean\n')
114
- % fprintf('\t3. Then, type:\n')
115
- % fprintf('\t\t make\n')
116
- % fprintf('\t4. Once finished, type:\n')
117
- % fprintf('\t\t chmod 755 tephra2-2012.exe\n')
118
- % fprintf('\t5. To test the compilation, type:\n')
119
- % fprintf('\t\t ./tephra2-2012.exe\n')
120
- % fprintf('\tYou should see:\n')
121
- % fprintf('\t\t Missing comand line arguments,\n')
122
- % fprintf('\t\t USAGE: <program name> <config file> <points file> <wind file> <file of grain sizes>')
123
- % return
124
- % else
125
- % cd(pth);
126
- % runit(project.run_pth,project.par,project.cores,pathC); % Runs model
127
- % end
128
-
129
69
130
70
pathC = [];
131
71
% Compiles the model and runs it
150
90
% Compiles the model and runs it
151
91
disp(' Compiling Tephra2...' )
152
92
cd(mod_pth ); % Navigates to the makefile
153
- system(' make clean' );
154
- [stat , cmd_out ] = system(' make' ); % Compiles TEPHRA2
93
+ system(' wsl make clean' );
94
+ [stat , cmd_out ] = system(' wsl make' ); % Compiles TEPHRA2
155
95
156
96
if stat == 0 % If compilation ok
157
97
disp(' Compiling done!' )
@@ -283,24 +223,18 @@ function runit(run_pth, par, cores, pathC)
283
223
function line_out = check_line(tline ,pathC )
284
224
285
225
% Some housekeeping tasks if run on windows
226
+ % Starting 1.7.4, using WSL
286
227
if ispc
287
- % if strcmp(computer('arch'), 'win64') % Cygwin 64 bits
288
- % pathC = 'C:\cygwin64\bin\bash';
289
- % elseif strcmp(computer('arch'), 'win32') % Cygwin 32 bits
290
- % pathC = 'C:\cygwin\bin\bash';
291
- % end
292
-
293
- % Added 08-2018: Propagating the custom cygwin directory
294
- pathC = fullfile(pathC , ' bash' );
295
228
296
229
pth_tmp = pwd ; % Retrieve path
297
230
pth_tmp(regexp(pth_tmp , ' \' )) = ' /' ;
298
231
pth_tmp(regexp(pth_tmp , ' :' )) = [];
299
-
232
+ drive = lower(pth_tmp(1 ));
233
+ pth_tmp = [drive , pth_tmp(2 : end )];
300
234
% Split the command line and add the cygdrive path
301
235
tline_split = strsplit(tline , ' ' );
302
236
for i = [2 ,3 ,4 ,5 ,7 ]
303
- tline_split{i } = regexprep([' /cygdrive /' , pth_tmp , ' /' , tline_split{i }],' \s+' ,' ' );
237
+ tline_split{i } = regexprep([' /mnt /' , pth_tmp , ' /' , tline_split{i }],' \s+' ,' ' );
304
238
end
305
239
306
240
% Concatanates final command line for cygwin
@@ -309,8 +243,8 @@ function runit(run_pth, par, cores, pathC)
309
243
tline(s : e ) = [];
310
244
tline = strrep(tline , ' \' , ' /' );
311
245
312
- % line_out = [pathC, ' --login -c "/cygdrive/', pth_tmp, '/MODEL/./tephra2-2012.exe ', tline, '"'];
313
- line_out = [' wsl ' , tline ];
246
+ % line_out = [pathC, ' --login -c "/cygdrive/', pth_tmp, '/MODEL/./tephra2-2012.exe ', tline, '"'];
247
+ line_out = [' wsl bash -c "./MODEL/tephra2-2012 ' , tline , ' " ' ];
314
248
else
315
249
line_out = tline ;
316
250
end
0 commit comments