我承認標題可能有點模糊,因此讓我舉例說明我想要做什麼以及哪些不起作用。我有一個調用一個子程序這是一個模塊中的主要程序:Fortran:從另一個模塊中的過程調用模塊中的函數
Program Test_program
Use module_A
Implicit none
Integer :: i
i = 1
call subroutine_A(i)
End program Test_program
這subroutine_A是在模塊A,並輪流調用function_B這是module_B:
module module_A
use module_B
implicit none
contains
subroutine subroutine_A(i)
implicit none
integer, intent(in) :: i
double precision :: j
j = function_B(i)
end subroutine subroutine_A
end module module_A
最後, module_B看起來像這樣:
module module_B
Implicit none
Contains
double precision function function_B(i)
implicit none
integer,intent(in) :: i
function_B = 5.d0*i
end function function_B
end module module_B
程序和模塊在不同的文件中。不幸的是,這不會編譯,因爲我收到一條錯誤消息:
錯誤子例程_A:對子例程function_B的引用不在CALL語句中。
看來程序認爲function_B是一個子程序,所以我不知道該怎麼做。 順便說一下,我試圖使用正確的封裝我的子程序和功能模塊,因爲我被告知,但如果這不是正確的方式,我打開建議(我被告知不要使用接口,但模塊,因此,因此這個測試)。
感謝
因此,您的實際代碼有一個名稱衝突,原始問題中沒有演示。對? – ja72 2013-03-04 06:25:37