Support for submodules ?
John Chludzinski
john.chludzinski@gmail.com
Tue Jan 29 17:33:00 GMT 2013
I'm starting a potentially large Fortran project and doing some
gfortran inventory. Just noticed "submodules", apparently a Fortran
analog to Ada's "package body".
Went to the Fortran Wiki for an example:
module points
type :: point
real :: x, y
end type point
interface
module function point_dist(a, b) result(distance)
type(point), intent(in) :: a, b
real :: distance
end function point_dist
end interface
end module points
submodule (points) points_a
contains
module function point_dist(a, b) result(distance)
type(point), intent(in) :: a, b
real :: distance
distance = sqrt((a%x - b%x)**2 + (a%y - b%y)**2)
end function point_dist
end submodule points_a
Tried compiling it and got:
$ gfortran -c t.f95
t.f95:7.5:
module function point_dist(a, b) result(distance)
1
Error: Unclassifiable statement at (1)
t.f95:8.38:
type(point), intent(in) :: a, b
1
Error: Unexpected data declaration statement in INTERFACE block at (1)
t.f95:9.23:
real :: distance
1
Error: Unexpected data declaration statement in INTERFACE block at (1)
t.f95:10.8:
end function point_dist
1
Error: Expecting END INTERFACE statement at (1)
t.f95:14:
submodule (points) points_a
1
Error: Unclassifiable statement at (1)
t.f95:16.2:
module function point_dist(a, b) result(distance)
1
Error: Unclassifiable statement at (1)
t.f95:17.15:
type(point), intent(in) :: a, b
1
Error: Derived type 'point' at (1) is being used before it is defined
t.f95:18.20:
real :: distance
1
Error: Unexpected data declaration statement in CONTAINS section at (1)
t.f95:19.22:
distance = sqrt((a%x - b%x)**2 + (a%y - b%y)**2)
1
Error: Expected a right parenthesis in expression at (1)
t.f95:20.5:
end function point_dist
1
Error: Expecting END PROGRAM statement at (1)
t.f95:21.3:
end submodule points_a
1
Error: Expecting END PROGRAM statement at (1)
Error: Unexpected end of file in 't.f95'
Is there support for this in the upcoming 4.8?
---John
More information about the Fortran
mailing list