我對Fortran很新,爲了研究我需要運行一個模型的怪物,所以我正在學習,因爲我正在學習。所以如果我問一個「愚蠢」的問題,我很抱歉。 我試圖編譯(Mac OSX,從命令行),我已經設法解決了一些事情,但現在我遇到了一些我不知道如何解決的問題。我想我明白了這個錯誤背後的想法,但是,不知道如何解決。Fortran - 顯式接口
該模型是巨大的,所以我只會發布我認爲相關的代碼段(雖然我可能是錯的)。我有幾個子程序文件,啓動用:
!==========================================================================================!
! This subroutine simply updates the budget variables. !
!------------------------------------------------------------------------------------------!
subroutine update_budget(csite,lsl,ipaa,ipaz)
use ed_state_vars, only : sitetype ! ! structure
implicit none
!----- Arguments -----------------------------------------------------------------------!
type(sitetype) , target :: csite
integer , intent(in) :: lsl
integer , intent(in) :: ipaa
integer , intent(in) :: ipaz
!----- Local variables. ----------------------------------------------------------------!
integer :: ipa
!----- External functions. -------------------------------------------------------------!
real , external :: compute_water_storage
real , external :: compute_energy_storage
real , external :: compute_co2_storage
!---------------------------------------------------------------------------------------!
do ipa=ipaa,ipaz
!------------------------------------------------------------------------------------!
! Computing the storage terms for CO2, energy, and water budgets. !
!------------------------------------------------------------------------------------!
csite%co2budget_initialstorage(ipa) = compute_co2_storage(csite,ipa)
csite%wbudget_initialstorage(ipa) = compute_water_storage(csite,lsl,ipa)
csite%ebudget_initialstorage(ipa) = compute_energy_storage(csite,lsl,ipa)
end do
return
end subroutine update_budget
!==========================================================================================!
!==========================================================================================!
我相處的
budget_utils.f90行錯誤信息:20.54:
真實的,外部:: compute_co2_storage 錯誤:(1)處的過程'compute_co2_storage'的僞參數'csite'具有需要此過程的顯式接口的屬性
(I ge一堆他們,但他們基本上都是一樣的)。現在,看着ed_state_vars.f90(這是「拿來主義」在子程序),我發現
!============================================================================!
!============================================================================!
!---------------------------------------------------------------------------!
! Site type:
! The following are the patch level arrays that populate the current site.
!---------------------------------------------------------------------------!
type sitetype
integer :: npatches
! The global index of the first cohort in all patches
integer,pointer,dimension(:) :: paco_id
! The number of cohorts in each patch
integer,pointer,dimension(:) :: paco_n
! Global index of the first patch in this vector, across all patches
! on the grid
integer :: paglob_id
! The patches containing the cohort arrays
type(patchtype),pointer,dimension(:) :: patch
等等等等 - 這又進了另一個500行左右。 因此,爲了能夠使用(虛擬)參數csite,似乎原始子例程需要其過程的顯式接口。再次,我對Fortran來說是最新的,但我真的很想了解它是如何「思考」的。我一直在尋找什麼意思,有一個明確的接口,何時(以及如何!)使用它等等。但我無法弄清楚它是如何適用於我的情況。我應該使用不同的編譯器(英特爾?)。任何提示?
編輯:那麼csite
聲明中的所有程序target
和聲明type(site type)
包含一大堆pointer
S,在sitetype
規定。但在所有程序中,sitetype
正在從另一個模塊(ed_state_vars.f90
)正確地use
d。所以我仍然困惑爲什麼它給了我明確的接口錯誤?
您的模塊中有'compute_water_storage'和其他函數嗎? – SethMMorton 2013-05-10 19:45:22
我們需要在'compute_co2_storage()'中看到'csite'的聲明,因爲錯誤消息是指該例程中聲明的屬性,而不是'update_budget()'中的聲明屬性。我懷疑它被聲明爲「可選」或「POINTER」或類似的東西。 – Deditos 2013-05-10 20:56:55
感謝您的所有反饋。 @SethMMorton:是的,作爲「真正的功能」。 @Deditos:在'compute_co2_storage()'中,'csite'聲明和我在發佈的子例程中一樣:'type(sitetype),target :: csite'。 – Geraldine 2013-05-13 13:48:53