1 ! Copyright 2016-2019 Free Software Foundation, Inc.
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.
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.
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/>.
16 ! This file is the Fortran source file for derived-type-function.exp.
17 ! It was contributed by Walfred Tedeschi (walfred.tedeschi@intel.com).
19 module class_Rectangle
23 type, public :: Rectangle
27 procedure :: area => rectangle_area
28 procedure :: print_area => print_area
32 function rectangle_area (this) result (area)
33 class (Rectangle), intent (in) :: this
36 area = this%a * this%b
37 end function rectangle_area
39 subroutine print_area (this)
40 class (Rectangle), intent (in) :: this
44 print *, ' area = ', area
45 end subroutine print_area
47 end module class_Rectangle
50 program rectangle_Test
54 type (Rectangle) :: aRec
57 aRec = Rectangle (2., 3.)
61 end program rectangle_Test