이 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
플래그는 더 긴 코드를 컴파일하는 데 필수적입니다.
내 코드는 경고없이 해당 옵션을 전달하지 않습니다. –