このgcc Fortranのコンパイルの警告に対する救済策は何ですか?Fortranのサブモジュールとgccの矛盾フラグとの混乱-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
は、より長いコードのコンパイルには不可欠です。
私のコードは、警告なしでそのオプションを渡すことはありません。 –