Mercurial > fem-fenics-eugenio
diff inst/import_ufl_Problem.m @ 255:072aee55bb75
Import UFL in a parallel-safe fashion
author | Eugenio Gianniti <eugenio.gianniti@mail.polimi.it> |
---|---|
date | Wed, 30 Jul 2014 18:09:13 +0200 |
parents | e3f57f92fa66 |
children | 61830a4f9ab9 |
line wrap: on
line diff
--- a/inst/import_ufl_Problem.m Sat Jul 26 19:38:23 2014 +0200 +++ b/inst/import_ufl_Problem.m Wed Jul 30 18:09:13 2014 +0200 @@ -26,36 +26,40 @@ function import_ufl_Problem (var_prob) - if nargin != 1 - error ("import_ufl_Problem: wrong number of input parameters."); - elseif ! ischar (var_prob) - error ("import_ufl_Problem: first argument is not a valid string"); - endif + if (is_master_node ()) + if nargin != 1 + error ("import_ufl_Problem: wrong number of input parameters."); + elseif ! ischar (var_prob) + error ("import_ufl_Problem: first argument is not a valid string"); + endif - if (check_hash (var_prob) || ! check_oct_files (var_prob, "Problem")) - n = length (mfilename ("fullpath")) - length (mfilename()); - path = strtrunc(mfilename ("fullpath"), n); + if (check_hash (var_prob) || ! check_oct_files (var_prob, "Problem")) + n = length (mfilename ("fullpath")) - length (mfilename()); + path = strtrunc(mfilename ("fullpath"), n); - private = fullfile (path, "include/"); - output = generate_fs (var_prob); - output += generate_rhs (var_prob); - output += generate_lhs (var_prob); - output += generate_makefile (var_prob, private); - if output != 0 - error ("Compilation failed"); - else - [output, textfile] = system (sprintf ("make -f Makefile_%s all", var_prob)); + private = fullfile (path, "include/"); + output = generate_fs (var_prob); + output += generate_rhs (var_prob); + output += generate_lhs (var_prob); + output += generate_makefile (var_prob, private); if output != 0 - display (text); error ("Compilation failed"); + else + [output, textfile] = system (sprintf ("make -f Makefile_%s all", var_prob)); + if output != 0 + display (text); + error ("Compilation failed"); + endif + [output, textfile] = system (sprintf ("make -f Makefile_%s clean", var_prob)); + if output != 0 + display (text); + error ("Compilation failed"); + endif + save_hash (var_prob); endif - [output, textfile] = system (sprintf ("make -f Makefile_%s clean", var_prob)); - if output != 0 - display (text); - error ("Compilation failed"); - endif - save_hash (var_prob); endif endif + barrier (); + endfunction