0
mod_matrices.o:(.data+0x1790): undefined reference to `allocator_rank_2_sub_'
模塊mMatrices(在mod_matrices.f08)調用函數allocator_rank_2_sub
這是在一個子模塊smAllocations(在mod_sub_matrices_allocators.f08)。代碼在將模塊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
經由化妝編譯:
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
`生成文件」
# 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
...
的最後部分
本機:克雷XC30
編譯器:Fortran的82年2月5日
的問題:什麼需要解決嗎?
摻入@ IanH的fix校正的代碼片斷:
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