7019
|
1 /* |
|
2 |
|
3 Copyright (C) 2007 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
|
20 |
|
21 */ |
|
22 |
6572
|
23 #include <octave/oct.h> |
|
24 #include <octave/f77-fcn.h> |
|
25 |
|
26 extern "C" |
|
27 { |
|
28 F77_RET_T |
|
29 F77_FUNC (fortsub, FORTSUB) |
|
30 (const int&, double*, F77_CHAR_ARG_DECL |
|
31 F77_CHAR_ARG_LEN_DECL); |
|
32 } |
|
33 |
|
34 DEFUN_DLD (fortdemo , args , , "Fortran Demo.") |
|
35 { |
|
36 octave_value_list retval; |
|
37 int nargin = args.length(); |
|
38 if (nargin != 1) |
|
39 print_usage (); |
|
40 else |
|
41 { |
|
42 NDArray a = args(0).array_value (); |
|
43 if (! error_state) |
|
44 { |
|
45 double *av = a.fortran_vec (); |
|
46 octave_idx_type na = a.nelem (); |
|
47 OCTAVE_LOCAL_BUFFER (char, ctmp, 128); |
|
48 |
6580
|
49 F77_XFCN (fortsub, FORTSUB, (na, av, ctmp |
|
50 F77_CHAR_ARG_LEN (128))); |
6572
|
51 |
|
52 if (f77_exception_encountered) |
|
53 error ("fortdemo: error in fortran"); |
|
54 else |
|
55 { |
|
56 retval(1) = std::string (ctmp); |
|
57 retval(0) = a; |
|
58 } |
|
59 } |
|
60 } |
|
61 return retval; |
|
62 } |