Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Error #6833 - Problems with functions in submodules

Jump to solution

Hi! My name is Jeferson. I am studying Modern Fortran to update my programs writing in FORTRAN 77.

I have been having problems with functions in submodules. I can compile and run the program without problems when I use the full form of function statement repeating in a submodule all the declarations from the interface. The problem is when I use the short form of the function without repeating the function statement and all the declarations from the interface.

The compiler returns the following error: "Error # 6833: The RESULT data type is specified multiply: on function statement and result name."

The example below is exactly the program I am trying to compile. This example is from the pages 330 and 331 of the book of METCALF, Michael; REID, John; COHEN, Malcolm; Modern Fortran Explained; 7th Edition; Oxford University Press; 2011.

program Submodules
    use points
    implicit none
    ! Variables
    type(point) :: pointa, pointb
    real :: distance    
    ! Body of Submodules
    pointa%x = 1
    pointa%y = 2
    pointb%x = 2
    pointb%y = 1
    print *, 'Ponto a = ', pointa
    print *, 'Ponto b = ', pointb
    distance = point_dist(pointa, pointb)    
    print *, 'Distance = ', distance
    pause
end program Submodules

module points
    type :: point
        real :: x, y
    end type point
    interface
        real module function point_dist(a, b)
            type(point), intent(in) :: a, b
        end function point_dist
    end interface
end module points

submodule (points) points_a
contains
    module procedure point_dist
        point_dist = sqrt((a%x-b%x)**2+(a%y-b%y)**2)
    end procedure point_dist
end submodule points_a

I can compile without errors change this function to a subroutine.

I am using the Microsoft Visual Studio Professional 2013 Update 3 with Intel Parallel Studio XE 2016 Update 1.

0 Kudos

Accepted Solutions
Highlighted
New Contributor III

Hi Jeferson,

Jump to solution

Hi Jeferson,

For me it was sufficient to remove the 'real' in line 24 --> module function point_dist(a, b). The compiler complains about a double definition as you quoted:

Severity    Code    Description    Project    File    Line    Suppression State
Error        error #6833: The RESULT data type is  multiply specified: on function statement and result name.        D:\02_Fortran\99_test\submodule_test_01\submod_points.f90    1    


Whether the original code lines from 'Modern Fortran Explained' are standard conform, Steve will know for sure.

Best regards, Johannes

View solution in original post

0 Kudos
7 Replies
Highlighted
New Contributor III
1 View

Hi Jeferson,

Jump to solution

Hi Jeferson,

For me it was sufficient to remove the 'real' in line 24 --> module function point_dist(a, b). The compiler complains about a double definition as you quoted:

Severity    Code    Description    Project    File    Line    Suppression State
Error        error #6833: The RESULT data type is  multiply specified: on function statement and result name.        D:\02_Fortran\99_test\submodule_test_01\submod_points.f90    1    


Whether the original code lines from 'Modern Fortran Explained' are standard conform, Steve will know for sure.

Best regards, Johannes

View solution in original post

0 Kudos
Highlighted

Thanks Johannes!

Jump to solution

Thanks Johannes!

Without the 'real' in line 24 the problem is solved, and the compiler no complains anymore.

I use the original code lines describe in 'Modern Fortran Explained' and the compiler complain, maybe the book is wrong, I hope that Steve can clarify this issue.

Best regards, Jeferson

0 Kudos
Highlighted

This is a compiler bug - I

Jump to solution

This is a compiler bug - I will let the developers know. Thanks. Issue ID is DPD200381662.

A better workaround is to remove the "real" prefix and then add a new line, after "module function...": "real point_dist".

Otherwise you are leaving the type implicit, which is bad.

Retired 12/31/2016
0 Kudos
Highlighted

Thanks Steve!

Jump to solution

Thanks Steve!

Now the program is running well.

Best regards, Jeferson

0 Kudos
Highlighted
Valued Contributor II

Would Implicit none added in

Jump to solution

Would Implicit none added in module points propagate into submodule points_a as a matter of interest?

0 Kudos
Highlighted

No, it doesn't. Only

Jump to solution

No, it doesn't. Only declarations of entities in the parent module are inherited.

Retired 12/31/2016
0 Kudos
Highlighted

I expect this bug to be fixed

Jump to solution

I expect this bug to be fixed in Parallel Studio XE 2016 Update 3.

Retired 12/31/2016
0 Kudos