Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29279 ディスカッション

submodules

Blane_J_
新規コントリビューター I
1,310件の閲覧回数

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 件の賞賛
1 解決策
andrew_4619
名誉コントリビューター III
1,310件の閲覧回数

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. 

元の投稿で解決策を見る

5 返答(返信)
andrew_4619
名誉コントリビューター III
1,310件の閲覧回数
Are they all in the same file?
Blane_J_
新規コントリビューター I
1,310件の閲覧回数

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

andrew_4619
名誉コントリビューター III
1,310件の閲覧回数
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

andrew_4619
名誉コントリビューター III
1,311件の閲覧回数

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. 

Blane_J_
新規コントリビューター I
1,310件の閲覧回数

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.

返信