0

エラーメッセージ:

mod_matrices.o:(.data+0x1790): undefined reference to `allocator_rank_2_sub_'

モジュール mMatrices (mod_matrices.f08 内) は、サブモジュール smAllocations (mod_sub_matrices_allocators.f08 内) にある関数allocator_rank_2_subを呼び出します。モジュールをモジュールとサブモジュールに分割する前に、コードは機能mMatricesしました。

モジュール:

module mMatrices
    use mPrecisionDefinitions,  only : ip, rp    
    implicit none

    type :: matrices
        real ( rp ), allocatable :: A ( : , : ), AS ( : , : ), ASAinv ( : , : )
    contains
        private
        procedure, nopass, public :: allocator_rank_2   => allocator_rank_2_sub
        procedure, public         :: construct_matrices => construct_matrices_sub
    end type matrices

    private :: allocator_rank_2_sub
    private :: construct_matrices_sub

    interface
        subroutine allocator_rank_2_sub ( array, rows, cols )
            use mPrecisionDefinitions, only : ip, rp
            real ( rp ), allocatable, intent ( out ) :: array ( : , : )
            integer ( ip ),           intent ( in )  :: rows, cols
        end subroutine allocator_rank_2_sub
    end interface

    contains
        subroutine construct_matrices_sub ( me, ints, mydof, measure )
            ...
                call me % allocator_rank_2 ( me % A, m, mydof )
            ...
        end subroutine construct_matrices_sub
end module mMatrices

サブモジュール:

submodule ( mMatrices ) smAllocations
    contains    
        module subroutine allocator_rank_2_sub ( array, rows, cols )
            ...
        end subroutine allocator_rank_2_sub
end submodule smAllocations

make によるコンパイル:

ftn -g -c -r s -o mod_precision_definitions.o mod_precision_definitions.f08
...
ftn -g -c -r s -o mod_matrices.o mod_matrices.f08
...
ftn -g -c -r s -o mod_sub_matrices_allocators.o mod_sub_matrices_allocators.f08
...
ftn -g -c -r s -o lsq.o lsq.f08
ftn -g -o lsq lsq.o --- mod_matrices.o --- mod_precision_definitions.o --- mod_sub_matrices_allocators.o ---
mod_matrices.o:(.data+0x1790): undefined reference to `allocator_rank_2_sub_'
make: *** [lsq] Error 1

「makefile」の最後の部分

# Main program depends on all modules
$(PRG_OBJ) : $(MOD_OBJS)

# resolve module interdependencies
...
mod_matrices.o                : mod_precision_definitions.o mod_parameters.o mod_intermediates.o
mod_sub_matrices_allocators.o : mod_matrices.o
...

マシン:Cray XC30

コンパイラ: Fortran 5.2.82

質問: 何を修正する必要がありますか?


@IanHの修正を組み込んだ修正されたコードフラグメント:

interface
    MODULE subroutine allocator_rank_2_sub ( array, rows, cols )
        use mPrecisionDefinitions, only : ip, rp
        real ( rp ), allocatable, intent ( out ) :: array ( : , : )
        integer ( ip ),           intent ( in )  :: rows, cols
    end subroutine allocator_rank_2_sub
end interface
4

1 に答える 1

2

モジュールの仕様部分にある allocator_rank_2_sub のインターフェイス ブロックに MODULE プレフィックスがありません。これは、意図した別のモジュール プロシージャではなく、外部プロシージャを指定することを意味します。リンカは、そのような外部プロシージャが見つからないと不平を言っています。

インターフェイス本体のサブルーチン ステートメントに MODULE プレフィックスを追加します。

于 2016-03-04T01:07:45.990 に答える