Commit | Line | Data |
---|---|---|
23be8da7 RB |
1 | ! Copyright 2018 Free Software Foundation, Inc. |
2 | ! | |
3 | ! This program is free software; you can redistribute it and/or modify | |
4 | ! it under the terms of the GNU General Public License as published by | |
5 | ! the Free Software Foundation; either version 3 of the License, or | |
6 | ! (at your option) any later version. | |
7 | ! | |
8 | ! This program is distributed in the hope that it will be useful, | |
9 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | ! GNU General Public License for more details. | |
12 | ! | |
13 | ! You should have received a copy of the GNU General Public License | |
14 | ! along with this program. If not, see <http://www.gnu.org/licenses/> . | |
15 | ||
16 | ! Source code for short-circuit-argument-list.exp. | |
17 | ||
18 | logical function function_no_arg() | |
19 | print *, "No, return true." | |
20 | function_no_arg = .TRUE. | |
21 | end function function_no_arg | |
22 | ||
23 | logical function function_no_arg_false() | |
24 | function_no_arg_false = .FALSE. | |
25 | end function function_no_arg_false | |
26 | ||
27 | logical function function_one_arg(x) | |
28 | logical, intent(in) :: x | |
29 | print *, "One, return true." | |
30 | function_one_arg = .TRUE. | |
31 | end function function_one_arg | |
32 | ||
33 | logical function function_two_arg(x, y) | |
34 | logical, intent(in) :: x, y | |
35 | print *, "Two, return true." | |
36 | function_two_arg = .TRUE. | |
37 | end function function_two_arg | |
38 | ||
39 | logical function function_array(logical_array) | |
40 | logical, dimension(4,2), target, intent(in) :: logical_array | |
41 | logical, dimension(:,:), pointer :: p | |
42 | p => logical_array | |
43 | print *, "Array, return true.", p(1,1), logical_array(1,1) | |
44 | function_array = .TRUE. | |
45 | end function function_array | |
46 | ||
47 | program generate_truth_table | |
48 | implicit none | |
49 | interface | |
50 | logical function function_no_arg() | |
51 | end function function_no_arg | |
52 | logical function function_no_arg_false() | |
53 | end function | |
54 | logical function function_one_arg(x) | |
55 | logical, intent(in) :: x | |
56 | end function | |
57 | logical function function_two_arg(x, y) | |
58 | logical, intent(in) :: x, y | |
59 | end function | |
60 | logical function function_array(logical_array) | |
61 | logical, dimension(4,2), target, intent(in) :: logical_array | |
62 | end function function_array | |
63 | end interface | |
64 | logical, dimension (4,2) :: truth_table | |
65 | logical :: a, b, c, d, e | |
66 | character(2) :: binary_string | |
67 | binary_string = char(0) // char(1) | |
68 | truth_table = .FALSE. | |
69 | truth_table(3:4,1) = .TRUE. | |
70 | truth_table(2::2,2) = .TRUE. | |
71 | a = function_no_arg() ! post_truth_table_init | |
72 | b = function_no_arg_false() | |
73 | c = function_one_arg(b) | |
74 | d = function_two_arg(a, b) | |
75 | e = function_array(truth_table) | |
76 | print *, truth_table(:, 1), a, b, e | |
77 | print *, truth_table(:, 2), c, d | |
78 | end program generate_truth_table |