texit matlab on error - cosmo - front and backend for Markov-Chain Monte Carlo inversion of cosmogenic nuclide concentrations
(HTM) git clone git://src.adamsgaard.dk/cosmo
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit b87a5a357c89179c1397be92a291c0d7523252e5
(DIR) parent 4bdfcc45d50e0c057f7b42f611d17e7693ab48fb
(HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date: Mon, 7 Dec 2015 14:32:38 +0100
exit matlab on error
Diffstat:
M matlab/file_scanner_mcmc_starter.m | 197 ++++++++++++++++---------------
1 file changed, 102 insertions(+), 95 deletions(-)
---
(DIR) diff --git a/matlab/file_scanner_mcmc_starter.m b/matlab/file_scanner_mcmc_starter.m
t@@ -58,104 +58,111 @@ disp('Entering main loop, waiting for input from web interface...');
%% main loop
while 1
- % detect all files in infolder starting with prefix
- infiles = dir(strcat(infolder, '/', prefix, '*'));
+ try
- % sort files according to modification time
- [sorteddates, sortidx] = sort([infiles.datenum]);
- infiles = infiles(sortidx);
-
- % process files sequentially
- for i = 1:length(infiles);
-
- % read full file name and path
- infile = strcat(infolder, '/', infiles(i).name);
-
- % move to waitfolder
- movefile(infile, waitfolder);
- waitfile = strcat(waitfolder, '/', infiles(i).name);
-
- idstring = strsplit(infile, '_');
- id = idstring(2);
- statusfile = char(strcat(infolder, '/status_', id));
- diary(char(strcat(infolder, '/log_', id)));
-
- if debug
- disp(infile);
- disp(strcat('Simulation id: ', id));
+ % detect all files in infolder starting with prefix
+ infiles = dir(strcat(infolder, '/', prefix, '*'));
+
+ % sort files according to modification time
+ [sorteddates, sortidx] = sort([infiles.datenum]);
+ infiles = infiles(sortidx);
+
+ % process files sequentially
+ for i = 1:length(infiles);
+
+ % read full file name and path
+ infile = strcat(infolder, '/', infiles(i).name);
+
+ % move to waitfolder
+ movefile(infile, waitfolder);
+ waitfile = strcat(waitfolder, '/', infiles(i).name);
+
+ idstring = strsplit(infile, '_');
+ id = idstring(2);
+ statusfile = char(strcat(infolder, '/status_', id));
+ diary(char(strcat(infolder, '/log_', id)));
+
+ if debug
+ disp(infile);
+ disp(strcat('Simulation id: ', id));
+ end
+
+ % read file and save data to local scope
+ [sample_id, name, email, lat, long, ...
+ be_conc, al_conc, c_conc, ne_conc, ...
+ be_uncer, al_uncer, c_uncer, ne_uncer, ...
+ zobs, ...
+ be_prod_spall, al_prod_spall, c_prod_spall, ne_prod_spall, ...
+ be_prod_muons, al_prod_muons, c_prod_muons, ne_prod_muons, ...
+ rock_density, ...
+ epsilon_gla_min, epsilon_gla_max, ...
+ epsilon_int_min, epsilon_int_max, ...
+ t_degla_min, t_degla_max, ...
+ record, ...
+ record_threshold_min, record_threshold_max, ...
+ nwalkers] ...
+ = import_php_file(waitfile, 1, 1); % only read first line
+
+ % run inversion
+ [Ss, save_file] = mcmc_inversion(matlab_scripts_folder, debug, ...
+ nwalkers, outfolder, ...
+ be_conc, al_conc, c_conc, ne_conc, ...
+ be_uncer, al_uncer, c_uncer, ne_uncer, ...
+ zobs, ...
+ be_prod_spall, al_prod_spall, c_prod_spall, ne_prod_spall, ...
+ be_prod_muons, al_prod_muons, c_prod_muons, ne_prod_muons, ...
+ rock_density, ...
+ epsilon_gla_min, epsilon_gla_max, ...
+ epsilon_int_min, epsilon_int_max, ...
+ t_degla_min, t_degla_max, ...
+ record, ...
+ record_threshold_min, record_threshold_max, ...
+ statusfile, id);
+
+ fid = fopen(statusfile, 'w');
+ fprintf(fid, 'Generating plots');
+ fclose(fid);
+
+ % generate plots
+ %CompareWalks2(Ss, save_file)
+ generate_plots(Ss, matlab_scripts_folder, ...
+ save_file, graphics_formats, show_figures, ...
+ sample_id, name, email, lat, long, ...
+ be_conc, al_conc, c_conc, ne_conc, ...
+ be_uncer, al_uncer, c_uncer, ne_uncer, ...
+ zobs, ...
+ be_prod_spall, al_prod_spall, c_prod_spall, ne_prod_spall, ...
+ be_prod_muons, al_prod_muons, c_prod_muons, ne_prod_muons, ...
+ rock_density, ...
+ epsilon_gla_min, epsilon_gla_max, ...
+ epsilon_int_min, epsilon_int_max, ...
+ t_degla_min, t_degla_max, ...
+ record, ...
+ record_threshold_min, record_threshold_max, ...
+ nwalkers);
+
+ % close all figures
+ close all;
+
+ % delete or archive the file so it is not processed again
+ %delete(infile)
+ %movefile(infile, archivefolder);
+ movefile(char(strcat(waitfolder, '/cosmo_', id)), archivefolder);
+
+ fid = fopen(statusfile, 'w');
+ fprintf(fid, 'Computations complete');
+ fclose(fid);
+
+ disp(['Computations complete, id = ' id]);
+
+ diary off;
+
+ %keyboard
end
-
- % read file and save data to local scope
- [sample_id, name, email, lat, long, ...
- be_conc, al_conc, c_conc, ne_conc, ...
- be_uncer, al_uncer, c_uncer, ne_uncer, ...
- zobs, ...
- be_prod_spall, al_prod_spall, c_prod_spall, ne_prod_spall, ...
- be_prod_muons, al_prod_muons, c_prod_muons, ne_prod_muons, ...
- rock_density, ...
- epsilon_gla_min, epsilon_gla_max, ...
- epsilon_int_min, epsilon_int_max, ...
- t_degla_min, t_degla_max, ...
- record, ...
- record_threshold_min, record_threshold_max, ...
- nwalkers] ...
- = import_php_file(waitfile, 1, 1); % only read first line
-
- % run inversion
- [Ss, save_file] = mcmc_inversion(matlab_scripts_folder, debug, ...
- nwalkers, outfolder, ...
- be_conc, al_conc, c_conc, ne_conc, ...
- be_uncer, al_uncer, c_uncer, ne_uncer, ...
- zobs, ...
- be_prod_spall, al_prod_spall, c_prod_spall, ne_prod_spall, ...
- be_prod_muons, al_prod_muons, c_prod_muons, ne_prod_muons, ...
- rock_density, ...
- epsilon_gla_min, epsilon_gla_max, ...
- epsilon_int_min, epsilon_int_max, ...
- t_degla_min, t_degla_max, ...
- record, ...
- record_threshold_min, record_threshold_max, ...
- statusfile, id);
-
- fid = fopen(statusfile, 'w');
- fprintf(fid, 'Generating plots');
- fclose(fid);
-
- % generate plots
- %CompareWalks2(Ss, save_file)
- generate_plots(Ss, matlab_scripts_folder, ...
- save_file, graphics_formats, show_figures, ...
- sample_id, name, email, lat, long, ...
- be_conc, al_conc, c_conc, ne_conc, ...
- be_uncer, al_uncer, c_uncer, ne_uncer, ...
- zobs, ...
- be_prod_spall, al_prod_spall, c_prod_spall, ne_prod_spall, ...
- be_prod_muons, al_prod_muons, c_prod_muons, ne_prod_muons, ...
- rock_density, ...
- epsilon_gla_min, epsilon_gla_max, ...
- epsilon_int_min, epsilon_int_max, ...
- t_degla_min, t_degla_max, ...
- record, ...
- record_threshold_min, record_threshold_max, ...
- nwalkers);
-
- % close all figures
- close all;
-
- % delete or archive the file so it is not processed again
- %delete(infile)
- %movefile(infile, archivefolder);
- movefile(char(strcat(waitfolder, '/cosmo_', id)), archivefolder);
-
- fid = fopen(statusfile, 'w');
- fprintf(fid, 'Computations complete');
- fclose(fid);
-
- disp(['Computations complete, id = ' id]);
-
- diary off;
- %keyboard
+ catch E
+ disp(E.message)
+ exit(1) % quit matlab on error
end
% sleep in order to reduce system load