- 追加された行はこの色です。
- 削除された行はこの色です。
*Fortran [#pbb06ff1]
-[[Fortran Wiki:http://fortranwiki.org/]]
--[[Fortran 2008 status:http://fortranwiki.org/fortran/show/Fortran+2008+status]]
--[[Fortran 2003 status:http://fortranwiki.org/fortran/show/Fortran+2003+status]]
-[[Fortran入門:http://www.nag-j.co.jp/fortran/]]
-[[Fortran 2003入門:http://www.nag-j.co.jp/fortran/fortran2003/]]
-[[Fortran2003でFFTW:http://sage-t.tumblr.com/post/57793790661/fortran2003-fftw]]
-[[fortran66のブログ:http://fortran66.hatenablog.com/]]
-[[Fortran Archives - Moonmile Solutions Blog:http://www.moonmile.net/blog/archives/category/dev/fortran]]
-[[PythonからFortranのサブルーチンを呼ぶ。:http://d.hatena.ne.jp/ignisan/20121017/p1]]
-[[FortranからPythonへ:http://www.slideshare.net/shibukawa/fortranpython-presentation]]
-http://gcc.gnu.org/onlinedocs/gfortran/Interoperable-Subroutines-and-Functions.html
-http://software.intel.com/en-us/forums/topic/270769
-http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlf101a.doc%2Fxlflr%2Finterop-iso-c-binding-module.htm
**処理系 [#xfad745a]
-[[GNU Fortran (gfortran):http://gcc.gnu.org/wiki/GFortran]]
--[[Fortran2008Status - GCC Wiki:http://gcc.gnu.org/wiki/Fortran2008Status]]
--[[Fortran2003Status - GCC Wiki:http://gcc.gnu.org/wiki/Fortran2003Status]]
**使い方 [#r3bbac60]
GNU Fortran (rev2, Built by MinGW-builds project) 4.8.1 で動作確認しています.~
***標準出力に "Hello World" を出力 [#x79017be]
----
-helloworld.f08
----
program helloworld
use iso_c_binding
implicit none
interface c_stdio
subroutine c_stdio_puts(s) bind(C, name='puts')
import
character(c_char), intent(in) :: s
end subroutine c_stdio_puts
end interface c_stdio
call c_stdio_puts("Hello World" // c_null_char)
end program helloworld
----
Fortran の文字列は null 終端文字列ではないので C の関数に渡す場合は c_null_char を末尾に追加して渡す必要があります.~
$ gfortran -o helloworld helloworld.f08
$ ./helloworld
MinGW の gfortran でビルドしたバイナリで
-Windows PowerShell から実行するとなにも表示されない
-コマンド プロンプトから実行するとアプリケーションエラーが発生する
といった現象が発生する場合は
$ gfortran -static -o helloworld helloworld.f08
のように -static オプションを追加してビルドすれば OK です.~