2017-01-25 1 views
1

이 gcc Fortran 컴파일 경고에 대한 해결책은 무엇입니까?Fortran 서브 모듈 및 gcc compliation 플래그와의 혼동 -Wuse-without-only

USE statement at (1) has no ONLY qualifier 

경고는 gcc 6.0, 6.1, 6.2 및 7.0에서 서브 모듈을 사용할 때 발생합니다.

전체 편집 순서 및 경고 :

$ gfortran -c -Wuse-without-only -o mod_module.o mod_module.f08 
$ gfortran -c -Wuse-without-only -o mod_module_sub.o mod_module_sub.f08 
mod_module_sub.f08:1:19: 

submodule (mModule) mSubModule 
        1 
Warning: USE statement at (1) has no ONLY qualifier [-Wuse-without-only] 
$ gfortran -c -Wuse-without-only -o demonstration.o demonstration.f08 
$ gfortran -o demonstration demonstration.o mod_module.o mod_module_sub.o 
$ ./demonstration 
this + that = 3.00000000  
expected value is 3 

메인 프로그램 (demonstration.f08) :

program demonstration 
    use mModule, only : myType 
    implicit none 
    type (myType) :: example 
     example % this = 1.0 
     example % that = 2.0 
     call example % adder () 
     write (*, *) 'this + that = ', example % other 
     write (*, *) 'expected value is 3' 
    stop 
end program demonstration 

모듈 (mod_module.f08) :

module mModule 
    implicit none 
    type :: myType 
     real :: this, that, other 
    contains 
     private 
     procedure, public :: adder => adder_sub 
    end type myType 

    private :: adder_sub 

    interface 
     module subroutine adder_sub (me) 
      class (myType), target :: me 
     end subroutine adder_sub 
    end interface 

end module mModule 

서브 모듈 (mod_module_sub .f08) :

submodule (mModule) mSubModule ! <=== problematic statement 
    implicit none 
contains 
    module subroutine adder_sub (me) 
     class (myType), target :: me 
     me % other = me % this + me % that 
    end subroutine adder_sub 
end submodule mSubModule 

즉, 서브 모듈을 지정하는 적절한 방법은 무엇입니까? -Wuse-without-only 플래그는 더 긴 코드를 컴파일하는 데 필수적입니다.

답변

2

원근법에 따라 이는 단지 컴파일러 버그 일뿐입니다. 버그 보고서를 제출하고 수정 될 때까지 기다리십시오 (또는 직접 수정하십시오).

(또 다른 관점은 코드가 서브 모듈을 사용 여부와 관계없이 자신의 호스트의 모든 개체에 대한 액세스를 제공하기 때문에, 경고가 적절한 것입니다. 그러나 호스트 연결을 제한하는 것은 F2015의 지원이 필요합니다.)

-Wuse-without-only은 그냥 특정 프로그래밍 스타일 (특히 유용하다고 생각하지 않는 프로그래밍 스타일)을 적용하는 데 도움이되는 경고입니다. 짧거나 긴 코드를 컴파일하는 것은 "필수적"일 수 없습니다. 그 동안 경고가 당신을 괴롭히는 경우, 그 옵션을 제거하십시오.

+0

내 코드는 경고없이 해당 옵션을 전달하지 않습니다. –