annotate examples/fortsub.f @ 7948:af10baa63915 ss-3-1-50

3.1.50 snapshot
author John W. Eaton <jwe@octave.org>
date Fri, 18 Jul 2008 17:42:48 -0400
parents 503001863427
children 4295d634797d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7019
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6572
diff changeset
1 c Copyright (C) 2007 John W. Eaton
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6572
diff changeset
2 c
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6572
diff changeset
3 c This file is part of Octave.
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6572
diff changeset
4 c
7081
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
5 c Octave is free software; you can redistribute it and/or
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
6 c modify it under the terms of the GNU General Public
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
7 c License as published by the Free Software Foundation;
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
8 c either version 3 of the License, or (at your option) any
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
9 c later version.
7019
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6572
diff changeset
10 c
7081
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
11 c Octave is distributed in the hope that it will be useful,
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
12 c but WITHOUT ANY WARRANTY; without even the implied
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
13 c warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
14 c PURPOSE. See the GNU General Public License for more
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
15 c details.
7019
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6572
diff changeset
16 c
7081
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
17 c You should have received a copy of the GNU General Public
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
18 c License along with Octave; see the file COPYING. If not,
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
19 c see <http://www.gnu.org/licenses/>.
7019
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6572
diff changeset
20
6572
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
21 subroutine fortsub (n, a, s)
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
22 implicit none
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
23 character*(*) s
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
24 real*8 a(*)
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
25 integer*4 i, n, ioerr
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
26 do i = 1, n
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
27 if (a(i) .eq. 0d0) then
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
28 call xstopx ('fortsub: divide by zero')
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
29 else
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
30 a(i) = 1d0 / a(i)
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
31 endif
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
32 enddo
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
33 write (unit = s, fmt = '(a,i3,a,a)', iostat = ioerr)
7081
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
34 $ 'There are ', n,
503001863427 [project @ 2007-10-31 01:08:14 by jwe]
jwe
parents: 7019
diff changeset
35 $ ' values in the input vector', char(0)
6572
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
36 if (ioerr .ne. 0) then
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
37 call xstopx ('fortsub: error writing string')
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
38 endif
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
39 return
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
40 end
8e7148b84b59 [project @ 2007-04-25 04:13:44 by jwe]
jwe
parents:
diff changeset
41