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