annotate inst/import_ufl_Functional.m @ 269:897e312cb440

Ensure the mkoctfile installed with running octave is used * inst/import_*.m: find the right mkoctfile and pass it through the environment * inst/private/generate_*.m: get mkoctfile from the environment
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Thu, 14 Aug 2014 17:10:29 +0200
parents 61830a4f9ab9
children f4d6ae912a08
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
152
1dbe146bff03 Update license to gpl v3
gedeone-octave <marcovass89@hotmail.it>
parents: 148
diff changeset
1 ## Copyright (C) 2013 Marco Vassallo <gedeone-octave@users.sourceforge.net>
148
f2193e825ad7 Maint: update copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 136
diff changeset
2 ##
109
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
3 ## This program is free software; you can redistribute it and/or modify it under
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
4 ## the terms of the GNU General Public License as published by the Free Software
152
1dbe146bff03 Update license to gpl v3
gedeone-octave <marcovass89@hotmail.it>
parents: 148
diff changeset
5 ## Foundation; either version 3 of the License, or (at your option) any later
109
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
6 ## version.
148
f2193e825ad7 Maint: update copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 136
diff changeset
7 ##
109
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
11 ## details.
148
f2193e825ad7 Maint: update copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 136
diff changeset
12 ##
109
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
13 ## You should have received a copy of the GNU General Public License along with
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
15
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 255
diff changeset
16
109
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
17 ## -*- texinfo -*-
181
0de6ca5e31a2 Fix error in the previously modified documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 179
diff changeset
18 ## @deftypefn {Function File} {} = import_ufl_Functional (@var{myproblem})
179
8190736845fe Update the Function description for the code release.
gedeone-octave <marcovass89@hotmail.it>
parents: 154
diff changeset
19 ## Import a Functional from a ufl file.
181
0de6ca5e31a2 Fix error in the previously modified documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 179
diff changeset
20 ##
179
8190736845fe Update the Function description for the code release.
gedeone-octave <marcovass89@hotmail.it>
parents: 154
diff changeset
21 ## @var{myproblem} is the name of the ufl file where
8190736845fe Update the Function description for the code release.
gedeone-octave <marcovass89@hotmail.it>
parents: 154
diff changeset
22 ## the Functional is defined. This function creates in the pwd a file
8190736845fe Update the Function description for the code release.
gedeone-octave <marcovass89@hotmail.it>
parents: 154
diff changeset
23 ## called @var{myproblem_Functional.oct}.
181
0de6ca5e31a2 Fix error in the previously modified documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 179
diff changeset
24 ##
179
8190736845fe Update the Function description for the code release.
gedeone-octave <marcovass89@hotmail.it>
parents: 154
diff changeset
25 ## @seealso{import_ufl_Problem, FunctionSpace, BilinearForm, LinearForm,
8190736845fe Update the Function description for the code release.
gedeone-octave <marcovass89@hotmail.it>
parents: 154
diff changeset
26 ## Functional}
109
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
27 ## @end deftypefn
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 255
diff changeset
28
136
c445cdf36fb1 Fix new naming convention for the generation of the problem from .ufl file.
gedeone-octave <marcovass89@hotmail.it>
parents: 109
diff changeset
29 function import_ufl_Functional (var_prob)
109
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
30
255
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
31 if (is_master_node ())
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 255
diff changeset
32 if (nargin != 1)
255
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
33 error ("import_ufl_Functional: wrong number of input parameters.");
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 255
diff changeset
34 elseif (! ischar (var_prob))
255
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
35 error ("import_ufl_Functional: first argument is not a valid string");
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
36 endif
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
37
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
38 if (check_hash (var_prob) || ! check_oct_files (var_prob, "Functional"))
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 255
diff changeset
39 n = length (mfilename ("fullpath")) - length (mfilename ());
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 255
diff changeset
40 path = strtrunc (mfilename ("fullpath"), n);
255
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
41
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
42 private = fullfile (path, "include/");
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
43 output = generate_fun (var_prob);
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
44 output += generate_makefile (var_prob, private);
269
897e312cb440 Ensure the mkoctfile installed with running octave is used
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 268
diff changeset
45
897e312cb440 Ensure the mkoctfile installed with running octave is used
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 268
diff changeset
46 # Find correct mkoctfile for this version of Octave
897e312cb440 Ensure the mkoctfile installed with running octave is used
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 268
diff changeset
47 bindir = octave_config_info ("bindir");
897e312cb440 Ensure the mkoctfile installed with running octave is used
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 268
diff changeset
48 ext = octave_config_info ("EXEEXT");
897e312cb440 Ensure the mkoctfile installed with running octave is used
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 268
diff changeset
49 shell_script = fullfile (bindir, sprintf ("mkoctfile-%s%s", OCTAVE_VERSION, ext));
897e312cb440 Ensure the mkoctfile installed with running octave is used
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 268
diff changeset
50
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 255
diff changeset
51 if (output != 0)
255
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
52 error ("Compilation failed");
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
53 else
269
897e312cb440 Ensure the mkoctfile installed with running octave is used
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 268
diff changeset
54 [output, textfile] = system ...
897e312cb440 Ensure the mkoctfile installed with running octave is used
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 268
diff changeset
55 (sprintf ("MKOCTFILE=%s make -f Makefile_%s fun", shell_script, var_prob));
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 255
diff changeset
56 if (output != 0)
255
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
57 display (text);
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
58 error ("Compilation failed");
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
59 endif
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
60 [output, textfile] = system (sprintf ("make -f Makefile_%s clean", var_prob));
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 255
diff changeset
61 if (output != 0)
255
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
62 display (text);
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
63 error ("Compilation failed");
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
64 endif
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
65 save_hash (var_prob);
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
66 endif
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
67 endif
109
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
68 endif
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
69
255
072aee55bb75 Import UFL in a parallel-safe fashion
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 231
diff changeset
70 barrier ();
109
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
71
50753c3cb0b6 New function for dealing with form of rank 0.
gedeone-octave <marcovass89@hotmail.it>
parents:
diff changeset
72 endfunction