我已經使用f2py(inputUtil.pyd)在python中編譯了fortran代碼,我將此函數導入到我的主python代碼中,並將兩個字符傳遞給此從一個字符串函數(locationAID和locationBID)python和f2py錯誤 - NameError:全局名稱'inputUtil'未定義
以下是錯誤消息:
>>> Traceback (most recent call last):
File "C:\FROM_OLD_HD\SynBio\Contact 5-23-12\contactsource_workingcopy\python\main.py", line 234, in batchExecute
self.prepareProteins(tempList[1].replace("protA: ",""),tempList[2].replace("protAID: ",""),tempList[3].replace("protB: ",""),tempList[4].replace("protBID: ",""))
File "C:\FROM_OLD_HD\SynBio\Contact 5-23-12\contactsource_workingcopy\python\main.py", line 668, in prepareProteins
total = inputUtil(locationAID,locationBID)
NameError: global name 'inputUtil' is not defined
這裏是我的主要Python代碼部分:
#import fortran modules
from contact import *
from inputUtil import *
....
def prepareProteins(self, locationA, locationAID, locationB, locationBID):
self.output("Generating temporary protein files...")
start_time = time.time()
shutil.copyfile(locationA,"."+os.sep+"prota.pdb")
shutil.copyfile(locationB,"."+os.sep+"protb.pdb")
total = inputUtil(locationAID,locationBID)
...
這裏是部分FO rtran代碼,我使用轉換f2py顯示的字符傳遞給該函數的Python:
subroutine inputUtil(chida,chidb)
c
integer resnr,nbar,ljnbar,ljrsnr
integer resns,nbars
integer resnc,nbarc
integer resnn,nbarn
c
integer numa,numb,ns,n
c
character*6 card,cards,cardc,cardn,ljcard
c
character*1 alt,ljalt,chid,ljchid,code,ljcode
character*1 alts,chids,codes
character*1 altc,chidc,codec
character*1 altn,chidn,coden
character*1 chida,chidb
....
f2py偉大的工作,所以我不認爲這是問題。我只是在學python - 我是一箇舊時代的Fortran程序員(從打卡當天開始!)。所以,請回復一個老人可以遵循的東西。
感謝您的任何幫助。
PunchDaddy
很好 - 非常感謝您的幫助! – pete 2013-04-15 14:30:16
沒問題!如果解決了您的問題,請考慮接受答案(點擊向下箭頭旁邊的勾號)。 – bananafish 2013-04-15 21:32:48