fortran66のブログ

fortran について書きます。

Windows 64bit + Python 64bit + f2py (Intel Visual Fortran + Microsoft Windows SDK)

メモ帳

参考ページ

Python 64bit

IPython->Install->Enthought Canopy http://ipython.org/install.html

Python のことはよく知らないので、Enthought Canopy で 64bit 2.7 系のお任せコース選択。

Microsoft Windows SDKC++ Compiler)

Compiling 64-bit extension modules on Windows

https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows

For Python 2.6, 2.7 and 3.1, you should use the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1. Later or earlier versions of the SDK will link with the wrong C runtime. This is required to make sure the extension is linked with the same C runtime version as Python. Using the correct version of the SDK is the only way to control this with Microsoft's build tools.

 

C:\Program Files\Microsoft SDKs\Windows\v7.0>set DISTUTILS_USE_SDK=1

C:\Program Files\Microsoft SDKs\Windows\v7.0>setenv /x64 /release

 

** If you need Fortran (e.g. for f2py or fwrap), Intel, Absoft and Portland have compilers compatible with Microsoft's C compiler and linker. Be very careful if you use an unofficial MinGW-w64 build of gfortran, as libgfortran is linked against an uncompatible C runtime. Unlike C and C++, there is no freely available Fortran compiler except MinGW-w64 gfortran on Windows 64.

最低限のインストールで済ませる。

f:id:fortran66:20140221025848p:plain

f2py 起動セッティング

DOS窓において以下の実行。

CHCP 437

"C:\Program Files (x86)\Intel\Composer XE 2013 SP1\bin\ipsxe-comp-vars.bat" intel64 vs2010

"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat"

set DISTUTILS_USE_SDK=1

"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\SetEnv /x64 /release"
  1. DOS窓 は US Mode にしておかないと f2py がコンパイラの情報を読み取れず困る。
  2. Intel Visual Fortran への Path を通しておく。
  3. MS SDK C++ への Path を通しておく。
  4. C++ compiler の環境変数x64 バイナリ出力の release 版とする。

この後、devenv で、VS2010 を起動する。

!f2py -c --fcompiler=intelvem -m python_module_name  fn.f90

で、Intel Visual Fortran (x64) + MS-SDK C++ の組み合わせで、python_module_name.pyd という Python module が作られる。

無論 VS2010 外の普通の Python 環境でもおk。