3 ! Check that pointer-returing functions
6 ! Contributed by Salvatore Filippone.
10 real(kind(1.d0)), allocatable :: area(:)
13 subroutine create_mesh(msh)
14 type(mesh), intent(out) :: msh
15 allocate(msh%area(10))
17 end subroutine create_mesh
24 public :: create_field, field
29 type(mesh), pointer :: msh => null()
36 interface create_field
37 module procedure create_field
40 subroutine create_field(fld,msh)
41 type(field), intent(out) :: fld
42 type(mesh), intent(in), target :: msh
45 end subroutine create_field
48 type(mesh), pointer :: msh_
49 type(field), intent(in) :: fld
52 end module class_field
54 module class_scalar_field
58 public :: create_field, scalar_field
64 real(kind(1.d0)), allocatable :: x(:)
65 real(kind(1.d0)), allocatable :: bx(:)
66 real(kind(1.d0)), allocatable :: x_old(:)
69 interface create_field
70 module procedure create_scalar_field
73 module procedure get_scalar_field_msh
76 subroutine create_scalar_field(fld,msh)
78 type(scalar_field), intent(out) :: fld
79 type(mesh), intent(in), target :: msh
80 call create_field(fld%base,msh)
81 allocate(fld%x(10),fld%bx(20))
82 end subroutine create_scalar_field
84 function get_scalar_field_msh(fld)
86 type(mesh), pointer :: get_scalar_field_msh
87 type(scalar_field), intent(in), target :: fld
89 get_scalar_field_msh => msh_(fld%base)
90 end function get_scalar_field_msh
91 end module class_scalar_field
95 use class_scalar_field
98 type(mesh), pointer :: mshp
99 type(scalar_field) :: quality
100 call create_mesh(msh)
101 call create_field(quality,msh)
102 mshp => msh_(quality)
105 ! { dg-final { cleanup-modules "class_mesh class_field class_scalar_field" } }