6363
6464mod_pth = [pwd , filesep , ' MODEL' , filesep , ' forward_src' , filesep ];
6565
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
7068if 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-
12969
13070 pathC = [];
13171 % Compiles the model and runs it
15090 % Compiles the model and runs it
15191 disp(' Compiling Tephra2...' )
15292 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
15595
15696 if stat == 0 % If compilation ok
15797 disp(' Compiling done!' )
@@ -283,24 +223,18 @@ function runit(run_pth, par, cores, pathC)
283223function line_out = check_line(tline ,pathC )
284224
285225% Some housekeeping tasks if run on windows
226+ % Starting 1.7.4, using WSL
286227if 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' );
295228
296229 pth_tmp = pwd ; % Retrieve path
297230 pth_tmp(regexp(pth_tmp , ' \' )) = ' /' ;
298231 pth_tmp(regexp(pth_tmp , ' :' )) = [];
299-
232+ drive = lower(pth_tmp(1 ));
233+ pth_tmp = [drive , pth_tmp(2 : end )];
300234 % Split the command line and add the cygdrive path
301235 tline_split = strsplit(tline , ' ' );
302236 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+' ,' ' );
304238 end
305239
306240 % Concatanates final command line for cygwin
@@ -309,8 +243,8 @@ function runit(run_pth, par, cores, pathC)
309243 tline(s : e ) = [];
310244 tline = strrep(tline , ' \' , ' /' );
311245
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 , ' " ' ];
314248else
315249 line_out = tline ;
316250end
0 commit comments