我想使用的功能OPAC從這個源代碼: http://opalopacity.llnl.gov/codes/xztrin21.f需要得到f2py工作,但不知道任何FORTRAN
我不uderstand代碼非常好,我只是想用它作爲Python模塊。我運行以下命令:
f2py -c xztrin21.f -m opal_opacity
,但我總是得到這樣的錯誤:
/tmp/tmpWe2VM7/src.linux-x86_64-2.7/opal_opacitymodule.c:1819:71: error: expected ‘;’, ‘,’ or ‘)’ before ‘!’ token
/tmp/tmpWe2VM7/src.linux-x86_64-2.7/opal_opacitymodule.c: In function ‘f2py_init_cst’:
/tmp/tmpWe2VM7/src.linux-x86_64-2.7/opal_opacitymodule.c:1828:35: error: ‘f2py_setup_cst’ undeclared (first use in this function)
/tmp/tmpWe2VM7/src.linux-x86_64-2.7/opal_opacitymodule.c:1828:35: note: each undeclared identifier is reported only once for each function it appears in
/tmp/tmpWe2VM7/src.linux-x86_64-2.7/opal_opacitymodule.c:1819:71: error: expected ‘;’, ‘,’ or ‘)’ before ‘!’ token
/tmp/tmpWe2VM7/src.linux-x86_64-2.7/opal_opacitymodule.c: In function ‘f2py_init_cst’:
/tmp/tmpWe2VM7/src.linux-x86_64-2.7/opal_opacitymodule.c:1828:35: error: ‘f2py_setup_cst’ undeclared (first use in this function)
/tmp/tmpWe2VM7/src.linux-x86_64-2.7/opal_opacitymodule.c:1828:35: note: each undeclared identifier is reported only once for each function it appears in
error: Command "gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/tmpWe2VM7/src.linux-x86_64-2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c /tmp/tmpWe2VM7/src.linux-x86_64-2.7/opal_opacitymodule.c -o /tmp/tmpWe2VM7/tmp/tmpWe2VM7/src.linux-x86_64-2.7/opal_opacitymodule.o" failed with exit status 1
我不認爲有真的什麼錯誤的代碼。我相信其他人能夠正常工作,所以我想我必須有一個錯誤的Fortran編譯器或其他東西。我不知道該怎麼做。
任何幫助apprecitated
編輯: 如果我嘗試編譯gfortran代碼我得到如下:
xztrin21.f:1025.72:
IF (H.EQ.0.) PAUSE 'Bad XA input.'
1
Warning: Deleted feature: PAUSE statement at (1)
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
我跑了第一個例子沒有任何麻煩。編譯器可能會遇到問題。請參閱我的編輯 – Tom83B
或者是否需要在代碼中的某個地方使用main()函數? – Tom83B
我不認爲你的編譯器有問題,它一定是你調用它的方式。只需在'f2py'上仔細閱讀文檔即可。此外,你遇到的第二個問題是因爲你正在編譯一個沒有'PROGRAM'的'SUBROUTINE'。它正在尋找一個'PROGRAM'和'END PROGRAM',但我猜你沒有一個。所以它沒有找到'main',因爲你沒有編譯程序!參見[這裏](http://www.see.ed.ac.uk/~jwp/pse2/modelling/fortran/simple.html)如何編寫一個簡單的'Fortran'程序,它應該找到'main'辦法。 –