diff --git a/demos/fortran/submodules/container.f90 b/demos/fortran/submodules/container.f90 index 1d9387c0..d8a6c471 100644 --- a/demos/fortran/submodules/container.f90 +++ b/demos/fortran/submodules/container.f90 @@ -3,6 +3,20 @@ submodule (parent) container contains + module procedure init + p%mother = mother + p%father = father + end procedure init + + module subroutine harmonize(p) + type(parent_type), intent(inout) :: p + real :: avg + + avg = 0.5 * (p%father + p%mother) + p%father = avg + p%mother = avg + end subroutine harmonize + module function parent_weight(p) result(w) type(parent_type), intent(in) :: p real :: w diff --git a/demos/fortran/submodules/parent.f90 b/demos/fortran/submodules/parent.f90 index e40fbca9..17b8370b 100644 --- a/demos/fortran/submodules/parent.f90 +++ b/demos/fortran/submodules/parent.f90 @@ -7,6 +7,15 @@ module parent end type parent_type interface + module subroutine init(p, mother, father) + type(parent_type), intent(out) :: p + real, intent(in) :: mother, father + end subroutine init + + module subroutine harmonize(p) + type(parent_type), intent(inout) :: p + end subroutine harmonize + module function parent_weight(p) result(w) type(parent_type), intent(in) :: p real :: w diff --git a/demos/fortran/submodules/submain.f90 b/demos/fortran/submodules/submain.f90 new file mode 100644 index 00000000..e47013a5 --- /dev/null +++ b/demos/fortran/submodules/submain.f90 @@ -0,0 +1,18 @@ +program submain + use parent + + implicit none + + type(parent_type) :: a,b + real :: dist, weight + + call init(a, 1.0, 2.0) + call init(b, 10.0, 12.0) + + call harmonize(a) + weight = parent_weight(b) + write(*,*) weight + dist = parent_distance(a, b) + write(*,*) dist + +end program submain diff --git a/demos/fortran/submodules/wscript b/demos/fortran/submodules/wscript index 73f8be13..771614e1 100644 --- a/demos/fortran/submodules/wscript +++ b/demos/fortran/submodules/wscript @@ -18,3 +18,9 @@ def build(bld): source = 'parent.f90 container.f90 helper.f90', target = 'fudge', ) + bld( + features = 'fc fcprogram', + source = 'submain.f90', + use = 'fudge', + target = 'submain', + )