сообщение об ошибке:Fortran ошибки ссылка: неопределенные ссылки, используя подмодули
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
Последняя часть `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