Mercurial > octave-dspies
changeset 18369:4b32677b6229 stable
Rename Fortran example files from 'fort' prefix to 'fortran' prefix.
* examples/fortrandemo.cc, examples/fortransub.f: Renamed files.
* examples/fortdemo.cc, examples/fortsub.f: Deleted files.
* examples/Makefile.am, doc/interpreter/Makefile.am: Change build
system to use new file names.
* doc/interpreter/external.txi: Change documentation to reflect new names.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 24 Jan 2014 09:32:55 -0800 |
parents | 877b82d73ed9 |
children | 7994d3ce6e8e |
files | doc/interpreter/Makefile.am doc/interpreter/external.txi examples/Makefile.am examples/fortdemo.cc examples/fortrandemo.cc examples/fortransub.f examples/fortsub.f |
diffstat | 7 files changed, 66 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/Makefile.am Fri Jan 24 09:11:01 2014 -0800 +++ b/doc/interpreter/Makefile.am Fri Jan 24 09:32:55 2014 -0800 @@ -59,8 +59,8 @@ $(top_srcdir)/examples/addtwomatrices.cc \ $(top_srcdir)/examples/celldemo.cc \ $(top_srcdir)/examples/embedded.cc \ - $(top_srcdir)/examples/fortdemo.cc \ - $(top_srcdir)/examples/fortsub.f \ + $(top_srcdir)/examples/fortrandemo.cc \ + $(top_srcdir)/examples/fortransub.f \ $(top_srcdir)/examples/funcdemo.cc \ $(top_srcdir)/examples/globaldemo.cc \ $(top_srcdir)/examples/helloworld.cc \
--- a/doc/interpreter/external.txi Fri Jan 24 09:11:01 2014 -0800 +++ b/doc/interpreter/external.txi Fri Jan 24 09:32:55 2014 -0800 @@ -1037,14 +1037,14 @@ given in the following example, where the C++ wrapper is @example -@EXAMPLEFILE(fortdemo.cc) +@EXAMPLEFILE(fortrandemo.cc) @end example @noindent and the Fortran function is @example -@EXAMPLEFILE(fortsub.f) +@EXAMPLEFILE(fortransub.f) @end example This example demonstrates most of the features needed to link to an @@ -1054,13 +1054,13 @@ @example @group -mkoctfile fortdemo.cc fortsub.f -[b, s] = fortdemo (1:3) +mkoctfile fortrandemo.cc fortransub.f +[b, s] = fortrandemo (1:3) @result{} b = 1.00000 0.50000 0.33333 s = There are 3 values in the input vector -[b, s] = fortdemo (0:3) -error: fortdemo: fortsub: divide by zero +[b, s] = fortrandemo (0:3) +error: fortrandemo: fortransub: divide by zero @end group @end example
--- a/examples/Makefile.am Fri Jan 24 09:11:01 2014 -0800 +++ b/examples/Makefile.am Fri Jan 24 09:32:55 2014 -0800 @@ -34,8 +34,8 @@ addtwomatrices.cc \ celldemo.cc \ embedded.cc \ - fortdemo.cc \ - fortsub.f \ + fortrandemo.cc \ + fortransub.f \ funcdemo.cc \ globaldemo.cc \ helloworld.cc \
--- a/examples/fortdemo.cc Fri Jan 24 09:11:01 2014 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -#include <octave/oct.h> -#include <octave/f77-fcn.h> - -extern "C" -{ - F77_RET_T - F77_FUNC (fortsub, FORTSUB) - (const int&, double*, F77_CHAR_ARG_DECL F77_CHAR_ARG_LEN_DECL); -} - -DEFUN_DLD (fortdemo, args, , "Fortran Demo") -{ - octave_value_list retval; - int nargin = args.length (); - - if (nargin != 1) - print_usage (); - else - { - NDArray a = args(0).array_value (); - if (! error_state) - { - double *av = a.fortran_vec (); - octave_idx_type na = a.numel (); - OCTAVE_LOCAL_BUFFER (char, ctmp, 128); - - F77_XFCN (fortsub, FORTSUB, - (na, av, ctmp F77_CHAR_ARG_LEN (128))); - - retval(1) = std::string (ctmp); - retval(0) = a; - } - } - return retval; -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/fortrandemo.cc Fri Jan 24 09:32:55 2014 -0800 @@ -0,0 +1,35 @@ +#include <octave/oct.h> +#include <octave/f77-fcn.h> + +extern "C" +{ + F77_RET_T + F77_FUNC (fortransub, FORTSUB) + (const int&, double*, F77_CHAR_ARG_DECL F77_CHAR_ARG_LEN_DECL); +} + +DEFUN_DLD (fortrandemo, args, , "Fortran Demo") +{ + octave_value_list retval; + int nargin = args.length (); + + if (nargin != 1) + print_usage (); + else + { + NDArray a = args(0).array_value (); + if (! error_state) + { + double *av = a.fortran_vec (); + octave_idx_type na = a.numel (); + OCTAVE_LOCAL_BUFFER (char, ctmp, 128); + + F77_XFCN (fortransub, FORTSUB, + (na, av, ctmp F77_CHAR_ARG_LEN (128))); + + retval(1) = std::string (ctmp); + retval(0) = a; + } + } + return retval; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/fortransub.f Fri Jan 24 09:32:55 2014 -0800 @@ -0,0 +1,21 @@ + subroutine fortransub (n, a, s) + implicit none + character*(*) s + real*8 a(*) + integer*4 i, n, ioerr + do i = 1, n + if (a(i) .eq. 0d0) then + call xstopx ('fortransub: divide by zero') + else + a(i) = 1d0 / a(i) + endif + enddo + write (unit = s, fmt = '(a,i3,a,a)', iostat = ioerr) + $ 'There are ', n, + $ ' values in the input vector', char(0) + if (ioerr .ne. 0) then + call xstopx ('fortransub: error writing string') + endif + return + end +
--- a/examples/fortsub.f Fri Jan 24 09:11:01 2014 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ - subroutine fortsub (n, a, s) - implicit none - character*(*) s - real*8 a(*) - integer*4 i, n, ioerr - do i = 1, n - if (a(i) .eq. 0d0) then - call xstopx ('fortsub: divide by zero') - else - a(i) = 1d0 / a(i) - endif - enddo - write (unit = s, fmt = '(a,i3,a,a)', iostat = ioerr) - $ 'There are ', n, - $ ' values in the input vector', char(0) - if (ioerr .ne. 0) then - call xstopx ('fortsub: error writing string') - endif - return - end -