構造解析ことはじめ/03 プログラムのインストール
 #floatcontents
 * Intel Compiler &Vine4; &Vine5; [#bd0c3450]
 ** パッケージの取得 [#fd73e69c]
 Intelのサイトからパッケージを取得します。かなりわかりにくいのですが、根気よく探します。~
 2009年春頃からますます探しにくくなりました。Intel Software Networkの検索ボックスで[[''non-commercial''というキーワードで検索>http://mysearch.intel.com/corporate/default.aspx?culture=en_US&q=non-commercial+development&category=all&adv=0&value=0&searchsubmit.x=0&searchsubmit.y=0]]してたどり着きました。もちろん非商用使用に限りますが。
 - 非商用開発ソフトウェア -- http://software.intel.com/en-us/articles/non-commercial-software-development/
 
 ここで''Accept''した後、対象となるソフトウェアの一覧が表示されますので、必要なパッケージをクリックするとメールアドレスを登録画面に移行します。そこでメールアドレスを登録すればダウンロードページに進みます。プログラムを使用するためには登録したアドレスに送られてくるシリアル番号が必要となります。
 
 ** インストール Parallel Studio XE 2011 &Vine5; [#de8dd4f7]
 Intel Compiler Suiteが進化してParallel Studio XEっていうのになったようです。中身は、
 
 - Intel Composer XE 2011
 - Intel Inspector XE 2011
 - Intel VTune Amplifier XE 2011
 
 のパッケージとなっています。~
 いろいろ入れてもたぶん使わないので、Intel Composer XEのみをインストールしました。インストールはIntel Compilerと変わりませんが、ディレクトリ構成が結構無茶な感じ(シンボリックリンクだらけ!)になりましたので、私はインストールの際に初期インストールディレクトリを変更しました。
 
 *** インストール時のエラー [#i030c81d]
 インストールスクリプトinstall.shを走らせた後、以下のエラーが出ることがあります。
  Something wrong with activation module. Please go to
  http://www.intel.com/software/products/support/ for your support options.
 Vine5の場合はlibstdc++ 3.3が不足しているのでaptでインストールします。
  # apt-get install libstdc++3
 これで回避できるはずです。
 
 *** インストールオプションの変更 [#idb8807d]
 ライセンス認証の後、Step 4 of 6のOptionsを変更しました。特にいろいろ気にしない方はそのままインストールしても問題ないと思います。~
 私が変更したのは以下の通り。
 - インストールディレクトリ [ ''/opt/intel/Compiler/12.0/084'' ]
 - インストールコンポーネント
 -- Intel Composer XE 2011 [ ''All'' ]
 --- Intel C++ Compiler XE version 12.0
 --- Intel Fortran Compiler XE version 12.0
 --- Intel Debugger version 12.0
 --- Intel Math Kernel Library 10.3
 --- Intel Integrated Performance Primitives 7.0
 --- Intel(R) Threading Building Blocks 3.0 core files and examples
 -- Intel Inspector XE 2011 [ ''None'' ]
 -- Intel VTune Amplifier XE 2011 [ ''None'' ]
 
 コンパイラのリビジョンはパッケージ中のrpmのファイル名を見ればわかります。たとえば、intel-compilerpro-common-084-12.0-0.noarch.rpmなら12.0.084ですね。ComposerXE的には2011.0.084だそうですが。
 
 *** インストール後の設定 [#y9d4174a]
 :RPM依存関係の修正 &Vine5;|
 Vine5ではIntel Compilerインストール後、依存関係のエラーが出るので以下のコマンドで修正します。
  #apt-get --fix-broken install
 これにより必要なパッケージがインストールされます。
 
 :環境設定|
 ログイン時に環境設定をする必要があります。統合されたようで1行で済むようになりました。bashの場合は.bashrc、tcshの場合は.cshrcを編集します。~
 インストールディレクトリが/opt/intel/Compiler/12.0/084の場合は以下の通りです。
 :.bashrc|
  # for Intel Compiler
  source /opt/intel/Compiler/12.0/084/bin/compilervars.sh ia32
 :.csrhc|
  # for Intel Compiler
  source /opt/intel/Compiler/12.0/084/bin/compilervars.csh ia32
 標準のままインストールしていれば、/opt/intel/bin/compilervars.shに変更すればいいだけです。
 
 インストール後の出力(参考)
  To get started using Intel(R) VTune(TM) Amplifier XE 2011:
      - Add the product bin64 (or bin32) directory (located in
  /opt/intel/vtune_amplifier_xe_2011) to your PATH environment variable.
        To start the graphical user interface: amplxe-gui
        To use the command-line interface: amplxe-cl
      - To view a table of getting started documents:
          /opt/intel/vtune_amplifier_xe_2011/documentation/en/documentation_amplifier.htm.
  To get started using Intel(R) Inspector XE 2011:
      - Add the product bin64 (or bin32) directory (located in /opt/intel/inspector_xe_2011) to your PATH environment variable.
        To start the graphical user interface: inspxe-gui
        To use the command-line interface: inspxe-cl
      - To view a table of getting started documents:
          /opt/intel/inspector_xe_2011/documentation/en/documentation_inspector_xe.htm.
  To get started using Intel(R) Composer XE 2011:
      - Set the environment variables for a terminal window using one of the
        following (replace "intel64" with "ia32" if you are using a 32-bit
        platform).
        For csh/tcsh:
            $ source /opt/intel/bin/compilervars.csh intel64
        For bash:
            $ source /opt/intel/bin/compilervars.sh intel64
        To invoke the installed compilers:
            For C++: icpc
            For C: icc
            For Fortran: ifort
        To get help, append the -help option or precede with the man command.
      - To view a table of getting started documents:
          /opt/intel/composerxe-2011/Documentation/en_US/documentation_c.htm.
 
 ** インストール Ver.11 &Vine4; &Vine5; [#y67edc97]
 2008年11月頃にver.11が出たようですので試してみました。~
 ちょっとだけドキュメントを読んでみたところAtomおよびCore i7に対応しているようです。
 - 2010-03-16 : [[Intel64(x86_64)アーキテクチャ用インストール方法>./Intel64]] &Vine5;
 - 2009-07-21 : ver.11.1.046をVine 4.2にインストールしてみました。手順は11.0と同様で問題ありませんでした。
 
 *** aptでのインストール [#v2c13156]
 - libstdc++3 -- libstdc++.so.5が必要
 -- インストールされていないとinstall.sh実行時に以下のエラーメッセージが表示されます。
  --------------------------------------------------------------------------------
  初期化しています。しばらくお待ちください...
  --------------------------------------------------------------------------------
  アクティベーション・モジュールに問題があります。サポートオプションについては、
  http://www.intel.com/software/products/support/ を参照してください。
  --------------------------------------------------------------------------------
  Enter キーを押すと中止します。:
 わかりにくいメッセージですがlibstdc++3をインストールすると解消されます。
 
 *** プログラムのインストール [#zae69488]
 インストール方法はVer.10とほとんど変わりませんが、インストーラが高機能になり少々手順が増えています・・・
  % tar zxvf l_cproc_p_11.1.046_ia32.tgz
  % cd l_cproc_p_11.1.046_ia32
  % su
  # ./install.sh
 あとは画面の手順に従えばOK。今回のC++パッケージにはMath Kernel Library(MKL)などいろいろ入っていますが、このMKLを使用してCCP4をIntel Compilerでビルドしたい場合はインストールしておきましょう(CCP4/Advancedインストール)。よくわからなければTypical Installで問題ないと思います。Fortranも同様です。
 
 *** ユーザーごとの設定ファイル [#seae76f5]
 Intel Compilerを使う場合はログイン時に環境設定をする必要があります。bashの場合は.bashrc、tcshの場合は.cshrcを編集します。
 :.bashrc|
  # for Intel Compiler
  source /opt/intel/Compiler/11.1/046/bin/iccvars.sh ia32    <-- C++の設定
  source /opt/intel/Compiler/11.1/046/bin/ifortvars.sh ia32  <-- Fortranの設定
 :.csrhc|
  # for Intel Compiler
  source /opt/intel/Compiler/11.1/046/bin/iccvars.csh ia32   <-- C++の設定
  source /opt/intel/Compiler/11.1/046/bin/ifortvars.csh ia32 <-- Fortranの設定
 
 *** Math Kernel Libraryのバージョン [#va92d9b1]
 #anno2(2010-05-25)
 AMBER8のインストール時に苦労したのですが、Intel Math Kernel Library (MKL)のバージョンによって挙動が異なることがあるようです(私はMKLを使用したプログラミングをしたことがないので詳細はよくわかりません)。そのため、使用するCPUなどの関係でコンパイラの特定のバージョンを使いたいが、MKLのバージョンは変えたくない、というようなときはMKLを単独でインストールします。特に、Intel Compiler 11.xではディフォルト設定でMKLも同時にインストールされるため注意する必要がありそうです。Intel CompilerとMKLのバージョンの関係は以下の通り。
 |Compiler|MKL |h
 |11.0    |10.1|
 |11.1    |10.2|
 AMBER8ではMKL 10.1と10.2間においてmake testの挙動が異なりました。MKL関係で挙動がおかしいと感じた場合、このことを考慮に入れておくと問題が回避できると思います。異なるバージョンを共存させる場合、ダイナミックリンクにすると依存関係が複雑になるのでスタティックリンクにしてください。
 
 *** ロケールがEUCの時の文字化け -- &Vine4; [#h5308124]
 Vine Linuxでは標準のロケールがEUC(ja_JP.eucJP)になっていますが、Intel CompilerのメッセージカタログはUTF-8しか用意されていません。これだと文字化けして鬱陶しいのでロケールがEUCの場合は英語メッセージが出力されるようにしてみます。~
 メッセージカタログは/opt/intel/Compiler/11.0/074/以下の、
 
 - mkl/lib/32/locale
 - idb/ia32/locale
 - ipp/ia32/lib/locale
 - lib/ia32/locale
 
 これらのディレクトリに格納されています。このディレクトリ中の''ja_JP''がUTF-8のメッセージカタログになっています。そのため環境変数''LANG''=''ja_JP.eucJP''の場合このディレクトリが参照されてしまうようです。そこで、ja_JP.eucJPをen_USにリンクしてしまいます。
  # cd /opt/intel/Compiler/11.0/074/lib/ia32/locale
  # ln -s en_US ja_JP.eucJP
 というようにシンボリックリンクを張ればja_JP.eucJPの時en_USが参照されるようになります。またはja_JPをja_JP.UTF-8に変更しても同様の効果が得られると思います。~
 メッセージカタログをコンバートすれば一番いいと思いますが、標準のmsgfmt/msgunfmtではcatという形式には対応していないのでできません・・・なんかいい方法はないものでしょうかねぇ。
 
 ** インストール Ver.10 [#b34f24ce]
 *** プログラムのインストール [#c573c472]
 ファイルが取得できたらインストールは簡単です。
  % tar zxvf l_cc_p_10.1.015.tar.gz
  % cd l_cc_p_10.1.015
  % su
  # ./install.sh
 これでインストールが可能です。デバッガのインストールはお好みでどうぞ。Fortranも同様の手順です。~
 なお、Ver.9の頃はsuでrootになってから作業をするとエラーが出ましたがsudoで行った場合、問題ありませんでした。もしエラーが起こった場合は試してみてください。
 
 *** ユーザーごとの設定ファイル [#e15b054b]
 Intel Compilerを使う場合はログイン時に環境設定をする必要があります。bashの場合は.bashrc、tcshの場合は.cshrcを編集します。
 :.bashrc|
  # for Intel Compiler
  source /opt/intel/cc/10.1.015/bin/iccvars.sh     <-- C++の設定
  source /opt/intel/fc/10.1.015/bin/ifortvars.sh   <-- Fortranの設定
 :.csrhc|
  # for Intel Compiler
  source /opt/intel/cc/10.1.015/bin/iccvars.csh    <-- C++の設定
  source /opt/intel/fc/10.1.015/bin/ifortvars.csh  <-- Fortranの設定
 
 ファイルを編集後、ターミナルを開き直して、
  % icc
  icc: command line error: no files specified; for help type "icc -help"
 となれば使用可能です。
 #br
 もし、すべてのユーザーで使うようなプログラムをIntel Compilerでコンパイルする場合は共有ライブラリディレクトリの設定が必要となるのでld.so.confに以下の一行を追加します。
  /opt/intel/cc/10.1.015/lib
 追加したらldconfigを実行します。
  # ldconfig