diff --git a/demos/fortran/submodules/container.f90 b/demos/fortran/submodules/container.f90 new file mode 100644 index 00000000..1d9387c0 --- /dev/null +++ b/demos/fortran/submodules/container.f90 @@ -0,0 +1,13 @@ +submodule (parent) container + implicit none + +contains + + module function parent_weight(p) result(w) + type(parent_type), intent(in) :: p + real :: w + + w = p%mother**2 + p%father**2 + end function parent_weight + +end submodule container diff --git a/demos/fortran/submodules/helper.f90 b/demos/fortran/submodules/helper.f90 new file mode 100644 index 00000000..b72de8c0 --- /dev/null +++ b/demos/fortran/submodules/helper.f90 @@ -0,0 +1,13 @@ +submodule (parent:container) helper + implicit none + +contains + + module function parent_distance(pa, pb) result(dist) + type(parent_type), intent(in) :: pa, pb + real :: dist + + dist = sqrt(parent_weight(pa) + parent_weight(pb)) + end function parent_distance + +end submodule helper diff --git a/demos/fortran/submodules/parent.f90 b/demos/fortran/submodules/parent.f90 new file mode 100644 index 00000000..e40fbca9 --- /dev/null +++ b/demos/fortran/submodules/parent.f90 @@ -0,0 +1,21 @@ +module parent + implicit none + + type parent_type + real :: mother + real :: father + end type parent_type + + interface + module function parent_weight(p) result(w) + type(parent_type), intent(in) :: p + real :: w + end function parent_weight + + module function parent_distance(pa, pb) result(dist) + type(parent_type), intent(in) :: pa, pb + real :: dist + end function parent_distance + end interface + +end module parent diff --git a/demos/fortran/submodules/wscript b/demos/fortran/submodules/wscript new file mode 100644 index 00000000..73f8be13 --- /dev/null +++ b/demos/fortran/submodules/wscript @@ -0,0 +1,20 @@ +#! /usr/bin/env python + +top = '.' +out = 'build' + +def options(opt): + opt.load('compiler_c') + opt.load('compiler_fc') + +def configure(conf): + conf.load('compiler_c') + conf.load('compiler_fc') + +def build(bld): + + bld( + features = 'fc fcshlib', + source = 'parent.f90 container.f90 helper.f90', + target = 'fudge', + ) diff --git a/demos/fortran/wscript b/demos/fortran/wscript index f1fb5d7c..f1223d80 100644 --- a/demos/fortran/wscript +++ b/demos/fortran/wscript @@ -78,3 +78,5 @@ def build(bld): target = 'mod/two_mods') bld.recurse('typemap') + if bld.env.FC_NAME == 'GFORTRAN' and int(bld.env.FC_VERSION[0]) >= 6: + bld.recurse('submodules')