Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
14 Views

submodules

Jump to solution

There is a compilation issue occured when circular reference is employed. See the codes:

module test1
    implicit none
    
    integer, parameter :: a = 5
    
    interface
        module subroutine sub1()
        end subroutine sub1
    end interface

end module test1
    
submodule(test1) submodule1
    use test2
    implicit none
    
    contains
    
    module procedure sub1
        implicit none
        print*, b
    end procedure sub1

end submodule submodule1

module test2
    implicit none
    
    integer, parameter :: b = 4

    interface
        module subroutine sub2()
        end subroutine sub2
    end interface

end module test2
    
submodule(test2) submodule2
    use test1
    implicit none
    
    contains
    
    module procedure sub2
        implicit none
        print*, a
    end procedure sub2

end submodule submodule2
    
program main
    use test1
    use test2
    
    !TO DO.

end program main

The use association in submodules are permitted by the standard. An error shows up when compile for the first time:

error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [TEST2]

If then we compile it again without cleanning-up, the target assembly will be created successfully. So is it a compiler mistake ? Or how should I do to solve it ?

0 Kudos

Accepted Solutions
Highlighted
Valued Contributor III
14 Views

Blane J. wrote:
Yes Andrew, they are all in the same file, separate case gives the same result.

In the same file is a certain fail, and would be a bit daft as the whole point of submodules is to separate the interface from the implimentation to avoid build cascades.  You are forcing things to be all recompiled. 

View solution in original post

0 Kudos
5 Replies
Highlighted
Valued Contributor III
14 Views
Are they all in the same file?
0 Kudos
Highlighted
New Contributor I
14 Views

Yes Andrew, they are all in the same file, separate case gives the same result.

0 Kudos
Highlighted
Valued Contributor III
14 Views
1>------ Build started: Project: blane_test, Configuration: Debug Win32 ------
1>Compiling with Intel(R) Visual Fortran Compiler 18.0.0.124 [IA-32]...
1>Source2.f90
1>Source4.f90
1>Source3.f90
1>Source5.f90
1>Source1.f90
1>Linking...
1>Embedding manifest...
1>
1>Build log written to  "file://C:\Users\....\blane_test\Debug\BuildLog.htm"
1>blane_test - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

It works OK for me

0 Kudos
Highlighted
Valued Contributor III
15 Views

Blane J. wrote:
Yes Andrew, they are all in the same file, separate case gives the same result.

In the same file is a certain fail, and would be a bit daft as the whole point of submodules is to separate the interface from the implimentation to avoid build cascades.  You are forcing things to be all recompiled. 

View solution in original post

0 Kudos
Highlighted
New Contributor I
14 Views

Yes, I then splited those entities each into different files and had the same result as you did, previously I only isolate the main program from the modules and submodules. Thanks Andrew.

0 Kudos